jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

TODO: Range to Trader bool #49

Closed jpcsupplies closed 8 years ago

jpcsupplies commented 8 years ago

Need to add the bool to check players distance from requested player/faction prior to allowing trade with them.. At the moment it is just a placeholder, but the sub should at least be created.

Desired Logic: Get current player location. Get target location (player or faction trade territory or central market) target distance = target location - player location (using xyz logic..) If ((target.distance >= max trade range) || (target location is within broadcast rage of player)) return true. else return false.

Notes: x=10 y=10 z=10 ta=20 ty=10 tz=11

20-10=10 10-10=0 11-10=1

10+1 = 11 ? probably need some sqr root formula.. gah Point 1 at (x1, y1, z1) and Point 2 at (x2, y2, z2).

xd = x2-x1
yd = y2-y1
zd = z2-z1
Distance = SquareRoot(xd*xd + yd*yd + zd*zd)

yuk.. c# have a sqr function?

these may be also usable.. ? GetPlayerRelayedBroadcasters.

Vector3D player; bool success = remote.GetNearestPlayer(out player); if (success) { player = remote.GetFreeDestination(player, 200, 15.0f);

}

jpcsupplies commented 8 years ago

made placeholder for use later..

jpcsupplies commented 8 years ago

might downgrade this to ENH so we can focus on getting an Alpha release out.. looks like it needs either some fiddly math functions, or some game api function, and players seem to be impatient for the player to player sell command atm

jpcsupplies commented 8 years ago

gone hunting and listed useful sounding api bits in #65 which i may be able to use for a distance check.. probably going to need help here

jpcsupplies commented 8 years ago

looks like this is implemented now