Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

426 lines
17 KiB
Plaintext

// perishable
#include "champ_h"
#include "hos_respawn_h"
#include "x3_inc_skin"
void fnMakeFriends(object oNPC)
{ // PURPOSE: TO make all enemies near oNPC temporary friends
int nN=1;
object oEnemy=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oNPC,nN);
while(GetIsObjectValid(oEnemy))
{ // set enemies to friends
if (GetIsInCombat(oNPC)) ClearAllActions(TRUE);
if (GetIsInCombat(oEnemy)) ClearAllActions(TRUE);
SetIsTemporaryFriend(oNPC,oEnemy,TRUE,20.0);
SetIsTemporaryFriend(oEnemy,oNPC,TRUE,20.0);
nN++;
oEnemy=GetNearestCreature(CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,oNPC,nN);
} // set enemies to friends
} // fnMakeFriends()
void fnFindDuplicates(object oPC)
{
object oItem=GetFirstItemInInventory(oPC);
int nGS;
int nUC;
int nVT;
int nMK;
int nTC;
string sS;
while(oItem!=OBJECT_INVALID)
{
sS=GetResRef(oItem);
if (sS=="rtsgame_settings") nGS++;
else if (sS=="rtsunit_creation") nUC++;
else if (sS=="rts_it_vote") nVT++;
else if (sS=="rtscreation_tool") nMK++;
else if (sS=="rts_it_teamwand") nTC++;
oItem=GetNextItemInInventory(oPC);
}
if (nGS>1)
{ // delete duplicate game setting
oItem=GetItemPossessedBy(oPC,"RTSGame_Settings");
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
} // delete duplicate game setting
if (nUC>1)
{ // delete duplicate unit creation
oItem=GetItemPossessedBy(oPC,"RTSUnit_Creation");
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
} // delete duplicate unit creation
if (nVT>1)
{ // delete duplicate voting tool
oItem=GetItemPossessedBy(oPC,"rts_it_vote");
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
} // delete duplicate voting tool
if (nMK>1)
{ // delete duplicate marking tool
oItem=GetItemPossessedBy(oPC,"RTSCreation_Tool");
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
} // delete duplicate marking tool
if (nTC>1)
{ // delete duplicate team control wand
oItem=GetItemPossessedBy(oPC,"rts_it_teamwand");
if (oItem!=OBJECT_INVALID) DestroyObject(oItem);
} // delete duplicate team control wand
} // fnFindDuplicates()
void fnJumpToDeath(object oDest)
{ // PURPOSE: Jump to the death waypoint in the plane of in between
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
// 09/21/2006 | Deva B. Winblood | Made sure they still jump when die in
// | | The Plane of In Between
object oMe=OBJECT_SELF;
if (GetArea(oDest)!=GetArea(oMe)||GetDistanceBetween(oMe,oDest)>3.0)
{ // jump
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,JumpToObject(oDest));
DelayCommand(1.0,fnJumpToDeath(oDest));
} // jump
} // fnJumpToDeath()
void fnCheckForElimVictory2()
{ // PURPOSE: To check for an elimination victory
object oPC=GetFirstPC();
int bElim=FALSE;
int nC;
string sID;
string sLID;
object oWinner;
int bMoreThanOneTeam=FALSE;
object oMod=GetModule();
object oEnd=GetWaypointByTag("END_GAME_POINT");
int nPlayerTeams;
int nLiving=0;
int nSPID;
int nDWF;
int nUND;
int nUNC;
while(oPC!=OBJECT_INVALID)
{ // check all PCs
if (GetIsDM(oPC)==FALSE)
{ // not a DM
sID=GetLocalString(oPC,"sTeamID");
if (GetArea(oEnd)!=GetArea(oPC))
{ // living
if (GetStringLength(sLID)>0&&sID!=sLID) bMoreThanOneTeam=TRUE;
sLID=sID;
nLiving++;
if (sID=="SPID") nSPID++;
else if (sID=="UNC") nUNC++;
else if (sID=="DWF") nDWF++;
else if (sID=="UND") nUND++;
} // living
nC++; // count PCs
} // not a DM
oPC=GetNextPC();
} // check all PCs
nPlayerTeams=0;
if (nSPID>0) nPlayerTeams++;
if (nUNC>0) nPlayerTeams++;
if (nUND>0) nPlayerTeams++;
if (nDWF>0) nPlayerTeams++;
if (bMoreThanOneTeam==FALSE&&nPlayerTeams!=1) bElim=TRUE;
if (bElim||nLiving==0)
{ // victory
oWinner=GetLocalObject(oMod,"oTeamLead"+sLID);
SetLocalInt(oMod,"nGameOver",TRUE);
ExecuteScript("rts_end_game",oMod);
} // victory
} // fnCheckForElimVictory2()
void fnHandleAlliance(string sID)
{ // PURPOSE: Process units of this team and make sure they join the allied faction
object oMod=GetModule();
string sAID=GetLocalString(oMod,"sIsAlliedTo"+sID);
object oProxy=GetObjectByTag(sID+"_PROXY");
object oAProxy=GetObjectByTag(sAID+"_PROXY");
object oCreature=GetFirstFactionMember(oProxy,FALSE);
while(oCreature!=OBJECT_INVALID)
{ // check each faction member
if (oCreature!=oProxy)
{ // change to new faction
DelayCommand(0.5,ChangeFaction(oCreature,oAProxy));
} // change to new faction
oCreature=GetNextFactionMember(oProxy,FALSE);
} // check each faction member
} // fnHandleAlliance()
void fnCheckForAlliances()
{ // PURPOSE: handle allied teams
object oMod=GetModule();
string sS;
sS=GetLocalString(oMod,"sIsAlliedToDWF");
if (GetStringLength(sS)>0&&GetLocalInt(oMod,"bIsAllianceLeaderDWF")!=TRUE) fnHandleAlliance("DWF");
sS=GetLocalString(oMod,"sIsAlliedToSPID");
if (GetStringLength(sS)>0&&GetLocalInt(oMod,"bIsAllianceLeaderSPID")!=TRUE) DelayCommand(1.0,fnHandleAlliance("SPID"));
sS=GetLocalString(oMod,"sIsAlliedToUNC");
if (GetStringLength(sS)>0&&GetLocalInt(oMod,"bIsAllianceLeaderUNC")!=TRUE) DelayCommand(2.0,fnHandleAlliance("UNC"));
sS=GetLocalString(oMod,"sIsAlliedToUND");
if (GetStringLength(sS)>0&&GetLocalInt(oMod,"bIsAllianceLeaderUND")!=TRUE) DelayCommand(3.0,fnHandleAlliance("UND"));
} // fnCheckForAlliances()
void privateHandleChampion(object oChampion)
{ // PURPOSE: Resurrect champion and send them to outer planes. Use module
// rules in regards to how to handle their equipment
// Version History
// mm/dd/yyyy | Modified By | Description
// 09/17/2006 | Deva B. Winblood | Initial version of this function
effect eRes=EffectResurrection();
effect eHeal=EffectHeal(GetMaxHitPoints(oChampion));
effect eSanctuary=EffectSanctuary(50);
effect eInvis=EffectInvisibility(INVISIBILITY_TYPE_IMPROVED);
effect eImmobile=EffectCutsceneImmobilize();
object oWP;
object oMod=GetModule();
int nDeath=GetLocalInt(oMod,"nRTSDeathMeth");
int nR;
ApplyEffectToObject(DURATION_TYPE_INSTANT,eRes,oChampion);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eHeal,oChampion);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSanctuary,oChampion,20.0);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eInvis,oChampion,20.0);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eImmobile,oChampion,20.0);
fnMakeFriends(oChampion);
SetCommandable(TRUE,oChampion);
SetPlotFlag(oChampion,TRUE);
DelayCommand(1.0,AssignCommand(oChampion,ActionCastSpellAtObject(SPELL_GREATER_RESTORATION,oChampion,METAMAGIC_ANY,TRUE,0,PROJECTILE_PATH_TYPE_DEFAULT,TRUE)));
DelayCommand(15.0,SetPlotFlag(oChampion,FALSE));
nR=d4();
oWP=GetWaypointByTag("NW_DEATH_TEMPLE_"+IntToString(nR));
DelayCommand(5.0,AssignCommand(oChampion,fnJumpToDeath(oWP)));
if (GetNearestObjectByTag("OUTER_PLANES",oChampion,1)!=OBJECT_INVALID)
{
//fnLoseSoulToken(oPC);
fnDestroyInventory(oChampion,TRUE);
}
else
{
if (GetLocalInt(oMod,"nRTSDeathMeth")!=0) ExecuteScript("rts_pcdrop",oChampion); // Drop Goodies
if (GetLocalInt(oMod,"nRTSDeathMeth")==4) fnDestroyInventory(oChampion,FALSE);
else fnDestroyInventory(oChampion,TRUE);
}
Champion_ResetPathing(oChampion);
SetLocalInt(oChampion,"nPathMode",CHAMPION_PATH_ESCAPE);
oWP=Champion_GetNextPath(oChampion,CHAMPION_PATH_ESCAPE);
DeleteLocalInt(oChampion,"nFiendDrain");
SetLocalObject(oChampion,"oPathDest",oWP);
if (GetLocalInt(GetArea(oChampion),"bOP"))
{ // Outer planes - deal with too many soul tokens
if (fnCountSoulTokens(oChampion))
{ // need an explosion
DelayCommand(7.0,fnSoulTokenExplode(GetLocation(oChampion)));
} // need an explosion
else
{ // create token
oWP=CreateObject(OBJECT_TYPE_ITEM,"soultoken",GetLocation(oChampion),TRUE);
} // create token
} // Outer planes - deal with too many soul tokens
else
{ // soul tokens
oWP=CreateObject(OBJECT_TYPE_ITEM,"soultoken",GetLocation(oChampion),TRUE);
} // soul tokens
} // privateHandleChampion()
void fnTimeMaintain()
{ // PURPOSE: Added November 17th, 2008 to prevent time stopping
object oMod=GetModule();
int nTimeSec=GetTimeSecond();
int nTimeMin=GetTimeMinute();
int nTimeHour=GetTimeHour();
int nStoredSec=GetLocalInt(oMod,"nStoredSec");
int nStoredMin=GetLocalInt(oMod,"nStoredMin");
int nStoredHour=GetLocalInt(oMod,"nStoredHour");
if (nStoredHour==nTimeHour&&nStoredMin==nTimeMin&&nStoredSec==nTimeMin)
{ // time is frozen
int nTimeM=GetTimeMillisecond();
nTimeM=nTimeM+10;
if (nTimeM>999) nTimeM=0;
SetTime(nTimeHour,nTimeMin,nTimeSec,nTimeM);
} // time is frozen
else
{ // time moves
SetLocalInt(oMod,"nStoredSec",nTimeSec);
SetLocalInt(oMod,"nStoredMin",nTimeMin);
SetLocalInt(oMod,"nStoredHour",nTimeHour);
} // time moves
} // fnTimeMaintain()
/////////////////////////////////////////////////////[ MAIN ]///////////////////
void main()
{
object oPC;
object oItem;
float fCount;
float fTime=HoursToSeconds(1);
object oHostile=GetObjectByTag("HOSTILE_MEMBER");
object oWP=GetWaypointByTag("INPROGRESS_JOIN");
effect eRes=EffectResurrection();
int nC;
fnTimeMaintain();
int nDay=GetCalendarDay();
int bIsDay=GetIsDay();
//SendMessageToPC(GetFirstPC(),"Calendar Day:"+IntToString(nDay)+" bIsDay:"+IntToString(bIsDay));
//SendMessageToPC(GetFirstPC()," VARIABLES: bIsDay:"+IntToString(GetLocalInt(GetModule(),"bIsDay"))+" nLastDay:"+IntToString(GetLocalInt(GetModule(),"nLastDay")));
if (!bIsDay&&GetLocalInt(GetModule(),"bIsDay")&&GetLocalInt(GetModule(),"nLastDay")!=nDay)
{ // need to run change to night script
SetLocalInt(GetModule(),"bIsDay",FALSE);
SetLocalInt(GetModule(),"nLastDay",nDay);
DelayCommand(12.0,ExecuteScript("hos1_ex_night",OBJECT_SELF));
} // need to run change to night script
else if (bIsDay&&!GetLocalInt(GetModule(),"bIsDay"))
{ // need to run change to day script
SetLocalInt(GetModule(),"bIsDay",TRUE);
DelayCommand(12.0,ExecuteScript("hos1_ex_day",OBJECT_SELF));
} // need to run change to day script
if (GetLocalInt(GetModule(),"nGameType")==2)
{ // control point capture
DelayCommand(2.0,ExecuteScript("rts_ex_control",GetModule()));
} // control point capture
if (GetTimeHour()!=GetLocalInt(GetModule(),"nHBStoredHour"))
{ // hour has passed
SetLocalInt(GetModule(),"nHBStoredHour",GetTimeHour());
DelayCommand(20.0,ExecuteScript("hourly_cleanup",GetModule()));
} // hour has passed
DelayCommand(3.0,fnCheckForAlliances());
if (GetLocalInt(GetModule(),"nTimeLimitDays")>0&&GetLocalInt(GetModule(),"nInProgress")) DelayCommand(2.0,ExecuteScript("timelimit_hb",OBJECT_SELF));
if (GetLocalInt(GetModule(),"nGameType")==0) { DelayCommand(1.0,fnCheckForElimVictory2()); }
if (GetLocalInt(GetModule(),"nInProgress")) DelayCommand(5.0,ExecuteScript("area_cleaning",GetModule()));
oPC=GetFirstPC();
while(oPC!=OBJECT_INVALID)
{ // !OI
if (GetIsDead(oPC)&&d8()<5) PopUpDeathGUIPanel(oPC,TRUE,TRUE);
if (GetLocalInt(oPC,"bControlUndead"))
{ // check to see if control undead has worn off
int nAbs=GetTimeHour()+GetCalendarDay()*24+GetCalendarMonth()*24*30+GetCalendarYear()*24*30*12;
if (nAbs>=GetLocalInt(oPC,"nControlUndeadEndTime"))
{ // its over
DeleteLocalInt(oPC,"nControlUndeadEndTime");
DeleteLocalInt(oPC,"bControlUndead");
DeleteLocalInt(oPC,"bActivateControlUndead");
SendMessageToPC(oPC,"Control Undead duration has completed.");
} // its over
else
{ // reapply visual effect
if (!GetLocalInt(oPC,"bActivateControlUndead"))
{ // activate control undead
ExecuteScript("hos1_ex_controlund",oPC);
SetLocalInt(oPC,"bActivateControlUndead",TRUE);
} // activate control undead
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_DUR_IOUNSTONE_RED),oPC,8.0);
} // reapply visual effect
} // check to see if control undead has worn off
oItem=GetItemPossessedBy(oPC,"rts_it_uw12");
if (oItem!=OBJECT_INVALID)
{ // endless ammo
if (GetItemStackSize(oItem)<99)
{ // reset stack
SetItemStackSize(oItem,99);
} // reset stack
} // endless ammo
oItem=GetItemPossessedBy(oPC,"rts_it_uw13");
if (oItem!=OBJECT_INVALID)
{ // endless ammo
if (GetItemStackSize(oItem)<99)
{ // reset stack
SetItemStackSize(oItem,99);
} // reset stack
} // endless ammo
oItem=GetItemPossessedBy(oPC,"rts_it_uw14");
if (oItem!=OBJECT_INVALID)
{ // endless ammo
if (GetItemStackSize(oItem)<99)
{ // reset stack
SetItemStackSize(oItem,99);
} // reset stack
} // endless ammo
/*if (GetLocalObject(oPC,"oListener")==OBJECT_INVALID)
{ // spawn listener
oItem=CreateObject(OBJECT_TYPE_CREATURE,"listener001",GetLocation(oPC));
SetLocalObject(oPC,"oListener",oItem);
SetLocalObject(oItem,"oMaster",oPC);
SetLocalInt(oItem,"bActivated",TRUE);
} // spawn listener */
if (GetLevelByClass(CLASS_TYPE_BARD,oPC)>0)
{ // check to see if have bard tool
oItem=GetItemPossessedBy(oPC,"rts_bardic");
if (oItem==OBJECT_INVALID) oItem=CreateItemOnObject("rts_bardic",oPC);
} // check to see if have bard tool
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
if (GetTag(oItem)=="NW_IT_TORCH001")
{ // torch
fCount=GetLocalFloat(oItem,"fUsage");
fCount=fCount+6.0;
if (fCount>fTime)
{ // burned out
SendMessageToPC(oPC,"Your torch burned out.");
DestroyObject(oItem);
} // burned out
else
{ SetLocalFloat(oItem,"fUsage",fCount); }
} // torch
if (GetLocalString(GetArea(oPC),"sTeamID")==GetLocalString(oPC,"sTeamID"))
{ // PC is in lair
string sRace=GetStringUpperCase(GetSubRace(oPC));
if (sRace=="SKELETON"&&!GetSkinInt(oPC,"bSetSkeletonProperties")) DelayCommand(2.0,ExecuteScript("sr_skeleton",oPC));
//else if (sRace=="DROW"&&!GetSkinInt(oPC,"bSetDrowProperties")) DelayCommand(2.0,ExecuteScript("sr_drow",oPC));
//else if (sRace=="WEMIC"&&!GetSkinInt(oPC,"bSetWemicProperties")) DelayCommand(2.0,ExecuteScript("sr_wemic",oPC)); <-- Handled via PRC8 now
//else if (sRace=="BROWNIE"&&!GetSkinInt(oPC,"bSetBrownieProperties")) DelayCommand(2.0,ExecuteScript("sr_brownie",oPC));
else if (GetStringLeft(sRace,4)=="WERE"&&!GetSkinInt(oPC,"bSet"+sRace+"Properties")) DelayCommand(2.0,ExecuteScript("sr_lycanthrope",oPC));
} // PC is in lair
// verify hostile faction reputation
if (GetIsReactionTypeHostile(oPC,oHostile)!=TRUE&&GetIsDM(oPC)!=TRUE&&oHostile!=OBJECT_INVALID)
{ // faction for hostile messed up for this PC
SendMessageToPC(oPC,"FACTION PROBLEM[perishable_hb]: Hostile creatures appear to be friendly to you. Attempting to correct now.");
AdjustReputation(oPC,oHostile,-100);
} // faction for hostile messed up for this PC
if (GetIsDM(oPC)!=TRUE&&GetLocalString(oPC,"sTeamID")==""&&GetLocalInt(GetModule(),"nInProgress")!=FALSE)
{ // make them choose a team
if (IsInConversation(oPC)!=TRUE)
{ // make them choose
AssignCommand(oPC,ClearAllActions(TRUE));
AssignCommand(oPC,JumpToObject(oWP));
AssignCommand(oPC,ActionStartConversation(oPC,"inprogress_join",TRUE,FALSE));
} // make them choose
} // make them choose a team
DelayCommand(2.0,fnFindDuplicates(oPC));
oPC=GetNextPC();
} // !OI
DelayCommand(1.0,ExecuteScript("crit_keep_alive",OBJECT_SELF));
DelayCommand(1.5,ExecuteScript("deconsolidate_hb",OBJECT_SELF));
if (GetLocalInt(GetModule(),"bPlayerBleeding")) DelayCommand(0.2,ExecuteScript("hos_bleeding",OBJECT_SELF));
oHostile=GetObjectByTag("dwf_champ");
if (GetIsObjectValid(oHostile)) SetAILevel(oHostile,AI_LEVEL_HIGH);
if (GetIsObjectValid(oHostile)&&(GetIsDead(oHostile)||GetCurrentHitPoints(oHostile)<1))
{ // res
privateHandleChampion(oHostile);
} // res
oHostile=GetObjectByTag("und_champ");
if (GetIsObjectValid(oHostile)) SetAILevel(oHostile,AI_LEVEL_HIGH);
if (GetIsObjectValid(oHostile)&&(GetIsDead(oHostile)||GetCurrentHitPoints(oHostile)<1))
{ // res
privateHandleChampion(oHostile);
} // res
oHostile=GetObjectByTag("unc_champ");
if (GetIsObjectValid(oHostile)) SetAILevel(oHostile,AI_LEVEL_HIGH);
if (GetIsObjectValid(oHostile)&&(GetIsDead(oHostile)||GetCurrentHitPoints(oHostile)<1))
{ // res
privateHandleChampion(oHostile);
} // res
oHostile=GetObjectByTag("spid_champ");
if (GetIsObjectValid(oHostile)) SetAILevel(oHostile,AI_LEVEL_HIGH);
if (GetIsObjectValid(oHostile)&&(GetIsDead(oHostile)||GetCurrentHitPoints(oHostile)<1))
{ // res
privateHandleChampion(oHostile);
} // res
}