//OTRES include file //2.6 added variable for PW support //OTRES trigger tag format: //StartingDestination_FinalDestination_HoursToGoToFinal_NextWaypoint_HoursToGoToNextWaypoint_Terrain_Facing //i.e. 7_3_24_1_8_Forest_s or 7_3_24_1_8_Forest_45 //(direction can be n, s, e, w, ne, nw, se, sw, or a number 0 through 360 //with east 0, north 90, etc.) //Which might translate to, "I am starting off at Point A and I want to go //to the Forest Tomb. It is 24 hours of travel to get there. To get there, //I will first be going to Waypoint 1, which is 8 hours of travel through a //forest, and I will be going generally south." //OTRESOnModuleLoad stores the jump descriptions and tags //on the module as an "array" void OTRESOnModuleLoad() {//OTRESOnModuleLoad start object oMod=GetModule(); /* Enter the destination description for DD1, DD2, etc. Enter the tag of the waypoint for the area for t1, t2, etc. Example SetLocalString(oMod,"DD1","The first forest Wayhouse"); SetLocalString(oMod,"t1","ForestWaypoint1"); */ SetLocalString(oMod,"DD1","The first forest Wayhouse"); //Description for players for location 1 used in OTRES dialog SetLocalString(oMod,"t1","ForestWaypoint1"); //Tag of OTRES arrival point for location 1 SetLocalString(oMod,"DD2","The second forest Wayhouse"); SetLocalString(oMod,"t2","ForestWaypoint2"); SetLocalString(oMod,"DD3","The Forest Tomb"); SetLocalString(oMod,"t3","ForestTomb"); SetLocalString(oMod,"DD4","The first plains Wayhouse"); SetLocalString(oMod,"t4","PlainsWaypoint1"); SetLocalString(oMod,"DD5","The second plains Wayhouse"); SetLocalString(oMod,"t5","PlainsWaypoint2"); SetLocalString(oMod,"DD6","The House on the Plains"); SetLocalString(oMod,"t6","PlainsHouse"); SetLocalString(oMod,"DD7","Point A"); SetLocalString(oMod,"t7","PointASouth"); SetLocalString(oMod,"DD8","Point A"); SetLocalString(oMod,"t8","PointAWest"); SetLocalString(oMod,"DD9","The first plains Wayhouse"); SetLocalString(oMod,"t9","PlainsWay1West"); SetLocalString(oMod,"DD10","The second plains Wayhouse"); SetLocalString(oMod,"t10","PlainsWay2West"); //add new area descriptions and tags here, increasing the number each time as above SetLocalInt(oMod,"iOTRESMax",10); //Highest number of OTRES locations, should match the highest DD and t above - used for error trapping SetLocalInt(oMod,"bPW",FALSE); //Set this to true for persistant worlds }//OTRESOnModuleLoad finish // * Prototype Array Functions (from Noel in nw_o0_itemmaker) void SetLocalArrayString(object oidObject, string sVarName, int nVarNum, string nValue); string GetLocalArrayString(object oidObject, string sVarName, int nVarNum); void SetLocalArrayInt(object oidObject, string sVarName, int nVarNum, int nValue); int GetLocalArrayInt(object oidObject, string sVarName, int nVarNum); //The following is a function for returning the travel time coefficient float TravelTimeCoeff() { float fTravelTimeCoeff=1.; //Changing this number would change travel times for all of OTRES which doesn't make sense /*Instead, say you want to simulate riding a horse. You might add a statement like this one to decrease the travel time by about 30% (rounding rules are used): */ int iBoughtAHorse=GetLocalInt(GetPCSpeaker(),"iBoughtAHorse"); if (iBoughtAHorse==TRUE) fTravelTimeCoeff=0.7; //*/ return fTravelTimeCoeff; } //The following function returns the encounter probability coefficient float EncounterCoeff() { float fEncounterCoeff=1.;//Changing this number would change the probability for all of OTRES which doesn't make sense /*Instead, say you want to simulate hiring a local guide who knows how to avoid the local dangers. You might add a statement like this one to decrease the encounter probability by about 20%: */ int iHiredAGuide=GetLocalInt(GetPCSpeaker(),"iHiredAGuide"); if (iHiredAGuide==TRUE) fEncounterCoeff=0.8; //*/ return fEncounterCoeff; } /*The following function reads off the OTRES variables and stores them as local variables on the OTRES trigger. Used only the first time a trigger is used.*/ void StoreOTRESVar(object oTrigger) {//begin StoreOTRESVar object oMod=GetModule(); //the module (used in accessing the array) int iOTRESMax=GetLocalInt(oMod,"iOTRESMax"); //max number of OTRES areas int iCount; //where am I in the tag's string string sChar; //one letter from the tag string sStartDestinationNum; //Where I am starting from string sFinalDestinationNum; //What is my final (or hub) destination string sFinalHoursToGo; //How many hours to the next area of interest string sNextDestinationNum; //What is my next waypoint destination string sHoursToGo; //How many hours to the next waypoint? Must be <=12 string sTerrain; //What terrain am I traveling in string sFacing; //What direction should I face when I arrive string sTriggerTag=GetTag(oTrigger); int iStringLength=GetStringLength(sTriggerTag); int iDim; //Array dimension //Starting Destination number loop for (iCount=0;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sStartDestinationNum+=sChar; } //Change sStartDestinationNum into the tag and description. iDim=StringToInt(sStartDestinationNum); if (iDim>iOTRESMax) //error trap {//begin error trap SendMessageToAllDMs("Error in OTRES - OTRES start destination tag has a number higher than the max - check OTRESOnModuleLoad"); object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems? object oMember=GetFirstFactionMember(oPC); while (oMember!=OBJECT_INVALID) { SendMessageToPC(oMember,"OTRES Error - your DM has been notified"); oMember=GetNextFactionMember(oPC); } }//end error trap string sStartDestinationTag=GetLocalArrayString(oMod,"t",iDim); string sStartDestinationDesc=GetLocalArrayString(oMod,"DD",iDim); //Final Destination number loop for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sFinalDestinationNum+=sChar; } //Change sFinalDestinationNum into the tag and description. iDim=StringToInt(sFinalDestinationNum); if (iDim>iOTRESMax) //error trap {//begin error trap SendMessageToAllDMs("Error in OTRES - OTRES final destinaiton tag has a number higher than the max - check OTRESOnModuleLoad"); object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems? object oMember=GetFirstFactionMember(oPC); while (oMember!=OBJECT_INVALID) { SendMessageToPC(oMember,"OTRES Error - your DM has been notified"); oMember=GetNextFactionMember(oPC); } }//end error trap string sFinalDestinationTag=GetLocalArrayString(oMod,"t",iDim); string sFinalDestinationDesc=GetLocalArrayString(oMod,"DD",iDim); //Hours to go to final loop. for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sFinalHoursToGo+=sChar; } //Next Waypoint number loop for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sNextDestinationNum+=sChar; } //Change sDestinationNum into the tag and description. iDim=StringToInt(sNextDestinationNum); if (iDim>iOTRESMax) //error trap {//begin error trap SendMessageToAllDMs("Error in OTRES - OTRES next destination tag has a number higher than the max - check OTRESOnModuleLoad"); object oPC=GetPCSpeaker(); //debug - possible source of multi-party problems? object oMember=GetFirstFactionMember(oPC); while (oMember!=OBJECT_INVALID) { SendMessageToPC(oMember,"OTRES Error - your DM has been notified"); oMember=GetNextFactionMember(oPC); } }//end error trap string sNextDestinationTag=GetLocalArrayString(oMod,"t",iDim); string sNextDestinationDesc=GetLocalArrayString(oMod,"DD",iDim); //Hours to go to next waypoint loop for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sHoursToGo+=sChar; } int iHoursToGo=StringToInt(sHoursToGo); //Terrain loop for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="_") break; sTerrain+=sChar; } //Facing loop for (iCount=iCount+1;iCount<=iStringLength;iCount++) { sChar=GetSubString(sTriggerTag,iCount,1); if (sChar=="") break; sFacing+=sChar; } //Change sFacing into float float fFacing; if (sFacing=="s") fFacing=DIRECTION_SOUTH; else if (sFacing=="n") fFacing=DIRECTION_NORTH; else if (sFacing=="e") fFacing=DIRECTION_EAST; else if (sFacing=="w") fFacing=DIRECTION_WEST; else if (sFacing=="se") fFacing=DIRECTION_SOUTH+45.; else if (sFacing=="sw") fFacing=DIRECTION_SOUTH-45.; else if (sFacing=="ne") fFacing=DIRECTION_NORTH-45.; else if (sFacing=="nw") fFacing=DIRECTION_NORTH+45.; else if (StringToFloat(sFacing)>=0.) fFacing=StringToFloat(sFacing); else fFacing=0.; //Finally, store local vars on trigger SetLocalFloat(oTrigger,"fFacing", fFacing); SetLocalInt(oTrigger,"iHoursToGo", iHoursToGo); SetLocalString(oTrigger,"sTerrain", sTerrain); SetLocalString(oTrigger,"sFinalHoursToGo", sFinalHoursToGo); //leave as string SetLocalString(oTrigger,"sStartDestinationTag", sStartDestinationTag); SetLocalString(oTrigger,"sStartDestinationDesc",sStartDestinationDesc); SetLocalString(oTrigger,"sFinalDestinationTag", sFinalDestinationTag); SetLocalString(oTrigger,"sFinalDestinationDesc",sFinalDestinationDesc); SetLocalString(oTrigger,"sNextDestinationTag", sNextDestinationTag); SetLocalString(oTrigger,"sNextDestinationDesc", sNextDestinationDesc); SetLocalInt(oTrigger,"iDoOnce", 1); //flag to do only once }//end StoreOTRESVar*/ void SetOTRESVar(object oTrigger,int bRandReturn) {//begin SetOTRESVar function //When called, it sets the travel variables on the party in preparation //for travel. Pass PC as oTrigger when leaving from random encounter. float fFacing=GetLocalFloat(oTrigger,"fFacing"); int iHoursToGo=GetLocalInt(oTrigger,"iHoursToGo"); string sTerrain=GetLocalString(oTrigger,"sTerrain"); string sFinalHoursToGo=GetLocalString(oTrigger,"sFinalHoursToGo"); //leave as string string sStartDestinationTag=GetLocalString(oTrigger,"sStartDestinationTag"); string sStartDestinationDesc=GetLocalString(oTrigger,"sStartDestinationDesc"); string sFinalDestinationTag=GetLocalString(oTrigger,"sFinalDestinationTag"); string sFinalDestinationDesc=GetLocalString(oTrigger,"sFinalDestinationDesc"); string sNextDestinationTag=GetLocalString(oTrigger,"sNextDestinationTag"); string sNextDestinationDesc=GetLocalString(oTrigger,"sNextDestinationDesc"); //If returning from a random encounter, change the next destination to //start destination and the traveltime to iTravelledHours and the facing if (bRandReturn==TRUE) {//Begin RandReturn string sTemp; sNextDestinationTag=sStartDestinationTag; sNextDestinationDesc=sStartDestinationDesc; //Travel Time iHoursToGo=GetLocalInt(GetPCSpeaker(),"iTravelledHours"); if (TravelTimeCoeff()!=1.0) //add back for travel time coefficient {//begin travel time correction float fHoursToGo=IntToFloat(iHoursToGo)/TravelTimeCoeff(); //Hours left in this segment modified by a travel time coefficient in otres_inc float fRoundTest=fHoursToGo-IntToFloat(FloatToInt(fHoursToGo)); if (fRoundTest>=0.5) //Correct for FloatToInt not rounding but truncating iHoursToGo=1+FloatToInt(fHoursToGo); else iHoursToGo=FloatToInt(fHoursToGo); }//end travel time correction*/ //Set the facing fFacing+=180; }//End RandReturn //////////////////////////////////////////////////////////////////////////////// //Set the variables on the party //Modified to fix multi-party bugs //////////////////////////////////////////////////////////////////////////////// object oPC=GetPCSpeaker(); object oMember=GetFirstFactionMember(oPC); SetLocalInt(oPC,"bTravel",TRUE); while (oMember!=OBJECT_INVALID) //Loop through the party { // Set the variables for the party SetLocalFloat(oMember,"fFacing", fFacing); SetLocalInt(oMember,"iHoursToGo", iHoursToGo); SetLocalString(oMember,"sTerrain", sTerrain); SetLocalString(oMember,"sFinalHoursToGo", sFinalHoursToGo); //leave as string SetLocalString(oMember,"sStartDestinationTag", sStartDestinationTag); SetLocalString(oMember,"sStartDestinationDesc",sStartDestinationDesc); SetLocalString(oMember,"sFinalDestinationTag", sFinalDestinationTag); SetLocalString(oMember,"sFinalDestinationDesc",sFinalDestinationDesc); SetLocalString(oMember,"sNextDestinationTag", sNextDestinationTag); SetLocalString(oMember,"sNextDestinationDesc", sNextDestinationDesc); oMember=GetNextFactionMember(oPC); } }//end SetOTRESVar function //This function reads and sets custom tokens for use in the travel conversation //It also stores the OTRES variables on the trigger if this hasn't been done yet void OTRESTokens(object oTrigger) {//Start OTRESTokens //Calls StoreOTRESVar if(!GetIsPC(oTrigger)) if(GetLocalInt(oTrigger,"iDoOnce")!=1) StoreOTRESVar(oTrigger); //Read all variables needed for tokens from trigger float fFacing=GetLocalFloat(oTrigger,"fFacing"); int iHoursToGo=GetLocalInt(oTrigger,"iHoursToGo"); string sTerrain=GetLocalString(oTrigger,"sTerrain"); string sFinalHoursToGo=GetLocalString(oTrigger,"sFinalHoursToGo"); //leave as string string sStartDestinationTag=GetLocalString(oTrigger,"sStartDestinationTag"); string sStartDestinationDesc=GetLocalString(oTrigger,"sStartDestinationDesc"); string sFinalDestinationTag=GetLocalString(oTrigger,"sFinalDestinationTag"); string sFinalDestinationDesc=GetLocalString(oTrigger,"sFinalDestinationDesc"); string sNextDestinationTag=GetLocalString(oTrigger,"sNextDestinationTag"); string sNextDestinationDesc=GetLocalString(oTrigger,"sNextDestinationDesc"); //Starting Destination set token SetCustomToken(124,sStartDestinationDesc); //Final Destination set token SetCustomToken(125,sFinalDestinationDesc); //Set token for Hours To Go To Final SetCustomToken(126,sFinalHoursToGo); //Next Waypoint set token SetCustomToken(127,sNextDestinationDesc); //Set token for Hours To Go To Next Waypoint string sHoursToGo=IntToString(iHoursToGo); SetCustomToken(128,sHoursToGo); //Set a flag for the conditional in case the next waypoint and the final are the same if (sFinalDestinationTag==sNextDestinationTag) SetLocalInt(GetPCSpeaker(),"bFinalNext",TRUE); else SetLocalInt(GetPCSpeaker(),"bFinalNext",FALSE); }//End OTRESTokens //OTRES Arrays (from Noel in nw_o0_itemmaker) string GetLocalArrayString(object oidObject, string sVarName, int nVarNum) { string sFullVarName = sVarName + IntToString(nVarNum) ; return GetLocalString(oidObject, sFullVarName); } void SetLocalArrayString(object oidObject, string sVarName, int nVarNum, string nValue) { string sFullVarName = sVarName + IntToString(nVarNum) ; SetLocalString(oidObject, sFullVarName, nValue); } int GetLocalArrayInt(object oidObject, string sVarName, int nVarNum) { string sFullVarName = sVarName + IntToString(nVarNum) ; return GetLocalInt(oidObject, sFullVarName); } void SetLocalArrayInt(object oidObject, string sVarName, int nVarNum, int nValue) { string sFullVarName = sVarName + IntToString(nVarNum) ; SetLocalInt(oidObject, sFullVarName, nValue); } //void main(){}