Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widget:UnitDestroyed does not contain attackerID, attackerDefID, and attackerTeam #4247

Closed
Varunda opened this issue Jan 29, 2025 · 1 comment
Labels
Bug Something isn't working

Comments

@Varunda
Copy link
Contributor

Varunda commented Jan 29, 2025

Description

the UnitDestroyed handler is missing some fields

looking at https://beyond-all-reason.github.io/spring/ldoc/modules/LuaHandle.html#UnitDestroyed, i'd expect to see attackerID, attackerDefID, and attackerTeampopulated, but all of them are nil when printed

this occurs whether i can see the unit being killed or not, and whether i can see the attacker unit or not

also not sure why weaponDefID isn't being populated, it's in the docs but not in the code

taking a look at the code i can't figure out why these aren't being populated: https://github.com/beyond-all-reason/spring/blob/BAR105/rts/Lua/LuaHandle.cpp#L1096

function widget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
    Spring.Echo(attackerID, attackerTeam)
end

Expected Behaviour

the value of attackerID, attackerDefID, and attackerTeam is set when a unit is destroyed

Actual Behaviour

attackerID, attackerDefID, and attackerTeam are all nil

Reproduction steps

  1. create a unit
  2. destroy the unit
  3. the fields attackerID, attackerDefID, and attackerTeam are nil when printed in the handler widget:UnitDestroyed

Other

widget is defined in Beyond-All-Reason\data\LuaUI\Widgets

basic widget that shows this:

function widget:GetInfo()
return {
	name    = "test,
	desc    = "a",
	author  = "varunda",
	date    = "2025",
	license = "MIT",
	layer   = 0,
	enabled = true,
}
end

function widget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam)
    Spring.Echo(attackerID, attackerTeam)
end

for a widget idea i had, i kinda need to know the team that destroyed a unit. i can understand why these fields might not be populated in some cases (attacker offscreen). but this occurs even when i kill units that i can see on screen

@Varunda
Copy link
Contributor Author

Varunda commented Jan 30, 2025

fixed in #4256

@Varunda Varunda closed this as completed Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant