//:://///////////////////////////////////////////// //:: Name rpo_inc //:: FileName rpo_inc.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* */ //::////////////////////////////////////////////// //:: Created By: Pad O'Lion //:: Created On: 06/30/2002 //::////////////////////////////////////////////// #include "array_api" int PWS_PLAYER_STATE_ALIVE = 0; int PWS_PLAYER_STATE_DYING = 1; int PWS_PLAYER_STATE_DEAD = 2; int PWS_PLAYER_STATE_STABLE = 3; int PWS_PLAYER_STATE_DISABLED = 4; int PWS_PLAYER_STATE_RESCUED = 5; int PWS_PLAYER_STATE_PRISON = 6; int PWS_PLAYER_STATE_PRISONESCAPE = 7; int RPO_PLAYER_REPUTATION_LAWFUL = 0; int RPO_PLAYER_REPUTATION_CRIMINAL = 1; // You may change the following strings to whatever you want to appear in the heading box string PWS_GUI_STRING_DEITY="You may click respawn to pray for resurrection or wait for a healer to come along."; string PWS_GUI_STRING_HEATHEN="Since you have no God you may only wait for a healer to come along."; string PWS_GUI_STRING_NOGODSYSTEM="You have died. You may respawn or wait for help."; // TRIGGERS, if set to 0 the listed system will be deactivated, defaults to 1 // NOTE: If you change any of these, you must recompile all modules that begin // with hc_ To do so, open them in script editor, and click compile and save. // Setting GODSYSTEM to 0 will remove ability to pray for resurrection. int GODSYSTEM=1; // Setting DEATHSYSTEM to 0 will allow respawn and quit and return to get // around being dead or dying. (Removes death amulets) int DEATHSYSTEM=1; // Setting BLEEDSYSTEM to 0 will remove the bleed to death system. int BLEEDSYSTEM=1; // Setting RESTSYSTEM to 0 will remove rest restrictions from play. // (You may also just not put hc_resting in OnPlayerResting int RESTSYSTEM=1; // Setting LOOTSYSTEM to 0 will remove the ability to loot a pc corpse. int LOOTSYSTEM=1; // LOOTALL - If set to 0, only owner of corpse can loot it. int LOOTALL=0; // RESTBREAK - Controls how long between rests if RESTSYSTEM is used int RESTBREAK=8; // REZCHANCE - Controls percent chance of sucessful resurrection IF GODSYSTEM int REZCHANCE=3; // Set LOGINMESSAGE to anything you want show to all players when logging in // If you want no message show, change LOGINMESSAGE to "" and recompile hc_entering string LOGINMESSAGE="Welcome to RPO! (http://www.roleplaying-online.com)"; void AddPrisoner(object oPrisoner, object oTarget = OBJECT_SELF); object GetPrisonerToImprison(object oTarget = OBJECT_SELF); void RemovePrisoner(object oPrisoner, object oTarget = OBJECT_SELF); void AdjustReputation2(object oTarget, object oSourceFactionMember, int nAdjustTo); void AdjustFactionReputation2(object oCreature, object oFactionMember, int nReputationType); void ClearAllFactionMembers (object oMember, object oPlayer); float GetFactionChallengeRating(object oMember); void DebugString(string sDebug); void UnequipPlayer(object oPlayer, int nHandsOnly = TRUE); void RemoveDeathAmulet(object oPlayer); object SpawnHero(object oPlayer); location GetLocFromFacingByDistance(object oObject, float fDistance); //:://///////////////////////////////////////////// //:: Name GetFreeBench //:: Copyright (c) 2001 Bioware Corp. //:: Get the nearest free Bench to oCreature in oArea //::////////////////////////////////////////////// //:: Created By: //:: Created On: //::////////////////////////////////////////////// object GetFreeBench(object oCreature, object oArea); //:://///////////////////////////////////////////// //:: Name AdjustFactionReputation //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// //::////////////////////////////////////////////// //:: Created By: Pad O'Lion //:: Created On: 07/06/2002 //:: void AdjustFactionReputation(object oCreature, object oFactionMember, int nReputationType); //:: oFactionMember: Member of the Faction to adjust //:: oCreature: Creature to modifies standing with oFactionMembers faction //:: nReputationType: REPUTATION_TYPE_ENEMY, REPUTATION_TYPE_FRIEND, REPUTATION_TYPE_NEUTRAL //::////////////////////////////////////////////// //void AdjustFactionReputation(object oCreature, object oFactionMember, int nReputationType); //:://///////////////////////////////////////////// //:: Name UnequipPlayer //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* */ //::////////////////////////////////////////////// //:: Created By: //:: Created On: //::////////////////////////////////////////////// void UnequipPlayer(object oPlayer, int nHandsOnly = TRUE) { AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND))); if (nHandsOnly == FALSE) { AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_ARMS, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_ARROWS, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_BELT, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_BOLTS, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_BOOTS, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_BULLETS, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_CHEST, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_CLOAK, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_HEAD, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTRING, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_NECK, oPlayer))); AssignCommand(oPlayer, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTRING, oPlayer))); } } void RemoveDeathAmulet(object oPlayer) { object oDeathAmulet = GetFirstItemInInventory(oPlayer); while(GetIsObjectValid(oDeathAmulet)) { if(GetTag(oDeathAmulet) == "deathamulet") { DestroyObject(oDeathAmulet); } oDeathAmulet = GetNextItemInInventory(oPlayer); } } object SpawnHero(object oPlayer) { int nRandom; string sHeroRef; location lPlayer = GetLocation(oPlayer); vector vPlayerVector = GetPosition (oPlayer); object oArea = GetArea (oPlayer); float fYPos=vPlayerVector.y - 50.0; // Set New Y Position to move if (fYPos<0.0) fYPos=0.0; vector vNewVector = Vector(vPlayerVector.x, fYPos, vPlayerVector.z); location lHero = Location(oArea, vNewVector, GetFacingFromLocation (lPlayer)); nRandom = d100(); if (nRandom <= 80) sHeroRef = "humanhero001"; else if (nRandom > 80 && nRandom <= 92) sHeroRef = "elvenhero001"; else if (nRandom > 92 && nRandom <= 100) sHeroRef = "halflinghero001"; //else if (nRandom > 96 && nRandom <= 98) // sHeroRef = "GnomeHero001"; //else if (nRandom > 98 && nRandom <= 100) // sHeroRef = "DwarvenHero001"; if (GetLocalInt(oPlayer, "PlayerState") == PWS_PLAYER_STATE_DEAD) // Player still dead? { object oHero = CreateObject(OBJECT_TYPE_CREATURE, sHeroRef, lHero); AssignCommand(oHero, ActionMoveToObject(oPlayer, TRUE)); return oHero; } return OBJECT_INVALID; } location GetLocFromFacingByDistance(object oObject, float fDistance) { float fYPos; float fXPos; float fA; float fB; float fC; vector vVector; location lNewLoc; vector vObjectVector = GetPosition (oObject); location lObject = GetLocation(oObject); float fFacing = GetFacingFromLocation(lObject); fC = fDistance; fA = cos(fFacing) * fC; fB = sqrt(pow(fDistance, 2.0) - pow(fA, 2.0)); if (fFacing < 0.0f) fB = fB * -1.0f; if (fFacing < -90.0f && fFacing >= -180.0f) fA = fA * -1.0f; vVector = Vector(vObjectVector.x + fA, vObjectVector.y + fB, vObjectVector.z); lNewLoc = Location(GetArea(oObject), vVector, GetFacingFromLocation(lObject)); return lNewLoc; } object GetFreeBench(object oCreature, object oArea) { int nNth = 1; string sTag; sTag = "Sittable"; object oObject = GetNearestObjectByTag(sTag, OBJECT_SELF, nNth); while (GetIsObjectValid(oObject)) { if (GetArea(oObject) == oArea) if (!GetIsObjectValid(GetSittingCreature(oObject))) return oObject; oObject = OBJECT_INVALID; nNth++; oObject = GetNearestObjectByTag(sTag, OBJECT_SELF, nNth); } return OBJECT_INVALID; } void Imprison(object oPrisoner, object oArrester, string sPrisonTag) { PrintString("Imprisoning: " + GetName(oPrisoner)); object oCell = GetObjectByTag(sPrisonTag); location lCell = GetLocation(oCell); if (GetIsObjectValid(oCell)) { SetLocalInt(oPrisoner, "PlayerState",PWS_PLAYER_STATE_PRISON); PrintString("Imprisoning: " + GetName(oPrisoner) + " to " + sPrisonTag); //SetLocalInt(oPrisoner, "RPO_Reputation", RPO_PLAYER_REPUTATION_CRIMINAL); RemoveDeathAmulet(oPrisoner); if (GetIsDead(oPrisoner)) { ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPrisoner); ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPrisoner)), oPrisoner); } UnequipPlayer (oPrisoner, TRUE); SendMessageToPC(oPrisoner, "You awake with blurred vision, as your sight begins to clear you find yourself in a prison."); AssignCommand(oPrisoner, JumpToLocation(lCell)); SetLocalInt(oPrisoner, "PlayerState",PWS_PLAYER_STATE_PRISON); } else { PrintString("Imprisoning: Error, can't find location " + sPrisonTag); CreateItemOnObject("deathamulet", oPrisoner); } } /* void AdjustFactionReputation(object oCreature, object oFactionMember, int nReputationType) { if (nReputationType == REPUTATION_TYPE_ENEMY) SetIsTemporaryEnemy(oCreature, oFactionMember); else if (nReputationType == REPUTATION_TYPE_FRIEND) SetIsTemporaryFriend(oCreature, oFactionMember); else if (nReputationType == REPUTATION_TYPE_NEUTRAL) SetIsTemporaryNeutral(oCreature, oFactionMember); PrintString ("Adjusting reputation of " + GetName(oCreature) + " to " + GetName(oFactionMember)); object oFM = GetFirstFactionMember(oFactionMember, FALSE); while (GetIsObjectValid(oFM)) { PrintString ("Adjusting reputation of " + GetName(oCreature) + " to " + GetName(oFM)); if (nReputationType == REPUTATION_TYPE_ENEMY) SetIsTemporaryEnemy(oCreature, oFM); else if (nReputationType == REPUTATION_TYPE_FRIEND) SetIsTemporaryFriend(oCreature, oFM); else if (nReputationType == REPUTATION_TYPE_NEUTRAL) SetIsTemporaryNeutral(oCreature, oFM); oFM = OBJECT_INVALID; object oFM = GetNextFactionMember(oFactionMember, FALSE); } } */ void AdjustFactionReputation2(object oCreature, object oFactionMember, int nReputationType) { if (nReputationType == REPUTATION_TYPE_ENEMY) AdjustReputation(oCreature, oFactionMember, -100); else if (nReputationType == REPUTATION_TYPE_FRIEND) AdjustReputation(oCreature, oFactionMember, 100); else if (nReputationType == REPUTATION_TYPE_NEUTRAL) AdjustReputation(oCreature, oFactionMember, 50); PrintString ("Adjusting reputation of " + GetName(oCreature) + " to " + GetName(oFactionMember)); object oFM = GetFirstFactionMember(oFactionMember, FALSE); while (GetIsObjectValid(oFM)) { PrintString ("Adjusting reputation of " + GetName(oCreature) + " to " + GetName(oFM)); if (nReputationType == REPUTATION_TYPE_ENEMY) AdjustReputation(oCreature, oFactionMember, -100); else if (nReputationType == REPUTATION_TYPE_FRIEND) AdjustReputation(oCreature, oFactionMember, 100); else if (nReputationType == REPUTATION_TYPE_NEUTRAL) AdjustReputation(oCreature, oFactionMember, 50); oFM = OBJECT_INVALID; object oFM = GetNextFactionMember(oFactionMember, FALSE); } } void AddPrisoner(object oPrisoner, object oTarget = OBJECT_SELF) { if (GetObjectArraySize("Prisoners", oTarget) < 1) { CreateObjectArray("Prisoners", 1, oPrisoner, oTarget); DebugString(GetName(oTarget) + " created prisoner list and added " + GetName(oPrisoner) + " to his list"); } else if (SearchObjectArray("Prisoners", oPrisoner, oTarget) == -1) { AppendObjectArray("Prisoners", oPrisoner, oTarget); DebugString(GetName(oTarget) + " added " + GetName(oPrisoner) + " to his list"); } SetLocalObject(oPrisoner, "Prisoner", oTarget); SetLocalObject(oTarget, "Prisoner", oPrisoner); } void RemovePrisoner(object oPrisoner, object oTarget = OBJECT_SELF) { RemoveObjectArray("Prisoners", SearchObjectArray("Prisoners", oPrisoner, oTarget), oTarget); DebugString(GetName(oTarget) + " removed " + GetName(oPrisoner) + " from his list"); // Clear both varibles linking guard and prisoner SetLocalObject(oPrisoner, "Prisoner", OBJECT_INVALID); SetLocalObject(oTarget, "Prisoner", OBJECT_INVALID); } object GetPrisonerToImprison(object oTarget = OBJECT_SELF) { int nNum = 0; object oPrisoner = OBJECT_INVALID; while (nNum < GetObjectArraySize("Prisoners", oTarget)) { oPrisoner = GetObjectArray("Prisoners", nNum, oTarget); if (GetLocalInt(oPrisoner, "State") != PWS_PLAYER_STATE_PRISON && (!GetIsObjectValid(GetLocalObject(oPrisoner, "Prisoner")) || GetLocalObject(oPrisoner, "Prisoner") == oTarget)) { if (GetIsDead(oPrisoner)) { DebugString(GetName(oTarget) + " found prisoner to imprison: " + GetName(oPrisoner)); return oPrisoner; } } else if (GetIsObjectValid(GetLocalObject(oPrisoner, "Prisoner")) && GetLocalObject(oPrisoner, "Prisoner") != oTarget) { DebugString(GetName(oTarget) + ": prisoner " + GetName(oPrisoner) + " already cought by " + GetName(GetLocalObject(oPrisoner, "Prisoner"))); RemovePrisoner(oPrisoner, oTarget); } else DebugString(GetName(oTarget) + ": prisoner " + GetName(oPrisoner) + " already in prison!"); nNum++; } return OBJECT_INVALID; } void DebugString(string sDebug) { if (GetLocalInt(GetModule(), "Debug") == TRUE) { PrintString(sDebug); } } void AdjustReputation2(object oTarget, object oSourceFactionMember, int nAdjustTo) { int nStanding = GetReputation(oSourceFactionMember, oTarget); int nAdjustment = nAdjustTo - nStanding; AdjustReputation(oTarget, oSourceFactionMember, nAdjustment); int nCurrentStanding = GetReputation(oSourceFactionMember, oTarget); DebugString("Adjusting " + GetName(oTarget) + " reputation to " + GetName(oSourceFactionMember) + " from " + IntToString(nStanding) + " to " + IntToString(nCurrentStanding) + " by " + IntToString(nAdjustTo)); } void ClearAllFactionMembers (object oMember, object oPlayer) { object oClear = GetFirstFactionMember (oMember, FALSE); while (GetIsObjectValid(oClear) == TRUE) { ClearPersonalReputation (oPlayer, oClear); oClear = GetNextFactionMember (oMember, FALSE); DebugString("Clearing reputation of " + GetName(oPlayer) + " to " + GetName(oClear) + ". New rep: " + IntToString(GetReputation(oClear, oPlayer))); } } float GetFactionChallengeRating(object oMember) { object oFM = OBJECT_INVALID; float fRating = 0.0; oFM = GetFirstFactionMember (oMember, FALSE); while (GetIsObjectValid(oFM) == TRUE) { fRating += GetChallengeRating(oFM); oFM = GetNextFactionMember (oMember, FALSE); } return fRating; }