EVENT ANIMATESPRITES: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
mNo edit summary
mNo edit summary
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{EventTable|1=EVENT_ANIMATESPRITES |2=[[screenpeek]]|3=[[tsprowner]]|4=0 values}}
EVENT_ANIMATESPRITES is a [[EDuke32_event_list|Game Event]].
EVENT_ANIMATESPRITES is a [[EDuke32_event_list|Game Event]].


This event can be used to manipulate sprites that are drawn on the screen (for example the color of a sprite when Nightvision Googles are used).  It is triggered only by drawn sprites when 16 has been added to the mdflags member of the corresponding sprite in the game world. Drawn sprites are accessed through the tsprite array, which has its own members separate from the regular actor array.  Members of the tsprite array are similar to members of the regular sprite array, but they begin with 'tspr' (E.g., xrepeat becomes tsprxrepeat ).
This [[event]] is triggered every time a sprite is displayed on the screen, if flag [[mdflags|SPREXT_TSPRACCESS]] is set on the [[mdflags]] member of the corresponding sprite in the game world. This event can be used to manipulate sprites that are drawn on the screen, independently of the actor properties. Drawn sprites are accessed through the tsprite array, which has its own members separate from the regular actor array.  Members of the tsprite array are similar to members of the regular sprite array, but they begin with 'tspr' (E.g., xrepeat becomes tsprxrepeat).
 
Note that one sprite can be rendered multiple times in the game world, through shadows or mirrors. Sprites with a cstat of 32768 are inaccessible through this event since they are not rendered (rather than merely being turned invisible). For the same reason, setting tsprcstat to 32768 will have no effect.
 
The game itself uses this event for a series of effects: changing the visible palette and/or shade of an actor to that of its sector or when Night Vision Goggles are used; not showing certain sprites depending of the video settings (by setting tsprxrepeat and tspryrepeat to zero); making the player sprites translucent when using third-person view mode; etc. The effects can be different for each player in a multiplayer game.


'''Example of how to use this event:'''
'''Example of how to use this event:'''
Line 20: Line 25:
   endevent
   endevent


The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid.  This effect cannot be achieved by setting the cstat of the player sprite directly.  Note that the code will only effect the player sprite, because only the player sprite has had 16 added to its mdflags member.
The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid.  This effect cannot be achieved by setting the cstat of the player sprite directly.  Note that the code will only affect the player sprite, because only the player sprite has had 16 added to its mdflags member.


See also [[gettspr]] and [[settspr]]
See [[gettspr]] and [[settspr]].


[[Category:Events]]
[[Category:Events]]

Latest revision as of 12:12, 4 February 2022

Event ID player# THISACTOR RETURN
EVENT_ANIMATESPRITES screenpeek tsprowner 0 values

EVENT_ANIMATESPRITES is a Game Event.

This event is triggered every time a sprite is displayed on the screen, if flag SPREXT_TSPRACCESS is set on the mdflags member of the corresponding sprite in the game world. This event can be used to manipulate sprites that are drawn on the screen, independently of the actor properties. Drawn sprites are accessed through the tsprite array, which has its own members separate from the regular actor array. Members of the tsprite array are similar to members of the regular sprite array, but they begin with 'tspr' (E.g., xrepeat becomes tsprxrepeat).

Note that one sprite can be rendered multiple times in the game world, through shadows or mirrors. Sprites with a cstat of 32768 are inaccessible through this event since they are not rendered (rather than merely being turned invisible). For the same reason, setting tsprcstat to 32768 will have no effect.

The game itself uses this event for a series of effects: changing the visible palette and/or shade of an actor to that of its sector or when Night Vision Goggles are used; not showing certain sprites depending of the video settings (by setting tsprxrepeat and tspryrepeat to zero); making the player sprites translucent when using third-person view mode; etc. The effects can be different for each player in a multiplayer game.

Example of how to use this event:

  gamevar TEMP 0 0
  actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
  getactor[THISACTOR].mdflags TEMP
  orvar TEMP 16
  setactor[THISACTOR].mdflags TEMP
  // rest of player code

In this first block of code, we add 16 to the mdflags member of the player sprite, so that it will be processed by the ANIMATESPRITES event. Next, is the code for the event:

  onevent EVENT_ANIMATESPRITES
  gettspr[THISACTOR].tsprcstat TEMP
  ifvarand TEMP 2
      xorvar TEMP 2
  settspr[THISACTOR].tsprcstat TEMP
  endevent

The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid. This effect cannot be achieved by setting the cstat of the player sprite directly. Note that the code will only affect the player sprite, because only the player sprite has had 16 added to its mdflags member.

See gettspr and settspr.