EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   A little Help with Script. (https://www.eqemulator.org/forums/showthread.php?t=42035)

superpally1 08-13-2018 08:42 PM

A little Help with Script.
 
Hello, I am fairly new to these forums. I have played on eqemu servers for years but I have only recently tried to run my own server. I have used Akkadius's npc scaling system recently however since i updated my server, i can not seem to get it to work anymore. Ive tried ID 50 and 10. Rules- true and false for zone controller. No luck. Here are my files if anyone feels the need to help/correct me. https://ufile.io/j68ey https://ufile.io/3ndl4
https://ufile.io/j8xl4
even made xml since it doesnt work with json https://ufile.io/y59qp
So I took it upon myself to make a scaling system I can use. Here is what i have so far. I can not figure out why this doesnt work. i am tryin to use what my charecter says as value for level and/or hp etc but i can not seem to get it to work. i can make it work with just level if i alter script to only account for that but i really want it to handle everything. =/

#Mob scaling
#---------------------------------------------
#---------------------------------------------
#---------------------------------------------
sub EVENT_SAY {

my $Level = quest::saylink("Scale Level", 1, "ScaleLevel");
my $HP = quest::saylink("Scale HP", 1, "ScaleHP");
# my $Hits = quest::saylink("Scale Min/Max Attack", 1, "ScaleMin/MaxAttack");
# my $HPRegen = quest::saylink("Scale HP Regen", 1, "ScaleHPRegen");
# my $ManaRegen = quest::saylink("Scale Mana Regen", 1, "ScaleManaRegen");
# my $Stats = quest::saylink("Scale Stats", 1, "ScaleStats");
# my $Resists = quest::saylink("Scale Resists", 1, "ScaleResists");
# my $Skills = quest::saylink("Scale Skills", 1, "ScaleSkills");

if ($text =~/Hail/i)
{
plugin::Whisper("Are you ready to [$Level], [$HP]");
# plugin::Whisper("Are you ready to [$Level], [$HP], [$Hits], [$HPRegen], [$ManaRegen], [$Stats], [$Resists], [$Skills]");
}
if ($text =~/Scale Level/i)
{
$client->Message(4, "What Level?");
if($text!~/Hail|Scale Level|ScaleLevel|WhatLevel|What Level/i)
{
plugin::ScaleLevel($text);
}
}
if ($text =~/Scale HP/i)
{
$client->Message(4, "What HP?");
if($text!~/Hail|Scale HP|ScaleHP|WhatHP|What HP/i)
{
plugin::ScaleHP($text);
}
}

}

i altered out the rest of script becouse i can not seem to even get this to work. Any help would be greatly appreciated







here are my plugins for Level and HP the others are the same.



sub ScaleLevel {
my $min = $_[0];
my $e = plugin::val('entity_list');
my @n = $e->GetNPCList();
foreach my $p (@n) {
$p->SetLevel($min);
}
}

sub ScaleHP {
my $min = $_[0];
my $e = plugin::val('entity_list');
my @n = $e->GetNPCList();
foreach my $p (@n) {
$p->ModifyNPCStat("max_hp",$min);
}
}

Randymarsh9 08-15-2018 05:45 PM

Welcome to the forums!

First of all, when posting code on here, try to wrap it in [code] blocks. That will make it much easier to read.

Now, onto your code itself. The sub EVENT_SAY is going to trigger once for each time you say something to the NPC. This means that your nested if statements are not going to work as you may be expecting.

For instance,
Code:

if ($text =~/Scale Level/i)
{
    $client->Message(4, "What Level?");
    if($text!~/Hail|Scale Level|ScaleLevel|WhatLevel|What Level/i)
    {
          plugin::ScaleLevel($text);
    }
}

Here, assuming the player chose to scale level, $text is going to be equal to "Scale Level." Once the $client->message line executes, it's immediately going to proceed to the next if statement. Since "Scale Level" will fail your regex check, the plugin::ScaleLevel will not run. The EVENT_SAY sub will then end.

You will need to restructure your code to account for the fact that you will never have different values for $text in the same execution of sub EVENT_SAY.

Also, for efficiency, you should use elsif's so that not every option is checked every time the NPC is spoken too. Right now, if someone hails your NPC, it will run the hail code, and then check every other prompt you have listed as well. It won't cause problems, but it does make the script slower.

superpally1 08-15-2018 07:27 PM

Thankyou for this knowledge. i am sorry i posted without code bracets. I will take what you said and build on it. thankyou again!

Almusious 08-17-2018 01:18 AM

Code:

#Mob scaling
use Scalar::Util qw(looks_like_number);
sub EVENT_SAY {
        if (!defined(plugin::REV($client, "operationmode")) || plugin::REV($client, "operationmode") eq '') {
                if ($text =~/Hail/i) {
                        plugin::Whisper("Are you ready to [".quest::saylink("Scale Level", 1, "ScaleLevel")."], [".quest::saylink("Scale HP", 1, "ScaleHP")."]");
                }
                elsif ($text =~/Scale Level/i) {
                        $client->SetEntityVariable("operationmode", "level");
                        $client->Message(4, "What Level?");
                }
                elsif ($text =~/Scale HP/i) {
                        $client->SetEntityVariable("operationmode", "hp");
                        $client->Message(4, "What HP?");
                }
        } else {
                if (looks_like_number($text)) {
                        my @npclist = $entity_list->GetNPCList();
                        if (plugin::REV($client, "operationmode") eq 'level') {
                                $client->SetEntityVariable("operationmode", "");
                                foreach my $singlenpc (@npclist) {
                                        $singlenpc->SetLevel($text);
                                }
                        } else {
                                $client->SetEntityVariable("operationmode", "");
                                my @npclist = $entity_list->GetNPCList();
                                foreach my $singlenpc (@npclist) {
                                        $singlenpc->ModifyNPCStat("max_hp",$min);
                                }
                        }
                }
        }
}



All times are GMT -4. The time now is 11:02 AM.

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