Thread: Pet scaling...
View Single Post
  #3  
Old 04-19-2017, 09:12 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,589
Default

Pet Scaling Plugin:
Code:
sub PetScale {
    my $client = plugin::val('client');
    my $entity_list = plugin::val('entity_list');
    my $npc = $entity_list->GetNPCByID($client->GetPetID());
    if (plugin::GetModifier() <= 1) {
        $client->Message(315, "Scaling your pet would be useless, so it was not scaled.");
        return;
    }
    my %h = ("ac" => ["Armor Class", $npc->GetAC(), int($npc->GetAC() * plugin::GetModifier())],
    "max_hp" => ["Health", $npc->GetMaxHP(), int($npc->GetMaxHP() * plugin::GetModifier())],
    "min_hit" => ["Minimum Damage", $npc->GetMinDMG(), int($npc->GetMinDMG() * plugin::GetModifier())],
    "max_hit" => ["Maximum Damage", $npc->GetMaxDMG(), int($npc->GetMaxDMG() * plugin::GetModifier())],
    "atk" => ["Attack", $npc->GetATK(), int((1000 - (1000 / $client->GetLevel())) * plugin::GetModifier())],
    "accuracy" => ["Accuracy", $npc->GetAccuracyRating(), int((1000 - (1000 / $client->GetLevel())) * plugin::GetModifier())]);
    foreach my $key (sort {$a cmp $b} keys %h) {
        if (!$npc->EntityVariableExists($key)) {
            $npc->ModifyNPCStat($key, $h{$key}[2]);
            $npc->SetHP($npc->GetMaxHP());
            $npc->ChangeSize($client->GetSize(), 1);
            $npc->SetLevel($client->GetLevel());
            $npc->SetEntityVariable($key, 1);
        } else {
            $client->Message(315, "Your pet has already been scaled.");
            return;
        }
    }
    quest::popup("Pet Scaling Information", "Your Modifier: <font color = '#00FF00'>" . plugin::commify(plugin::GetModifier()) . "</font><br>
                                            Accuracy: <font color = '#00FFFF'>" . plugin::commify($h{"accuracy"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"accuracy"}[2]) . "</font><br>
                                            Armor Class: <font color = '#00FFFF'>" . plugin::commify($h{"ac"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"ac"}[2]) . "</font><br>
                                            Attack: <font color = '#00FFFF'>" . plugin::commify($h{"atk"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"atk"}[2]) . "</font><br>
                                            Health: <font color = '#00FFFF'>" . plugin::commify($h{"max_hp"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"max_hp"}[2]) . "</font><br>
                                            Minimum Damage: <font color = '#00FFFF'>" . plugin::commify($h{"min_hit"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"min_hit"}[2]) . "</font><br>
                                            Maximum Damage: <font color = '#00FFFF'>" . plugin::commify($h{"max_hit"}[1]) . "</font> - <font color = '#FFFF00'>" . plugin::commify($h{"max_hit"}[2]) . "</font><br>");
    $client->Message(315, "Your pet is now completely scaled.");
}

sub GetModifier {
    my $client = plugin::val('client');
    return 1000 if ($client->Admin() == 255);
    return (($client->GetCHA() / 100 > 1) ? ($client->GetCHA() / 100) : 1);
}

return 1;
Pet Scaling in global NPC/Player scripts:
Code:
## quests/global/global_player.pl
sub EVENT_SAY {
    if ($text=~/#Scale/i) {
        if ($client->GetPetID() > 0) {
            plugin::PetScale();
        }
    }
}

sub EVENT_SIGNAL {
    if ($signal == 999) {
        plugin::PetScale();
    }
}

## quests/global/global_npc.pl
sub EVENT_SPAWN {
    if ($npc->GetOwnerID() > 0 && $entity_list->GetMobByID($npc->GetOwnerID())->IsClient()) {
        quest::settimer("PetScale", 1);
    }
}

sub EVENT_TIMER {
    if ($timer eq "PetScale") {
        quest::stoptimer("PetScale");
        $entity_list->GetClientByID($npc->GetOwnerID())->SignalClient(999);
    }
}
It's old, and it does what I wanted it to do. Change it however you'd like.
Reply With Quote