//////////////////////////////////////////////////////////////// // Arena - Version 1.0 - Main Script // By Deva Bryson Winblood //////////////////////////////////////////////////////////////// //#include "NW_I0_GENERIC" void fnMove(object oDest,float fRange=1.1) { // special move make sure not stuck float fDist=GetDistanceBetween(oDest,OBJECT_SELF); int nR=GetLocalInt(OBJECT_SELF,"nStuckCount"); object oOb; location lLoc; float fLDist=GetLocalFloat(OBJECT_SELF,"fLDist"); if (fDist>fRange) { // not there yet if (fDist==fLDist) { // stuck ClearAllActions(); oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,OBJECT_SELF,d8()); if (oOb==OBJECT_INVALID) oOb=GetNearestObject(OBJECT_TYPE_WAYPOINT,OBJECT_SELF,d10()); if (oOb==OBJECT_INVALID) oOb=GetNearestObject(OBJECT_TYPE_DOOR,OBJECT_SELF,d10()); if (oOb==OBJECT_INVALID) { // check for blocking creature oOb=GetNearestObject(OBJECT_TYPE_CREATURE,OBJECT_SELF,1); if (oOb!=OBJECT_INVALID&&GetDistanceBetween(oOb,OBJECT_SELF)>2.0) oOb=OBJECT_INVALID; } // check for blocking creature if (oOb!=OBJECT_INVALID&&GetObjectType(oOb)!=OBJECT_TYPE_CREATURE) { // move to arbitrary point ActionMoveToObject(oOb,TRUE,2.0); DelayCommand(5.0,ClearAllActions()); DelayCommand(5.1,ActionMoveToObject(oDest,TRUE,fRange)); } // move to arbitrary point else if (oOb!=OBJECT_INVALID) { // creature nearby lLoc=GetLocation(oOb); AssignCommand(oOb,ActionMoveAwayFromObject(OBJECT_SELF,FALSE,3.0)); DelayCommand(5.0,AssignCommand(oOb,ActionMoveToLocation(lLoc,TRUE))); ClearAllActions(); DelayCommand(1.0,ActionMoveToObject(oDest,TRUE,fRange)); } // creature nearby ActionMoveToObject(oDest,TRUE,fRange); nR++; SetLocalInt(OBJECT_SELF,"nStuckCount",nR); if (nR>4||GetArea(OBJECT_SELF)!=GetArea(oDest)) { // teleport ClearAllActions(); JumpToObject(oDest); } // teleport } // stuck else { SetLocalFloat(OBJECT_SELF,"fLDist",fDist); } if (GetCurrentAction()!=ACTION_MOVETOPOINT) ActionMoveToObject(oDest,FALSE,fRange); DelayCommand(4.0,fnMove(oDest,fRange)); } // not there yet else { DeleteLocalInt(OBJECT_SELF,"nStuckCount"); DeleteLocalFloat(OBJECT_SELF,"fLDist"); SetFacing(GetFacing(oDest)); } } // fnMove() void fnBreedHate(object oPerson1,object oPerson2) { // make them hate each other oPerson1 will attack oPerson2 ChangeToStandardFaction(oPerson1,STANDARD_FACTION_HOSTILE); AssignCommand(oPerson1,ClearAllActions()); DelayCommand(4.0,AssignCommand(oPerson1,ActionAttack(oPerson2))); //DetermineCombatRound(); /*SendMessageToPC(oPerson2,"BreedHate("+GetName(oPerson1)+","+GetName(oPerson2)+")"); if(GetIsEnemy(oPerson2,oPerson1)==TRUE) SendMessageToPC(oPerson2,GetName(oPerson1)+" considers "+GetName(oPerson2)+" an enemy."); if(GetIsEnemy(oPerson1,oPerson2)==TRUE) SendMessageToPC(oPerson2,GetName(oPerson2)+" considers "+GetName(oPerson1)+" an ememy.");*/ } // fnBreedHate() void fnDepartSpectators(object oMerch) { // make spectators depart int nC=1; object oSpec; object oDest; while(nC<13) { // depart oSpec=GetLocalObject(oMerch,"oSpectator"+IntToString(nC)); oDest=GetNearestObjectByTag("ARENA_SpectatorExit1"); if (nC>6) oDest=GetNearestObjectByTag("ARENA_SpectatorExit2"); if (oSpec!=OBJECT_INVALID) { // valid spectator AssignCommand(oSpec,ClearAllActions(TRUE)); AssignCommand(oSpec,DelayCommand(45.0,DestroyObject(oSpec))); // safety net AssignCommand(oSpec,ActionForceMoveToObject(oDest,FALSE,1.0,43.0)); AssignCommand(oSpec,ActionDoCommand(DestroyObject(oSpec))); } // valid spectator nC++; } // depart } // fnDepartSpectators() void fnCheer(object oSpectator,int nAnim,int nCheer) { // cheer AssignCommand(oSpectator,ActionPlayAnimation(nAnim,1.0,3.0)); PlayVoiceChat(nCheer,oSpectator); } // fnCheer() void fnCheering(object oNear,int nP=10) { // cheering object oWP; int nC=1; int nR; float fTime; int nF; object oSpec; while(nC<13) { // check for cheering oWP=GetNearestObjectByTag("ARENA_Spectator"+IntToString(nC),oNear,1); if (oWP!=OBJECT_INVALID) { // valid waypoint oSpec=GetNearestObject(OBJECT_TYPE_CREATURE,oWP,1); if(oSpec!=OBJECT_INVALID&&GetDistanceBetween(oWP,oSpec)<2.0) { // valid spectator nR=d100(); if (nR<=nP) { // cheer okay nF=d4(); fTime=IntToFloat(nF); nR=d4(); if (nR==1) { // first cheer DelayCommand(fTime,fnCheer(oSpec,ANIMATION_FIREFORGET_VICTORY1,VOICE_CHAT_CHEER)); } // first cheer else if (nR==2) { // second cheer DelayCommand(fTime,fnCheer(oSpec,ANIMATION_FIREFORGET_VICTORY2,VOICE_CHAT_CHEER)); } // second cheer else if (nR==3) { // third cheer DelayCommand(fTime,fnCheer(oSpec,ANIMATION_FIREFORGET_VICTORY3,VOICE_CHAT_ATTACK)); } // third cheer else { // fourth cheer DelayCommand(fTime,fnCheer(oSpec,ANIMATION_FIREFORGET_SALUTE,VOICE_CHAT_LAUGH)); } // fourth cheer } // cheer okay } // valid spectator } // valid waypoint nC++; } // check for cheering } // fnCheering() ///-------------------------------------------------------[ MAIN ]-------------- void main() { object oH=GetNearestObjectByTag("ARENA_EventMaster",OBJECT_SELF,1); object oC=GetLocalObject(oH,"oContestant"); object oG=GetLocalObject(oH,"oGladiator"); object oM=GetLocalObject(oH,"oMaster"); object oMD=GetNearestObjectByTag("ARENA_Announcer",OBJECT_SELF,1); int nState=GetLocalInt(oH,"nState"); int nType=GetLocalInt(oH,"nType"); float fDist; object oOb; object oWP; int nR; int nC; string sS; if (nState<6&&nState>0&&oC==OBJECT_INVALID) { // error nState=8; SetLocalInt(oH,"nState",8); } // error switch(nState) { // main state switch--------------------------------- case 1: { // entered arena fDist=GetDistanceBetween(oM,oMD); if (fDist>1.5) { // move master if (GetCurrentAction(oM)!=ACTION_MOVETOPOINT) { // move AssignCommand(oM,ClearAllActions()); AssignCommand(oM,ActionForceMoveToObject(oMD,TRUE,1.0,3.0)); AssignCommand(oM,ActionDoCommand(SetFacing(GetFacing(oMD)))); } // move } // move master else { // tell PC to get moving AssignCommand(oM,SpeakString("What are you just standing there for "+GetName(oC)+"? Stand on your mark so we can get this fight underway!")); } // tell PC to get moving nC=1; while(nC<13) { // create spectators oWP=GetNearestObjectByTag("ARENA_Spectator"+IntToString(nC)); if (oWP!=OBJECT_INVALID) { // valid location oOb=GetNearestObject(OBJECT_TYPE_CREATURE,oWP,1); sS=GetResRef(oOb); sS=GetStringLeft(sS,9); if (oOb==OBJECT_INVALID||sS!="spectator"||GetDistanceBetween(oOb,oWP)>1.5) { // okay to create nR=d8(); sS="spectator"+IntToString(nR); oOb=CreateObject(OBJECT_TYPE_CREATURE,sS,GetLocation(oWP),FALSE); SetLocalObject(oH,"oSpectator"+IntToString(nC),oOb); } // okay to create } // valid location nC++; } // create spectators fDist=GetDistanceBetween(oM,oMD); if (fDist>1.5) { // move master if (GetCurrentAction(oM)!=ACTION_MOVETOPOINT) { // move AssignCommand(oM,fnMove(oMD,1.0)); } // move } // move master break; } // entered arena case 2: { // PC stepped in starting place fnCheering(oC); nR=d6(); nC=0; if (nR==4||nR==5) nC=1; if (nR==6) nC=2; if (nType==0) { nR=1; nC=0; } else if (nType==1) nR=2; else if (nType==2) nR=5; else if (nType==3) nR=8; else if (nType==4) { nR=11; nC=0; } sS="Gladiator"+IntToString(nR+nC); oOb=GetNearestObjectByTag("ARENA_OppositionDoor"); AssignCommand(oOb,ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN,1.0,3.0)); oOb=GetNearestObjectByTag("ARENA_OpponentSpawn"); oG=CreateObject(OBJECT_TYPE_CREATURE,sS,GetLocation(oOb),FALSE); SetLocalObject(oH,"oGladiator",oG); //SetIsTemporaryFriend(oG,oC,TRUE,20.0); //SetIsTemporaryFriend(oC,oG,TRUE,20.0); oOb=GetNearestObjectByTag("ARENA_OpponentWalk"); AssignCommand(oG,ActionMoveToObject(oOb,FALSE,1.0)); SetLocalInt(oH,"nState",3); /*fDist=GetDistanceBetween(oM,oMD); if (fDist>1.5) { // move master if (GetCurrentAction(oM)!=ACTION_MOVETOPOINT) { // move AssignCommand(oM,ClearAllActions()); AssignCommand(oM,ActionForceMoveToObject(oMD,TRUE,1.0,30.0)); AssignCommand(oM,ActionDoCommand(SetFacing(GetFacing(oMD)))); } // move } // move master */ break; } // PC stepped in starting place case 3: { // Gladiator arrives at starting place oOb=GetNearestObjectByTag("ARENA_OpponentWalk"); fnCheering(oC,8); if (GetDistanceBetween(oOb,oG)<1.2) { // arrived SetLocalInt(oH,"nState",4); } // arrived else { // make sure moving if (GetCurrentAction(oG)!=ACTION_MOVETOPOINT) { // move AssignCommand(oG,ClearAllActions()); AssignCommand(oG,ActionMoveToObject(oOb,FALSE,1.0)); } // move } // make sure moving /* fDist=GetDistanceBetween(oM,oMD); if (fDist>1.5) { // move master if (GetCurrentAction(oM)!=ACTION_MOVETOPOINT) { // move AssignCommand(oM,ClearAllActions()); AssignCommand(oM,ActionForceMoveToObject(oMD,TRUE,1.0,30.0)); AssignCommand(oM,ActionDoCommand(SetFacing(GetFacing(oMD)))); } // move } // move master */ break; } // Gladiator arrives at starting place case 4: { // announcer arrives and shouts if (GetDistanceBetween(oMD,oM)>1.0) { // still moving /*if (GetCurrentAction(oM)!=ACTION_MOVETOPOINT) { // move AssignCommand(oM,ClearAllActions()); AssignCommand(oM,ActionForceMoveToObject(oOb,FALSE,1.0,15.0)); } // move */ } // still moving else { // arrived DelayCommand(2.0,AssignCommand(oM,SpeakString("LET THE MATCH BEGIN!"))); DelayCommand(2.0,PlayVoiceChat(VOICE_CHAT_ATTACK,oM)); DelayCommand(2.1,fnCheering(oC,20)); DelayCommand(3.0,fnBreedHate(oG,oC)); SetLocalInt(oH,"nState",5); } // arrived break; } // announcer arrives and shouts case 5: { // battle continues fnCheering(oC); SetIsTemporaryEnemy(oC,oG); SetIsTemporaryEnemy(oG,oC); if (oG==OBJECT_INVALID||GetIsDead(oG)==TRUE) SetLocalInt(oH,"nState",7); else if (oC==OBJECT_INVALID||GetIsDead(oC)==TRUE) SetLocalInt(oH,"nState",6); break; } // battle continues case 6: { // Victory gladiator if (oC!=OBJECT_INVALID) { // move dead PC AssignCommand(oC,JumpToObject(oH)); } // move dead PC AssignCommand(oM,SpeakString(GetName(oG)+" is victorious!")); DeleteLocalObject(oH,"oContestant"); DeleteLocalInt(oH,"nState"); DeleteLocalInt(oH,"nPay"); DeleteLocalInt(oH,"nType"); ExecuteScript("arena_placebar",OBJECT_SELF); DestroyObject(oG); DeleteLocalObject(oH,"oGladiator"); fnDepartSpectators(oH); AssignCommand(oM,ActionForceMoveToObject(oH,FALSE,1.0,5.0)); break; } // Victory gladiator case 7: { // Victory PC fnDepartSpectators(oH); AssignCommand(oM,SpeakString(GetName(oC)+" is victorious!")); AssignCommand(oM,ActionForceMoveToObject(oH,FALSE,1.0,5.0)); oOb=GetNearestObjectByTag("ArenaBarrier",oC,1); if (oOb!=OBJECT_INVALID) DestroyObject(oOb); break; } // Victory PC case 8: { // error DeleteLocalObject(oH,"oContestant"); DeleteLocalInt(oH,"nState"); DeleteLocalInt(oH,"nPay"); DeleteLocalInt(oH,"nType"); ExecuteScript("arena_placebar",OBJECT_SELF); DestroyObject(oG); DeleteLocalObject(oH,"oGladiator"); fnDepartSpectators(oH); AssignCommand(oM,ActionForceMoveToObject(oH,FALSE,1.0,5.0)); break; } // error default: break; } // main state switch--------------------------------- if (nState>0&&nState!=8) DelayCommand(4.0,ExecuteScript("arena_mainscript",OBJECT_SELF)); } //------------------------------------------------------------[ MAIN ]----------