EVENT EGS: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Maybe not?
Fox (talk | contribs)
No edit summary
Line 1: Line 1:
EVENT_EGS is a [[EDuke32_event_list|Game Event]].
EVENT_EGS is a [[EDuke32_event_list|Game Event]].


This [[event]] is triggered when any sprite is spawned on the map. Like [[EVENT_GAME]], this event run for all actors, thus the gamevar [[THISACTOR]] refers to the ID of the sprite that is executing the code.
This [[event]] is triggered when a new sprite is spawned on the map.


This event occurs the moment a sprite is spawned.
This event run for all actors, thus the gamevar [[THISACTOR]] refers to the ID of the sprite that is executing the code.
 
Internally, this is the moment the sprite structures and gamevars are reset for the sprite ID.
 
In comparison, [[EVENT_SPAWN]] runs for all sprites that pre-exist when the map is loaded and newly spawned sprites, and internally is used for changing the properties of specific sprites (such as enemies, etc).
 
Note that EVENT_EGS and EVENT_SPAWN are triggered the moment the sprite is spawned.
 
For example:
  useractor notenemy ACTOR
  useractor notenemy ACTOR
   espawn PIGCOP
   espawn PIGCOP
   ifvarg RETURN -1
   setactor[RETURN].pal 1
    setactor[RETURN].pal 1
  enda
  enda
   
   
Line 14: Line 21:
     spritepal 2
     spritepal 2
  endevent
  endevent
In this case, the PIGCOP palette will be 1, because the EVENT_EGS code is triggered before the lines below the [[spawn]] command.
In this case, the PIGCOP palette will be 1, because EVENT_EGS takes place before the lines below the [[espawn]] command.
 
This event does not run for sprites present in the map file. For those, try [[EVENT_SPAWN]] or [[EVENT_LOADACTOR]].


Deleting sprites during EVENT_EGS may cause problems, since some hard-coded functions may try to change their properties after they were spawned (similar to the [[espawn]] example above).
[[Category:Events]]
[[Category:Events]]

Revision as of 10:47, 5 January 2020

EVENT_EGS is a Game Event.

This event is triggered when a new sprite is spawned on the map.

This event run for all actors, thus the gamevar THISACTOR refers to the ID of the sprite that is executing the code.

Internally, this is the moment the sprite structures and gamevars are reset for the sprite ID.

In comparison, EVENT_SPAWN runs for all sprites that pre-exist when the map is loaded and newly spawned sprites, and internally is used for changing the properties of specific sprites (such as enemies, etc).

Note that EVENT_EGS and EVENT_SPAWN are triggered the moment the sprite is spawned.

For example:

useractor notenemy ACTOR
  espawn PIGCOP
  setactor[RETURN].pal 1
enda

onevent EVENT_EGS
  ifactor PIGCOP
    spritepal 2
endevent

In this case, the PIGCOP palette will be 1, because EVENT_EGS takes place before the lines below the espawn command.

Deleting sprites during EVENT_EGS may cause problems, since some hard-coded functions may try to change their properties after they were spawned (similar to the espawn example above).