Eliminate player self-damage: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 3: Line 3:
<pre>
<pre>
getactor[THISACTOR].htextra TEMP
getactor[THISACTOR].htextra TEMP
ifvarg TEMP 0 // if the actor is set to take some damage from a weapon...
 
{
ifvarg TEMP 0                           // if the actor is set to take some damage from a weapon...
        getactor[THISACTOR].htowner TEMP // gets the owner of the weapon into TEMP
{
ifvarvare TEMP THISACTOR // if the owner of the weapon IS this actor
  getactor[THISACTOR].htowner TEMP     // gets the owner of the weapon into TEMP
          setactor[THISACTOR].htextra 0 // set the damage to 0
  ifvarvare TEMP THISACTOR             // if the owner of the weapon IS this actor
        }
    setactor[THISACTOR].htextra -1      // set the damage to -1, the default value
}
</pre>
</pre>
[[Category: Tutorials]]

Latest revision as of 11:07, 19 October 2021

The following code can be used to make it so that actors (including players) do not take damage from their own weapons. To function, the code should be placed in the actor code (in the block of code beginning with ACTOR ACTORNAME) above the place in the code where the command ifhitweapon is used. It assumes that the gamevar TEMP has been declared.

getactor[THISACTOR].htextra TEMP

ifvarg TEMP 0                            // if the actor is set to take some damage from a weapon...
{
  getactor[THISACTOR].htowner TEMP      // gets the owner of the weapon into TEMP
  ifvarvare TEMP THISACTOR              // if the owner of the weapon IS this actor
    setactor[THISACTOR].htextra -1       // set the damage to -1, the default value
}