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?
how to get unit ID of units attacking you (in a widget)
Moderator: Moderators
-
- Posts: 3
- Joined: 28 Jul 2009, 13:25
Re: how to get unit ID of units attacking you (in a widget)
hey,
what will your widget do?
what will your widget do?
-
- Posts: 3
- Joined: 28 Jul 2009, 13:25
Re: how to get unit ID of units attacking you (in a widget)
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.
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)
try ctrl/alt+move.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.
Re: how to get unit ID of units attacking you (in a widget)
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.
* 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)
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.
- TheFatController
- Balanced Annihilation Developer
- Posts: 1177
- Joined: 10 Dec 2006, 18:46
Re: how to get unit ID of units attacking you (in a widget)
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.
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)
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.
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.
-
- Posts: 3
- Joined: 28 Jul 2009, 13:25
Re: how to get unit ID of units attacking you (in a widget)
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)
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,...
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)
(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.
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.