//////////////////////////////////////////////////////////////////////////////// // debug_routine - Script to handle debug chat commands // By Deva B. Winblood. March 1st, 2009 //////////////////////////////////////////////////////////////////////////////// #include "x3_inc_string" #include "npcactivitiesh" #include "color_header" #include "header_sounds" #include "speech_j_h" #include "rtsh_multiplay" ////////////////////////////////////// // PROTOTYPES ////////////////////////////////////// // FILE: debug_routine FUNCTION: LocationToStringMsg() // Convert a location to a format that is useful in a dialog. string LocationToStringMsg(location lLoc); void SendMessageToAllPCs(string sMsg); void VarDumpCreature(object oPC,object oTarget); void SetObjectInteger(object oOb,string sInput); void SetObjectString(object oOb,string sInput); void SetObjectFloat(object oOb,string sInput); void CreateItem(string sInput); /////////////////////////////////////////////////////////[ MAIN ]/////////////// void main() { object oPC=OBJECT_SELF; object oTarget=GetLocalObject(oPC,"oDebugTarget"); location lTarget=GetLocalLocation(oPC,"lDebugTarget"); string sOriginal=GetLocalString(oPC,"sOriginal"); string sMsg=GetLocalString(oPC,"sMsg"); string sUpper=GetStringUpperCase(sMsg); string sCmd=StringParse(sUpper," "); string sRemainder=StringRemoveParsed(sMsg,sCmd," "); string sTeamID=GetLocalString(oPC,"sTeamID"); int nN; string sS; DeleteLocalString(oPC,"sOriginal"); DeleteLocalString(oPC,"sMsg"); PrintString("[DEBUG COMMAND from "+GetName(oPC)+"] '"+sMsg+"'"); if (sUpper=="?"||sUpper=="HELP") { // list the debug commands SendMessageToPC(oPC,"[======= DEBUG WAND COMMANDS =======]"); SendMessageToPC(oPC,"[VARDUMP = Variable dump"); SendMessageToPC(oPC,"[IVAR = set integer variable"); SendMessageToPC(oPC,"[SVAR = set string variable"); SendMessageToPC(oPC,"[FVAR = set float variable"); SendMessageToPC(oPC,"[VARRESET = Delete as many variables as you can."); SendMessageToPC(oPC,"[==== Non-Object Specific ====]"); SendMessageToPC(oPC,"[AREADUMP = Dump information about this area"); SendMessageToPC(oPC,"[GIVEXP = give yourself experience"); SendMessageToPC(oPC,"[GIVEGOLD = give yourself gold"); SendMessageToPC(oPC,"[GIVEMANA = give your team mana"); SendMessageToPC(oPC,"[GIVESOUL = give your team souls"); SendMessageToPC(oPC,"[GIVEIRON = give yourself an iron bar"); SendMessageToPC(oPC,"[GIVEMITH = give yourself a mithril bar"); SendMessageToPC(oPC,"[GIVEADAM = give yourself an adamantium bar"); SendMessageToPC(oPC,"[GIVEITEM = give yourself specified item"); SendMessageToPC(oPC,"[RESREFLIST = list of some resrefs might wantto give"); SendMessageToPC(oPC,"[IMOD = set module integer"); SendMessageToPC(oPC,"[SMOD = set module string"); SendMessageToPC(oPC,"[FMOD = set module float"); SendMessageToPC(oPC,"[MODDUMP = Dump information about the module"); SendMessageToPC(oPC,"[TEAMDUMP = Dump information about the team"); SendMessageToPC(oPC,"[JUMPTAG = Jump to area by tag"); SendMessageToPC(oPC,"[JUMPLIST = Provide a list of area tags"); SendMessageToPC(oPC,"[NPCREPORT = Complete NPC report... warning: slow"); SendMessageToPC(oPC,"[AREAREPORT = Complete AREA report... warning: slow"); SendMessageToPC(oPC,"[ITEMLOC = Where are special Item Locations"); SendMessageToPC(oPC,"[NPCLOC = Where are special NPC Locations"); SendMessageToPC(oPC,"[SETHOUR = set what hour it should be."); } // list the debug commands else if (sUpper=="VARDUMP") { // variable dump if (GetIsObjectValid(oTarget)) { // valid target nN=GetObjectType(oTarget); if (nN==OBJECT_TYPE_CREATURE) { // creature VarDumpCreature(oPC,oTarget); } // creature else if (nN==OBJECT_TYPE_DOOR) { // door SendMessageToPC(oPC,"Door Variable Dump not yet implemented."); } // door else if (nN==OBJECT_TYPE_ITEM) { // item SendMessageToPC(oPC,"Item Variable Dump not yet implemented."); } // item else if (nN==OBJECT_TYPE_PLACEABLE) { // placeable SendMessageToPC(oPC,"Placeable Variable Dump not yet implemented."); } // placeable else { // unsupported SendMessageToPC(oPC,"The targeted object '"+GetName(oTarget)+"' is not a valid debug wand target type."); } // unsupported } // valid target else { // invalid target SendMessageToPC(oPC,"No valid target is specified. Try using the Debug Wand to target an object."); } // invalid target } // variable dump else if (sCmd=="IVAR") { // set integer variable SetObjectInteger(oTarget,sRemainder); } // set integer variable else if (sCmd=="SVAR") { // set string variable SetObjectString(oTarget,sRemainder); } // set string variable else if (sCmd=="FVAR") { // set float variable SetObjectFloat(oTarget,sRemainder); } // set float variable else if (sUpper=="VARRESET") { // reset as many variables as possible SendMessageToPC(oPC,"VARRESET command not yet implemented."); } // reset as many variables as possible else if (sUpper=="AREADUMP") { // dump information about this area SendMessageToPC(oPC,"AREADUMP command not yet implemented."); } // dump information about this area else if (sCmd=="GIVEXP") { // Give XP int nX=StringToInt(sRemainder); string sS="[Debug Wand: Give XP:"+IntToString(nX)+"] Given to "+GetName(oPC)+"."; PrintString(sS); SendMessageToAllPCs(sS); GiveXPToCreature(oPC,nX); } // Give XP else if (sCmd=="GIVEGOLD") { // Give Gold int nX=StringToInt(sRemainder); string sS="[Debug Wand: Give Gold:"+IntToString(nX)+"] Given to "+GetName(oPC)+"."; PrintString(sS); SendMessageToAllPCs(sS); GiveGoldToCreature(oPC,nX); } // Give Gold else if (sCmd=="GIVEMANA") { // Give Mana int nX=StringToInt(sRemainder); string sS="[Debug Wand: Give Mana:"+IntToString(nX)+"] Given to the team of "+GetName(oPC)+"."; PrintString(sS); SendMessageToAllPCs(sS); int nMana=fnGetTeamMana(oPC); nMana=nMana+nX; fnSetTeamMana(oPC,nMana); } // Give Mana else if (sCmd=="GIVESOUL") { // Give Soul int nX=StringToInt(sRemainder); string sS="[Debug Wand: Give Soul:"+IntToString(nX)+"] Given to the team of "+GetName(oPC)+"."; PrintString(sS); SendMessageToAllPCs(sS); int nMana=fnGetTeamSouls(oPC); nMana=nMana+nX; fnSetTeamSouls(oPC,nMana); } // Give Soul else if (sUpper=="GIVEIRON") { // give Iron CreateItem("bar_iron"); } // give Iron else if (sUpper=="GIVEMITH") { // give mithril CreateItem("bar_mith"); } // give mithril else if (sUpper=="GIVEADAM") { // give adamantium CreateItem("bar_admant"); } // give adamantium else if (sCmd=="GIVEITEM") { // give item CreateItem(sRemainder); } // give item else if (sUpper=="RESREFLIST") { // list of common resrefs SendMessageToPC(oPC,"[=== Some useful ResRefs ===]"); SendMessageToPC(oPC,"[ITEM]==========================[RESREF]"); SendMessageToPC(oPC,"Bar of Iron=====================bar_iron"); SendMessageToPC(oPC,"Bar of Mithril==================bar_mith"); SendMessageToPC(oPC,"Bar of Adamantium===============bar_admant"); SendMessageToPC(oPC,"Gold Nugget=====================gold_nugget"); SendMessageToPC(oPC,"Empty Water Bottle==============dh2_ewbot"); SendMessageToPC(oPC,"Potion of Water Breathing=======it_pot_wb"); SendMessageToPC(oPC,"Large Mana Crystal==============mana_crystal_5"); SendMessageToPC(oPC,"Mana Crystal====================mana_crystal_2"); SendMessageToPC(oPC,"Tiny Mana Crystal===============mana_crystal_1"); SendMessageToPC(oPC,"Soul Token======================soultoken"); SendMessageToPC(oPC,"Random House Debug Wand=========rh_debug"); } // list of common resrefs else if (sCmd=="IMOD") { // integer module SetObjectInteger(GetModule(),sRemainder); } // integer module else if (sCmd=="SMOD") { // string module SetObjectString(GetModule(),sRemainder); } // string module else if (sCmd=="FMOD") { // float module SetObjectFloat(GetModule(),sRemainder); } // float module else if (sUpper=="MODDUMP") { // dump information about the module SendMessageToPC(oPC,"MODDUMP command not yet implemented."); } // dump information about the module else if (sCmd=="TEAMDUMP") { // dump information about specific team SendMessageToPC(oPC,"TEAMDUMP command not yet implemented."); } // dump information about specific team else if (sCmd=="JUMPTAG") { // jump to a specific area by tag object oArea=GetObjectByTag(sRemainder); if (GetIsObjectValid(oArea)) { // found object oFirst=GetFirstObjectInArea(oArea); object oWP=GetNearestObjectByTag("AREA_DEBUG",oFirst); if (GetTag(oFirst)=="AREA_DEBUG") oWP=oFirst; AssignCommand(oPC,ClearAllActions(TRUE)); AssignCommand(oPC,JumpToObject(oWP)); } // found else { // error SendMessageToPC(oPC,"Area with the tag '"+sRemainder+"' not found. Try ]JUMPLIST"); } // error } // jump to a specific area by tag else if (sUpper=="JUMPLIST") { // provide list of area tags SendMessageToPC(oPC,"[== List of Areas and the tag to jump to them ==]"); int nCount=0; object oAWP=GetObjectByTag("AREA_DEBUG",nCount); while(GetIsObjectValid(oAWP)) { // areas SendMessageToPC(oPC,"#"+IntToString(nCount+1)+"="+GetName(GetArea(oAWP))+" TAG:"+GetTag(GetArea(oAWP))); nCount++; oAWP=GetObjectByTag("AREA_DEBUG",nCount); } // areas } // provide list of area tags else if (sUpper=="NPCREPORT") { // detailed NPC report SendMessageToPC(oPC,"NPCREPORT command not yet implemented."); } // detailed NPC report else if (sUpper=="AREAREPORT") { // detailed AREA report SendMessageToPC(oPC,"AREAREPORT command not yet implemented."); } // detailed AREA report else if (sUpper=="ITEMLOC") { // special item locations list SendMessageToPC(oPC,"ITEM command not yet implemented."); } // special item locations list else if (sUpper=="NPCLOC") { // special npc locations list SendMessageToPC(oPC,"NPCLOC command not yet implemented."); } // special npc locations list else if (sCmd=="SETHOUR") { // advance time int nHour=StringToInt(sRemainder); if (nHour>23) nHour=23; if (nHour<1) nHour=0; SetTime(nHour,GetTimeMinute(),GetTimeSecond(),GetTimeMillisecond()); SendMessageToPC(oPC,"Time set."); } // advance time else { // error SendMessageToPC(oPC,"Unknown debug command '"+sUpper+"' try typing ]HELP"); } // error } /////////////////////////////////////////////////////////[ MAIN ]/////////////// ////////////////////////////////////// // FUNCTIONS ////////////////////////////////////// string LocationToStringMsg(location lLoc) { // PURPOSE: Stringify Location string sRet; object oArea=GetAreaFromLocation(lLoc); vector vPos=GetPositionFromLocation(lLoc); float fFacing=GetFacingFromLocation(lLoc); sRet="Tag:"+GetTag(oArea)+"(X:"+FloatToString(vPos.x)+",Y:"+FloatToString(vPos.y)+",Z:"+FloatToString(vPos.z)+")F:"+FloatToString(fFacing); return sRet; } // LocationToStringMsg() void SendMessageToAllPCs(string sMsg) { // PURPOSE: Send Message to all PCs object oPC=GetFirstPC(); while(GetIsObjectValid(oPC)) { // send to all SendMessageToPC(oPC,sMsg); oPC=GetNextPC(); } // send to all } // SendMessageToAllPCs() void SetObjectInteger(object oOb,string sInput) { // PURPOSE: Set Integer if (GetIsObjectValid(oOb)) { // object exists string sVar=StringParse(sInput," "); string sValue=StringRemoveParsed(sInput,sVar," "); SetLocalInt(oOb,sVar,StringToInt(sValue)); string sS="[Debug Wand: Set Integer '"+sVar+"' to value '"+sValue+"' on object '"+GetName(oOb)+"'] Action done by "+GetName(OBJECT_SELF)+"."; PrintString(sS); SendMessageToAllPCs(sS); } // object exists else { // error SendMessageToPC(OBJECT_SELF,"[OBJECT NOT SPECIFIED] - Target an object with the wand before using this command."); } // error } // SetObjectInteger() void CreateItem(string sInput) { // PURPOSE: Create Item on OBJECT_SELF object oMe=OBJECT_SELF; string sMsg; object oItem=CreateItemOnObject(sInput,oMe); sMsg="[DEBUG WAND: Create Item '"+GetName(oItem)+"' on '"+GetName(oMe)+"']"; PrintString(sMsg); SendMessageToAllPCs(sMsg); } // CreateItem() void SetObjectString(object oOb,string sInput) { // PURPOSE: Set String if (GetIsObjectValid(oOb)) { // object exists string sVar=StringParse(sInput," "); string sValue=StringRemoveParsed(sInput,sVar," "); SetLocalString(oOb,sVar,sValue); string sS="[Debug Wand: Set String '"+sVar+"' to value '"+sValue+"' on object '"+GetName(oOb)+"'] Action done by "+GetName(OBJECT_SELF)+"."; PrintString(sS); SendMessageToAllPCs(sS); } // object exists else { // error SendMessageToPC(OBJECT_SELF,"[OBJECT NOT SPECIFIED] - Target an object with the wand before using this command."); } // error } // SetObjectString() void SetObjectFloat(object oOb,string sInput) { // PURPOSE: Set Float if (GetIsObjectValid(oOb)) { // object exists string sVar=StringParse(sInput," "); string sValue=StringRemoveParsed(sInput,sVar," "); SetLocalFloat(oOb,sVar,StringToFloat(sValue)); string sS="[Debug Wand: Set Float '"+sVar+"' to value '"+sValue+"' on object '"+GetName(oOb)+"'] Action done by "+GetName(OBJECT_SELF)+"."; PrintString(sS); SendMessageToAllPCs(sS); } // object exists else { // error SendMessageToPC(OBJECT_SELF,"[OBJECT NOT SPECIFIED] - Target an object with the wand before using this command."); } // error } // SetObjectFloat() void VarDumpCreature(object oPC,object oTarget) { // PURPOSE: Complete NPC or PC variable dump object oOb; string sS; int nN; int nL; float fF; location lLoc; vector vVec; string sMsg; sMsg="[ VARIABLE DUMP FOR:"+GetName(oTarget)+"(TAG:"+GetTag(oTarget)+", RES:"+GetResRef(oTarget)+") sTeamID:"+GetLocalString(oTarget,"sTeamID")+" ]"; SendMessageToPC(oPC,sMsg); PrintString(sMsg); if (GetIsPC(oTarget)) { // PC Variable dump } // PC Variable dump else { // NPC Variable dump sMsg="Basic Info- HP:"+StringToRGBString(IntToString(GetCurrentHitPoints(oTarget)),"777")+" CR:"+StringToRGBString(FloatToString(GetChallengeRating(oTarget)),"777")+" PlotFlag:"+StringToRGBString(IntToString(GetPlotFlag(oTarget)),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); lLoc=GetLocation(oTarget); sMsg="Location: "+StringToRGBString(LocationToStringMsg(lLoc),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nMState:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nMState")),"777")+", nSState:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nSState")),"777")+", nState:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nState")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nIID:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nIID")),"777")+", nTimedUpgradeSet:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nTimedUpgradeSet")),"777")+", nTimeToUpgrade:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nTimeToUprade")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="oDestWP:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oDestWP")),"777")+", nRun:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nRun")),"777")+", nHealing:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nHealing")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nAIBusy:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nAIBusy")),"777")+", nUnitNum:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nUnitNum")),"777")+", nBornTime:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nBornTime")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nKills:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nKills")),"777")+", nFollowDist:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nFollowDist")),"777")+", nParm:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nParm")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nRecon:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nRecon")),"777")+", nControlled:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nControlled")),"777")+", nMana:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nMana")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nStoredCR:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nStoredCR")),"777")+", bChampion:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"bChampion")),"777")+", oMaster:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oMaster")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nLevel:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nLevel")),"777")+", nOLevel:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nOLevel")),"777")+", sKN:"+StringToRGBString(GetLocalString(oTarget,"sKN"),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="oAK:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oAK")),"777")+", nPathPosition_EXP:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nPathPosition_EXP")),"777")+", nPathPosition_CON:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nPathPosition_CON")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nPathPosition_ASS:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nPathPosition_ASS")),"777")+", nPathPosition_ESC:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nPathPosition_ESC")),"777")+", oPathDest:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oPathDest")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nMode:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nMode")),"777")+", sDeathScript:"+StringToRGBString(GetLocalString(oTarget,"sDeathScript"),"777")+", bConsolidationLeader:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"bConsolidationLeader")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="bPassive:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"bPassive")),"777")+", sRandomHead:"+StringToRGBString(GetLocalString(oTarget,"sRandomHead"),"777")+", sRandomAppearance:"+StringToRGBString(GetLocalString(oTarget,"sRandomAppearance"),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="sRandomPhenotype:"+StringToRGBString(GetLocalString(oTarget,"sRandomPhenotype"),"777")+", sRandomTail:"+StringToRGBString(GetLocalString(oTarget,"sRandomTail"),"777")+", sRandomSkinColor:"+StringToRGBString(GetLocalString(oTarget,"sRandomSkinColor"),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="sRandomHairColor:"+StringToRGBString(GetLocalString(oTarget,"sRandomHairColor"),"777")+", oASDest:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oASDest")),"777")+", fASLDist:"+StringToRGBString(FloatToString(GetLocalFloat(oTarget,"fASLDist")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="lASRelative:"+StringToRGBString(LocationToStringMsg(GetLocalLocation(oTarget,"lASRelative")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="lASLoc:"+StringToRGBString(LocationToStringMsg(GetLocalLocation(oTarget,"lASLoc")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="nASSC:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nASSC")),"777")+", nASSR:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nASSR")),"777")+", nASTCount:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"nASTCount")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="fGFacing:"+StringToRGBString(FloatToString(GetLocalFloat(oTarget,"fGFacing")),"777")+", oGArea:"+StringToRGBString(GetName(GetLocalObject(oTarget,"oGArea")),"777")+", bFormationGuard:"+StringToRGBString(IntToString(GetLocalInt(oTarget,"bFormationGuard")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); sMsg="fGX:"+StringToRGBString(FloatToString(GetLocalFloat(oTarget,"fGX")),"777")+", fGY:"+StringToRGBString(FloatToString(GetLocalFloat(oTarget,"fGY")),"777")+", fGZ:"+StringToRGBString(FloatToString(GetLocalFloat(oTarget,"fGZ")),"777"); SendMessageToPC(oPC,sMsg); PrintString(sMsg); } // NPC Variable dump } // VarDumpCreature()