Osrs inc

osrs_inc is an include script used by OSRS. ///////////////////////////////////////////////////////////////////////////// // // file: //     osrs_inc // // purpose: //     Include script for all Open Source Rule Set files, for use by OSRS only. // /////////////////////////////////////////////////////////////////////////////

// the include file for user events
 * 1) include "osrs_inc_user"

// determine the object class of oCaller const int I_OSRS_EVENT_CLASS_UNKNOWN  = -2; // const int I_OSRS_EVENT_CLASS_ERROR    = -1; // const int I_OSRS_EVENT_CLASS_DEFAULT  = 0;  // used ONLY to represent the default value that comes back from a GetLocalInt call upon an object that has not yet been initialized. const int I_OSRS_EVENT_CLASS_AREA     = 1;  // const int I_OSRS_EVENT_CLASS_CREATURE = 2;  // const int I_OSRS_EVENT_CLASS_DOOR     = 3; const int I_OSRS_EVENT_CLASS_ENCOUNTER = 4; // const int I_OSRS_EVENT_CLASS_MERCHANT = 5;  // const int I_OSRS_EVENT_CLASS_MODULE   = 6;  // const int I_OSRS_EVENT_CLASS_PLACEABLE = 7; const int I_OSRS_EVENT_CLASS_TRAP     = 8;  // const int I_OSRS_EVENT_CLASS_TRIGGER  = 9;

// used in GetLocalInt and SetLocalInt calls so that identification of an // object only occurs during the first call to osrs_GetCallerEventClass const string S_CALLER_EVENT_CLASS = "S_CALLER_EVENT_CLASS";

/*   // determine what type of object is calling this script int iCallingClass = osrs_GetCallerEventClass(OBJECT_SELF);

switch(iCallingClass) {       case I_OSRS_EVENT_CLASS_UNKNOWN: case I_OSRS_EVENT_CLASS_ERROR: case I_OSRS_EVENT_CLASS_DEFAULT: return;

case I_OSRS_EVENT_CLASS_AREA: case I_OSRS_EVENT_CLASS_CREATURE: case I_OSRS_EVENT_CLASS_ENCOUNTER: case I_OSRS_EVENT_CLASS_MERCHANT: case I_OSRS_EVENT_CLASS_MODULE: case I_OSRS_EVENT_CLASS_TRAP: case I_OSRS_EVENT_CLASS_TRIGGER: case I_OSRS_EVENT_CLASS_DOOR: case I_OSRS_EVENT_CLASS_PLACEABLE:

default: return; }



/////////////////////////////////////////////////////////////////////////////// // int osrs_GetCallerEventClass(object oCaller); // Call this function with OBJECT_SELF as the argument to determine what type // of object you are. With this information you can determine which // appropriate object script to run. // This function returns a class indicator. If the caller calls this function // with an object that cannot // "own" such an event, like an item that can be picked up and placed in a PC's // inventory, then it returns an error. // The purpose of this function is so // that instead of having 75 different scripts to code and maintain, we can // limit it to just 42 (one for each event type; each event determines the // object type that it is running upon and calls the appropriate function). // This also allows us to use a common concept of OnHeartbeat, because you // might have had many such scripts before, but with OSRS you get only one // event, and it determines the appropriate object event involved. // // In order to alleviate some concerns over speed, OSRS has optimized this // function to use Bioware's local variable system. If the object has already // been identified in some previous call (which would be normal for an // OnHeartbeat event), then the local variable provides a quick and stable // (time delay) solution, so // that after the object calling this script has been identified once, // subsequent calls for identification will instead reference and utilize the // local variable that has been set upon it's object. int osrs_GetCallerEventClass(object oCaller); int osrs_GetCallerEventClass(object oCaller) {   // validate parameter first before referencing it's attributes if (!GetIsObjectValid(oCaller)) return I_OSRS_EVENT_CLASS_ERROR;

// check to see if this Object has been identified earlier. int iPreExistingIdentification = GetLocalInt(oCaller, S_CALLER_EVENT_CLASS); if (iPreExistingIdentification != I_OSRS_EVENT_CLASS_DEFAULT) return iPreExistingIdentification; // otherwise, the specific class for this object has not yet been determined.

// CLASSES LEFT TO CHECK: // AREA, CREATURE, ENCOUNTER, MERCHANT, MODULE, TRAP, TRIGGER, DOOR, PLACEABLE, UNKNOWN

// what type of object is this? int iCallerObjectType = GetObjectType(oCaller); switch(iCallerObjectType) {       case OBJECT_TYPE_CREATURE:          // Specifies the object is a creature (PC, animal, monster etc). SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_CREATURE); return I_OSRS_EVENT_CLASS_CREATURE;

case OBJECT_TYPE_DOOR:             // Specifies the object is a door. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_DOOR); return I_OSRS_EVENT_CLASS_DOOR;

case OBJECT_TYPE_ENCOUNTER:        // Should specify an object which is an encounter, although no reference to this constant appears within NWScript other than its declaration. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_ENCOUNTER); return I_OSRS_EVENT_CLASS_ENCOUNTER;

case OBJECT_TYPE_PLACEABLE:        // Specifies the object is a placeable. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_PLACEABLE); return I_OSRS_EVENT_CLASS_PLACEABLE;

case OBJECT_TYPE_STORE:            // Specifies the object is a store. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_MERCHANT); return I_OSRS_EVENT_CLASS_MERCHANT;

case OBJECT_TYPE_TRIGGER:          // Specifies the object is a trigger. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_TRIGGER); return I_OSRS_EVENT_CLASS_TRIGGER;

// case OBJECT_TYPE_ALL:              // Specifies all objects. Used for unrestricted searches. Strangely, OBJECT_TYPE_ALL and OBJECT_TYPE_INVALID equal the same value. case OBJECT_TYPE_INVALID:          // Specifies the object is invalid. Strangely, OBJECT_TYPE_INVALID and OBJECT_TYPE_ALL equal the same value. OBJECT_TYPE_INVALID has an integer value of 32,767. case OBJECT_TYPE_AREA_OF_EFFECT:   // Specifies the object is an area of effect (AOE). case OBJECT_TYPE_ITEM:             // Specifies the object is an item. case OBJECT_TYPE_WAYPOINT: SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_ERROR); return I_OSRS_EVENT_CLASS_ERROR;

default: break; }

// CLASSES LEFT TO CHECK: // AREA, MODULE, TRAP, UNKNOWN

// is it the module? if (oCaller == GetModule) {       SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_MODULE); return I_OSRS_EVENT_CLASS_MODULE; }

// CLASSES LEFT TO CHECK: // AREA, TRAP, UNKNOWN

// is it an area? if (GetIsAreaAboveGround(oCaller) != AREA_INVALID) {       SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_AREA); return I_OSRS_EVENT_CLASS_AREA; }

// CLASSES LEFT TO CHECK: // TRAP, UNKNOWN

// traps have a base type int iTrapBaseType = GetTrapBaseType(oCaller); switch (iTrapBaseType) {       case TRAP_BASE_TYPE_AVERAGE_ACID: case TRAP_BASE_TYPE_AVERAGE_ACID_SPLASH: case TRAP_BASE_TYPE_AVERAGE_ELECTRICAL: case TRAP_BASE_TYPE_AVERAGE_FIRE: case TRAP_BASE_TYPE_AVERAGE_FROST: case TRAP_BASE_TYPE_AVERAGE_GAS: case TRAP_BASE_TYPE_AVERAGE_HOLY: case TRAP_BASE_TYPE_AVERAGE_NEGATIVE: case TRAP_BASE_TYPE_AVERAGE_SONIC: case TRAP_BASE_TYPE_AVERAGE_SPIKE: case TRAP_BASE_TYPE_AVERAGE_TANGLE: case TRAP_BASE_TYPE_DEADLY_ACID: case TRAP_BASE_TYPE_DEADLY_ACID_SPLASH: case TRAP_BASE_TYPE_DEADLY_ELECTRICAL: case TRAP_BASE_TYPE_DEADLY_FIRE: case TRAP_BASE_TYPE_DEADLY_FROST: case TRAP_BASE_TYPE_DEADLY_GAS: case TRAP_BASE_TYPE_DEADLY_HOLY: case TRAP_BASE_TYPE_DEADLY_NEGATIVE: case TRAP_BASE_TYPE_DEADLY_SONIC: case TRAP_BASE_TYPE_DEADLY_SPIKE: case TRAP_BASE_TYPE_DEADLY_TANGLE: case TRAP_BASE_TYPE_EPIC_ELECTRICAL: case TRAP_BASE_TYPE_EPIC_FIRE: case TRAP_BASE_TYPE_EPIC_FROST: case TRAP_BASE_TYPE_EPIC_SONIC: case TRAP_BASE_TYPE_MINOR_ACID: case TRAP_BASE_TYPE_MINOR_ACID_SPLASH: case TRAP_BASE_TYPE_MINOR_ELECTRICAL: case TRAP_BASE_TYPE_MINOR_FIRE: case TRAP_BASE_TYPE_MINOR_FROST: case TRAP_BASE_TYPE_MINOR_GAS: case TRAP_BASE_TYPE_MINOR_HOLY: case TRAP_BASE_TYPE_MINOR_NEGATIVE: case TRAP_BASE_TYPE_MINOR_SONIC: case TRAP_BASE_TYPE_MINOR_SPIKE: case TRAP_BASE_TYPE_MINOR_TANGLE: case TRAP_BASE_TYPE_STRONG_ACID: case TRAP_BASE_TYPE_STRONG_ACID_SPLASH: case TRAP_BASE_TYPE_STRONG_ELECTRICAL: case TRAP_BASE_TYPE_STRONG_FIRE: case TRAP_BASE_TYPE_STRONG_FROST: case TRAP_BASE_TYPE_STRONG_GAS: case TRAP_BASE_TYPE_STRONG_HOLY: case TRAP_BASE_TYPE_STRONG_NEGATIVE: case TRAP_BASE_TYPE_STRONG_SONIC: case TRAP_BASE_TYPE_STRONG_SPIKE: case TRAP_BASE_TYPE_STRONG_TANGLE: SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_TRAP); return I_OSRS_EVENT_CLASS_TRAP;

// if it is not one of these base trap types then it is NOT a trap default: // this function does not _appear_ to return INVALID if it is called // upon a non-trap object, therefore I do not know what the result // will be when the argument is definitely not a trap! Here I log // this to the Log File so we can revise the code with the // appropriate value and complete this section. WriteTimestampedLogEntry("OSRS_inc::OSRS_GetClass: "+               "GetTrapBaseType returned unknown value '"+                IntToString(iTrapBaseType)+"'."                ); break;

}

// CLASSES LEFT TO CHECK: // UNKNOWN

// Therefore, anything else that calls this script, we are either unable // to determine, or does not apply for the purposes of this function, // which is to identify the type of object (a class) that can own and // respond to events. SetLocalInt(oCaller, S_CALLER_EVENT_CLASS, I_OSRS_EVENT_CLASS_ERROR); return I_OSRS_EVENT_CLASS_ERROR;

}

///////////////////////////////////////////////////////////////////////// // Area::OnUserDefined event int osrs_a_oud; int osrs_a_oud {   return 1; }

///////////////////////////////////////////////////////////////////////// // Area::OnHeartbeat event int osrs_a_oh; int osrs_a_oh {   return 1; }

///////////////////////////////////////////////////////////////////////// // Area::OnExit event int osrs_a_oexi; int osrs_a_oexi {   return 1; }

///////////////////////////////////////////////////////////////////////// // Area::OnEnter event int osrs_a_oent; int osrs_a_oent {   return 1; }

///////////////////////////////////////////////////////////////////////// // Encounter::OnEnter event int osrs_e_oent; int osrs_e_oent {   return TRUE; }

///////////////////////////////////////////////////////////////////////// // Trigger::OnEnter event int osrs_tri_oent; int osrs_tri_oent {   return TRUE; }

///////////////////////////////////////////////////////////////////////// // Trigger::OnClick event int osrs_tri_ocli; int osrs_tri_ocli {   return TRUE; }

//////////////////////////////////////////////////////////////////////// // Encounter::OnExit event int osrs_e_oexi; int osrs_e_oexi {   return TRUE; }

//////////////////////////////////////////////////////////////////////// // Trigger::OnExit event int osrs_tri_oexi; int osrs_tri_oexi {   return TRUE; }

///////////////////////////////////////////////////////////////////////////// // Encounter::OnHeartbeat event int osrs_e_oh; int osrs_e_oh {   return TRUE; }

///////////////////////////////////////////////////////////////////////////// // Trigger::OnHeartbeat event int osrs_tri_oh; int osrs_tri_oh {   return TRUE; }

///////////////////////////////////////////////////////////////////////////// // Trigger::OnHeartbeat event int osrs_c_oh; int osrs_c_oh {   return TRUE; }

///////////////////////////////////////////////////////////////////////////// // Trigger::OnHeartbeat event int osrs_d_oh; int osrs_d_oh {   return TRUE; }

///////////////////////////////////////////////////////////////////////////// // Trigger::OnHeartbeat event int osrs_p_oh; int osrs_p_oh {   return TRUE; }

//////////////////////////////////////////////// // Merchant::OnStoreClosed event int osrs_me_osc; int osrs_me_osc {   return TRUE; }

///////////////////////////////////////////////// // Merchant::OnOpenStore event int osrs_me_oos; int osrs_me_oos {   // This script was in the default merchant I dropped. It might be from X2 expansion only. ExecuteScript("nw_d1_startstore", OBJECT_SELF); // stilltodo: this function needs to be wrapped in a toggle?

return TRUE; }

///////////////////////////////////////////////// // Trap::OnDisarm event int osrs_tra_odisa; int osrs_tra_odisa {   return TRUE; }

//////////////////////////// // Module::OnUserDefined event int osrs_mo_oud; int osrs_mo_oud {   return TRUE; }

//////////////////////////// // Module::OnHeartbeat Pre-event int osrs_mo_oh; int osrs_mo_oh {   return TRUE; }

//////////////////////////// // Creature::OnUserDefined event int osrs_c_oud; int osrs_c_oud {   return TRUE; }

//////////////////////////// // Trigger::OnUserDefined event int osrs_tri_oud; int osrs_tri_oud {   return TRUE; }

//////////////////////////// // Encounter::OnUserDefined event int osrs_e_oud; int osrs_e_oud {   return TRUE; }

//////////////////////////// // Placeable::OnUserDefined event int osrs_p_oud; int osrs_p_oud {   return TRUE; }

//////////////////////////// // Door::OnUserDefined event int osrs_d_oud; int osrs_d_oud {   return TRUE; }

//////////////////////////// // Trap::OnUserDefined event int osrs_tra_oud; int osrs_tra_oud {   return TRUE; }

////////////////////////////////////////////////// // Trap::OnTrapTriggered event int osrs_tra_ott; int osrs_tra_ott {   return TRUE; }

////////////////////////////////////////////////// // Encounter::OnEnter event int osrs_e_oexh; int osrs_e_oexh {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnSpellCastAt event int osrs_p_osca; int osrs_p_osca {   return TRUE; }

//////////////////////////////////////////////// // Door::OnSpellCastAt event int osrs_d_osca; int osrs_d_osca {   return TRUE; }

//////////////////////////////////////////////// // Creature::OnSpellCastAt event int osrs_c_osca; int osrs_c_osca {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnDamaged event int osrs_p_oda; int osrs_p_oda {   return TRUE; }

////////////////////////////////////////////////// // Creature::OnDamaged event int osrs_c_oda; int osrs_c_oda {   return TRUE; }

////////////////////////////////////////////////// // Door::OnDamaged event int osrs_d_oda; int osrs_d_oda {   return TRUE; }

////////////////////////////////////////////////// // Creature::OnDeath event int osrs_c_ode; int osrs_c_ode {   return TRUE; }

////////////////////////////////////////////////// // Door::OnDeath event int osrs_d_ode; int osrs_d_ode {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnDeath event int osrs_p_ode; int osrs_p_ode {   return TRUE; }

////////////////////////////////////////////////// // Door::OnPhysicalAttacked event int osrs_d_opa; int osrs_d_opa {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnPhysicalAttacked event int osrs_p_opa; int osrs_p_opa {   return TRUE; }

////////////////////////////////////////////////// // Creature::OnPhysicalAttacked event int osrs_c_opa; int osrs_c_opa {   return TRUE; }

//////////////////////////////////// // Door::OnClosed event int osrs_d_oclo; int osrs_d_oclo {   return TRUE; }

//////////////////////////////////// // Placeable::OnClosed event int osrs_p_oclo; int osrs_p_oclo {   return TRUE; }

////////////////////////////////////////////////// // Creature::OnDisturbed event int osrs_c_odist; int osrs_c_odist {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnDisturbed event int osrs_p_odist; int osrs_p_odist {   return TRUE; }

////////////////////////////////////////////////// // Door::OnFailToOpen event int osrs_d_ofto; int osrs_d_ofto {   return TRUE; }

////////////////////////////////////////////////// // Creature::OnPerception event int osrs_c_op; int osrs_c_op {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnUnLock event int osrs_p_oul; int osrs_p_oul {   return TRUE; }

////////////////////////////////////////////////// // Door::OnUnLock event int osrs_d_oul; int osrs_d_oul {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnUsed event int osrs_p_ou; int osrs_p_ou {   return TRUE; }

////////////////////////////////////////////////// // Module::OnUnAcquireItem event int osrs_mo_ouai; int osrs_mo_ouai {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnOpen event int osrs_p_oo; int osrs_p_oo {   return TRUE; }

////////////////////////////////////////////////// // Door::OnOpen event int osrs_d_oo; int osrs_d_oo {   return TRUE; }

////////////////////////////////////////////////// // Placeable::OnLock event int osrs_p_ol; int osrs_p_ol {   return TRUE; }

////////////////////////////////////////////////// // Door::OnLock event int osrs_d_ol; int osrs_d_ol {   return TRUE; }

////////////////////////////////////////////////// // Door::OnAreaTransitionsClickedevent int osrs_d_oatc; int osrs_d_oatc {   return TRUE; }

/////////////////////////////////////////////////////////////// // Module::OnModuleLoad event int osrs_mo_oml; int osrs_mo_oml {   return TRUE; }

/////////////////////////////////////////////////////////////// // Module::OnAcquireItem event int osrs_mo_oacqi; int osrs_mo_oacqi {   return TRUE; }

////////////////////////////////////////////////////// // Trigger::OnHeartbeat event int osrs_t_oh; int osrs_t_oh {   return TRUE; }

//////////////////////////////////////////////////// // trap::OnHeartbeat event int osrs_tra_oh; int osrs_tra_oh {   return TRUE; }

//////////////////////////////////////////////////// // Module::OnActivateItem event int osrs_mo_oacti; int osrs_mo_oacti {   return TRUE; }

//////////////////////////////////////////////////// // Creature::OnBlocked event int osrs_c_ob; int osrs_c_ob {   return TRUE; }

//////////////////////////////////////////////////// // Creature::OnConversation event int osrs_c_ocon; int osrs_c_ocon {   return TRUE; }

//////////////////////////////////////////////////// // Creature::OnCombatRoundEnd event int osrs_c_ocre; int osrs_c_ocre {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnCutSceneAbort event int osrs_mo_ocsa; int osrs_mo_ocsa {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnClientEnter event int osrs_mo_oce; int osrs_mo_oce {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnClientLeave event int osrs_mo_ocl; int osrs_mo_ocl {   return TRUE; }

//////////////////////////////////////////////////////////// // Creature::OnSpawn event int osrs_c_os; int osrs_c_os {   return TRUE; }

//////////////////////////////////////////////////////////// // Creature::OnRested event int osrs_c_or; int osrs_c_or {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerUnEquipItem event int osrs_mo_opuei; int osrs_mo_opuei {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerDeath event int osrs_mo_opde; int osrs_mo_opde {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerDying event int osrs_mo_opdy; int osrs_mo_opdy {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerEquipItem event int osrs_mo_opei; int osrs_mo_opei {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerLevelUp event int osrs_mo_oplu; int osrs_mo_oplu {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerRespawn event int osrs_mo_opresp; int osrs_mo_opresp {   return TRUE; }

//////////////////////////////////////////////////////////// // Module::OnPlayerRest event int osrs_mo_oprest; int osrs_mo_oprest {   return TRUE; }