View topic - Please add a weapondef tag for friendly fire



All times are UTC + 1 hour


Post new topic Reply to topic  [ 20 posts ] 
Author Message
PostPosted: 02 Nov 2010, 02:05 
Evolution RTS Developer
User avatar

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.


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 02:45 
Blood & Steel Developer
User avatar

Joined: 25 Aug 2004, 12:31
Location: Has not played *a in years.
how are gadgets unreliable?


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 04:00 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
UnitPreDamaged should handle this fine :?


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 04:48 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
http://pastebin.com/Tw5Cy8Ya

Works for units weapons, not for unit death explosions.

http://pastebin.com/vdhbT2RH

Doesn't work at all.


Plus, these are tags that should be in the engine weapondefs anyway.


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 05:04 
User avatar

Joined: 07 Dec 2008, 02:35
Death explosion
=> Attacker is dead
=> Attacker parameters are nil (attackerID, attackerDefID, attackerTeam)
=> Your gadgets function doesn't fire

WeaponID works just fine however, so your gadget would turn into something like...

noFriendlyFireWeapons = {WeaponDefNames[...].weaponDef = true, ...}

Which is a bit more hassle than just putting a tag on the weapon (Unless weapons have customparams?)


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 05:08 
Blood & Steel Developer
User avatar

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?


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 05:11 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
Kamikaze units that don't chain.

Also, why doesn't the noenemy fire one work? That one is a massive pain in the cock.

Thanks for explaining that niobium. Makes a lot mroe sense now.


Top
 Offline Profile  
 
PostPosted: 02 Nov 2010, 05:29 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
Niobium wrote:
Death explosion
=> Attacker is dead
=> Attacker parameters are nil (attackerID, attackerDefID, attackerTeam)
=> Your gadgets function doesn't fire

This is bad. Spring should be fixed so attackerDefID and attackerTeam are still there even if the unit is dead.


Top
 Offline Profile  
 
PostPosted: 03 Nov 2010, 06:22 
P.U.R.E. Developer
User avatar

Joined: 21 Feb 2005, 03:38
Location: Herding cats uphill whilst wearing roller skates.
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.


Top
 Offline Profile  
 
PostPosted: 03 Nov 2010, 16:34 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
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?


Top
 Offline Profile  
 
PostPosted: 03 Nov 2010, 19:22 
P.U.R.E. Developer
User avatar

Joined: 21 Feb 2005, 03:38
Location: Herding cats uphill whilst wearing roller skates.
Quote:
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.


Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 00:12 
User avatar

Joined: 07 Dec 2008, 02:35
CarRepairer wrote:
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.


Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 00:19 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
Argh wrote:
Quote:
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).


Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 14:16 
User avatar

Joined: 23 Oct 2004, 00:43
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.


Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 18:39 
Redacted
User avatar

Joined: 08 Jan 2007, 06:13
Location: Don't be silly. If there's no machine heaven, where do all the toasters go?
There are tombstones, they just get cleared after each frame.

It would be nice for a projectile to give at least some of the information even after a unit's long gone.


Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 20:41 
P.U.R.E. Developer
User avatar

Joined: 21 Feb 2005, 03:38
Location: Herding cats uphill whilst wearing roller skates.
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



Top
 Offline Profile  
 
PostPosted: 04 Nov 2010, 21:09 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Pxtl: Don't forget unitIds get reused!


Top
 Offline Profile  
 
PostPosted: 05 Nov 2010, 00:59 
P.U.R.E. Developer
User avatar

Joined: 21 Feb 2005, 03:38
Location: Herding cats uphill whilst wearing roller skates.
True. What's the rationale behind that, btw? Seems unlikely we'd ever hit the limit on that number...


Top
 Offline Profile  
 
PostPosted: 05 Nov 2010, 02:59 
User avatar

Joined: 23 Oct 2004, 00:43
@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.


Top
 Offline Profile  
 
PostPosted: 05 Nov 2010, 14:17 
Spring Developer
User avatar

Joined: 22 Sep 2007, 08:51
unitIds for new units are chosen randomly out of the currently unused IDs. this is to make some forms of cheating harder.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.