EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Special_Abilities on the fly in Perl? (https://www.eqemulator.org/forums/showthread.php?t=38679)

Hateborne 08-27-2014 02:55 PM

Special_Abilities on the fly in Perl?
 
Afternoon ladies/gents/trolls,

I'm curious on how one might modify npc special_abilities on the fly through perl? I'm having issues with $npc->NPCSpecialAttacks as two comma delimited bits would trainwreck and it does not accept the special_abilities as a string:
Code:

$npc->NPCSpecialAttacks("12,1^13,1^14,1", 0);
I then tried the bit below, no luck.
Code:

$npc->ModifyNPCStat("special_abilities", "12,1^13,1^14,1");
$npc->ModifyNPCStat("special_attacks", "12,1^13,1^14,1");

Is there a way to edit these on the fly? What I'm trying to accomplish is to get a mob to ignore combat and charge at another NPC. If there are other ways to accomplish this, PLEASE LET ME KNOW. Also, if a way to handle these on-the-fly is possible, that would be incredibly helpful too.


Thank You!
-Hate

nilbog 08-27-2014 02:59 PM

I'm not sure if you've tried:

Quote:

quest::modifynpcstat(identifier, value) # Changes NPC stats on the fly. Changes are not saved to DB.
Might be useful for i.e. quest::modifynpcstat("max_hit", "700"); Just make sure to name the field correctly.

Kingly_Krab 08-27-2014 02:59 PM

I don't believe special_abilities have been added to Perl yet, it is something that could be done, but I haven't seen it used any where yet.

Here's the $npc->ModifyNPCStat code (this is also used for quest::modifynpcstat):
Code:

void NPC::ModifyNPCStat(const char *identifier, const char *newValue)
{
    std::string id = identifier;
    std::string val = newValue;
    for(int i = 0; i < id.length(); ++i)
    {
        id[i] = std::tolower(id[i]);
    }

    if(id == "ac")
    {
        AC = atoi(val.c_str());
        return;
    }

    if(id == "str")
    {
        STR = atoi(val.c_str());
        return;
    }

    if(id == "sta")
    {
        STA = atoi(val.c_str());
        return;
    }

    if(id == "agi")
    {
        AGI = atoi(val.c_str());
        return;
    }

    if(id == "dex")
    {
        DEX = atoi(val.c_str());
        return;
    }

    if(id == "wis")
    {
        WIS = atoi(val.c_str());
        CalcMaxMana();
        return;
    }

    if(id == "int" || id == "_int")
    {
        INT = atoi(val.c_str());
        CalcMaxMana();
        return;
    }

    if(id == "cha")
    {
        CHA = atoi(val.c_str());
        return;
    }

    if(id == "max_hp")
    {
        base_hp = atoi(val.c_str());
        CalcMaxHP();
        if(cur_hp > max_hp)
            cur_hp = max_hp;
        return;
    }

    if(id == "max_mana")
    {
        npc_mana = atoi(val.c_str());
        CalcMaxMana();
        if(cur_mana > max_mana)
            cur_mana = max_mana;
        return;
    }

    if(id == "mr")
    {
        MR = atoi(val.c_str());
        return;
    }

    if(id == "fr")
    {
        FR = atoi(val.c_str());
        return;
    }

    if(id == "cr")
    {
        CR = atoi(val.c_str());
        return;
    }

    if(id == "pr")
    {
        PR = atoi(val.c_str());
        return;
    }

    if(id == "dr")
    {
        DR = atoi(val.c_str());
        return;
    }

    if(id == "PhR")
    {
        PhR = atoi(val.c_str());
        return;
    }

    if(id == "runspeed")
    {
        runspeed = (float)atof(val.c_str());
        CalcBonuses();
        return;
    }

    if(id == "special_attacks")
    {
        //Added reset flag.
        NPCSpecialAttacks(val.c_str(), 0, 1);
        return;
    }

    if(id == "attack_speed")
    {
        attack_speed = (float)atof(val.c_str());
        CalcBonuses();
        return;
    }

    if(id == "atk")
    {
        ATK = atoi(val.c_str());
        return;
    }

    if(id == "accuracy")
    {
        accuracy_rating = atoi(val.c_str());
        return;
    }

    if(id == "avoidance")
    {
        avoidance_rating = atoi(val.c_str());
        return;
    }

    if(id == "trackable")
    {
        trackable = atoi(val.c_str());
        return;
    }

    if(id == "min_hit")
    {
        min_dmg = atoi(val.c_str());
        return;
    }

    if(id == "max_hit")
    {
        max_dmg = atoi(val.c_str());
        return;
    }

    if(id == "attack_count")
    {
        attack_count = atoi(val.c_str());
        return;
    }

    if(id == "see_invis")
    {
        see_invis = atoi(val.c_str());
        return;
    }

    if(id == "see_invis_undead")
    {
        see_invis_undead = atoi(val.c_str());
        return;
    }

    if(id == "see_hide")
    {
        see_hide = atoi(val.c_str());
        return;
    }

    if(id == "see_improved_hide")
    {
        see_improved_hide = atoi(val.c_str());
        return;
    }

    if(id == "hp_regen")
    {
        hp_regen = atoi(val.c_str());
        return;
    }

    if(id == "mana_regen")
    {
        mana_regen = atoi(val.c_str());
        return;
    }

    if(id == "level")
    {
        SetLevel(atoi(val.c_str()));
        return;
    }

    if(id == "aggro")
    {
        pAggroRange = atof(val.c_str());
        return;
    }

    if(id == "assist")
    {
        pAssistRange = atof(val.c_str());
        return;
    }

    if(id == "slow_mitigation")
    {
        slow_mitigation = atoi(val.c_str());
        return;
    }
    if(id == "loottable_id")
    {
        loottable_id = atof(val.c_str());
        return;
    }
    if(id == "healscale")
    {
        healscale = atof(val.c_str());
        return;
    }
    if(id == "spellscale")
    {
        spellscale = atof(val.c_str());
        return;
    }
}


Hateborne 08-27-2014 03:06 PM

Well then, that was crazy fast. That will make things interesting. Thank you gents for the scary fast replies.


-Hate

Kingly_Krab 08-27-2014 03:12 PM

Haha, I wasn't aware it was fast, I had just logged in and saw a bold post and checked it out. You're welcome.

demonstar55 08-27-2014 03:23 PM

the NPCSpecialAttacks still work on the old letter system rather than the newer system.

https://github.com/EQEmu/Server/blob.../npc.cpp#L1414

wolfwalkereci 08-27-2014 04:36 PM

some servers use it, just don't think many or even any of the quests on peq do/did

demonstar55 08-27-2014 05:35 PM

Looking at the PEQ quests they do quest::modifynpcstat("special_attacks",ABfHG); my bad, still uses the old codes though.


All times are GMT -4. The time now is 07:37 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.