j-nz / Ascension-Island

MIT License
0 stars 0 forks source link

Chat additions #2

Open j-nz opened 1 year ago

j-nz commented 1 year ago
else if (GetStringLeft(sSaid, 5) == "/bio ") 
{ 
string sRemove = StringParse(sSaid, " "); 
string sBio = StringRemoveParsed(sSaid, sRemove, " ");
SendMessageToPC(oSpeaker, "You have reset your current bio."); 
SetDescription(oSpeaker, sBio); 
//ExportSingleCharacter(oSpeaker); 
}
j-nz commented 1 year ago

Edit and add the following chunk to fire only if oPC does not have the Gift of Psionics (Suggested pre-reqs. 18 INT and 14 CHA at character creation).

if (nVolume == TALKVOLUME_PARTY && !bTeam)
    {
        SendMessageToPC(oPC, "Party chat has been disabled");
        SetPCChatMessage("");
    }
j-nz commented 1 year ago

Check what is wanted from here:

 if ((sParams = ParseCommand(sMessage, "/help")) != BADPARSE)
    {
        string sHelp = "Available chat commands:\n" +
            COLOR_CODE_GREEN + "/bug [text]  "  + COLOR_CODE_END + "- Report a bug to the team\n" +
            COLOR_CODE_GREEN + "/walk        "  + COLOR_CODE_END + "- Toggle always walk mode\n" +
            COLOR_CODE_GREEN + "/helm        "  + COLOR_CODE_END + "- Toggle helm visibility\n" +
            COLOR_CODE_GREEN + "/cloak       "  + COLOR_CODE_END + "- Toggle cloak visibility\n" +
            COLOR_CODE_GREEN + "/roll        "  + COLOR_CODE_END + "- Roll dice, ability/skill check or save\n" +
            COLOR_CODE_GREEN + "/e           "  + COLOR_CODE_END + "- perform a quick emote\n" +
            COLOR_CODE_GREEN + "/note        "  + COLOR_CODE_END + "- Start writing a new note\n" +
            COLOR_CODE_GREEN + "/deity [name] " + COLOR_CODE_END + "- Convert to worship a deity\n" +
            COLOR_CODE_GREEN + "/dmg [f|c|a|l] " + COLOR_CODE_END + "- Switch spell damage type\n" +
            COLOR_CODE_GREEN + "/spar        "  + COLOR_CODE_END + "- Toggle sparring mode\n" +
            COLOR_CODE_GREEN + "/horn [signal] "  + COLOR_CODE_END + "- Blow your faction's horn\n" +
            COLOR_CODE_GREEN + "/rest        "  + COLOR_CODE_END + "- Check your current rest timer\n" +
            COLOR_CODE_GREEN + "/soundset [number]   "  + COLOR_CODE_END + "- Change your current soundset\n" +
            COLOR_CODE_GREEN + "/head [number]   "  + COLOR_CODE_END + "- Change your current head model\n" +
            COLOR_CODE_GREEN + "/delete [password] "  + COLOR_CODE_END + "- Delete current character from vault\n" +
            COLOR_CODE_GREEN + "/stats        "  + COLOR_CODE_END + "- See some stats about the current character\n" +
            COLOR_CODE_GREEN + "/vfx [1-18] "  + COLOR_CODE_END + "- Apply an additional visual effect to character\n" +
            COLOR_CODE_GREEN + "/dispell        "  + COLOR_CODE_END + "- Remove all beneficial spell effects from self\n" +
            "To quickslot a command macro, it needs to be prefixed with /tk, such as '/tk /walk'";

        SendMessageToPC(oPC, sHelp);
    }
    else if ((sParams = ParseCommand(sMessage, "/bug")) != BADPARSE)
    {
        dbg_ReportBug(sParams, oPC);
    }
    else if ((sParams = ParseCommand(sMessage, "/walk")) != BADPARSE)
    {
        int bWalk = !GetLocalInt(oPC, "WALK_MODE");
        SendMessageToPC(oPC, "Always walk mode " + (bWalk ? "on" : "off"));
        SetLocalInt(oPC, "WALK_MODE", bWalk);
        NWNX_Player_SetAlwaysWalk(oPC, bWalk);
        NWNX_Creature_SetWalkRateCap(oPC, bWalk ? 2000.0f : -1.0f);
    }
    else if ((sParams = ParseCommand(sMessage, "/helm")) != BADPARSE)
    {
        object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
        int bHidden = !GetHiddenWhenEquipped(oHelm);
        SetHiddenWhenEquipped(oHelm, bHidden);
        SendMessageToPC(oPC, "Helmet appearance " + (bHidden ? "hidden" : "shown"));
    }
    else if ((sParams = ParseCommand(sMessage, "/cloak")) != BADPARSE)
    {
        object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC);
        int bHidden = !GetHiddenWhenEquipped(oCloak);
        SetHiddenWhenEquipped(oCloak, bHidden);
        SendMessageToPC(oPC, "Cloak appearance " + (bHidden ? "hidden" : "shown"));
    }
    else if ((sParams = ParseCommand(sMessage, "/roll")) != BADPARSE)
    {
        sParams = GetStringLowerCase(sParams);
        string sRollHelp = "Available rolls:\n" +
                "d2, d3, d4, d6, d8, d10, d12, d20, d100 - Roll a die without modifiers\n" +
                "str, dex, con, int, wis, cha            - Roll d20 + ability modifier\n" +
                "reflex, will, fort                      - Roll d20 + save\n" +
                "animal, appraise, bluff, conc, \n" +
                "distrap, disc, heal, hide, intim, \n" +
                "listen, lore, ms, lock, parry, perform\n" +
                "persuade, pp, search, spell, spot\n" +
                "settrap, taunt, tumble, umd             - Roll d20 + skill modifier\n" +
                "Type '/roll #[cmd]' to roll in private (only visible to DMs)";
        int bPrivate = FALSE;

        if (GetStringLeft(sParams, 1) == "#")
        {
            bPrivate = TRUE;
            sParams = GetSubString(sParams, 1, GetStringLength(sParams)-1);
        }
        SetLocalInt(oPC, CS_ROLLS_VAR_PRIVACY, bPrivate ? CHR_ROLL_PRIVACY_PRIVATE : CHR_ROLL_PRIVACY_PUBLIC);

             if (sParams == "d2")    chr_DoDieRoll(oPC, 2, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d3")    chr_DoDieRoll(oPC, 3, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d4")    chr_DoDieRoll(oPC, 4, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d6")    chr_DoDieRoll(oPC, 6, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d8")    chr_DoDieRoll(oPC, 8, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d10")   chr_DoDieRoll(oPC, 10, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d12")   chr_DoDieRoll(oPC, 12, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d20")   chr_DoDieRoll(oPC, 20, 1, TRUE, FALSE, TRUE);
        else if (sParams == "d100")  chr_DoDieRoll(oPC, 100, 1, TRUE, FALSE, TRUE);
        // Abilities
        else if (sParams == "str")   chr_DoAbilityCheck(oPC, ABILITY_STRENGTH, 0, !bPrivate);
        else if (sParams == "dex")   chr_DoAbilityCheck(oPC, ABILITY_DEXTERITY, 0, !bPrivate);
        else if (sParams == "con")   chr_DoAbilityCheck(oPC, ABILITY_CONSTITUTION, 0, !bPrivate);
        else if (sParams == "int")   chr_DoAbilityCheck(oPC, ABILITY_INTELLIGENCE, 0, !bPrivate);
        else if (sParams == "wis")   chr_DoAbilityCheck(oPC, ABILITY_WISDOM, 0, !bPrivate);
        else if (sParams == "cha")   chr_DoAbilityCheck(oPC, ABILITY_CHARISMA, 0, !bPrivate);
        // Saves
        else if (sParams == "fort")    chr_DoSavingThrow(oPC, SAVING_THROW_FORT, 0, !bPrivate);
        else if (sParams == "will")    chr_DoSavingThrow(oPC, SAVING_THROW_WILL, 0, !bPrivate);
        else if (sParams == "reflex")  chr_DoSavingThrow(oPC, SAVING_THROW_REFLEX, 0, !bPrivate);
        // skills
        else if (sParams == "animal")    chr_DoSkillCheck(oPC, SKILL_ANIMAL_EMPATHY, 0, !bPrivate);
        else if (sParams == "appraise")  chr_DoSkillCheck(oPC, SKILL_APPRAISE, 0, !bPrivate);
        else if (sParams == "bluff")     chr_DoSkillCheck(oPC, SKILL_BLUFF, 0, !bPrivate);
        else if (sParams == "conc")      chr_DoSkillCheck(oPC, SKILL_CONCENTRATION, 0, !bPrivate);
        else if (sParams == "distrap")   chr_DoSkillCheck(oPC, SKILL_DISABLE_TRAP, 0, !bPrivate);
        else if (sParams == "disc")      chr_DoSkillCheck(oPC, SKILL_DISCIPLINE, 0, !bPrivate);
        else if (sParams == "heal")      chr_DoSkillCheck(oPC, SKILL_HEAL, 0, !bPrivate);
        else if (sParams == "hide")      chr_DoSkillCheck(oPC, SKILL_HIDE, 0, !bPrivate);
        else if (sParams == "intim")     chr_DoSkillCheck(oPC, SKILL_INTIMIDATE, 0, !bPrivate);
        else if (sParams == "listen")    chr_DoSkillCheck(oPC, SKILL_LISTEN, 0, !bPrivate);
        else if (sParams == "lore")      chr_DoSkillCheck(oPC, SKILL_LORE, 0, !bPrivate);
        else if (sParams == "ms")        chr_DoSkillCheck(oPC, SKILL_MOVE_SILENTLY, 0, !bPrivate);
        else if (sParams == "lock")      chr_DoSkillCheck(oPC, SKILL_OPEN_LOCK, 0, !bPrivate);
        else if (sParams == "parry")     chr_DoSkillCheck(oPC, SKILL_PARRY, 0, !bPrivate);
        else if (sParams == "perform")   chr_DoSkillCheck(oPC, SKILL_PERFORM, 0, !bPrivate);
        else if (sParams == "persuade")  chr_DoSkillCheck(oPC, SKILL_PERSUADE, 0, !bPrivate);
        else if (sParams == "pp")        chr_DoSkillCheck(oPC, SKILL_PICK_POCKET, 0, !bPrivate);
        else if (sParams == "search")    chr_DoSkillCheck(oPC, SKILL_SEARCH, 0, !bPrivate);
        else if (sParams == "spell")     chr_DoSkillCheck(oPC, SKILL_SPELLCRAFT, 0, !bPrivate);
        else if (sParams == "spot")      chr_DoSkillCheck(oPC, SKILL_SPOT, 0, !bPrivate);
        else if (sParams == "settrap")   chr_DoSkillCheck(oPC, SKILL_SET_TRAP, 0, !bPrivate);
        else if (sParams == "taunt")     chr_DoSkillCheck(oPC, SKILL_TAUNT, 0, !bPrivate);
        else if (sParams == "tumble")    chr_DoSkillCheck(oPC, SKILL_TUMBLE, 0, !bPrivate);
        else if (sParams == "umd")       chr_DoSkillCheck(oPC, SKILL_USE_MAGIC_DEVICE, 0, !bPrivate);

        else if (sParams == "") SendMessageToPC(oPC, sRollHelp);
        else SendMessageToPC(oPC, "Unknown roll '" + sParams + "'\n" + sRollHelp);
    }
    else if ((sParams = ParseCommand(sMessage, "/e")) != BADPARSE)
    {
        AssignCommand(oPC, ClearAllActions());
        if (sParams == "worship")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_WORSHIP, 1.0, 1000.0));
        else if (sParams == "dance")
        {
            object oRightHand = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
            object oLeftHand =  GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);

            AssignCommand(oPC,ActionUnequipItem(oRightHand));
            AssignCommand(oPC,ActionUnequipItem(oLeftHand));

            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY2,1.0));
            AssignCommand(oPC,ActionDoCommand(PlayVoiceChat(VOICE_CHAT_LAUGH,oPC)));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_LOOPING_TALK_LAUGHING, 2.0, 2.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY1,1.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY3,2.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_LOOPING_GET_MID, 3.0, 1.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_LOOPING_TALK_FORCEFUL,1.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY2,1.0));
            AssignCommand(oPC,ActionDoCommand(PlayVoiceChat(VOICE_CHAT_LAUGH,oPC)));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_LOOPING_TALK_LAUGHING, 2.0, 2.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY1,1.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY3,2.0));
            AssignCommand(oPC,ActionDoCommand(PlayVoiceChat(VOICE_CHAT_LAUGH,oPC)));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_LOOPING_GET_MID, 3.0, 1.0));
            AssignCommand(oPC,ActionPlayAnimation( ANIMATION_FIREFORGET_VICTORY2,1.0));

            AssignCommand(oPC,ActionDoCommand(ActionEquipItem(oLeftHand,INVENTORY_SLOT_LEFTHAND)));
            AssignCommand(oPC,ActionDoCommand(ActionEquipItem(oRightHand,INVENTORY_SLOT_RIGHTHAND)));
        }
        else if (sParams == "read")
        {
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_READ));
            DelayCommand(3.0, AssignCommand( oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_READ)));
        }
        else if (sParams == "sit")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 1000.0));
        else if (sParams == "drunk")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_DRUNK, 1.0, 1000.0));
        else if (sParams == "plead")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING, 1.0, 1000.0));
        else if (sParams == "tired")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_TIRED, 1.0, 1000.0));
        else if (sParams == "forceful")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0, 1000.0));
        else if (sParams == "laugh")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_TALK_LAUGHING, 1.0, 1000.0));
        else if (sParams == "victory")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1, 1.0, 1000.0));
        else if (sParams == "victory2")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY2, 1.0, 1000.0));
        else if (sParams == "victory3")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY3, 1.0, 1000.0));
        else if (sParams == "low")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 1000.0));
        else if (sParams == "mid")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_MID, 1.0, 1000.0));
        else if (sParams == "dead")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_DEAD_FRONT, 1.0, 1000.0));
        else if (sParams == "deadback")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_DEAD_BACK, 1.0, 1000.0));
        else if (sParams == "listen")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_LISTEN, 1.0, 1000.0));
        else if (sParams == "cast")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_CONJURE1, 1.0, 1000.0));
        else if (sParams == "cast2")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_CONJURE2, 1.0, 1000.0));
        else if (sParams == "look")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_LOOK_FAR, 1.0, 1000.0));
        else if (sParams == "meditate")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE, 1.0, 1000.0));
        else if (sParams == "bow")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_BOW));
        else if (sParams == "duck")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_DODGE_DUCK));
        else if (sParams == "dodge")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_DODGE_SIDE));
        else if (sParams == "drink")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK));
        else if (sParams == "greet")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_GREETING));
        else if (sParams == "salute")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE));
        else if (sParams == "taunt")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT));
        else if (sParams == "spasm")
            AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_SPASM));
        else
        {
            SendMessageToPC(oPC, "Available emotes: worship, dance, read, sit, drunk, plead, tired, "
                + "forceful, laugh, victory, victory2, victory3, low, mid, dead, deadback, listen, "
                + "cast, cast2, look, meditate, bow, duck, dodge, drink, greet, salute, taunt, spasm");
        }

    }
    else if ((sParams = ParseCommand(sMessage, "/note")) != BADPARSE)
    {
        object oNote = CreateItemOnObject("note_item", oPC);
        SignalEvent(GetModule(), EventActivateItem(oNote, GetLocation(oPC)));
    }
    else if ((sParams = ParseCommand(sMessage, "/deity")) != BADPARSE)
    {
        SetDeity(oPC, sParams);
        ExportSingleCharacter(oPC);
        SendMessageToPC(oPC, "You are now worshipping " + COLOR_CODE_GREEN + sParams + COLOR_CODE_END);
        string sMsg = GetName(oPC) + " has converted to " + sParams;
        SendMessageToAllDMs(COLOR_CODE_BLUE_DARK + sMsg + COLOR_CODE_END);
        WriteTimestampedLogEntry(sMsg);
    }
    else if ((sParams = ParseCommand(sMessage, "/dmg")) != BADPARSE)
    {
        string sDmg = GetStringLowerCase(GetSubString(sParams, 0, 1));
        if (sDmg == "f")
        {
            SendMessageToPC(oPC, "Switching to fire-based spells.");
            SetLocalInt(oPC, "SPELL_DAMAGE_TYPE", IP_CONST_DAMAGETYPE_FIRE);
        }
        else if (sDmg == "c")
        {
            SendMessageToPC(oPC, "Switching to cold-based spells.");
            SetLocalInt(oPC, "SPELL_DAMAGE_TYPE", IP_CONST_DAMAGETYPE_COLD);
        }
        else if (sDmg == "a")
        {
            SendMessageToPC(oPC, "Switching to acid-based spells.");
            SetLocalInt(oPC, "SPELL_DAMAGE_TYPE", IP_CONST_DAMAGETYPE_ACID);
        }
        else if (sDmg == "l")
        {
            SendMessageToPC(oPC, "Switching to lightning-based spells.");
            SetLocalInt(oPC, "SPELL_DAMAGE_TYPE", IP_CONST_DAMAGETYPE_ELECTRICAL);
        }
        else
        {
            SendMessageToPC(oPC, "Set the damage type for some customizable spells. Availble: [f]ire, [a]cid, [c]old, [l]ightning.");
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/spar")) != BADPARSE)
    {
        int bSpar = !GetLocalInt(oPC, "FACTION_SPARRING_MODE");
        SendMessageToPC(oPC, "Sparring mode " + (bSpar ? "on" : "off"));
        SetLocalInt(oPC, "FACTION_SPARRING_MODE", bSpar);
        fctn_UpdateReputation(oPC);
    }
    else if ((sParams = ParseCommand(sMessage, "/horn")) != BADPARSE)
    {
        AnphSendWarningCall(oPC, StringToInt(sParams));
    }
    else if ((sParams = ParseCommand(sMessage, "/rest")) != BADPARSE)
    {
        int tNow = NWNX_Time_GetTimeStamp();
        int tLastRest = GetLocalInt(oPC, CHR_REST_VAR_REST_TIME);
        int tDifference = tNow - tLastRest;

        if (tDifference < FloatToInt(HoursToSeconds(CHR_REST_INTERVAL_HOURS)))
        {
            float fHoursToWait = (HoursToSeconds(CHR_REST_INTERVAL_HOURS) - tDifference) / HoursToSeconds(1);
            SendMessageToPC(oPC, "You may rest again in " + FloatToString(fHoursToWait, 2, 1) + " hours.");
        }
        else
        {
            SendMessageToPC(oPC, "You are tired enough to rest now.");
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/soundset")) != BADPARSE)
    {
        int nCurrentVoice = NWNX_Creature_GetSoundset(oPC);
        int nNew = StringToInt(sParams);
        if (nNew > 0 || sParams == "0")
        {
            NWNX_Creature_SetSoundset(oPC, nNew);
            SendMessageToPC(oPC, "Soundset changed from " + IntToString(nCurrentVoice) + " to " + IntToString(nNew));
        }
        else
        {
            SendMessageToPC(oPC, "Your current soundset is " + IntToString(nCurrentVoice));
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/delete")) != BADPARSE)
    {
        string sPassword = "yes I really do want to delete this character immediately";
        if (sParams == sPassword)
        {
            NWNX_Administration_DeletePlayerCharacter(oPC, TRUE);
        }
        else
        {
            SendMessageToPC(oPC, COLOR_CODE_RED + "This command will delete your character from the server!" + COLOR_CODE_END);
            SendMessageToPC(oPC, COLOR_CODE_RED + "------------------------" + COLOR_CODE_END);
            SendMessageToPC(oPC, "To proceed, type '/detete " + sPassword + "' without the quotes. You must match the case perfectly.");
            SendMessageToPC(oPC, COLOR_CODE_RED + "------------------------" + COLOR_CODE_END);
            SendMessageToPC(oPC, COLOR_CODE_RED + "This command will delete your character from the server!" + COLOR_CODE_END);
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/head")) != BADPARSE)
    {
        int nCurrentModel = GetCreatureBodyPart(CREATURE_PART_HEAD, oPC);
        int nNew = StringToInt(sParams);
        if (nNew > 0 || sParams == "0")
        {
            SetCreatureBodyPart(CREATURE_PART_HEAD, nNew, oPC);
            SendMessageToPC(oPC, "Head model changed from " + IntToString(nCurrentModel) + " to " + IntToString(nNew));
        }
        else
        {
            SendMessageToPC(oPC, "Your current head model is " + IntToString(nCurrentModel));
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/stats")) != BADPARSE)
    {
        string sPCID = IntToString(chr_GetPCID(oPC));
        NWNX_SQL_ExecuteQuery("SELECT Deaths, PVPKills, Playtime, DonatedStuff, xp/playtime, playtime/xp FROM "
                                +SQL_TABLE_CHARDATA+" WHERE PCID="+sPCID);

        if (NWNX_SQL_ReadyToReadNextRow())
        {
            NWNX_SQL_ReadNextRow();
            string sDeaths = NWNX_SQL_ReadDataInActiveRow(0);
            string sPVPKills = NWNX_SQL_ReadDataInActiveRow(1);
            string sPlaytime = NWNX_SQL_ReadDataInActiveRow(2);
            string sDonated = NWNX_SQL_ReadDataInActiveRow(3);
            string sXPPerSec = NWNX_SQL_ReadDataInActiveRow(4);
            string sSecPerXP = NWNX_SQL_ReadDataInActiveRow(5);

            string sMessage = "---------------------------\n" +
                              "You are PCID " + COLOR_CODE_GREEN + sPCID + COLOR_CODE_END + "\n" +
                              "Total deaths: "+ COLOR_CODE_GREEN + sDeaths + COLOR_CODE_END + "\n" +
                              "Total PvP Kills: "+ COLOR_CODE_GREEN + sPVPKills + COLOR_CODE_END + "\n" +
                              "Total playtime: "+ COLOR_CODE_GREEN + sPlaytime + COLOR_CODE_END +" seconds (~" + COLOR_CODE_GREEN+ IntToString((StringToInt(sPlaytime)+1800) / 3600) + COLOR_CODE_END + " hours)\n" +
                              "Total gear donated worth: " +  COLOR_CODE_GREEN + sDonated + COLOR_CODE_END + "\n" +
                              "Average XP points gained per second: " + COLOR_CODE_GREEN + sXPPerSec + COLOR_CODE_END + "\n" +
                              "Average playtime (seconds) per XP point: " + COLOR_CODE_GREEN + sSecPerXP + COLOR_CODE_END + "\n" +
                              "---------------------------\n";
            SendMessageToPC(oPC, sMessage);
        }
        else
        {
            dbg_Warning("Error getting stats from database", oPC);
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/vfx")) != BADPARSE)
    {
        effect e = GetFirstEffect(oPC);
        while (GetIsEffectValid(e))
        {
            if (GetEffectTag(e) == "CHAT_CMD_VFX")
            {
                RemoveEffect(oPC, e);
                break;
            }
            e = GetNextEffect(oPC);
        }

        int n = StringToInt(sParams);
        if (n > 0 && n < 19)
        {
            n--; // 0 based
            if (n < 14) // Helms
            {
                n += 4300 + GetRacialType(oPC)*60 + GetGender(oPC)*30;
            }
            else if (n < 17)
            {
                n = (n-14) + 4760 + GetRacialType(oPC)*20 + GetGender(oPC)*10;
            }
            else if (n < 18)
            {
                n = (n-17) + 6736 + GetRacialType(oPC)*2 + GetGender(oPC);
            }

            e = EffectVisualEffect(n);
            e = TagEffect(e, "CHAT_CMD_VFX");
            ApplyEffectToObject(DURATION_TYPE_PERMANENT, e, oPC);
        }
        else
        {
            SendMessageToPC(oPC, "Invalid VFX number specified, removing.");
        }
    }
    else if ((sParams = ParseCommand(sMessage, "/dispell")) != BADPARSE)
    {
        effect e = GetFirstEffect(oPC);
        while (GetIsEffectValid(e))
        {
            // Dispell positive efects only
            switch (GetEffectType(e))
            {
                case EFFECT_TYPE_DAMAGE_RESISTANCE:
                case EFFECT_TYPE_REGENERATE:
                case EFFECT_TYPE_DAMAGE_REDUCTION:
                case EFFECT_TYPE_TEMPORARY_HITPOINTS:
                case EFFECT_TYPE_INVULNERABLE:
                case EFFECT_TYPE_IMMUNITY:
                case EFFECT_TYPE_HASTE:
                case EFFECT_TYPE_ABILITY_INCREASE:
                case EFFECT_TYPE_ATTACK_INCREASE:
                case EFFECT_TYPE_DAMAGE_INCREASE:
                case EFFECT_TYPE_DAMAGE_IMMUNITY_INCREASE:
                case EFFECT_TYPE_AC_INCREASE:
                case EFFECT_TYPE_MOVEMENT_SPEED_INCREASE:
                case EFFECT_TYPE_SAVING_THROW_INCREASE:
                case EFFECT_TYPE_SPELL_RESISTANCE_INCREASE:
                case EFFECT_TYPE_SKILL_INCREASE:
                case EFFECT_TYPE_INVISIBILITY:
                case EFFECT_TYPE_IMPROVEDINVISIBILITY:
                case EFFECT_TYPE_ELEMENTALSHIELD:
                case EFFECT_TYPE_POLYMORPH:
                case EFFECT_TYPE_SANCTUARY:
                case EFFECT_TYPE_TRUESEEING:
                case EFFECT_TYPE_SEEINVISIBLE:
                case EFFECT_TYPE_TIMESTOP:
                case EFFECT_TYPE_SPELLLEVELABSORPTION:
                case EFFECT_TYPE_ULTRAVISION:
                case EFFECT_TYPE_CONCEALMENT:
                case EFFECT_TYPE_SPELL_IMMUNITY:
                case EFFECT_TYPE_VISUALEFFECT:
                case EFFECT_TYPE_TURN_RESISTANCE_INCREASE:
                case EFFECT_TYPE_ETHEREAL:

                if (GetEffectSubType(e) == SUBTYPE_MAGICAL && GetEffectDurationType(e) == DURATION_TYPE_TEMPORARY)
                    RemoveEffect(oPC, e);
            }
            e = GetNextEffect(oPC);
        }
    }
    else
    {
        // Don't handle unknown commands
        return;
    }
j-nz commented 1 year ago
if (nVolume == TALKVOLUME_SILENT_SHOUT)
    {
        NWNX_WebHook_SendWebHookHTTPS("discordapp.com", WEBHOOK_DM, sMessage, GetSubString(GetName(oPC), 0, 20));
    }
j-nz commented 1 year ago
object oOther = GetLocalObject(oPC, "SPEAK_THROUGH_OTHER");
    if (GetIsObjectValid(oOther))
    {
        AssignCommand(oOther, SpeakString(sMessage, nVolume));
        SetPCChatMessage("");
    }
j-nz commented 1 year ago
 // -- Possessed Familiar

    if (GetIsPossessedFamiliar(oSpeaker))
    {
        FloatingTextStringOnCreature("You can not speak when possessing familair.", oSpeaker, FALSE);
        SetPCChatMessage();
        return;
    }
j-nz commented 1 year ago
//Add this where you see it here in your script.
  if(GetStringLeft(GetStringLowerCase(GetPCChatMessage()), 5) == "!buff")
  {
    //Make the PC not speak anything..
    SetPCChatMessage("");

    //Make the PC instant cast all of their buff spells.
    ExecuteScript("fastbuff_pc", oPC);

    //Stop the script here.
    return;
  }
j-nz commented 1 year ago
void FollowNearestPDM(object oSelf)
{
    location lTarget =GetLocation(oSelf);
    object oPDM;
    oPDM = GetFirstObjectInShape(SHAPE_SPHERE,50.0,lTarget,FALSE,OBJECT_TYPE_CREATURE);
    while(GetIsObjectValid(oPDM))
    {
        if(GetIsDMPossessed(oPDM))
        {
            string sFname =GetName(oPDM,FALSE);
            AssignCommand(oSelf, ActionForceFollowObject(oPDM, 3.5f));
            SetPCChatMessage("");
            AssignCommand(oSelf,SpeakString("I am following "+sFname+" now", GetPCChatVolume()));
            return;
        }
    oPDM =GetNextObjectInShape(SHAPE_SPHERE,50.0,lTarget,FALSE,OBJECT_TYPE_CREATURE);
    }
}
j-nz commented 1 year ago
// Set the text after this fuction to the color you specify.
// Numbers from (0-15)
//  (1,1,1)  =  Black
//  (15,15,1):= YELLOW
//  (15,5,1) := ORANGE
//  (15,1,1) := RED
//  (7,7,15) := BLUE
//  (1,15,1) := NEON GREEN
//  (1,11,1) := GREEN
//  (9,6,1)  := BROWN
//  (11,9,11):= LIGHT PURPLE
//  (12,10,7):= TAN
//  (8,1,8)  := PURPLE
//  (13,9,13):= PLUM
//  (1,7,7)  := TEAL
//  (1,15,15):= CYAN
//  (1,1,15) := BRIGHT BLUE
//  (0,0,0) or (15,15,15) = WHITE
string ColorTextRGB(int red = 15,int green = 15,int blue = 15);

string ColorTextRGB(int red = 15,int green = 15,int blue = 15)
{
    string sColor = GetLocalString(GetModule(),"ColorSet");
    if(red > 15) red = 15; if(green > 15) green = 15; if(blue > 15) blue = 15;

    return "<c" +
    GetSubString(sColor, red - 1, 1) +
    GetSubString(sColor, green - 1, 1) +
    GetSubString(sColor, blue - 1, 1) +">";

}

//setting the color of speech by volume
void ColorSet(string sSpoken)
{
    int iVolume = GetPCChatVolume();

    if(iVolume==TALKVOLUME_PARTY)
    {
        SetPCChatMessage(ColorTextRGB(15,1,1)+sSpoken);
    }
    if(iVolume==TALKVOLUME_WHISPER)
    {
        SetPCChatMessage(ColorTextRGB(15,15,15)+sSpoken);
    }
}
j-nz commented 1 year ago
 else if (sSpoke == "/relevel")
        {
            if (iDM)
            {
                SendMessageToPC(oSpeaker,"Relevely:");
                object oPC = GetFirstPC();
                while (GetIsObjectValid(oPC))
                {
                    object oSoulStone = GetSoulStone(oPC);
                    int iRelevelCount = GetLocalInt(oSoulStone,"RELEVEL_COUNT");
                    SendMessageToPC(oSpeaker,GetName(oPC)+":"+IntToString(iRelevelCount));
                    oPC = GetNextPC();
                }
                return;
            }
            else
            {
                int iHasRelevel = GetLocalInt(oSpeaker,"HAS_RELEVEL");
                if (iHasRelevel==FALSE)
                {
                    int iXP = GetXP(oSpeaker);
                    SetLocalInt(oSpeaker,"HAS_RELEVEL",1);
                    object oSoulStone = GetSoulStone(oSpeaker);
                    int iRelevelCount = GetLocalInt(oSoulStone,"RELEVEL_COUNT");
                    SetLocalInt(oSoulStone,"RELEVEL_COUNT",iRelevelCount+1);
                    SetXP(oSpeaker,0);
                    DelayCommand(1.0,SetXP(oSpeaker,iXP));
                    ApplyClassConditions(oSpeaker);
                    return;
                }
            }
        }
j-nz commented 1 year ago
#include "inc_chatutils"
#include "inc_effect"
#include "inc_examine"

const string HELP1 = "-dispel allows you to remove all buffs on any player, including yourself, provided you were the one who cast them. In addition, it can remove the effect of the -blind or -deaf commands. To target another player, send -dispel to them as a Tell.\n\n-dispel [+] Tag\nUsed to dispel a specific buff with a visual effect. Example: '-dispel bar' will dispel Barkskin.";
const string HELP2 = " The following is a list of spell tags for available spells:\n'bar' = Barkskin\n'clai' = Clairaudience/Clairvoyance\n'clar' = Clarity\n'dea' = Death Armor\n'ele' = Elemental Shield\n'ene' = Energy Buffer\n'ent' = Entropic Shield\n'eth' = Ethereal Visage\n'fre' = Freedom of Movement\n'gho' = Ghostly Visage\n'glo' = Globe of Invulernability\n'gma' = Greater Spell Mantle\n'gst' = Greater Stoneskin";
const string HELP3 = "\n'imp' = Improved Invisibility\n'inv' = Invisibility\n'isp' = Invisibility Sphere\n'lmi' = Lesser Mind Blank\n'lma' = Lesser Spell Mantle\n'lig' = Light\n'mes' = Mestil's Acid Sheath\n'min' = Mind Blank\n'mgl' = Minor Globe of Invulnerability\n'pre' = Premonition\n'pgo' = Protection from Good\n'pev' = Protection from Evil\n'pel' = Protection from Elements\n'res' = Resist Elements";
const string HELP4 = "\n'san' = Sanctuary\n'see' = See Invisibility\n'sha' = Shadow Shield\n'shi' = Shield\n'sil' = Silence\n'sma' = Spell Mantle\n'sre' = Spell Resistance\n'sto' = Stoneskin\n'tru' = True Seeing\n'ult' = Ultravision\n'wou' = Wounding Whispers";
string HELP = HELP1 + HELP2 + HELP3 + HELP4;

void main()
{
  object oSpeaker = OBJECT_SELF;
  object oTarget  = chatGetTarget(oSpeaker);
  string sParams = chatGetParams(oSpeaker);
  int spellID;
  int ERROR = 1;
  int ERROR_NONE = 0;
  int ERROR_SPELL_NOT_FOUND = 1;
  int ERROR_INVALID_SPELL_ID = 2;

  if (chatGetParams(oSpeaker) == "?")
  {
    DisplayTextInExamineWindow("-dispel", HELP);
  }

  else
  {
    if (!GetIsObjectValid(oTarget))
    {
      oTarget = oSpeaker;
    }
    effect eBuff = GetFirstEffect(oTarget);

  if(GetStringLeft(sParams, 1) != "")
  {
   if (GetStringLeft(sParams, 3) == "bar") spellID = SPELL_BARKSKIN;
   else if (GetStringLeft(sParams, 4) == "clai") spellID = SPELL_CLAIRAUDIENCE_AND_CLAIRVOYANCE;
   else if (GetStringLeft(sParams, 4) == "clar") spellID = SPELL_CLARITY;
   else if (GetStringLeft(sParams, 3) == "dea") spellID = SPELL_DEATH_ARMOR;
   else if (GetStringLeft(sParams, 3) == "ele") spellID = SPELL_ELEMENTAL_SHIELD;
   else if (GetStringLeft(sParams, 3) == "ene") spellID = SPELL_ENERGY_BUFFER;
   else if (GetStringLeft(sParams, 3) == "ent") spellID = SPELL_ENTROPIC_SHIELD;
   else if (GetStringLeft(sParams, 3) == "eth") spellID = SPELL_ETHEREAL_VISAGE;
   else if (GetStringLeft(sParams, 3) == "fre") spellID = SPELL_FREEDOM_OF_MOVEMENT;
   else if (GetStringLeft(sParams, 3) == "gho") spellID = SPELL_GHOSTLY_VISAGE;
   else if (GetStringLeft(sParams, 3) == "glo") spellID = SPELL_GLOBE_OF_INVULNERABILITY;
   else if (GetStringLeft(sParams, 3) == "gma") spellID = SPELL_GREATER_SPELL_MANTLE;
   else if (GetStringLeft(sParams, 3) == "gst") spellID = SPELL_GREATER_STONESKIN;
   else if (GetStringLeft(sParams, 3) == "imp") spellID = SPELL_IMPROVED_INVISIBILITY;
   else if (GetStringLeft(sParams, 3) == "inv") spellID = SPELL_INVISIBILITY;
   else if (GetStringLeft(sParams, 3) == "isp") spellID = SPELL_INVISIBILITY_SPHERE;
   else if (GetStringLeft(sParams, 3) == "lmi") spellID = SPELL_LESSER_MIND_BLANK;
   else if (GetStringLeft(sParams, 3) == "lma") spellID = SPELL_LESSER_SPELL_MANTLE;
   else if (GetStringLeft(sParams, 3) == "lig") spellID = SPELL_LIGHT;
   else if (GetStringLeft(sParams, 3) == "mes") spellID = SPELL_MESTILS_ACID_SHEATH;
   else if (GetStringLeft(sParams, 3) == "min") spellID = SPELL_MIND_BLANK;
   else if (GetStringLeft(sParams, 3) == "mgl") spellID = SPELL_MINOR_GLOBE_OF_INVULNERABILITY;
   else if (GetStringLeft(sParams, 3) == "pol") spellID = SPELL_POLYMORPH_SELF;
   else if (GetStringLeft(sParams, 3) == "pre") spellID = SPELL_PREMONITION;
   else if (GetStringLeft(sParams, 3) == "pgo") spellID = SPELL_PROTECTION_FROM_GOOD;
   else if (GetStringLeft(sParams, 3) == "pev") spellID = SPELL_PROTECTION_FROM_EVIL;
   else if (GetStringLeft(sParams, 3) == "pel") spellID = SPELL_PROTECTION_FROM_ELEMENTS;
   else if (GetStringLeft(sParams, 3) == "res") spellID = SPELL_RESIST_ELEMENTS;
   else if (GetStringLeft(sParams, 3) == "san") spellID = SPELL_SANCTUARY;
   else if (GetStringLeft(sParams, 3) == "see") spellID = SPELL_SEE_INVISIBILITY;
   else if (GetStringLeft(sParams, 3) == "sha") spellID = SPELL_SHADOW_SHIELD;
   else if (GetStringLeft(sParams, 3) == "shi") spellID = SPELL_SHIELD;
   else if (GetStringLeft(sParams, 3) == "sil") spellID = SPELL_SILENCE;
   else if (GetStringLeft(sParams, 3) == "sma") spellID = SPELL_SPELL_MANTLE;
   else if (GetStringLeft(sParams, 3) == "sre") spellID = SPELL_SPELL_RESISTANCE;
   else if (GetStringLeft(sParams, 3) == "sto") spellID = SPELL_STONESKIN;
   else if (GetStringLeft(sParams, 3) == "ten") spellID = SPELL_TENSERS_TRANSFORMATION;
   else if (GetStringLeft(sParams, 3) == "tru") spellID = SPELL_TRUE_SEEING;
   else if (GetStringLeft(sParams, 3) == "ult") spellID = SPELL_DARKVISION;
   else if (GetStringLeft(sParams, 3) == "wou") spellID = SPELL_WOUNDING_WHISPERS;
   else
   {
   SendMessageToPC(oSpeaker, "That is not a valid spell identifier.");
   ERROR = ERROR_INVALID_SPELL_ID;

   }
  }

  //else spellID = GetEffectSpellId(eBuff);

    while (GetIsEffectValid(eBuff))
    {

      if(GetEffectCreator(eBuff) == oSpeaker &&
        (GetIsTaggedEffect(eBuff, EFFECT_TAG_CONSOLE_COMMAND_DISPELLABLE) ||
        (/*!GetIsEffectHarmful(eBuff) &&*/ GetEffectSubType(eBuff) != SUBTYPE_SUPERNATURAL && GetEffectSubType(eBuff) != SUBTYPE_EXTRAORDINARY &&
         GetEffectType(eBuff) != EFFECT_TYPE_POLYMORPH /*&& GetEffectType(eBuff) != EFFECT_TYPE_VISUALEFFECT*/)) && (!spellID || GetEffectSpellId(eBuff) == spellID) && ERROR != ERROR_INVALID_SPELL_ID)
      {
        RemoveEffect(oTarget, eBuff);
        ERROR = ERROR_NONE;
      }

      eBuff = GetNextEffect(oTarget);
    }

    if (ERROR == ERROR_NONE)
      {
        string output = "You have stripped ";
        output += (oTarget == oSpeaker) ? ("yourself") : (GetName(oTarget));
        if (GetStringLeft(sParams, 1) != "") output += " of a spell.";
        else output += " of all magical effects cast by you.";
        SendMessageToPC(oSpeaker, output);
      }
    else if (ERROR == ERROR_SPELL_NOT_FOUND) SendMessageToPC(oSpeaker, "Spell not currently cast.");
  }

  chatVerifyCommand(oSpeaker);
}
j-nz commented 1 year ago

const string HELP = "This command shows the current date, including the Faerunian month and year. It also shows important meter states. Using this command with the -s parameter will display the information in a shortened format.";

j-nz commented 1 year ago
#include "inc_chatutils"
#include "inc_pc"
#include "inc_examine"

const string HELP = "-hood [variant]. Dons a hood. If variant is passed in, equips that variant instead.";

const int INVALID_HEAD_ID = 0;

int getDesiredHeadId(int variant);
void toggleHood(int desiredHeadId);
void restoreHead();

void main()
{
    string params = chatGetParams(OBJECT_SELF);

    if (params == "?")
    {
        DisplayTextInExamineWindow("-hood", HELP);
    }
    else
    {
        int toggle = params == "" ? TRUE : FALSE;
        int desiredHeadId = getDesiredHeadId(StringToInt(params));

        if (desiredHeadId == INVALID_HEAD_ID)
        {
            SendMessageToPC(OBJECT_SELF, "No hood exists for your appearance type!");
        }
        else
        {
            if (!toggle)
            {
                restoreHead(); // We specifically have a variant. Restore before toggling.
            }

            toggleHood(desiredHeadId);
        }
    }

    chatVerifyCommand(OBJECT_SELF);
}

int getDesiredHeadId(int variant)
{
    int desiredHeadId = INVALID_HEAD_ID;

    switch (GetAppearanceType(OBJECT_SELF))
    {
        case APPEARANCE_TYPE_DWARF:

            desiredHeadId = GetGender(OBJECT_SELF) == GENDER_MALE ? INVALID_HEAD_ID : 3;
            break;

        case APPEARANCE_TYPE_ELF:

            desiredHeadId = GetGender(OBJECT_SELF) == GENDER_MALE ? 15 : 14;
            break;

        case APPEARANCE_TYPE_GNOME:

            desiredHeadId = GetGender(OBJECT_SELF) == GENDER_MALE ? 6 : 5;
            break;

        case APPEARANCE_TYPE_HALF_ELF:
        case APPEARANCE_TYPE_HUMAN:

            if (GetGender(OBJECT_SELF) == GENDER_MALE)
            {
                desiredHeadId = 2;
            }
            else
            {
                desiredHeadId = variant == 1 ? 12 : 143;
            }
            break;

        case APPEARANCE_TYPE_HALF_ORC:

            desiredHeadId = GetGender(OBJECT_SELF) == GENDER_MALE ? INVALID_HEAD_ID : 2;
            break;

        case APPEARANCE_TYPE_HALFLING:

            desiredHeadId = GetGender(OBJECT_SELF) == GENDER_MALE ? 9 : 10;
            break;
    }

    return desiredHeadId;
}

void toggleHood(int desiredHeadId)
{
    object hide = gsPCGetCreatureHide(OBJECT_SELF);
    int savedHeadId = GetLocalInt(hide, "HEAD");
    int currentHeadId = GetCreatureBodyPart(CREATURE_PART_HEAD, OBJECT_SELF);

    if (currentHeadId == desiredHeadId || savedHeadId != INVALID_HEAD_ID) // We already have a hood; restore.
    {
        restoreHead();
    }
    else // Save old head and use new one.
    {
        SetLocalInt(hide, "HEAD", currentHeadId);
        SetCreatureBodyPart(CREATURE_PART_HEAD, desiredHeadId, OBJECT_SELF);
    }
}

void restoreHead()
{
    object hide = gsPCGetCreatureHide(OBJECT_SELF);
    int savedHeadId = GetLocalInt(hide, "HEAD");

    if (savedHeadId != INVALID_HEAD_ID)
    {
        SetCreatureBodyPart(CREATURE_PART_HEAD, savedHeadId, OBJECT_SELF);
        SetLocalInt(hide, "HEAD", INVALID_HEAD_ID);
    }
}
j-nz commented 1 year ago
#include "inc_chatutils"
#include "inc_examine"
#include "nwnx_creature"
#include "x3_inc_string"

void main()
{
    string params = chatGetParams(OBJECT_SELF);

    if (params == "?" || params == "")
    {
        DisplayTextInExamineWindow(
            chatCommandTitle("-walk") + " " + chatCommandParameter("[Type]"),

            "Toggles between various walk speed capping options.\n\n" +

            chatCommandParameter("alwayswalk") + "\n" +
            "Forces the character to always walk, as if they had detect mode active.\n\n" +

            chatCommandParameter("naturalwalk") + "\n" +
            "Forces the character to always walk at a normal pace, as if they had no movement-speed increasing effects."
        );
    }
    else
    {
        if (GetActionMode(OBJECT_SELF, ACTION_MODE_STEALTH) == TRUE)
        {
          SendMessageToPC(OBJECT_SELF, "You cannot use this in stealth mode.");
        }
        else if (params == "alwayswalk")
        {
            int alreadyOn = GetLocalInt(OBJECT_SELF, "ALWAYS_WALK");
            NWNX_Player_SetAlwaysWalk(OBJECT_SELF, alreadyOn ? 0 : 1);
            SetLocalInt(OBJECT_SELF, "ALWAYS_WALK", alreadyOn ? 0 : 1);
            SendMessageToPC(OBJECT_SELF, "Toggled alwayswalk " + (alreadyOn ? "off!" : "on!"));
        }
        else if (params == "naturalwalk")
        {
            int alreadyOn = GetLocalInt(OBJECT_SELF, "NATURAL_WALK");
            NWNX_Creature_SetWalkRateCap(OBJECT_SELF, alreadyOn ? -1.0 : 2000.0);
            SetLocalInt(OBJECT_SELF, "NATURAL_WALK", alreadyOn ? 0 : 1);
            SendMessageToPC(OBJECT_SELF, "Toggled naturalwalk " + (alreadyOn ? "off!" : "on!"));
        }
        else
        {
            SendMessageToPC(OBJECT_SELF, StringToRGBString("Invalid parameter: " + params, STRING_COLOR_RED));
        }
    }

    chatVerifyCommand(OBJECT_SELF);
}
j-nz commented 1 year ago

Make SHOUT channel an area wide channel rather than server wide.

j-nz commented 1 year ago
#include "nwnx_chat"
#include "nwnx_redis_short"

int GetChatPermissionLevel(object oPC) {
  return HGET(GetName(GetModule()) + ":" + GetPCPublicCDKey(oPC),"chatLevel");
}

void SetChatPermissionLevel(object oPC, int nLevel) {
  HSET(GetName(GetModule()) + ":" + GetPCPublicCDKey(oPC),"chatLevel", IntToString(nLevel));
  return;
}

int processChatPermission(object oPC, string sMessage) {
  switch(GetChatPermissionLevel(oPC)) {
    // only able to talk in party
    case 1: {
      FloatingTextStringOnCreature("Your chat has been redirected to party.",oPC,TRUE);
      NWNX_Chat_SkipMessage();
      NWNX_Chat_SendMessage(NWNX_CHAT_CHANNEL_PLAYER_PARTY,sMessage, oPC);
      return 0;
    }
    // blocking all chat completely
    case 2: {
      FloatingTextStringOnCreature("You are banned from chat.",oPC,TRUE);
      NWNX_Chat_SkipMessage();
      return 0;
    }
    default: return 1;
  }
  return 1;
}
j-nz commented 1 year ago
// process a pm to user message
    // dm commands
    // warn mute command
    if (TestStringAgainstPattern(sMessage,"!dm warnmute") && GetIsDM(oPC) && NWNX_Chat_GetChannel() == 4 || NWNX_Chat_GetChannel() == 20 ){
        SetChatPermissionLevel(NWNX_Chat_GetTarget(), 2);
    }

    // mute command
    if (TestStringAgainstPattern(sMessage,"!dm mute") && GetIsDM(oPC) && NWNX_Chat_GetChannel() == 4 || NWNX_Chat_GetChannel() == 20 ){
        SetChatPermissionLevel(NWNX_Chat_GetTarget(), 2);
    }

    // mute command
    if (TestStringAgainstPattern(sMessage,"!dm unmute") && GetIsDM(oPC) && NWNX_Chat_GetChannel() == 4 || NWNX_Chat_GetChannel() == 20 ){
        SetChatPermissionLevel(NWNX_Chat_GetTarget(), 0);
    }
j-nz commented 1 year ago
#include "anph_cfg"
#include "dbg_inc"
#include "dev_inc"
#include "faction_inc"
#include "nwnx_player"
#include "nwnx_creature"
#include "nwnx_webhook"
#include "nwnx_admin"
#include "nwnx_time"
#include "pat_inc"

const string WEBHOOK_DM = "/api/webhooks/451344020606812161/th1si5n0tar43lAPiK3y-n3v3rPuTaPiKEY5inS0urceRep0_Y_amIap0tat0lalalaF/slack";

const string BADPARSE = "[BADPARSE]";
string ParseCommand(string sMessage, string sCommand)
{
    int sCommandLen = GetStringLength(sCommand);
    if (GetStringLeft(sMessage, sCommandLen) == sCommand)
        return GetSubString(sMessage, sCommandLen+1, GetStringLength(sMessage)-sCommandLen-1);
    else
        return BADPARSE;
}

void main()
{
    object oDM = GetPCChatSpeaker();
    if (!dev_IsTeamMember(oDM))
    {
        dbg_Warning("dev_commands called on non-team PC", oDM);
        return;
    }

    string sParams;
    string sMessage = GetPCChatMessage();

    if ((sParams = ParseCommand(sMessage, "#modname")) != BADPARSE)
    {
        if (sParams == "" || sParams == " ")
            sParams = "Anphillia " + ANPH_VERSION + " (" + NWNX_Time_GetSystemDate() +")";
        NWNX_Administration_SetModuleName(sParams);
    }
    else if ((sParams = ParseCommand(sMessage, "#password")) != BADPARSE)
    {
        if (sParams == "" || sParams == " ")
            NWNX_Administration_ClearPlayerPassword();
        else
            NWNX_Administration_SetPlayerPassword(sParams);
    }
    else if ((sParams = ParseCommand(sMessage, "#xp")) != BADPARSE)
    {
        if (sParams == "reload")
            ExecuteScript("xp_reload", OBJECT_SELF);

        string sNotification = COLOR_CODE_BLUE_DARK + "XP tables reloaded from database" + COLOR_CODE_END;
        SendMessageToPC(oDM, sNotification);
        SendMessageToAllDMs(sNotification);
    }
    else if ((sParams = ParseCommand(sMessage, "#faction")) != BADPARSE)
    {
        if (sParams == "reset")
        {
            object oPC = GetFirstPC();
            while (oPC != OBJECT_INVALID)
            {
                fctn_UpdateReputation(oPC);
                oPC = GetNextPC();
            }
        }
        string sNotification = COLOR_CODE_BLUE_DARK + "Faction relations for PCs reset." + COLOR_CODE_END;
        SendMessageToPC(oDM, sNotification);
        SendMessageToAllDMs(sNotification);
    }
    else if ((sParams = ParseCommand(sMessage, "#gainxp")) != BADPARSE)
    {
        GiveXPToCreature(oDM, StringToInt(sParams));
    }
    else if ((sParams = ParseCommand(sMessage, "#area")) != BADPARSE)
    {
        if (sParams == "neutral")
        {
            SetLocalInt(GetArea(oDM), "AREA_NEUTRAL_ZONE", 1);
            string sNotification = COLOR_CODE_BLUE_DARK + "Area " + GetName(GetArea(oDM)) + " is now a neutral zone." + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
        else if (sParams == "pvp")
        {
            SetLocalInt(GetArea(oDM), "AREA_NEUTRAL_ZONE", 0);
            string sNotification = COLOR_CODE_BLUE_DARK + "Area " + GetName(GetArea(oDM)) + " is now a pvp zone." + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
    }
    else if ((sParams = ParseCommand(sMessage, "#encounter")) != BADPARSE)
    {
        if (sParams == "on")
        {
            util_ToggleEncountersInArea(GetArea(oDM), TRUE);
            string sNotification = COLOR_CODE_BLUE_DARK + "Enabled encounters in " + GetName(GetArea(oDM)) + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
        else if (sParams == "off")
        {
            util_ToggleEncountersInArea(GetArea(oDM), FALSE);
            string sNotification = COLOR_CODE_BLUE_DARK + "Disabled encounters in " + GetName(GetArea(oDM)) + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
    }
    else if ((sParams = ParseCommand(sMessage, "#gainitem")) != BADPARSE)
    {
        CreateItemOnObject(sParams, oDM, max(1, StringToInt(sParams)));
    }
    else if ((sParams = ParseCommand(sMessage, "#pat")) != BADPARSE)
    {
        if (sParams == "clearareacache")
        {
            pat_ClearAreaCache();
            string sNotification = COLOR_CODE_BLUE_DARK + "PAT Area CR Cache cleared" + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
        if (sParams == "updateareas")
        {
            pat_UpdateAreasTable();
            string sNotification = COLOR_CODE_BLUE_DARK + "PAT Area table updated" + COLOR_CODE_END;
            SendMessageToPC(oDM, sNotification);
            SendMessageToAllDMs(sNotification);
        }
    }
    else return;

    string sMsg = GetName(oDM) + " used command " + sMessage;
    NWNX_WebHook_SendWebHookHTTPS("discordapp.com", WEBHOOK_DM, sMsg, GetName(oDM));
    WriteTimestampedLogEntry(sMsg);
    SetPCChatMessage("");
}
j-nz commented 1 year ago
int nParse(string sCommand, int nCurrent)
{
int nReport = 99999999;

if (sCommand == "next") {nCurrent++; return nCurrent;}
else if (sCommand == "prev") {nCurrent = nCurrent - 1; return nCurrent;}
else if (StringToInt(sCommand) >= 1) {nCurrent = StringToInt(sCommand); return nCurrent;}
else return nReport;
}
j-nz commented 1 year ago
void main()
{
    object oPC = OBJECT_SELF;

    if(GetLocalInt(oPC, "QUICKCHAT_DISABLED")){
        FloatingTextStringOnCreature("You cannot use quick chat so frequently.",
                                     oPC, FALSE);
        BypassEvent();
        return;
    }

    SetLocalInt(oPC, "QUICKCHAT_DISABLED", TRUE);

    DelayCommand(3.0, DeleteLocalInt(oPC, "QUICKCHAT_DISABLED"));
}