Joined: 17 Nov 2005, 02:43 Location: Raegquitting Spring on 04/24/12
Boolean so that this explosion or weapon impact does either no damage, or damage to friendly units
Another Boolean that specifies whether this explosion does damage to enemy units or not.
THIS INCLUDES AOE!
Suggested tag names:
noFriendlyFire noEnemyFire
Atm most of us are trying to achieve this via gadgets and the like but said gadgets are unreliable. Besides, there should be a switch in the engine for it.
Edit: This also goes for unit death explosions as well as weapons assigned to units.
Joined: 25 Aug 2004, 12:31 Location: Has not played *a in years.
You want deaths to damage enemies and features, but not friendlies? Why have death explosions do any damage at all then? I guess it is important for damaging nearby enemies when your units die?
You can set the kamikaze weapon to be a watchweapon, and then:
Code:
function gadget:Explosion(weaponID, px, py, pz, ownerID) if(weaponID == myNiftyWeapon) then teamID = Spring.GetUnitTeam(ownerID) return false end end
...I think that will give you a valid UnitID on death. The alternative is to manually cause an explosion in COB via emit-sfx during the death sequence before returning.
This wouldn't solve the scenario where a regular unit fires a weapon, dies before it reaches its target and again unitpredamaged would fail to give the parameters.
CarRepairer wrote:
Spring should be fixed so attackerDefID and attackerTeam are still there even if the unit is dead.
This wouldn't solve the scenario where a regular unit fires a weapon, dies before it reaches its target and again unitpredamaged would fail to give the parameters.
True, but it should fix Forb's immediate problem.
As for the fix, maybe just store the team ID? I can see all sorts of problems cropping up if dead unit IDs are still considered to be valid.
This wouldn't solve the scenario where a regular unit fires a weapon, dies before it reaches its target and again unitpredamaged would fail to give the parameters.
CarRepairer wrote:
Spring should be fixed so attackerDefID and attackerTeam are still there even if the unit is dead.
...would solve it. Would it be difficult to fix?
Units dying before shots hit is common enough that it makes it impossible to implement team-based or unitdef-based special damages consistently. While unitdef-based things could be handled by unique weapondefs through a troublesome process, even simple team-based damages like 'Team X has +10% damage' are impossible, especially so when the damage modifications are large.
Imo this is bug (in that it causes buggy inconsistent behavior), but looking at the spring code it doesn't appear to be a super easy fix of tacking on some parameters in one place. It seems like it would require all projectiles to get ownerTeam/ownerDef on creation , and then passing those values onto created explosions/damage, which would then pass them into the damage functions. Basic changes, but quite a few of them.
I can see all sorts of problems cropping up if dead unit IDs are still considered to be valid.
Not unitID, I just said unitDefID (attackerDefID + attackerTeamID).
Niobium wrote:
Imo this is bug (in that it causes buggy inconsistent behavior), but looking at the spring code it doesn't appear to be a super easy fix of tacking on some parameters in one place. It seems like it would require all projectiles to get ownerTeam/ownerDef on creation , and then passing those values onto created explosions/damage, which would then pass them into the damage functions. Basic changes, but quite a few of them.
Thanks for the explanation. I hope this could be resolved. Even if it's just teamID that is maintained, it would suffice (teamID + weaponID).
Perhaps a better method would be to have dead units leave behind a data-tombstone that contains some simple information, and add a method GetDeadUnitInfo(unitID) that returns as subset of the live unit's info. In this case, that would happen transparently in the background and the DeadUnitINfo's DefID and TeamID would be passed into the predamaged handler?
edit: too bad we don't just get an invalid AttackerID instead of a "nil" one. Then you could simply cache all the Unit IDs on unit creation, storing their team and unitdefID there. That collection would logically outlive the units, so you could use that to check the info of dead units.
Hmm. So, does Explosion() return nil for the ownerID, or a number, if the firing Unit is dead?
If the second case, and you want a tombstone keeper, that's a fairly routine Gadget- we could put Units in an array, with dead/alive states, and sync that with weapons instead of querying Spring. I don't think there's a need for an engine fix on this, frankly:
Code:
local unitList = {} function gadget:UnitCreated(unitID, unitDefID, teamID, builderID) unitList[unitID] = {dead = false, deadTimes = 0} end
function gadget:UnitDestroyed(unitID, unitDefID, teamID, attackerID) unitList[unitID].dead = true end
function gadget:GameFrame(f) if f % 33 < 0.1 then for i,k in ipairs(unitList) do if k.dead = true then if k.deadTimes > 2 then unitList[i] = nil --clear this location else k.deadTimes = k.deadTimes + 1 end end end end end
function gadget:Explosion() --check for match with dead / living here, if yes then set something up for UnitPreDamaged()... end
@zwzsg - well, that depends on teh unitID reuse algorithm. If it keeps going upwards until wraparound and then grabs the next available one, the UnitID should last long enough for any death explosion. Plus, if you're using an "on unit create" approach I mentioned, you would at least *know* when a UnitID was reused, and could keep track of all uses of the unitID.
But either way, you still need AttackerID to be passed in UnitPreDamaged instead of Nil to take that approach.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum