| Author: | LuckDragon |
| Script Name: | Old School Random Encounter Table |
| Description: | Based on the old PnP Random Encounter Tables.. where certain creatures were encountered in certain areas. |
| Instructions on Use: | Place it in the module's OnHeartbeat script and modify as necessary. |
Script:
| //::////////////////////////////////////////////////////// //:: PnP Random Encounters //::////////////////////////////////////////////////////// /* This Script Generates Old School Random Encounters like the ones from a random encounter table in a PnP module */ //::////////////////////////////////////////////////////// //:: Created By: LuckDragon //::////////////////////////////////////////////////////// void DoEncCheck (object oPlayer) { if (!GetIsPC(oPlayer) || GetIsInCombat(oPlayer)) { return; } location lPLoc = GetLocation(oPlayer); int iDirection=d8(); float fX; float fY; switch(iDirection) { case 1: // North fX=0.0; fY=10.0; break; case 2: // South fX=0.0; fY=-10.0; break; case 3: // East fX=10.0; fY=0.0; break; case 4: // West fX=-10.0; fY=0.0; break; case 5: // Northeast fX=10.0; fY=10.0; break; case 6: // Southeast fX=10.0; fY=-10.0; break; case 7: // Southwest fX=-10.0; fY=-10.0; break; case 8: // Northwest fX=-10.0; fY=10.0; break; } vector vStart = GetPositionFromLocation(lPLoc); vector vOffset = Vector(fX,fY); vector vEndvector = vStart+vOffset; int myCounter = GetLocalInt(oPlayer,"myCounter"); int nNumMons,i; string creaturetype; int doEncounter = 0; object thisplayArea = GetArea(oPlayer); int numRounds = 1; location lLoc = Location(thisplayArea,vEndvector,GetFacing(oPlayer)); if (thisplayArea == GetArea(GetObjectByTag("Road_To_Solace_Township"))) { if (GetIsNight() == TRUE) { numRounds=2; } else if (GetIsDay() == TRUE) { numRounds=4; } } // Added For Township Of Solace else if (thisplayArea == GetArea(GetObjectByTag("Township_Of_Solace"))) { if (GetIsNight() == TRUE) { numRounds=3; } else if (GetIsDay() == TRUE) { numRounds=6; } } // End Added For Township Of Solace if (myCounter > numRounds) { myCounter = 0; } myCounter = myCounter + 1; SetLocalInt(oPlayer,"myCounter",myCounter); if (numRounds == myCounter) { myCounter=1; SetLocalInt(OBJECT_SELF,"myCounter",myCounter); // The following line uses the Tagname of the Area, not the ResRef if (thisplayArea == GetArea(GetObjectByTag("Road_To_Solace_Township"))) { int nIsEncounter = d10(1); if (nIsEncounter == 1) { doEncounter = 1; myCounter=0; int nWhichMon = d3(1); switch (nWhichMon) { case 1: nNumMons = d3(1); // creaturetype uses the blueprintresref of the creature, not the Tag creaturetype="genericgoblin"; break; case 2: nNumMons = 1; creaturetype="elfmerchant"; break; case 3: nNumMons = d2(1)+1; creaturetype="NW_PANTHER"; break; } } } // Added For Township Of Solace else if (thisplayArea == GetArea(GetObjectByTag("Township_Of_Solace"))) { int nIsEncounter = d4(1); if (nIsEncounter == 1) { doEncounter = 1; myCounter=0; int nWhichMon = d4(1); switch (nWhichMon) { case 1: nNumMons = d2(1); creaturetype="nw_panther"; break; case 2: nNumMons = d3(1)+1; creaturetype="nw_dog"; break; case 3: nNumMons = d4(1); creaturetype="nw_goblina"; break; case 4: nNumMons = d2(2)+1; creaturetype="nw_orca"; break; } } } // End Added For Township Of Solace if (doEncounter == 1) { for (i=0;i<nNumMons;i++) { object oCreated = CreateObject( OBJECT_TYPE_CREATURE, creaturetype, lLoc, FALSE); } } } } /* OnHeartbeat main */ void main() { object pc = GetFirstPC(); DoEncCheck(pc); while (GetIsObjectValid(pc)) { DoEncCheck(pc); pc = GetNextPC(); } } |