EVENT EGS: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
 
m prune more trash info
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
EVENT_EGS is triggered when any sprite is spawned on the map. [[onevent]] code for this event is executed by the new sprite during the tick in which it is spawned.  The gamevar [[THISACTOR]] refers to the ID of the sprite that is executing the code.
{{EventTable|1=EVENT_EGS|2=closest player to sprite|3=spawned sprite|4=0 values}}
EVENT_EGS is a [[EDuke32_event_list|Game Event]].
 
This [[event]] is triggered when a new sprite is spawned on the map after load. It is NOT triggered for any pre-placed sprites that are already on the map at load-time.
 
In comparison, [[EVENT_SPAWN]] runs for all sprites that pre-exist when the map is loaded, AS WELL AS all newly spawned sprites.
 
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).
 
EVENT_EGS can be used to save the original sprite [[owner]] before it's changed.
 
[[Category:Events]]

Latest revision as of 00:32, 5 February 2022

Event ID player# THISACTOR RETURN
EVENT_EGS closest player to sprite spawned sprite 0 values

EVENT_EGS is a Game Event.

This event is triggered when a new sprite is spawned on the map after load. It is NOT triggered for any pre-placed sprites that are already on the map at load-time.

In comparison, EVENT_SPAWN runs for all sprites that pre-exist when the map is loaded, AS WELL AS all newly spawned sprites.

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).

EVENT_EGS can be used to save the original sprite owner before it's changed.