#include "adv_include" #include "disease_include" // Reinitializes a player character's stats but doesn't replace items. // Should be called any time there's been changes to the code for character upgrades // oPC = The player to reinitialize // iNewCharacterVersion = Only used in the script "update_character". It will set the character version to this number // fDelay = The amount of time before the reset message is displayed // bUnequipItems = If set to TRUE, all items must be void ReinitializePlayerCharacter(object oPC, int iNewCharacterVersion = -1, float fDelay = 8.0, int bResetSPCooldown = FALSE); // Cycles through the effects on a creature and removes a specific one from him or her. void RemoveSingleEffect(object oCreature, int iEffectType); // Wrapper function which should be called whenever an item's name needs to be changed due to various systems in place. // For example, this should be called when the number of bullets in a gun changes. void UpdateItemName(object oItem); // This should be called instead of CreateItemOnObject! // This will prevent the inventory limitation system from firing when items are created on a PC via script. // A lot of times the PCs will go over their item limit when items are created in their inventory. This could end up // with several errors, so that's why this function needs to be used. // Also provides one new optional feature: SetName function. object CreateItemOnObjectSafe(string sItemTemplate, object oTarget=OBJECT_SELF, int nStackSize=1, string sNewTag="", string sNewName=""); // Same as CopyItem but it prevents the inventory limitation system from firing. Use this instead of CopyItem! object CopyItemSafe(object oItem, object oTargetInventory=OBJECT_INVALID, int bCopyVars=TRUE); // Copies all variables from oSource to oCopy // Uses the LINUX version of NWNX_FUNCS. // Windows currently not supported. void CopyVariables(object oSource, object oCopy); void ReinitializePlayerCharacter(object oPC, int iNewCharacterVersion = -1, float fDelay = 8.0, int bResetSPCooldown = FALSE) { object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); ADV_InitializePC(oPC, TRUE); DISEASE_SetDiseaseCap(oPC, 100); if(iNewCharacterVersion > 0) { SetLocalInt(oDatabase, "CHARACTER_VERSION", iNewCharacterVersion); } if(bResetSPCooldown) { // Reset cooldown on player's SP reset DeleteLocalInt(oDatabase, "SP_RESET_ALLOCATION_COOLDOWN"); } // Remove all effects effect eEffect = GetFirstEffect(oPC); while(GetIsEffectValid(eEffect)) { RemoveEffect(oPC, eEffect); eEffect = GetNextEffect(oPC); } DelayCommand(fDelay, FloatingTextStringOnCreature(ColorTokenRed() + "Your stats have been reset and all SP has been reimbursed.", oPC, FALSE)); // Linux if(ADV_USING_LINUX) { } // Windows else { NWNXFuncs_UpdateCharacterSheet(oPC); } } void RemoveSingleEffect(object oCreature, int iEffectType) { effect eEffect = GetFirstEffect(oCreature); while(GetIsEffectValid(eEffect)) { if(GetEffectType(eEffect) == iEffectType) { RemoveEffect(oCreature, eEffect); } eEffect = GetNextEffect(oCreature); } } void UpdateItemName(object oItem) { object oPC = GetItemPossessor(oItem); object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); string sName = GetName(oItem, TRUE); int iBulletCount = GetLocalInt(oItem, GUN_MAGAZINE_BULLET_COUNT); struct GunInfoStruct stGunInfo = GUN_GetGunInfo(oItem); string sNewName; string sResref = GetResRef(oItem); // Firearms - Display current and max bullets chambered in the gun if(stGunInfo.iMagazineSize > 0) { sNewName = sName + ColorToken(0, 255, 0) + " (" + IntToString(iBulletCount) + "/" + IntToString(stGunInfo.iMagazineSize) + ")" + ColorTokenEnd(); } // Radios - Display current channel number else if(sResref == RADIO_RESREF) { int iChannel = GetLocalInt(oDatabase, RADIO_CHANNEL); if(iChannel > 0) { sNewName = sName + ColorToken(0, 255, 0) + " (Channel " + IntToString(iChannel) + ")"; } } // Durability - Display current durability // To-Do // Update item name SetName(oItem, sNewName); } object CreateItemOnObjectSafe(string sItemTemplate, object oTarget=OBJECT_SELF, int nStackSize=1, string sNewTag="", string sNewName="") { int bPC = GetIsPC(oTarget); // Prevent inventory system from firing. if(bPC) { SetLocalInt(oTarget, "INV_PREVENT_SYSTEM_FROM_FIRING", TRUE); DelayCommand(0.5,DeleteLocalInt(oTarget, "INV_PREVENT_SYSTEM_FROM_FIRING")); } object oItem = CreateItemOnObject(sItemTemplate, oTarget, nStackSize, sNewTag); if(sNewName != "") { SetName(oItem, sNewName); } if(bPC) { //DeleteLocalInt(oTarget, "INV_PREVENT_SYSTEM_FROM_FIRING"); } return oItem; } object CopyItemSafe(object oItem, object oTargetInventory=OBJECT_INVALID, int bCopyVars=TRUE) { SetLocalInt(oTargetInventory, "INV_PREVENT_SYSTEM_FROM_FIRING", TRUE); object oCopy = CopyItem(oItem, oTargetInventory, bCopyVars); DelayCommand(0.5, DeleteLocalInt(oTargetInventory, "INV_PREVENT_SYSTEM_FROM_FIRING")); return oCopy; } void CopyVariables(object oSource, object oCopy) { int iVarCount = GetLocalVariableCount(oSource); struct LocalVariable stCurVar = GetFirstLocalVariable(oSource); int iCurVar; for(iCurVar = 0; iCurVar <= iVarCount; iCurVar++) { switch(stCurVar.type) { case VARIABLE_TYPE_INT: SetLocalInt(oCopy, stCurVar.name, GetLocalInt(oSource, stCurVar.name)); break; case VARIABLE_TYPE_FLOAT: SetLocalFloat(oCopy, stCurVar.name, GetLocalFloat(oSource, stCurVar.name)); break; case VARIABLE_TYPE_STRING: SetLocalString(oCopy, stCurVar.name, GetLocalString(oSource, stCurVar.name)); break; case VARIABLE_TYPE_OBJECT: SetLocalObject(oCopy, stCurVar.name, GetLocalObject(oSource, stCurVar.name)); break; case VARIABLE_TYPE_LOCATION: SetLocalLocation(oCopy, stCurVar.name, GetLocalLocation(oSource, stCurVar.name)); break; } stCurVar = GetNextLocalVariable(stCurVar); } } // Error checking //void main(){}