ig.

EntityEventDefense

new EntityEventDefense()

Defense Event where enemies are spawned and try to destroy entities, and the player must defend entities and/or destroy the spawned entities. Tip: for events to properly reset after a loss, make sure they either (a) trigger themselves through collision, or (b) you have a reverse trigger in ig.SpawnerEvent#loseTarget that targets the trigger that triggered this event!

Author:
  • Collin Hover - collinhover.com
Source:
Example
// defense events are triggers
// that coordinate one or more spawners
// you may want to add a spawner for entities to destroy
// i.e. you need to kill these entities to win the event
// remember, the destroy and defend properties are maps of names
// and work the same way as a trigger's target property
myEvent.destroy.1 = "spawner_enemy";
// you may want to add a spawner for entities to defend
// i.e. if these entities die, you lose the event
myEvent.defend.1 = "spawner_friendly";
// you can also add entities directly
// and skip using spawners
myEvent.defend.1 = "entity_friendly";
// and for events to properly reset after a loss
// (a) easy method:
// make sure they trigger via collision
// i.e. the player has to collide with the event box
// to start the event
myEvent.triggerable = true;
// (b) complex method:
// or if colliding with the event box is not possible
// you'll need to have a reverse trigger in loseTarget
// that targets the trigger that triggered this event
// so when player collides with myEventTrigger
myEventTrigger.target.1 = myEvent;
// (and myEventTrigger doesn't activate and die)
myEventTrigger.suicidal = false;
// it will activate the event
// and when the event is lost
myEvent.loseTarget.1 = myReverseTrigger;
// the event will activate the reverse trigger
myReverseTrigger.target.1 = myEventTrigger;
// which will unactivate the original trigger
// so that the player can collide with it
// to restart the event

autoComplete

Default Value:
  • false
Source:

defend :Object

Map of names of spawners that spawn entities that must remain alive until all spawned are dead to win.

Source:
See:

<readonly> defendEntities :Array

List of entities to be defended, populated on activation.

Source:

<readonly> defendSpawners :Array

List of spawners that spawn entities to be defended, populated on activation.

Source:

destroy :Object

Map of names of spawners that spawn entities that must be killed to win.

Source:
See:

<readonly> destroyEntities :Array

List of entities to be destroyed, populated on activation.

Source:

<readonly> destroySpawners :Array

List of spawners that spawn entities to be destroyed, populated on activation.

Source:

loseTarget :Object

Map of names of entities that should be triggered when defense lost.

Source:
See:

loseUnspawnsDefend :Boolean

Whether entities to be defended should be unspawned when event is won.

Default Value:
  • true
Source:

loseUnspawnsDestroy :Boolean

Whether entities to be destroyed should be unspawned when event is lost.

Default Value:
  • true
Source:

winTarget :Object

Map of names of entities that should be triggered when sucessfully defended, i.e. win.

Source:
See:

winUnspawnsDefend :Boolean

Whether entities to be defended should be unspawned when event is won.

Default Value:
  • false
Source:

won :Boolean

Whether event has been won.

Default Value:
  • false
Source:

linkDefendEntity()

Links a defend entity by hooking a signal to watch for a change in the event.

Parameters:
Name Type Description
ig.EntityExtended
Source:

linkDestroyEntity()

Links a destroy entity by hooking a signal to watch for a change in the event.

Parameters:
Name Type Description
ig.EntityExtended
Source:

lose()

Called automatically when defense is lost.

Source:

setup()

Called on activate to setup defense event.

Source:

teardown()

Called on win, lose, and deactivate to tear down and cleanup the defense.

Source:

unlinkDefendEntity()

Unlinks a defend entity.

Parameters:
Name Type Description
ig.EntityExtended
Source:

unlinkDestroyEntity()

Unlinks a destroy entity.

Parameters:
Name Type Description
ig.EntityExtended
Source:

updateDefendStatus(entity)

When defending, called automatically when an entity to defend is destroyed, i.e. losing.

Parameters:
Name Type Description
entity ig.EntityExtended
Source:

updateDestroyStatus(entity)

When destroying, called automatically when an entity to destroy is destroyed, i.e. winning.

Parameters:
Name Type Description
entity ig.EntityExtended
Source:

win()

Called automatically when sucessfully defended.

Source: