Pls help re CMD_ATTACK and distance to target

Pls help re CMD_ATTACK and distance to target

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
EmMeister
Posts: 4
Joined: 18 Mar 2007, 07:08

Pls help re CMD_ATTACK and distance to target

Post by EmMeister »

I need a little bit of help here from you guys.

CODE:
-- Check current command and current location --
local curCmd = table.getn(cQueue)
if (curCmd > 0 and cQueue[curCmd].id == CMD_ATTACK) then
local ux, uy, ut = Spring.GetUnitPosition(ud)
local tX, tY, tZ = Spring.GetUnitPosition(cQueue[curCmd].target)
end

In the above I am trying to get the position of a unit who's next command is to attack something. I also need the location of it's target so that I can estimate distance. Because I really don't know what the members of CMD_ATTACK are I don't know if it is a unit ID, a map location, has a simple member such as .DistToTarget or etc. How can I get the position of the target unit? Additionally, where can I look for answers like this in the future so I don't have to bother all you smart people with newb questions?
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Post by Licho »

I guess that you have to check source:
https://taspring.clan-sy.com/svn/spring ... ileCAI.cpp

As you can see, you have to check params property of queue. If it has 1 value, it's unit ID. If it has more, it's coordinates for "attack ground".
EmMeister
Posts: 4
Joined: 18 Mar 2007, 07:08

Thanks !!

Post by EmMeister »

:lol: Thanks, Licho. I can't wait to get home now and put it together.
Post Reply

Return to “Lua Scripts”