WeaponCtrJump: Difference between revisions

From Eternity Wiki
Jump to navigationJump to search
m (mess)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Player weapon codepointer. Parameterized codepointer.
{{codepointer|description=
 
This codepointer compares one of the counters with a value or another counter, and jumps instantly to frame ''statenum'' if the condition is met.|usage=
:''Usage:''
'''WeaponCtrJump'''(''statenum'', ''checktype'', ''value'', ''cnum'', ''psprnum'')|parameters=
::'''WeaponCtrJump'''(''statenum'', ''checktype'', ''value'', ''cnum'', ''psprnum'')
*''statenum'': name or Dehacked number of frame to jump to.
===Effect===
*''checktype'': what type of comparison to apply, depending on the number or mnemonic used.
This codepointer is used for frame scripting within a player weapons' frames. It's not designed to affect non-player game world objects or the player avatar. It's used on the frames of guns that typically appear in front of the game screen.
 
In Eternity each player weapon has three (or eight in the development versions) counters that can be edited and conditionally checked by codepointers to achieve scripted effects.
 
This codepointer compares one of the counters with a value or another counter, and jumps instantly to frame ''statenum'' if the condition is met. Otherwise, it will work normally and jump to next frame after frame's tics duration. This can be used for any of two weapon sprite types: normal gun, or muzzle flash.
 
===Arguments===
*'''args0''': ''statenum'': name or Dehacked number of frame to jump to.
*'''args1''': ''checktype'': what type of comparison to apply, depending on the number or mnemonic used.
::'''Numbers 0-6 are used to compare a counter value with a constant
::'''Numbers 0-6 are used to compare a counter value with a constant
:::0 ''less''
:::0 ''less''
Line 29: Line 20:
:::12 ''notequal_counter''
:::12 ''notequal_counter''
:::13 ''and_counter''.
:::13 ''and_counter''.
*'''args2''': ''value'': constant value or counter number (0-2 or 0-7 in development versions) to compare against ('''right operand''').
*''value'': constant value or counter number (0-2) to compare against ('''right operand''').
*'''args3''': ''cnum'': counter number (0-2 or 0-7) to compare ('''left operand''').
*''cnum'': counter number (0-2) to compare ('''left operand''').
*'''args4''': ''psprnum'': what gun sprite type this function affects:
*''psprnum'': what gun sprite type this function affects:
::0 ''weapon'': affect main weapon sprite
::0 ''weapon'': affect main weapon sprite
::1 ''flash'': affect muzzle flash sprite (which appears overlapping the main weapon sprite).
::1 ''flash'': affect muzzle flash sprite (which appears overlapping the main weapon sprite).|examples=
{{example|description=The following example modifies the Doom pistol to go into recharging animation after each ten shots, IF there is ammo left:|code=
'''framedelta'''              <nowiki>{</nowiki> '''name'''=S_PISTOL3; '''action'''=[[WeaponSetCtr]](0,1,add); '''tics'''=0; '''nextframe'''=S_PISTOL3TESTAMMO<nowiki>}</nowiki>
# CheckReload so it doesn't recharge when no ammo
'''frame''' S_PISTOL3TESTAMMO <nowiki>{</nowiki> '''cmp'''="PISG<nowiki>|2|*|0|</nowiki>[[CheckReload]]                                      <nowiki>|@next"</nowiki><nowiki>}</nowiki>
# use 0 tics so duration is always 0   
'''frame''' S_PISTOL3TESTCTR  <nowiki>{</nowiki> '''cmp'''="PISG<nowiki>|2|*|0|</nowiki>''WeaponCtrJump''(S_PISTOLRECHARGE,equal,10,0,weapon)<nowiki>|@next"</nowiki><nowiki>}</nowiki>
# same form as ''original'' S_PISTOL3.
'''frame''' S_PISTOL3NORMAL  <nowiki>{</nowiki> '''cmp'''="PISG<nowiki>|2|*|4|</nowiki>*                                                <nowiki>|</nowiki>S_PISTOL4"<nowiki>}</nowiki>
# reset counter if recharge happens.
'''frame''' S_PISTOLRECHARGE  <nowiki>{</nowiki> '''cmp'''="PISG<nowiki>|2|*|4|</nowiki>WeaponSetCtr(0,0,assign)                        <nowiki>|</nowiki>S_PISTOLREC1"<nowiki>}</nowiki> 
# Add S_PISTOLREC1 and subsequent frames here.}}|notes=This codepointer is used for frame scripting within a player weapons' frames. It's not designed to affect non-player game world objects or the player avatar. It's used on the frames of guns that typically appear in front of the game screen.


===Example===
In Eternity each player weapon has three counters that can be edited and conditionally checked by codepointers to achieve scripted effects.
The following example modifies the Doom pistol to go into recharging animation after each ten shots, IF there is ammo left:
 
'''framedelta''' { '''name'''=S_PISTOL3; '''action'''=[[WeaponSetCtr]](0,1,add); '''tics'''=0; '''nextframe'''=S_PISTOL3TESTAMMO}
Otherwise, it will work normally and jump to next frame after frame's tics duration. This can be used for any of two weapon sprite types: normal gun, or muzzle flash.|seealso=
'''frame''' S_PISTOL3TESTAMMO {'''cmp'''="PISG|2|*|0|[[CheckReload]]|@next"}      # CheckReload so it doesn't recharge when no ammo
*[[List_of_codepointers#Frame_scripting|Weapon frame scripting codepointers]]}}
'''frame''' S_PISTOL3TESTCTR {'''cmp'''="PISG|2|*|0|''WeaponCtrJump''(S_PISTOLRECHARGE,equal,10,0,weapon)|@next"} # use 0 tics so duration is always 0
'''frame''' S_PISTOL3NORMAL {'''cmp'''="PISG|2|*|4|*|S_PISTOL4"} # same form as ''original'' S_PISTOL3.
'''frame''' S_PISTOLRECHARGE {'''cmp'''="PISG|2|*|4|WeaponSetCtr(0,0,assign)|S_PISTOLREC1"}  # reset counter if recharge happens.
# Add S_PISTOLREC1 and subsequent frames here.
==See also==
*[[List of codepointers]]
[[Category:Codepointers]]

Latest revision as of 05:43, 9 May 2011

Description

This codepointer compares one of the counters with a value or another counter, and jumps instantly to frame statenum if the condition is met.

Usage

WeaponCtrJump(statenum, checktype, value, cnum, psprnum)

Parameters

  • statenum: name or Dehacked number of frame to jump to.
  • checktype: what type of comparison to apply, depending on the number or mnemonic used.
Numbers 0-6 are used to compare a counter value with a constant
0 less
1 lessorequal
2 greater
3 greaterorequal
4 equal
5 notequal
6 and (bitwise operation): if result is nonzero, condition is passed.
Numbers 7-13 are used to compare a counter value with another counter's value:
7 less_counter
8 lessorequal_counter
9 greater_counter
10 greaterorequal_counter
11 equal_counter
12 notequal_counter
13 and_counter.
  • value: constant value or counter number (0-2) to compare against (right operand).
  • cnum: counter number (0-2) to compare (left operand).
  • psprnum: what gun sprite type this function affects:
0 weapon: affect main weapon sprite
1 flash: affect muzzle flash sprite (which appears overlapping the main weapon sprite).

Examples

The following example modifies the Doom pistol to go into recharging animation after each ten shots, IF there is ammo left:

framedelta              { name=S_PISTOL3; action=WeaponSetCtr(0,1,add); tics=0; nextframe=S_PISTOL3TESTAMMO}

# CheckReload so it doesn't recharge when no ammo 
frame S_PISTOL3TESTAMMO { cmp="PISG|2|*|0|CheckReload                                      |@next"} 

# use 0 tics so duration is always 0     
frame S_PISTOL3TESTCTR  { cmp="PISG|2|*|0|WeaponCtrJump(S_PISTOLRECHARGE,equal,10,0,weapon)|@next"}

# same form as original S_PISTOL3. 
frame S_PISTOL3NORMAL   { cmp="PISG|2|*|4|*                                                |S_PISTOL4"}

# reset counter if recharge happens.
frame S_PISTOLRECHARGE  { cmp="PISG|2|*|4|WeaponSetCtr(0,0,assign)                         |S_PISTOLREC1"}  

# Add S_PISTOLREC1 and subsequent frames here.

Notes

This codepointer is used for frame scripting within a player weapons' frames. It's not designed to affect non-player game world objects or the player avatar. It's used on the frames of guns that typically appear in front of the game screen.

In Eternity each player weapon has three counters that can be edited and conditionally checked by codepointers to achieve scripted effects.

Otherwise, it will work normally and jump to next frame after frame's tics duration. This can be used for any of two weapon sprite types: normal gun, or muzzle flash.

See also