EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development: Custom Code (https://www.eqemulator.org/forums/forumdisplay.php?f=665)
-   -   Modifying the Steadfast servant (https://www.eqemulator.org/forums/showthread.php?t=42390)

Kattamaran.CH 04-10-2019 07:13 AM

Modifying the Steadfast servant
 
Ok i need a simple buffer / healer and thought i might be a nice idea to modify the steadfast serverant.

- i am able to change the reuse time of the AA - check
- i am able to change the duration until he fades - check
- now id like to have the level check and diffrent spells per level range removed and at the very top id like to enter the IDs of the buffs he needs to cast, the HoT and HP% on wich he casts it are ok, another thing id like to add is a direct heal spell and also at what HP% he should heal it.


any lua specialist able to change those features in the code?:

Code:

#
# Steadfast Servant Veteran AA

$HPThreshold = 50;      # HP Threshold at which HoT will be cast.
$Frequency = 35;        # Frequency in seconds with which the EVENT_TIMER is executed.
$Range = 100;          # How close a player must be for a chance to be buffed.

@ManaRegenSpells = (697, 174, 1693, 6898);      # Breeze, Clarity, Clarity II, Servant's Breath
@HasteSpells = (10, 170, 171, 172);            # Augmentation, Alacrity, Celerity, Swift like the wind
@HoTSpells = (2502, 2175, 1283, 1522);          # Celestial Remedy,  Health, Cleansing, Elixir
@ACSpells = (18, 19, 20, 3470);                # Guard, Armor of Faith, Shield of Words, Ward of Gallantry

sub EVENT_SPAWN {
        quest::settimer("RandomAction", $Frequency);
}

sub EVENT_TIMER {

        # First we find our owner and see if is in range and in need of any buffs.
        #
        $OwnerID = $npc->GetFollowID();

        if($OwnerID <= 0)
        {
                return;
        }
        $Owner = $entity_list->GetClientByID($OwnerID);

        if($Owner)
        {
                $x = $Owner->GetX();
                $y = $Owner->GetY();
                $z = $Owner->GetZ();

                $Distance = $npc->CalculateDistance($x, $y, $z);

                if($Distance < $Range) {
                        if(BuffPlayer($Owner))
                        {
                                # We cast a buff on our owner, so we are done for this cycle.
                                return;
                        }
                }
        }

        # Our owner didn't need any buffs, so look for someone else within range.
        #
        $c = $entity_list->GetRandomClient($x, $y, $z, $Range, $Owner);

        if(!$c)
        {
                return;
        }

        BuffPlayer($c);
}

sub BuffPlayer
{
        $c = $_[0];

        if($c)
        {
                $ClientID = $c->GetID();

                $HPRatio = ($c->GetHP() / $c->GetMaxHP()) * 100;

                $Level = $c->GetLevel();

                if($Level < 15)
                {
                        $SpellSet = 0;
                }
                elsif($Level < 30)
                {
                        $SpellSet = 1;
                }
                elsif($Level < 50)
                {
                        $SpellSet = 2;
                }
                else
                {
                        $SpellSet = 3;
                }

                $ManaRegenSpell = $ManaRegenSpells[$SpellSet];
                $HasteSpell = $HasteSpells[$SpellSet];
                $HoTSpell = $HoTSpells[$SpellSet];
                $ACSpell = $ACSpells[$SpellSet];

                if($HPRatio <= $HPThreshold)
                {
                        # Check if the player already has our HoT spell on.
                        #
                        $Slot = $c->FindBuff($HoTSpell);
                        if(!$Slot)
                        {
                                if($c->CanBuffStack($HoTSpell, $npc->GetLevel(), True) >= 0)
                                {
                                        $npc->FaceTarget($c);
                                        $npc->CastSpell($HoTSpell, $ClientID);
                                        return 1;
                                }
                        }
                }

                # Next the mana regen buff. Only cast this if the player uses mana.
                #
                if($c->GetMaxMana() > 0)
                {
                        $Slot = $c->FindBuff($ManaRegenSpell);
                        if(!$Slot)
                        {
                                if($c->CanBuffStack($ManaRegenSpell, $npc->GetLevel(), True) >= 0)
                                {
                                        $npc->FaceTarget($c);
                                        $npc->CastSpell($ManaRegenSpell, $ClientID);
                                        return 1;
                                }
                        }
                }

                # Finally, see if they need our Haste or AC buff.
                #
                @Buffs = ($HasteSpell, $ACSpell);

                foreach $Spell (@Buffs)
                {
                        $Slot = $c->FindBuff($Spell);
                        if(!$Slot)
                        {
                                if($c->CanBuffStack($Spell, $npc->GetLevel(), True) >= 0)
                                {
                                        $npc->FaceTarget($c);
                                        $npc->CastSpell($Spell, $ClientID);
                                        return 1;
                                }
                        }
                }
        }

        return 0;
}


Kattamaran.CH 04-10-2019 07:59 AM

Im playing around with the script. Is there a command to instant cast for a npc and overrule whatever the spell has defined as casting time?
Something diffrent to CastSpell?

When i use my buff npc with the perlscript he can instantly buff all spells.

Drathil 12-03-2023 03:25 AM

Could you please tell me where I can find the Steadfast Servant script? Would like to edit it as well, but I cannot find it in the scripts.

Ishtass 12-03-2023 04:55 PM

Quote:

Originally Posted by Drathil (Post 269468)
Could you please tell me where I can find the Steadfast Servant script? Would like to edit it as well, but I cannot find it in the scripts.

quests\global\a_steadfast_servant.lua


All times are GMT -4. The time now is 03:24 PM.

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