/********************************************************************** * * Title: temporary_structure.script * Description: script that handles the temporary player structure **********************************************************************/ /***** INCLUDES ********************************************************/ include library.utils; include library.planetary_map; /***** CONSTANTS *******************************************************/ const string_id SID_LOCATION_REGISTRATION_CANCELLED = new string_id("travel", "location_registration_cancelled"); /***** TRIGGERS ********************************************************/ trigger OnLostItem(obj_id destContainer, obj_id transferer, obj_id item) { if ( utils.isNestedWithin(destContainer, self) ) return SCRIPT_CONTINUE; removeRegistrant(self, item); return SCRIPT_CONTINUE; } trigger OnTriggerVolumeExited( string volName, obj_id who ) { if ( who == self ) return SCRIPT_CONTINUE; if ( volName.equals("camp_" + self) ) removeRegistrant(self, who); return SCRIPT_CONTINUE; } /***** MESSAGEHANDLERS *************************************************/ messageHandler removeRegistrant() { obj_id objItem = params.getObjId("objItem"); removeRegistrant(self, objItem); return SCRIPT_CONTINUE; } /***** COMMANDHANDLERS *************************************************/ /***** FUNCTIONS **************************************************/ void removeRegistrant(obj_id self, obj_id item) { if ( !isIdValid(self) || !isIdValid(item) || !isPlayer(item) ) return; resizeable obj_id[] registrants = utils.getResizeableObjIdBatchScriptVar(self, "registrants"); if ( registrants != null && registrants.length > 0 ) { int idx = utils.getElementPositionInArray(registrants, item); if ( idx > -1 ) { registrants = utils.removeElementAt(registrants, idx); if ( registrants == null || registrants.length == 0 ) { utils.removeBatchScriptVar(self, "registrants"); if ( planetary_map.updateFacilityActive(self, false) ) detachScript(self, "planet_map.active_registered"); } else { utils.setBatchScriptVar(self, "registrants", registrants); } if ( item.isLoaded() ) { sendSystemMessage(item, SID_LOCATION_REGISTRATION_CANCELLED); utils.removeScriptVar(item, "registerWithLocation"); } return; } } }