Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 44.07 KB | None | 0 0
  1. #NOTE!
  2. #Sync this between treecontroller.pl and this file!!
  3.  
  4. sub EVENT_CONNECT {
  5.     if (($status == 1)) {
  6.         quest::settimer("Leaderboard", 3);
  7.         quest::setglobal("TokenCounter", 0, 5, "F");
  8.     }
  9.     if ($client->GetLanguageSkill(0) < 100) {
  10.         quest::setlanguage(0, 100);
  11.     }
  12.     if ($client->GetSkill(40) < 200) {
  13.         quest::setskill(40, 200);
  14.     }
  15.     if (plugin::HasItem(64513)) {
  16.         plugin::Message("You still have some hot coffee, it will cool down soon!");
  17.         quest::settimer("Cool13501", 900);
  18.     }
  19.     if (plugin::HasItem(4045)) {
  20.         plugin::Message("The silver will harden soon.");
  21.         quest::settimer("cool13529", 1800);
  22.     }
  23.     if (plugin::HasItem(4043)) {
  24.         plugin::Message("The blazing embers will cool soon.");
  25.         quest::settimer("cool4043", 900);
  26.        
  27.     }
  28. }
  29.  
  30. sub EVENT_ZONE {
  31.     if ($client->GetHP() < 1) {
  32.         my @killverbs = ("slain","annihilated","destroyed","wrecked","laid to rest","vanquished","defeated","ended","totaled","killed","snuffed out","beaten","knocked off");
  33.         quest::gmsay("Alas, $name has been ".$killverbs[quest::ChooseRandom(0..$#killverbs)]." by ".$client->GetTarget()->GetCleanName()."!", 335, 1, 0, 0);
  34.         if (!defined $qglobals{"deaths"}) {
  35.             quest::setglobal("deaths",1,5,"F");
  36.         }
  37.         else {
  38.             quest::setglobal("deaths",$qglobals{"deaths"}+1,5,"F");
  39.         }
  40.     }
  41. }
  42.  
  43.  
  44. sub EVENT_TIMER {
  45.     my @array = split(' ', $qglobals{"Alt Bind"});
  46.     if ($timer eq "gotoclz") {
  47.         quest::stoptimer ("gotoclz");
  48.         $client->Message (12, "Please wait while you are moved.");
  49.         quest::movepc(190,0,0,0,0);
  50.     }
  51.     elsif ($timer eq "gotojail") {
  52.         quest::stoptimer ("gotojail");
  53.         #$client->Message (12, "You are being moved due to suspect of running an incompatible and/or unpatched client!");
  54.         #quest::movepc(45,0,0,0,220);
  55.     }
  56.     elsif ($timer eq "Zoned") {
  57.         quest::stoptimer("Zoned");
  58.         if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
  59.             quest::selfcast(35);
  60.             quest::setglobal("NexusBind", 1, 5, "F");
  61.         }
  62.     }
  63.     elsif ($timer eq "Leaderboard") {
  64.         quest::stoptimer("Leaderboard");
  65.         my %hash = plugin::LeaderboardTypeHash();
  66.         foreach my $type (sort {$a cmp $b} keys %hash) {
  67.             $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
  68.         }
  69.         if ($status < 100) {
  70.             plugin::GetLeaderboard(%qglobals);
  71.         }
  72.         quest::settimer("Leaderboard", 3600);
  73.     }
  74.     elsif ($timer eq "Cool13501") {
  75.         my $amount = plugin::CountItem(64513);
  76.         quest::stoptimer("Cool13501");
  77.         plugin::Message("Your coffee has cooled down and turned into " . quest::varlink(3239) . "!");
  78.         plugin::DeleteItem(64513, $amount);
  79.         quest::summonitem(3239, $amount);
  80.     }
  81.     elsif ($timer eq "cool4043") {
  82.         my $amount = plugin::CountItem(4043);
  83.         quest::stoptimer("cool4043");
  84.         plugin::Message("The embers stop burning.");
  85.         plugin::DeleteItem(4043, $amount);
  86.         quest::summonitem(4044, $amount);
  87.     }
  88.     elsif ($timer eq "cool13529") {
  89.         my $amount = plugin::CountItem(4045);
  90.         quest::stoptimer("cool13529");
  91.         plugin::Message("The silver hardens.");
  92.         plugin::DeleteItem(4045, $amount);
  93.         quest::summonitem(33789, $amount);
  94.     }
  95.     if ($timer eq "TokenTimer") {
  96.     quest::setglobal("TokenCounter", ($qglobals{"TokenCounter"} + 1), 5, "F");
  97.     quest::gmsay("Your token counter incremented: " . $qglobals{"TokenCounter"}); # Will send white text to all players in the current zone with an admin status of >= 80
  98.     if ( $qglobals{"TokenCounter"} == 60 ) {
  99.     $client->AddCrystals(1, 0);
  100.     $client->Message (15, "You've earned a loyalty token!");
  101.     quest::setglobal("TokenCounter", 0, 4, "F");
  102.     }
  103.     }
  104.     elsif ($timer =~ /WardTimer/i) { #Ward Timer for placable object
  105.    
  106.         #We don't stop this timer unless the object ceases to exist
  107.         my @arg = split('WardTimer', $timer);
  108.         my $id = $arg[1];
  109.         #quest::gmsay("tick tock $id", 15);
  110.         $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $id));
  111.         if(defined($object) &&  plugin::HasRadius($id))
  112.         {
  113.             my $triggered = 0;
  114.             if(plugin::GetRadiusData($id, "npcflag"))
  115.             {
  116.                 #do stuff
  117.                 my @npcs = $entity_list->GetNPCList();
  118.                 foreach my $singlenpc (@npcs)
  119.                 {
  120.                     my $rad = plugin::GetRadiusData($id, "radius");
  121.                     if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
  122.                     int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad && !$singlenpc->IsPet())
  123.                   {                
  124.                     if(plugin::GetRadiusData($id, "remove"))
  125.                     {
  126.                         $triggered = 1;
  127.                     }
  128.                     if(plugin::GetRadiusData($id, "spell_id"))
  129.                     {
  130.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singlenpc);
  131.                     }
  132.                    
  133.                     if(plugin::GetRadiusData($id, "spell_id2"))
  134.                     {
  135.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singlenpc);
  136.                     }
  137.                    
  138.                     if(plugin::GetRadiusData($id, "spell_id3"))
  139.                     {
  140.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singlenpc);
  141.                     }
  142.                   }
  143.                   else
  144.                   {
  145.                         #   quest::gmsay("No radius!", 15);
  146.                   }
  147.                 }
  148.             }
  149.             else
  150.             {
  151.                 my @clients = $entity_list->GetClientList();
  152.                 foreach my $singleclient (@clients)
  153.                 {
  154.                     my $rad = plugin::GetRadiusData($id, "radius");
  155.                     if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
  156.                     int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
  157.                   {
  158.                     if(plugin::GetRadiusData($id, "remove"))
  159.                     {
  160.                         $triggered = 1;
  161.                     }
  162.                    
  163.                     if(plugin::GetRadiusData($id, "spell_id"))
  164.                     {
  165.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id"), $singleclient);
  166.                     }
  167.                    
  168.                     if(plugin::GetRadiusData($id, "spell_id2"))
  169.                     {
  170.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id2"), $singleclient);
  171.                     }
  172.                    
  173.                     if(plugin::GetRadiusData($id, "spell_id3"))
  174.                     {
  175.                         $client->SpellFinished(plugin::GetRadiusData($id, "spell_id3"), $singleclient);
  176.                     }
  177.                    
  178.                   }
  179.                   else
  180.                   {
  181.                         #quest::gmsay("No radius!", 15);
  182.                   }
  183.                 }
  184.             }
  185.             if($triggered)
  186.             {
  187.                 $object->Depop();
  188.                 quest::stoptimer($timer);
  189.             }
  190.            
  191.         }
  192.         else #stop the timer
  193.         {
  194.             #quest::gmsay("No Timer!", 15);
  195.             quest::stoptimer($timer);
  196.         }
  197.     }
  198. }
  199.  
  200. sub EVENT_DISCOVER_ITEM {
  201.     if ($status < 150) {
  202.         quest::gmsay("$name has discovered " . quest::varlink($itemid) . ".", 335, 1, 0, 0);
  203.     }
  204.     if (!defined $qglobals{"discovereditems"}) {
  205.         quest::setglobal("discovereditems",1,5,"F");
  206.     }
  207.     else {
  208.         quest::setglobal("discovereditems",$qglobals{"discovereditems"}+1,5,"F");
  209.     }
  210. }
  211.  
  212. sub EVENT_FORAGE_FAILURE {
  213.     if (!defined $qglobals{"foragefails"}) {
  214.         quest::setglobal("foragefails",1,5,"F");
  215.     }
  216.     else {
  217.         quest::setglobal("foragefails",$qglobals{"foragefails"}+1,5,"F");
  218.     }
  219. }
  220.  
  221. sub EVENT_FORAGE_SUCCESS {
  222.     if (!defined $qglobals{"foragesuccesses"}) {
  223.         quest::setglobal("foragesuccesses",1,5,"F");
  224.     }
  225.     else {
  226.         quest::setglobal("foragesuccesses",$qglobals{"foragesuccesses"}+1,5,"F");
  227.     }
  228. }
  229.  
  230. sub EVENT_DUEL_LOSE {
  231.     if (!defined $qglobals{"duelslost"}) {
  232.         quest::setglobal("duelslost",1,5,"F");
  233.     }
  234.     else {
  235.         quest::setglobal("duelslost",$qglobals{"duelslost"}+1,5,"F");
  236.     }
  237. }
  238.  
  239. sub EVENT_DUEL_WIN {
  240.     if (!defined $qglobals{"duelswon"}) {
  241.         quest::setglobal("duelswon",1,5,"F");
  242.     }
  243.     else {
  244.         quest::setglobal("duelswon",$qglobals{"duelswon"}+1,5,"F");
  245.     }
  246. }
  247.  
  248. sub EVENT_COMBINE_SUCCESS {
  249.     my @skillidarray = (59,60,61,63,64,65,68,69);
  250.     my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Crafting");
  251.     my $counter = 0;
  252.     foreach $individualskill (@skillidarray) {
  253.         $skillglobal = "skill".$individualskill."";
  254.         if (!defined $qglobals{$skillglobal}) {
  255.             quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  256.         }
  257.         else {
  258.             if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
  259.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  260.                 if (($client->GetRawSkill($individualskill) % 10) == 0) {
  261.                     quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
  262.                 }
  263.             }
  264.             elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
  265.                 #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level!  Resynchronizing...");
  266.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  267.             }
  268.         }
  269.         $counter++;
  270.     }  
  271.     if ($status < 150) {
  272.         my $savevalue = "".$recipe_name.$recipe_id."";
  273.         if (!defined $qglobals{$savevalue}) {
  274.             quest::gmsay("$name has discovered the recipe for '$recipe_name'.", 335, 1, 0, 0);
  275.             quest::targlobal($savevalue, $charid, "F", 0, 0, 0);
  276.         }
  277.     }
  278.     if ($recipe_id == 13501) {
  279.         plugin::Message("Drink your coffee before it gets cold!");
  280.         quest::settimer("Cool13501", 900);
  281.     }
  282.     if ($recipe_id == 13529) {
  283.         plugin::Message("The silver will harden soon.");
  284.         quest::settimer("cool13529", 1800);
  285.     }
  286.     if (!defined $qglobals{"tscombines"}) {
  287.         quest::setglobal("tscombines",1,5,"F");
  288.     }
  289.     else {
  290.         quest::setglobal("tscombines",$qglobals{"tscombines"}+1,5,"F");
  291.     }
  292.    
  293.    
  294.     @row = plugin::GetRecipeTrivial($recipe_id);
  295.    
  296.     if($client->GetSkill($row[1]) < $row[0])
  297. {
  298.     if (($class eq "Warrior") && ($clientdeity == 205))
  299.     {
  300.         $client->SetEXP($client->GetEXP() + (2 x $client->CalcEXP(18)), $client->GetAAEXP() )
  301.         }
  302.     else
  303.     {
  304.         $client->SetEXP($client->GetEXP() + $client->CalcEXP(18), $client->GetAAExp() );
  305.     }
  306. }
  307.    
  308.     if(plugin::HasRecipe($recipe_id))
  309.     {
  310.         my $randomreturn = plugin::RandomRange(0, 200);
  311.         my $rare = 0;
  312.        
  313.         if(plugin::GetRecipeData($recipe_id, "legendaryresult") && $rare == 0)
  314.         {
  315.             if($randomreturn < plugin::GetRecipeData($recipe_id, "legendarychance") * 2)
  316.             {  
  317.                 $client->Message(15, "Great! You find " . plugin::GetRecipeData($recipe_id, "legendaryqty") . " " . plugin::GetRecipeData($recipe_id, "legendarytext") . "!");
  318.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "legendaryresult"), plugin::GetRecipeData($recipe_id, "legendaryqty"));
  319.                 $rare = 1;
  320.             }
  321.         }
  322.        
  323.         if(plugin::GetRecipeData($recipe_id, "epicresult") && $rare == 0)
  324.         {
  325.             if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
  326.             {  
  327.                 $client->Message(15, "Amazing discovery! You find " . plugin::GetRecipeData($recipe_id, "epicqty") . " " . plugin::GetRecipeData($recipe_id, "epictext") . "!");
  328.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "epicresult"), plugin::GetRecipeData($recipe_id, "epicqty"));
  329.                 $rare = 1;
  330.             }
  331.         }
  332.        
  333.         if(plugin::GetRecipeData($recipe_id, "urareresult") && $rare == 0)
  334.         {
  335.             if($randomreturn < plugin::GetRecipeData($recipe_id, "urarechance") * 2)
  336.             {  
  337.                 $client->Message(15, "Wow! You find " . plugin::GetRecipeData($recipe_id, "urareqty") . " " . plugin::GetRecipeData($recipe_id, "uraretext") . "!");
  338.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "urareresult"), plugin::GetRecipeData($recipe_id, "urareqty"));
  339.                 $rare = 1;
  340.             }
  341.         }
  342.        
  343.         if(plugin::GetRecipeData($recipe_id, "rareresult") && $rare == 0)
  344.         {
  345.             if($randomreturn < plugin::GetRecipeData($recipe_id, "rarechance") * 2)
  346.             {  
  347.                 $client->Message(15, "You find " . plugin::GetRecipeData($recipe_id, "rareqty") . " " . plugin::GetRecipeData($recipe_id, "raretext") . "!");
  348.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "rareresult"), plugin::GetRecipeData($recipe_id, "rareqty"));
  349.                 $rare = 1;
  350.             }
  351.         }
  352.         if(plugin::GetRecipeData($recipe_id, "uncommonresult") && $rare == 0)
  353.         {
  354.             if($randomreturn < plugin::GetRecipeData($recipe_id, "uncommonchance") * 2)
  355.             {  
  356.                 $client->Message(15, "You find... " . plugin::GetRecipeData($recipe_id, "uncommonqty") . " " . plugin::GetRecipeData($recipe_id, "uncommontext") . "!");
  357.                 $client->SummonItem(plugin::GetRecipeData($recipe_id, "uncommonresult"), plugin::GetRecipeData($recipe_id, "uncommonqty"));
  358.                 $rare = 1;
  359.             }
  360.         }
  361.         if($rare == 0)
  362.         {
  363.             $client->Message(15, "Nice! You find " . plugin::GetRecipeData($recipe_id, "qty") . " " . plugin::GetRecipeData($recipe_id, "text") . "!");
  364.             $client->SummonItem(plugin::GetRecipeData($recipe_id, "result"), plugin::GetRecipeData($recipe_id, "qty"));
  365.         }
  366.     }
  367. }
  368.  
  369. sub EVENT_COMBINE_FAILURE {
  370.     my @skillidarray = (59,60,61,63,64,65,68,69);
  371.     my @skillnames = ("Alchemy","Cooking","Tailoring","Blacksmithing","Woodworking","Brewing","Jewelcrafting","Pottery");
  372.     my $counter = 0;
  373.     foreach $individualskill (@skillidarray) {
  374.         $skillglobal = "skill".$individualskill."";
  375.         if (!defined $qglobals{$skillglobal}) {
  376.             quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  377.         }
  378.         else {
  379.             if ($client->GetRawSkill($individualskill) > $qglobals{$skillglobal}) {
  380.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  381.                 if (($client->GetRawSkill($individualskill) % 10) == 0) {
  382.                     quest::gmsay("After much work, $name has obtained a skill level of ".$client->GetRawSkill($individualskill)." in ".$skillnames[$counter]."!", 335, 1, 0, 0);
  383.                 }
  384.             }
  385.             elsif ($client->GetRawSkill($individualskill) < $qglobals{$skillglobal}) {
  386.                 #$client->Message (15, "ERROR: We've lost QGLOBAL record of your ".$skillnames[$counter]." skill level!  Resynchronizing...");
  387.                 quest::setglobal($skillglobal, $client->GetRawSkill($individualskill), 5, "F");
  388.             }
  389.         }
  390.         $counter++;
  391.     }
  392.     if (!defined $qglobals{"tsfailures"}) {
  393.         quest::setglobal("tsfailures",1,5,"F");
  394.     }
  395.     else {
  396.         quest::setglobal("tfailures",$qglobals{"tsfailures"}+1,5,"F");
  397.     }
  398. }
  399.  
  400. sub EVENT_ENTERZONE {
  401.     quest::settimer("Zoned", 5);
  402.     quest::settimer ("TokenTimer", 60); ## Token Timer
  403.     my @approvedzonelist = (    "xuolia", "nexus", "saquia", "marblepalace", "malefix", "airplane", "drybone",
  404.                                 "shipmvu", "cemetary", "sewers", "enochia", "malsyrian", "miserymire","daggerdepth",
  405.                                 "maridmanor","sleeper","qeynos","mmca","innothuleb","airplane","chapel",
  406.                                 "chapeldark","citymist","firiona","gukd","qcat");
  407.     my @startingzonelist = ("clz", "theater", "purgatory");
  408.     my $gm_status = $client->GetGM();
  409.     if ((!$gm_status) && ($status < 80)) {
  410.         if (!defined $qglobals{$zonesn}) {
  411.             #quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
  412.             quest::targlobal($zonesn, 1, "F", 0, 0, 0);
  413.         }
  414.         if ($zonesn ~~ @approvedzonelist)   {
  415.             if ((defined $qglobals{"newtoon"}) && ($qglobals{"newtoon"} == 1) ) {
  416.                 quest::settimer("gotoclz", 2);
  417.             }
  418.         }
  419.         elsif ($zonesn eq "kerraridge") {
  420.             quest::movepc(247,260.98,-448.03,3.75,64.5);
  421.         }
  422.         elsif (!($zonesn ~~ @startingzonelist)) {
  423.             quest::settimer("gotojail",2);
  424.         }
  425.     }
  426.     else {
  427.         #$client->Message (15, "NOTICE: Staff member detected.  Ignoring zone rules.");
  428.     }
  429.    
  430.     if(!defined($qglobals{"HasScribedUse"}))
  431.     {
  432.         quest::setglobal("HasScribedUse", 1, 5, "F");
  433.         if(!$client->HasSpellScribed(7651))
  434.         {
  435.             $client->ScribeSpell(7651, $client->GetFreeSpellBookSlot());
  436.         }
  437.         quest::traindisc(132313);
  438.     }
  439.     if(!$entity_list->GetNPCByNPCTypeID(1000503))
  440.     {
  441.         quest::spawn2(1000503, 0, 0, 0, 0, 0, 0);
  442.     }
  443.    
  444. }
  445.  
  446. sub EVENT_CLICKDOOR {
  447.     if($status >= 80){
  448.         plugin::Doors_Manipulation_EVENT_CLICKDOOR(); # Door Manipulation Plugin
  449.     }
  450. }
  451.  
  452. sub EVENT_SAY {
  453.  
  454.     @args = split(' ', $text);
  455.     if ($status >= 80) {
  456.         plugin::Doors_Manipulation_EVENT_SAY(); # Door Shit
  457.         #@args = split(' ', $text);
  458.         if ($text=~/#dis/i) {
  459.             $client->Message (15, "Distance from " . $client->GetTarget()->GetCleanName() . " to you.");
  460.             $client->Message (15, "X: " . ($client->GetTarget()->GetX() - $client->GetX())  . " Y: " . ($client->GetTarget()->GetY() - $client->GetY())  . "  Z: " . ($client->GetTarget()->GetZ() - $client->GetZ()));
  461.         }
  462.         elsif ($text=~/#stats/i) {
  463.             $client->Message (15, "MinDMG: ".$client->GetTarget()->CastToNPC()->GetMinDMG()." -- MaxDMG: ".$client->GetTarget()->CastToNPC()->GetMaxDMG()."");
  464.             $client->Message (15, "Beard Color: ".$client->GetTarget()->GetBeardColor()." -- Bodytype: ".$client->GetTarget()->GetBodyType()." -- Eye 1 Color ".$client->GetTarget()->GetEyeColor1()." -- Eye 2 Color: ".$client->GetTarget()->GetEyeColor2()."");
  465.             $client->Message (15, "Luclin Face Type: ".$client->GetTarget()->GetLuclinFace()."");
  466.         }
  467.         elsif ($text=~/#gmcon/i) {
  468.             $client->Message (15, "DEBUG: ".$client->CalcEXP(4)."");
  469.             ## $pc->GetLevelCon($npc->GetLevel())
  470.         }
  471.         elsif($args[0]=~/#groundspawn/i){
  472.             if ($args[1]) {
  473.                 my $itemdrop = $args[1];
  474.                 my $CX = $client->GetX();
  475.                 my $CY = $client->GetY();
  476.                 my $CZ = $client->GetZ();
  477.                 my $CH = $client->GetHeading();
  478.                 $connect = plugin::LoadMysql();
  479.                 $sth = $connect->prepare("SELECT idfile FROM items WHERE id = $itemdrop");
  480.                 $sth->execute();
  481.                 my $graphic = $sth->fetchrow_array();
  482.                 $sth = $connect->do("INSERT INTO `ground_spawns` VALUES ('', $zoneid, 0, $CX, $CY, $CZ, $CX, $CY, $CH, '".$graphic."_ACTORDEF', $itemdrop, 1, 'Auto', 300000)");
  483.                 $client->Message(315, "Groundspawn added to $zonesn!");
  484.             }
  485.             else { $client->Message(315,"Groundspawn: Item ID required!"); }
  486.         }
  487.         elsif($args[0]=~/#treespawn/i && $status > 150){
  488.             if ($args[1] && $args[2] && $args[3] && $args[4]) {
  489.                 plugin::InsertStaticTreeProcedure($text, $client);
  490.                 $client->Message(13, "TreeSpawn added to $zonesn at your location!");
  491.             }
  492.             else { $client->Message(13,"Format: #treespawn itemid respawntimer basegrowth addsize"); }
  493.         }
  494.         elsif (($text=~/#gmwho/i) && ($status >= 250)) {
  495.             my %classhash = (
  496.                 1   => "Warrior",
  497.                 2   => "Cleric",
  498.                 3   => "Paladin",
  499.                 4   => "Ranger",
  500.                 5   => "Shadow Knight",
  501.                 6   => "Druid",
  502.                 7   => "Monk",
  503.                 8   => "Bard",
  504.                 9   => "Rogue",
  505.                 10  => "Shaman",
  506.                 11  => "Necromancer",
  507.                 12  => "Wizard",
  508.                 13  => "Magician",
  509.                 14  => "Enchanter",
  510.                 15  => "Beastlord",
  511.                 16  => "Berserker",
  512.             );
  513.             my %racehash = (
  514.                 1   =>  "Human",
  515.                 2   =>  "Babarian",
  516.                 3   =>  "Erudite",
  517.                 4   =>  "Wood Elf",
  518.                 5   =>  "High Elf",
  519.                 6   =>  "Dark Elf",
  520.                 7   =>  "Half Elf",
  521.                 8   =>  "Dwarf",
  522.                 9   =>  "Troll",
  523.                 10  =>  "Ogre",
  524.                 11  =>  "Halfling",
  525.                 12  =>  "Gnome",
  526.                 128 =>  "Iksar",
  527.                 130 =>  "Vah Shir",
  528.                 330 =>  "Froglok",
  529.             );
  530.             my @clientsarray = $entity_list->GetClientList();
  531.             $client->Message (11, "(GM List) Players in Zone:");
  532.             $client->Message (11, "----------------------------------");
  533.             foreach my $singleclient (@clientsarray) {
  534.                 my $clientguildname;
  535.                 my $longip = $singleclient->GetIP();
  536.                 $firstoctet = $longip % 256;
  537.                 $longip -= $firstoctet;
  538.                 $longip /= 256;
  539.                 $secondoctet = $longip % 256;
  540.                 $longip -= $secondoctet;
  541.                 $longip /= 256;
  542.                 $thirdoctet = $longip % 256;
  543.                 $longip -= $thirdoctet;
  544.                 $longip /= 256;
  545.                 if (quest::getguildnamebyid($singleclient->GuildID())) {
  546.                     $clientguildname = "".quest::getguildnamebyid($singleclient->GuildID())."";
  547.                 } else { $clientguildname = "UNGUILDED"; }
  548.                 my $dottedip = "$firstoctet.$secondoctet.$thirdoctet.$longip";
  549.                 my $wholist =   "[".$singleclient->GetLevel()." ".plugin::customclass($singleclient->GetClass(),$singleclient->GetDeity()).
  550.                                 "] ".$singleclient->GetName()." (".$classhash{$singleclient->GetClass()}.") (".
  551.                                 $racehash{$singleclient->GetRace()}.") <".$clientguildname."> [IP: ".$dottedip."]";
  552.                 $client->Message (11, "".$wholist."");
  553.             }
  554.             $client->Message (11, "There are ".scalar (@clientsarray)." players in zone!");
  555.         }
  556.     }
  557.     if ($text=~/^#Update/i && $status < 100) {         
  558.             plugin::GetLeaderboard(%qglobals);
  559.             plugin::ShowLeaderboard("HP");
  560.         }
  561.     if ($args[0]=~/#Leaderboard/i) {
  562.        
  563.         if(!defined($args[1]))
  564.         {
  565.             my %hash = plugin::LeaderboardTypeHash();
  566.             foreach my $type (sort {$a cmp $b} keys %hash) {
  567.                 $client->Message(315, quest::saylink("#leaderboard $type", 1, "Top 10 Players in $type"));
  568.             }
  569.         }
  570.         elsif($args[1] =~ /update/i && $status < 100)
  571.         {
  572.             plugin::GetLeaderboard(%qglobals);
  573.         }
  574.         plugin::ShowLeaderboard(substr($text, 13));
  575.  
  576.     }
  577.    
  578.     if($args[0] =~/^#house/i)
  579.     {
  580.         if($args[1] =~ /check/i)
  581.         {
  582.             $client->SetEntityVariable("DoorCommand", "Info");
  583.             quest::signalwith(1000505, $client->GetID());
  584.         }
  585.         if($args[1] =~ /buy/i)
  586.         {
  587.             $client->SetEntityVariable("DoorCommand", "BuyHouse");
  588.             quest::signalwith(1000505, $client->GetID());
  589.         }
  590.         if($args[1] =~ /purchase/i)
  591.         {
  592.             $client->SetEntityVariable("DoorCommand", "PurchaseHouse");
  593.             quest::signalwith(1000505, $client->GetID());
  594.         }
  595.         if($args[1] =~ /sell/i)
  596.         {
  597.             $client->SetEntityVariable("DoorCommand", "SellHouse");
  598.             quest::signalwith(1000505, $client->GetID());
  599.         }
  600.         if($args[1] =~ /relinquish/i)
  601.         {
  602.             $client->SetEntityVariable("DoorCommand", "RelinquishHouse");
  603.             quest::signalwith(1000505, $client->GetID());
  604.         }
  605.         if($args[1] =~ /payrent/i)
  606.         {
  607.             $client->SetEntityVariable("DoorCommand", "PayRent");
  608.             quest::signalwith(1000505, $client->GetID());
  609.         }
  610.        
  611.     }
  612.    
  613.     if($args[0] =~/^#object/i)
  614.     {
  615.         if(defined($args[3]) && defined($args[2]) && defined($args[1]))
  616.         {
  617.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1] . " " . $args[2] . " " . $args[3]);
  618.         }
  619.         elsif(defined($args[1]) && defined($args[2]))
  620.         {
  621.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1] . " " . $args[2]);
  622.         }
  623.         elsif(defined($args[1]))
  624.         {
  625.             $client->SetEntityVariable("DoorCommand",  $args[0] . " " . $args[1]);
  626.         }
  627.         else
  628.         {
  629.             $client->SetEntityVariable("DoorCommand",  $args[0]);
  630.         }
  631.         quest::signalwith(1000505, $client->GetID());
  632.     }
  633.  
  634.     if ($args[0] eq "#tree") {         
  635.         if($args[1] =~ /harvest/i)
  636.         {
  637.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));           
  638.             if(defined($object))
  639.             {
  640.                 if($zonesn eq "neighborhood" && !$object->GetEntityVariable("IsStaticTree"))
  641.                 {
  642.                     $client->SetEntityVariable("DoorCommand", "HarvestItem");
  643.                     quest::signalwith(1000505, $client->GetID());
  644.                 }
  645.                 else
  646.                 {
  647.                     if(plugin::IsTree($object->GetItemID()))
  648.                     {
  649.                         my $randomroll = plugin::RandomRange($object->GetEntityVariable("TreeGrowth") / 40, $object->GetEntityVariable("TreeGrowth") / 15);
  650.                         my $randomreturn = plugin::RandomRange(0, 200);
  651.                         if($randomroll < 1)
  652.                         {
  653.                             $client->Message(15, "You feel like you're a poor excuse for a gardener. You get your seed back.");
  654.                             $client->SummonItem($object->GetItemID(), 1);
  655.                         }
  656.                         else
  657.                         {
  658.                             my $rare = 0;
  659.                             if(plugin::GetTreeData($object->GetItemID(), "rareresult"))
  660.                             {
  661.                                 if($randomreturn < plugin::GetTreeData($object->GetItemID(), "rarechance") * 2)
  662.                                 {  
  663.                                     $client->Message(15, "[RARE] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "raretext") . " in addition to your yield!");
  664.                                     $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "rareresult"), $randomroll);
  665.                                     $rare = 1;
  666.                                 }
  667.                             }
  668.                             if(plugin::GetTreeData($object->GetItemID(), "uncommonresult") && $rare == 0)
  669.                             {
  670.                                 if($randomreturn < plugin::GetTreeData($object->GetItemID(), "uncommonchance") * 2)
  671.                                 {  
  672.                                     $client->Message(15, "[UNCOMMON] You find $randomroll " . plugin::GetTreeData($object->GetItemID(), "uncommontext") . " in addition to your yield!");
  673.                                     $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "uncommonresult"), $randomroll);
  674.                                     $rare = 1;
  675.                                 }
  676.                             }
  677.                            
  678.                             if($rare == 0)
  679.                             {
  680.                                 $client->Message(15, "[COMMON] You harvest the " . plugin::GetTreeData($object->GetItemID(), "plant") .". You gain $randomroll " . plugin::GetTreeData($object->GetItemID(), "text") . " from your yield.");
  681.                                 $client->SummonItem(plugin::GetTreeData($object->GetItemID(), "result"), $randomroll);
  682.                             }
  683.                            
  684.                             if($object->GetEntityVariable("TreeGrowth") >= $randomreturn)
  685.                             {
  686.                                 $client->Message(15, "You dig amongst the dirt and find something extra. It's a miracle of growth!");
  687.                                 $client->SummonItem($object->GetItemID(), 1);
  688.                             }
  689.                         }
  690.                        
  691.                         if(!$object->GetEntityVariable("IsStaticTree"))
  692.                         {
  693.                             plugin::DeleteTreeProcedure($object);
  694.                         }
  695.                         else
  696.                         {
  697.                             quest::signalwith(1000503, $object->GetID());
  698.                         }
  699.                     }
  700.                     else
  701.                     {
  702.                         $client->Message(13, "That's not a tree..");
  703.                     }
  704.                 }
  705.             }
  706.             else
  707.             {
  708.                     $client->Message(13, "Please select a plant to harvest.");
  709.             }
  710.         }
  711.         if($args[1] =~ /pickup/i)
  712.         {  
  713.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  714.             if(defined($object))
  715.             {
  716.                 if($zonesn eq "neighborhood")
  717.                 {
  718.                     $client->SetEntityVariable("DoorCommand", "PickupItem");
  719.                     quest::signalwith(1000505, $client->GetID());
  720.                 }
  721.                 else
  722.                 {
  723.                 #   if($object->GetEntityVariable("Owner") != $client->AccountID() && !$client->GetGM())
  724.                 #   {
  725.                 #       $client->Message(13, "Hmm, you think it'd be wise to not mess with another person's property..");
  726.                 #   }
  727.                     if(!plugin::IsTree($object->GetItemID()))
  728.                     {
  729.                         $client->Message(15, "You pick up the house item laying on the ground.");
  730.                         quest::summonitem($object->GetItemID(), 1);
  731.                         plugin::DeleteTreeProcedure($object);
  732.                     }
  733.                     else
  734.                     {
  735.                         $client->Message(13, "That's a plant. Try harvesting it.");
  736.                     }
  737.                 }
  738.             }
  739.             else
  740.             {
  741.                     $client->Message(13, "Please select a plant to harvest.");
  742.             }
  743.         }
  744.         elsif($args[1] =~ /check/i)
  745.         {
  746.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  747.             if(defined($object))
  748.             {
  749.                     $client->Message(15, "You tend to your plant.");
  750.                     $client->Message(15, " :: Water:" . $object->GetEntityVariable("TreeWater"));
  751.                     $client->Message(15, " :: Growth:" . $object->GetEntityVariable("TreeGrowth"));
  752.             }
  753.             else
  754.             {
  755.                 $client->Message(13, "Please select a plant to check.");
  756.             }
  757.         }
  758.         elsif($args[1] =~ /clickeffect/i)
  759.         {
  760.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  761.             if(defined($object))
  762.             {
  763.                 if($client->AccountID() == $object->GetEntityVariable("Owner"))
  764.                 {
  765.                     if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
  766.                     {
  767.                         if(plugin::HasEffect($object->GetItemID()) && defined $qglobals{"Reuse" . $object->GetItemID()})
  768.                         {
  769.                             if(plugin::GetEffectData($object->GetItemID(), "reuse"))
  770.                             {
  771.                                 if(time() - $qglobals{"Reuse" . $object->GetItemID()} < plugin::GetEffectData($object->GetItemID(), "reuse"))
  772.                                 {
  773.                                     $client->Message(13, "Reuse timer not expired for the effect " . plugin::GetEffectData($object->GetItemID(), "text") . ".");
  774.                                     return 0;  
  775.                                 }
  776.                             }
  777.                         }
  778.                         $client->Message(15, "You activate the ability " . (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "text") : "that is on" . " on the object!"));
  779.                         #$client->Message(15, plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0));
  780.                         $client->SpellFinished(plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0), $client);
  781.                        
  782.                         if(plugin::HasEffect($object->GetItemID()))
  783.                         {
  784.                             if(defined(plugin::GetEffectData($object->GetItemID(), "reuse")))
  785.                             {
  786.                                 quest::setglobal("Reuse" . $object->GetItemID(), time(), 5, "F");
  787.                             }
  788.                         }
  789.                     }
  790.                 }
  791.                 else
  792.                 {
  793.                     $client->Message(13, "This isn't yours to activate! Please select an object to activate that is on your plot.")
  794.                 }
  795.             }
  796.             else
  797.             {
  798.                 $client->Message(13, "Please select an object to activate that is on your plot.");
  799.             }
  800.         }
  801.         elsif($args[1] =~ /water/i)
  802.         {
  803.             $object = $entity_list->GetObjectByID($client->GetEntityVariable("TreeID"));
  804.             if(defined($object))
  805.             {
  806.                 $client->Message(15, "You kneel beside the plant to water it...");
  807.                 $slot = plugin::check_hasitem_inslot($client, 2046);
  808.                 if($slot != 65535)
  809.                 {
  810.                     $client->DeleteItemInInventory($slot, 1, 1);
  811.                     $client->SummonItem(16598, 1);
  812.                     $total = $object->GetEntityVariable("TreeWater") + 1;
  813.                     $client->Message(15, "... and the soil absorbs the water thirstily! Moisture Content: $total");
  814.                     $object->SetEntityVariable("TreeWater", $object->GetEntityVariable("TreeWater") + 1);
  815.                     plugin::UpdateTreeProcedure($object);                  
  816.                 }
  817.                 else
  818.                 {
  819.                     $client->Message(15, "... but you don't have a bottle of water!");
  820.                 }
  821.             }
  822.             else
  823.             {
  824.                 $client->Message(13, "Please select a plant to check.");
  825.             }
  826.         }
  827.     }
  828.     if($text=~/#gmzone/i){  
  829.         plugin::SendToInstance("public", "overthere", 1, 1836, 3098, -50, "GM_Zone3", 604800);  # Send to Overthere for Weapons/Spells Preview
  830.     }
  831.         if ($text =~/^#Online Month$/i)
  832.         {
  833.             my $GET_SECONDS     = (60 * 60 * 24 * 30);  # 1 Month (Minutes)
  834.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Month (Seconds)
  835.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  836.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  837.             #$client->Message(2, "IP Log Online Month: $GET_ONLINE_IP");
  838.             $client->Message(2, "Players online this month: $GET_ONLINE_CHAR");
  839.         }
  840.  
  841.         if ($text =~/^#Online Week$/i)
  842.         {
  843.             my $GET_SECONDS     = (60 * 60 * 24 * 7);   # 1 Week (Minutes)
  844.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Week (Seconds)
  845.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  846.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  847.             #$client->Message(2, "IP Log Online Week: $GET_ONLINE_IP");
  848.             $client->Message(2, "Players online this week: $GET_ONLINE_CHAR");
  849.         }
  850.  
  851.         if ($text =~/^#Online Today$/i)
  852.         {
  853.             my $GET_SECONDS     = (60 * 60 * 24 * 1);   # 1 Day (Minutes)
  854.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 1 Day (Seconds)
  855.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  856.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  857.             #$client->Message(2, "IP Log Online Today: $GET_ONLINE_IP");
  858.             $client->Message(2, "Players online today: $GET_ONLINE_CHAR");
  859.         }
  860.  
  861.         if ($text =~/^#Online 30$/i)
  862.         {
  863.             my $GET_SECONDS     = (30 * 60 * 1 * 1);    # 30 Minutes (Minutes)
  864.             my $GET_MINUTES     = $GET_SECONDS / 60;    # 30 Minutes (Seconds)
  865.             my $GET_ONLINE_IP   = GET_IP_ONLINE($GET_MINUTES);
  866.             my $GET_ONLINE_CHAR = GET_PLAYERS_ONLINE($GET_SECONDS);
  867.             #$client->Message(2, "IP Log Online 30 Minutes: $GET_ONLINE_IP");
  868.             $client->Message(2, "Players online in the last 30 minutes: $GET_ONLINE_CHAR");
  869.         }
  870.         if ($text=~/#namepet/i) {
  871.     my $pet_ent = $entity_list->GetMobByID($client->GetPetID());
  872.    
  873.     my @arg = split(" ", $text);
  874.    
  875.     my $pet_name = fixname($arg[1]);
  876.    
  877.     if (length($pet_name) > 10 || length($pet_name) < 3) {
  878.         $client->Message(13, "Pet name invalid!");
  879.         return;
  880.     }
  881.    
  882.         if ($pet_ent) {
  883.             $pet_ent->TempName($pet_name);
  884.         }
  885.     }
  886.  
  887.     if ($text =~/#wiki/i)
  888.     {
  889.     $client->SendWebLink("https://wiki.eqemulator.org/");
  890.     }
  891. }
  892.  
  893.  
  894.  
  895. sub EVENT_LOOT {
  896.     if ($looted_id == 4043) {
  897.     quest::settimer("cool4043", 900);
  898.     }
  899.     if (!defined $qglobals{"looteditems"}) {
  900.         quest::setglobal("looteditems",1,5,"F");
  901.     }
  902.     else {
  903.         quest::setglobal("looteditems",$qglobals{"looteditems"}+1,5,"F");
  904.     }
  905. }
  906.  
  907. sub EVENT_LEVEL_UP {
  908.     if ($status < 150) {
  909.         if ((defined $qglobals{"noobie"}) && ($qglobals{"noobie"} >= 1)) {
  910.             quest::gmsay(   "Rejoice, $name is now a level $ulevel ".plugin::customclass($client->GetClass(),$client->GetDeity()).
  911.                             "!", 335, 1, 0, 0);
  912.         }
  913.     }
  914. }  
  915.  
  916. sub EVENT_TRADE {
  917.     if (!defined $qglobals{"tradeditems"}) {
  918.         quest::setglobal("tradeditems",1,5,"F");
  919.     }
  920.     else {
  921.         quest::setglobal("tradeditems",$qglobals{"tradeditems"}+1,5,"F");
  922.     }
  923. }
  924.  
  925. sub EVENT_SIGNAL {
  926.     if ($signal == 4398) {
  927.         quest::popup ("Blank Map",
  928.             "<br> <br>You unroll your map and look down at it. Would you like to mark your location?<br>
  929.             <br> <br>",50010,1); ## global player signals begin with 500 to avoid conflict with zone specific player.pl
  930.     }
  931. }
  932.  
  933. sub EVENT_POPUPRESPONSE {
  934.     my $space = " ";
  935.     my $xvar = int($client->GetX());
  936.     my $x = int($client->GetX());
  937.     my $yvar = int($client->GetY());
  938.     my $y = int($client->GetY());
  939.     my $zvar = int($client->GetZ());
  940.     my $z = int($client->GetZ());
  941.     $global = "$xvar$space$yvar$space$zvar$space$zoneid";
  942.    
  943.     if ($popupid == 50010) {
  944.     $client->Message(15,"You mark a large red X on your map.");
  945.     $client->SetGlobal("Alt Bind", $global, 5, "F");
  946.     plugin::DeleteItem(4398);
  947.     quest::summonitem(4149);
  948.     }
  949. }
  950.  
  951.  
  952. sub EVENT_PLAYER_PICKUP
  953. {
  954.     $object = $entity_list->GetObjectByID($picked_up_entity_id);
  955.    
  956.    
  957.     if($client->GetGM())
  958.     {
  959.         $client->Message(15, "[GM] This is model " . $object->GetModelName());
  960.     }
  961.    
  962.     if(plugin::IsTree($object->GetItemID()))
  963.     {
  964.         #$object = $entity_list->GetObjectByID($picked_up_entity_id);
  965.         if(defined($object))
  966.         {
  967.             $client->Message(15, "This is a " . plugin::GetTreeData($object->GetItemID(), "plant") . " plant. What would you like to do with it?");
  968.             $client->Message(15, quest::saylink("#tree harvest", 1, "   ::Harvest"));
  969.             $client->Message(15, quest::saylink("#tree check", 1, "   ::Check"));
  970.             $client->Message(15, quest::saylink("#tree water", 1, "   ::Water"));
  971.             $client->SetEntityVariable("TreeID", $object->GetID());
  972.         }
  973.         return 1;
  974.     }
  975.     elsif(plugin::HasRadius($object->GetItemID()))
  976.     {
  977.         $client->Message(15, "This is a " . plugin::GetRadiusData($object->GetItemID(), "name") . ".");
  978.         if($object->GetEntityVariable("WardOwner"))
  979.         {
  980.             if(!$entity_list->GetClientByID($object->GetEntityVariable("WardOwner")))
  981.             {
  982.                 $object->Depop();
  983.             }
  984.        
  985.         }
  986.         return 1;
  987.     }
  988.     elsif(defined($object->GetEntityVariable("DBID")) && !defined($object->GetEntityVariable("UpLevel")))
  989.     {
  990.         $client->Message(15, "This is a house item. What would you like to do with it?");
  991.         $client->Message(15, quest::saylink("#tree pickup", 1, "   ::Pickup"));
  992.         if(plugin::HasEffect($object->GetItemID()) || $object->GetEntityVariable("ClickEffect"))
  993.         {
  994.             $client->Message(15, quest::saylink("#tree clickeffect", 1, "   ::Activate Effect"));
  995.         }
  996.         $client->SetEntityVariable("TreeID", $object->GetID());
  997.         $client->SetEntityVariable("Effect", $object->GetID());
  998.         if($zonesn eq "neighborhood" && $object->GetItemID() != 1801)
  999.         {
  1000.             $client->Message(15, quest::saylink("#object", 1, "   ::Neighborhood Object Commands"));
  1001.         }
  1002.         return 1;
  1003.     }
  1004.     #$client->Message(13, "Is your client locking up?");
  1005.     return 0;
  1006. }
  1007.  
  1008. sub EVENT_CAST
  1009. {
  1010.  
  1011.  
  1012.     if($spell_id == 7651)
  1013.     {
  1014.    
  1015.         if($zonesn eq "neighborhood" && !plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
  1016.         {
  1017.             if($client->GetEntityVariable("PlacingItemID") != 12673)
  1018.             {
  1019.             $client->SetEntityVariable("DoorCommand", "PlaceItem");
  1020.             quest::signalwith(1000505, $client->GetID());
  1021.             }
  1022.         }
  1023.         else
  1024.         {
  1025.             if(plugin::HasRadius($client->GetEntityVariable("PlacingItemID")))
  1026.             {
  1027.                 my $object = $entity_list->GetObjectByID($client->GetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID")));
  1028.                 my $radiusobj = $client->GetEntityVariable("PlacingItemID");
  1029.                 if(plugin::GetRadiusData($radiusobj, "reqclass") != 0 && plugin::GetRadiusData($radiusobj, "reqclass") != $client->GetClass())
  1030.                 {
  1031.                     if(plugin::GetRadiusData($radiusobj, "errmsgclass") && plugin::GetRadiusData($radiusobj, "errmsgclass") ne "")
  1032.                     {
  1033.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgclass"));
  1034.                     }
  1035.                 }
  1036.                 elsif(plugin::GetRadiusData($radiusobj, "reqdeity") != 0 && plugin::GetRadiusData($radiusobj, "reqdeity") != $client->GetDeity())
  1037.                 {
  1038.                     if(plugin::GetRadiusData($radiusobj, "errmsgdeity") && plugin::GetRadiusData($radiusobj, "errmsgdeity") ne "")
  1039.                     {
  1040.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgdeity"));
  1041.                     }
  1042.                 }
  1043.                 elsif(plugin::GetRadiusData($radiusobj, "reqlevel") != 0 && $client->GetLevel() < plugin::GetRadiusData($radiusobj, "reqlevel"))
  1044.                 {
  1045.                     if(plugin::GetRadiusData($radiusobj, "errmsglevel") && plugin::GetRadiusData($radiusobj, "errmsglevel") ne "")
  1046.                     {
  1047.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsglevel"));
  1048.                     }
  1049.                 }
  1050.                 elsif(defined($object))
  1051.                 {
  1052.                     if(plugin::GetRadiusData($radiusobj, "errmsgplaced") && plugin::GetRadiusData($radiusobj, "errmsgplaced") ne "")
  1053.                     {
  1054.                         $client->Message(15, plugin::GetRadiusData($radiusobj, "errmsgplaced"));
  1055.                     }
  1056.                 }
  1057.                 else
  1058.                 {
  1059.                     $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
  1060.                     if($slot != 65535)
  1061.                     {
  1062.                         $client->DeleteItemInInventory($slot, 1, 1);
  1063.                         $spawnid = quest::creategroundobject($client->GetEntityVariable("PlacingItemID"), $client->GetTargetRingX(), $client->GetTargetRingY(), $client->GetTargetRingZ(), $client->GetHeading(), plugin::GetRadiusData($radiusobj, "expire")); #This spawns the ward, which lasts 60 seconds. Stores in $spawnid
  1064.                         $object = $entity_list->GetObjectByID($spawnid);
  1065.                         $object->SetEntityVariable("WardOwner", $client->GetID());
  1066.                         $object->SetSize($client->GetEntityVariable("PlacingSize") ? $client->GetEntityVariable("PlacingSize") : 100);
  1067.                         quest::settimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"), plugin::GetRadiusData($radiusobj, "timer")); #Starts a timer with string "WardTimer" as $timer
  1068.                         my $triggered = 0;
  1069.                         if(plugin::GetRadiusData($radiusobj, "npcflag"))
  1070.                         {
  1071.                             #do stuff
  1072.                             my @npcs = $entity_list->GetNPCList();
  1073.                             foreach my $singlenpc (@npcs)
  1074.                             {
  1075.                                 my $rad = plugin::GetRadiusData($radiusobj, "radius");
  1076.                                 if(int($object->GetX()) > int($singlenpc->GetX())-$rad && int($object->GetX()) < int($singlenpc->GetX())+$rad &&
  1077.                                 int($object->GetY()) > int($singlenpc->GetY())-$rad && int($object->GetY()) < int($singlenpc->GetY())+$rad)
  1078.                               {                
  1079.                                 if(plugin::GetRadiusData($radiusobj, "remove"))
  1080.                                 {
  1081.                                     $triggered = 1;
  1082.                                 }
  1083.                                 if(plugin::GetRadiusData($radiusobj, "spell_id"))
  1084.                                 {
  1085.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singlenpc);
  1086.                                 }
  1087.                                
  1088.                                 if(plugin::GetRadiusData($radiusobj, "spell_id2"))
  1089.                                 {
  1090.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singlenpc);
  1091.                                 }
  1092.                                
  1093.                                 if(plugin::GetRadiusData($radiusobj, "spell_id3"))
  1094.                                 {
  1095.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singlenpc);
  1096.                                 }
  1097.                               }
  1098.                               else
  1099.                               {
  1100.                                     #   quest::gmsay("No radius!", 15);
  1101.                               }
  1102.                             }
  1103.                         }
  1104.                         else
  1105.                         {
  1106.                             my @clients = $entity_list->GetClientList();
  1107.                             foreach my $singleclient (@clients)
  1108.                             {
  1109.                                 my $rad = plugin::GetRadiusData($radiusobj, "radius");
  1110.                                 if(int($object->GetX()) > int($singleclient->GetX())-$rad && int($object->GetX()) < int($singleclient->GetX())+$rad &&
  1111.                                 int($object->GetY()) > int($singleclient->GetY())-$rad && int($object->GetY()) < int($singleclient->GetY())+$rad)
  1112.                               {
  1113.                                 if(plugin::GetRadiusData($radiusobj, "remove"))
  1114.                                 {
  1115.                                     $triggered = 1;
  1116.                                 }
  1117.                                
  1118.                                 if(plugin::GetRadiusData($radiusobj, "spell_id"))
  1119.                                 {
  1120.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id"), $singleclient);
  1121.                                 }
  1122.                                
  1123.                                 if(plugin::GetRadiusData($radiusobj, "spell_id2"))
  1124.                                 {
  1125.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id2"), $singleclient);
  1126.                                 }
  1127.                                
  1128.                                 if(plugin::GetRadiusData($radiusobj, "spell_id3"))
  1129.                                 {
  1130.                                     $client->SpellFinished(plugin::GetRadiusData($radiusobj, "spell_id3"), $singleclient);
  1131.                                 }
  1132.                                
  1133.                               }
  1134.                               else
  1135.                               {
  1136.                                     #quest::gmsay("No radius!", 15);
  1137.                               }
  1138.                             }
  1139.                         }
  1140.                         if($triggered)
  1141.                         {
  1142.                             $object->Depop();
  1143.                             quest::stoptimer("WardTimer" . $client->GetEntityVariable("PlacingItemID"));
  1144.                         }
  1145.                        
  1146.                         $client->SetEntityVariable("WardID" . $client->GetEntityVariable("PlacingItemID"), $spawnid);
  1147.                     }
  1148.                     else
  1149.                     {
  1150.                     $client->Message(15, "You have run out of " . plugin::GetRadiusData($radiusobj, "name"). "!");
  1151.                     }
  1152.                 }
  1153.             }
  1154.             else
  1155.             {
  1156.                 if(!defined($client->GetEntityVariable("PlacingItemID")))
  1157.                 {
  1158.                 $client->Message(15, "Please select an item to use in the world before casting this ability.");
  1159.                 }
  1160.                 else
  1161.                 {
  1162.                     $slot = plugin::check_hasitem_inslot($client, $client->GetEntityVariable("PlacingItemID"));
  1163.                     if (plugin::CheckTreeRadius($client->GetTargetRingX(), $client->GetTargetRingY())) {
  1164.                         $client->Message(15, "There is an object too close, choose another location.");
  1165.                         return;
  1166.                     }
  1167.                    
  1168.                     if($slot != 65535)
  1169.                     {
  1170.                         $client->DeleteItemInInventory($slot, 1, 1);
  1171.                        
  1172.                         $spawnid = quest::creategroundobject($client->GetEntityVariable("PlacingItemID"), $client->GetTargetRingX(), $client->GetTargetRingY(), $client->GetTargetRingZ(), $client->GetHeading(), 0);   #62671 original ID
  1173.                         #quest::gmsay("SpawnID is $spawnid", 15);
  1174.                         $object = $entity_list->GetObjectByID($spawnid);
  1175.                         $object->SetSize(($client->GetEntityVariable("PlacingGrowth") / 5) + $client->GetEntityVariable("PlacingSize"));
  1176.                         $object->SetSolidType(0);
  1177.                         $object->SetEntityVariable("TreeGrowth", $client->GetEntityVariable("PlacingGrowth") / 5);
  1178.                         $object->SetEntityVariable("TreeWater", 0);
  1179.                         $object->SetEntityVariable("TreeDisease", 0);
  1180.                         $object->SetEntityVariable("TreeSize", $client->GetEntityVariable("PlacingSize"));
  1181.                         $object->SetEntityVariable("PlacingEffect", (plugin::HasEffect($object->GetItemID()) ? plugin::GetEffectData($object->GetItemID(), "spell_id") : (defined($object->GetEntityVariable("ClickEffect")) ? $object->GetEntityVariable("ClickEffect") : 0)));
  1182.                         $object->SetEntityVariable("Owner", $client->AccountID());
  1183.                         plugin::InsertTreeProcedure($object);
  1184.                         quest::signalwith(1000503,$spawnid);
  1185.                     }
  1186.                     else
  1187.                     {
  1188.                         $client->Message(15, "You need to highlight a useable item!");
  1189.                     }
  1190.                 }
  1191.             }
  1192.         }
  1193.     }
  1194. }
  1195.  
  1196.  
  1197.  
  1198. sub GET_PLAYERS_ONLINE
  1199. {
  1200.     my $GET_ONLINE      = 0;
  1201.     my $connect         = LoadMySQLConnection();
  1202.     my $query           =   "
  1203.                             SELECT count(last_login)
  1204.                             FROM character_data
  1205.                             WHERE UNIX_TIMESTAMP() - ($_[0]) < last_login
  1206.                             ";
  1207.     # $client->Message(7, "$query");
  1208.     my $query_handle = $connect->prepare($query);
  1209.     $query_handle->execute();
  1210.     if ($query_handle->rows)
  1211.     {
  1212.         my $ref     = $query_handle->fetchrow_hashref();
  1213.         $GET_ONLINE = $ref->{'count(last_login)'};
  1214.     }
  1215.  
  1216.     $query_handle->finish();
  1217.     $connect->disconnect();
  1218.     return $GET_ONLINE;
  1219. } # End GET_PLAYERS_ONLINE
  1220.  
  1221.  
  1222. sub GET_IP_ONLINE
  1223. {
  1224.     my $GET_ONLINE      = 0;
  1225.     my $connect         = LoadMySQLConnection();
  1226.     my $query           =   "
  1227.                             SELECT count(lastused)
  1228.                             FROM account_ip
  1229.                             WHERE TIMESTAMPDIFF(MINUTE, lastused, NOW()) < $_[0]
  1230.                             ";
  1231.     # $client->Message(7, "$query");
  1232.     my $query_handle = $connect->prepare($query);
  1233.     $query_handle->execute();
  1234.     if ($query_handle->rows)
  1235.     {
  1236.         my $ref     = $query_handle->fetchrow_hashref();
  1237.         $GET_ONLINE = $ref->{'count(lastused)'};
  1238.     }
  1239.     $query_handle->finish();
  1240.     $connect->disconnect();
  1241.     return $GET_ONLINE;
  1242. } # End GET_IP_ONLINE
  1243.  
  1244.  
  1245. sub LoadMySQLConnection
  1246. {
  1247.     use DBI;
  1248.     use DBD::mysql;
  1249.     # GET DB, USER, AND PASS FROM CONFIG FILE
  1250.     my $confile = "eqemu_config.xml"; #default config file
  1251.     # open(F, "<$confile") or die "Unable to open config: $confile\n";
  1252.     open(F, "<$confile") or quest::gmsay("GM: sub LoadMySQLConnection() 'open' FAILED !!!!", 15, 1);
  1253.     my $indb = 0;
  1254.  
  1255.     while(<F>)
  1256.     {
  1257.         s/\r//g;
  1258.         if(/<database>/i)                       { $indb = 1; }
  1259.         next unless($indb == 1);
  1260.         if(/<\/database>/i)                     { $indb = 0; last; }
  1261.         if(/<host>(.*)<\/host>/i)               { $host = $1; }
  1262.         elsif(/<username>(.*)<\/username>/i)    { $user = $1; }
  1263.         elsif(/<password>(.*)<\/password>/i)    { $pass = $1; }
  1264.         elsif(/<db>(.*)<\/db>/i)                { $db   = $1; }
  1265.     }
  1266.  
  1267.     # DATA SOURCE NAME
  1268.     my $dsn = "dbi:mysql:$db:localhost:3306";
  1269.     # PERL DBI CONNECT
  1270.     my $connect = DBI->connect($dsn, $user, $pass) or quest::gmsay("GM: sub LoadMySQLConnection() 'connect' FAILED !!!!", 15, 1);
  1271.     return $connect;
  1272. } # End LoadMySQLConnection()
  1273.  
  1274.  
  1275.  
  1276. sub EVENT_DISCONNECT {
  1277.     quest::stoptimer ("activitycheck$charid");
  1278. }
  1279.  
  1280. sub fixname {
  1281.    local $_  = shift;
  1282.    s/[^A-Za-z]+//g;
  1283.    return $_;
  1284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement