-
Notifications
You must be signed in to change notification settings - Fork 22
Object Events (Area of Effect process)
ToEE uses the Object Event system for handling AoE effects, such as grease, web etc. It's in charge of detecting creatures entering or leaving an AoE and usually applies or removes secondary status effects (such as Prone or Webbed).
In vanilla ToEE, registering an AoE process is done behind the scenes in a hard-coded fashion whenever you apply spell conditions (such as 'sp-grease').
Temple+ allows you to register custom events via python using a new PyObjHandle method object_event_append
.
Example usage:
def AuraOfDespairBegin(attachee, args, evt_obj):
radius_feet = 10.0 + (attachee.radius / 12.0)
obj_evt_id = attachee.object_event_append(OLC_CRITTERS, radius_feet)
args.set_arg(2, obj_evt_id)
return 0
In this example, the object attachee
will act as the center of the AoE.
The engine will detect creatures going in/out of the AoE using the specified radius (given in feet). When this happens, it will trigger an event of type ET_OnObjectEvent. You should define callbacks to respond to such event.
Example callbacks:
def AuraOfDespairAoEEntered(attachee, args, evt_obj):
#print "Aura of Despair entered event"
obj_evt_id = args.get_arg(2)
if obj_evt_id != evt_obj.evt_id:
#print "Aura of Despair Entered: ID mismatch " + str(evt_obj.evt_id) + ", stored was: " + str(obj_evt_id)
return 0
#print "Aura of Despair Entered, event ID: " + str(obj_evt_id)
tgt = evt_obj.target
if tgt == OBJ_HANDLE_NULL:
return 0
if attachee == OBJ_HANDLE_NULL:
return 0
if not tgt.allegiance_shared(attachee) and not tgt.is_friendly(attachee):
tgt.condition_add_with_args("Despaired_Aura", 0, 0, obj_evt_id)
return 0
auraDesp.AddHook(ET_OnObjectEvent, EK_OnEnterAoE, AuraOfDespairAoEEntered, ())
def AuraOfDespairAoEExited(attachee, args, evt_obj):
obj_evt_id = args.get_arg(2)
if obj_evt_id != evt_obj.evt_id:
#print "Aura of Despair Exited: ID mismatch " + str(evt_obj.evt_id) + ", stored was: " + str(obj_evt_id)
return 0
#print "Aura of Despair (ID " + str(obj_evt_id) +") Exited, critter: " + attachee.description + " "
args.condition_remove()
return 0
auraDespEffect.AddHook(ET_OnObjectEvent, EK_OnLeaveAoE, AuraOfDespairAoEExited, ())
Note that the latter (AoEExited) is a callback for the Despaired_Aura Modifier, so it gets removed whenever a Despaired creature leaves the AoE.