Page 1 of 1
how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 10:02
by obliter8or
Hi all
Im interested in trying to make a widget that assists with some of the micro managment in Spring mods. at the moment Im just exploring what widgets are capable of with the call-ins and call-outs.
from what I can see there is no way of detecting who is attaching your units. the call-in I was hoping to use was:
widget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer)
but for all my efforts so fay I cannot get the unit ID that delt the damage.
dose any one know how I could do this?
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 11:00
by manolo_
hey,
what will your widget do?
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 11:26
by obliter8or
at the moment the plan is for it suply a basic group managing:
1 - a UI for creating groups and adding and removing selected units from the current groups.
2 - keeping the group together. ie when you order the group to move it mooves as one (as best it can) and it controls the range of unit movements when the group is stationary.
3 - when enemy units come into sight units attack the ones they are most effective against.
for my honours thesis at uni I'm making a basic unit group AI for RTS games. spring is by far the best place to test my architecture.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 11:30
by imbaczek
obliter8or wrote:2 - keeping the group together. ie when you order the group to move it mooves as one (as best it can) and it controls the range of unit movements when the group is stationary.
try ctrl/alt+move.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 11:49
by hoijui
i guess the reason you do not get the ID of the unit that dealt the damage is, that this is kind of... nothing you would know usually.
* your units do not have sensors that track all the projectiles all the time
* in heavy fire fights, humans would not know eihter where a shot came form that hit them, sometimes
* you can be shot at from outside LOS/Radar coverage
i don't know how hard it would be to change the event to include this info. before even considering this, we should think about if it is.. legal to know that.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 11:56
by Argh
In the next release of Spring, I believe that Kloot's callouts for Projectiles + the stuff I explored on this topic about a month ago should allow for this. IOW, this is probably possible to do right now, but only with a developmental release from Buildbot.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 12:02
by TheFatController
Units can get the location of a unit outside of LOS / radar using the Guard command (guard sets them to attack the unit that did the damage to the thing that's been attacked even if its out of sight) not sure if this also attaches the unitId to their attack command or not tho.
I was trying to think of a way to abuse this but nothing really reliable aside from a LRPC finder widget of some type.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 12:11
by Niobium
Spring.GetUnitLastAttacker(unitID) -> attackerID
Call this on :UnitDamaged, and there you go, the missing piece.
Note that it will only return the attackers ID if it can see the attacker (Los or radar), so you should nil check it.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 14:14
by obliter8or
thats fine I dont want the widget to 'cheat'. just collect some stats on which units are effective against others.
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 16:12
by manolo_
mmmh, dunno if this will work.
e.g. u have a group of A, B and C, now u attack with D (A is good vs D), A will move forward (i assume all other back), now u attack with E (E is superb vs A, but bad vs B), now A will move back and B forward,...
Re: how to get unit ID of units attacking you (in a widget)
Posted: 05 Aug 2009, 18:15
by zwzsg
(synced) function gadget:UnitDamaged(UnitID,UnitDefID,Team,Damage,Para,WeaponID,AttackerID,AttackerDefID,AttackerTeam)
function widget:UnitDamaged(UnitID,UnitDefID,Team,Damage,Para,WeaponID)
Same callin name, but as a gadget, it is passed the attacker, as a widget it isn't, even if the attacker is in los.
Personnaly, I fell back on assuming the attacker is the nearest enemy and using :
local AttackerID=Spring.GetUnitNearestEnemy(UnitID,400) -- where 400 is the radius to look for enemies
if AttackerID then ...
But Niobium proposition sounds better.