//////////////////////////////////////////////////////////////////////////////// // RTS - Load Player // By Deva Bryson Winblood. 01/22/2004 //////////////////////////////////////////////////////////////////////////////// /* #include "rtsh_multiplay" void fnRemoveAllInventory(object oMe) { object oItem=GetFirstItemInInventory(oMe); object oPC=oMe; int nGold=GetGold(oMe); TakeGoldFromCreature(nGold,oMe,TRUE); SetXP(oMe,0); while(oItem!=OBJECT_INVALID) { // strip DestroyObject(oItem); oItem=GetNextItemInInventory(oMe); } // strip oItem=GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_ARMS,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_ARROWS,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_BELT,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_BOLTS,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_BULLETS,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_NECK,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC); DestroyObject(oItem); oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC); DestroyObject(oItem); } // fnRemoveAllInventory() void fnAdjustReputation(object oPC,string sTeam) { // adjust reputation of this PC for sTeam object oWP=GetWaypointByTag(sTeam+"_RESOURCES"); object oCr=CreateObject(OBJECT_TYPE_CREATURE,sTeam+"0",GetLocation(oWP)); if (sTeam!=GetLocalString(oPC,"sTeamID")) AdjustReputation(oPC,oCr,-100); else { AdjustReputation(oPC,oCr,100); } DestroyObject(oCr); } // fnAdjustReputation() /////////////////////////////////////////////////////////////////// M A I N void fnLoadPC() { object oPC=OBJECT_SELF; object oMod=GetModule(); string sPID=GetName(oPC)+GetPCPlayerName(oPC); int nN1; int nN2; string sS1; string sS2; float fF1; float fF2; float fF3; vector vV; string sID; location lLoc; object oOb; oOb=GetLocalObject(oMod,sPID+"oArea"); if (oOb!=OBJECT_INVALID) { // character stored - load it nN1=GetLocalInt(oMod,sPID+"nSAdv"); SetLocalInt(oPC,"nSAdvCompleted",nN1); nN1=GetLocalInt(oMod,sPID+"nXP"); SetXP(oPC,nN1); // Set XP back to what is stored sS1=GetLocalString(oMod,sPID+"sID"); SetLocalString(oPC,"sTeamID",sS1);// set TeamID sID=sS1; oOb=GetLocalObject(oMod,sPID+"oArea"); // put the PC back where they were fF1=GetLocalFloat(oMod,sPID+"fLX"); fF2=GetLocalFloat(oMod,sPID+"fLY"); fF3=GetLocalFloat(oMod,sPID+"fLZ"); vV=Vector(fF1,fF2,fF3); lLoc=Location(oOb,vV,GetFacing(oPC)); AssignCommand(oPC,ClearAllActions(TRUE)); AssignCommand(oPC,JumpToLocation(lLoc)); // teleport PC nN1=GetLocalInt(oMod,sPID+"nVXP"); if (nN1>0) SetLocalInt(oPC,"nVampireXP",nN1); // set vampire XP nN1=GetLocalInt(oMod,sPID+"nIsVampire"); if (nN1==TRUE) { // vampire DelayCommand(2.0,ExecuteScript("player_vampire",oPC)); } // vampire nN1=GetLocalInt(oMod,sPID+"nKills"); SetLocalInt(oPC,"nKills",nN1); nN1=GetLocalInt(oMod,sPID+"nDeaths"); SetLocalInt(oPC,"nDeaths",nN1); // restore gold nN1=GetGold(oPC); nN2=GetLocalInt(oMod,sPID+"nGold"); if (nN1nN2) { // take gold nN1=nN1-nN2; TakeGoldFromCreature(nN1,oPC,TRUE); } // take gold //////////// Adjust alignment nN1=GetLocalInt(oMod,sPID+"nAGE"); if (nN1==ALIGNMENT_EVIL)AdjustAlignment(oPC,ALIGNMENT_EVIL,100); else if (nN1==ALIGNMENT_GOOD) AdjustAlignment(oPC,ALIGNMENT_GOOD,100); else if (nN1==ALIGNMENT_NEUTRAL) AdjustAlignment(oPC,ALIGNMENT_NEUTRAL,100); nN1=GetLocalInt(oMod,sPID+"nALC"); if (nN1==ALIGNMENT_LAWFUL) AdjustAlignment(oPC,ALIGNMENT_LAWFUL,100); else if (nN1==ALIGNMENT_CHAOTIC) AdjustAlignment(oPC,ALIGNMENT_CHAOTIC,100); //////////// Restore Inventory nN1=1; sS1=GetLocalString(oMod,sPID+"sInv"+IntToString(nN1)); while(sS1!="") { // restore inventory oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); nN1++; sS1=GetLocalString(oMod,sPID+"sInv"+IntToString(nN1)); } // restore inventory ///// Restore equipped inventory sS1=GetLocalString(oMod,sPID+"sI_Arms"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_ARMS))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Arrows"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_ARROWS))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Belt"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_BELT))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Bolts"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_BOLTS))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Boots"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_BOOTS))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Bullets"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_BULLETS))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Carmour"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_CARMOUR))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Chest"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_CHEST))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Cloak"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_CLOAK))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Head"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_HEAD))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Lhand"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_LEFTHAND))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Lring"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_LEFTRING))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Neck"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_NECK))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Rhand"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_RIGHTHAND))); } // restore item sS1=GetLocalString(oMod,sPID+"sI_Rring"); if (sS1!="") { // restore item oOb=CreateItemOnObject(sS1,oPC); sS2=GetTag(oOb); DestroyObject(oOb); if (GetItemPossessedBy(oPC,sS2)==OBJECT_INVALID) oOb=CreateItemOnObject(sS1,oPC); DelayCommand(1.0,AssignCommand(oPC,ActionEquipItem(oOb,INVENTORY_SLOT_RIGHTRING))); } // restore item /////////////////////////////////// // Team related portion /////////////////////////////////// oOb=GetLocalObject(oMod,"oTeamLead"+sID); if (oOb==OBJECT_INVALID||oOb==oPC) { // make me the team leader SetLocalObject(oMod,"oTeamLead"+sID,oPC); nN1=GetLocalInt(oMod,"nManaStore"+sID); fnSetTeamMana(oPC,nN1); nN1=GetLocalInt(oMod,"nSoulStore"+sID); fnSetTeamSouls(oPC,nN1); nN1=GetLocalInt(oMod,"nStartSoul"+sID); SetLocalInt(oPC,"nStartSoul",nN1); } // make me the team leader fnAdjustReputation(oPC,"SPID"); fnAdjustReputation(oPC,"DWF"); fnAdjustReputation(oPC,"UNC"); fnAdjustReputation(oPC,"UND"); nN1=GetLocalInt(oMod,sPID+"nKicked"); if (nN1>3) BootPC(oPC); SetLocalInt(oPC,"nKicked",nN1); nN1=GetLocalInt(oMod,sPID+"nBuilder"); SetLocalInt(oPC,"nBuilder",nN1); if (nN1==TRUE||oPC==GetLocalObject(oMod,"oTeamLead"+sID)) { // make sure have builders tools if (GetItemPossessedBy(oPC,"RTSUnit_Creation")==OBJECT_INVALID) oOb=CreateItemOnObject("rtsunit_creation",oPC); if (GetItemPossessedBy(oPC,"RTSCreation_Tool")==OBJECT_INVALID) oOb=CreateItemOnObject("rtscreation_tool",oPC); } // make sure have builders tools } // character stored - load it } void main() { object oPC=OBJECT_SELF; fnRemoveAllInventory(oPC); DelayCommand(5.0,fnLoadPC()); } //////////////////////////////////////////////////////////////////////// M A I N */