Welcome, Guest. Please login or register.
Did you miss your activation email?
October 31, 2024, 06:09:01 pm *

Login with username, password and session length
Pages: 1 [2] 3
Print
Author Topic: Holiday Weeked!!!  (Read 16625 times)
Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #15 on: May 24, 2013, 08:58:51 pm »

There are a LOT of npc_name.pl scripts with addloot() now.

Even if someone else did all the copy/paste work for me, I'd still have a ton of files to upload and download via server and email to person, and also would need to verify the code since yes I am paranoid. Would be easy to slip in 1 line of code to make yourself GM powers or free loot.

A real long term solution would be to eventually convert all my addloot() into a custom plugin that I can edit the plugin in 1 spot that would affect all the scripts that use it.

Might actually do this some day when I get enough time and bored. Most of the stuff is in T7, T8, and ToFS for addloot. And of course a little bit in each tier for random essence/spell drops too.
Logged

Hunter - EZ Server GM
hateborne
Legend
*******
Posts: 2282


Don't nerf me bro!


View Profile
« Reply #16 on: May 24, 2013, 10:05:33 pm »

There are a LOT of npc_name.pl scripts with addloot() now.

Even if someone else did all the copy/paste work for me, I'd still have a ton of files to upload and download via server and email to person, and also would need to verify the code since yes I am paranoid. Would be easy to slip in 1 line of code to make yourself GM powers or free loot.

A real long term solution would be to eventually convert all my addloot() into a custom plugin that I can edit the plugin in 1 spot that would affect all the scripts that use it.

Might actually do this some day when I get enough time and bored. Most of the stuff is in T7, T8, and ToFS for addloot. And of course a little bit in each tier for random essence/spell drops too.

You might be able to get dirty and do a 'sed' command to replace addloot() with a block to do exactly that. I'll try to write something up this weekend for you. You should be able to dump it across the entire quests folder (and obviously across each zone). Only kick is that it would require some *nix base or UNIX Utils for Windows.


-Hate
Logged

I'm so sorry Hunter, I tried...
Natedog
Master
******
Posts: 830


View Profile
« Reply #17 on: May 24, 2013, 10:19:21 pm »

Code:
# AddLoot(itemid, amount, chance) --- Amount is usually 1 unless the item has charges --- chance higher numbers for better loot chances
 sub AddLoot {
my $itemdrop = $_[0];
my $amount = $_[1];
my $chance = $_[2];

#Set to 2 for double lootz!
my $tries = 2;

for($i = 1; $i <= $tries; $i++)
{
my $random_number = int(rand(100)+1);
if($random_number <= $chance)
{
quest::addloot($itemdrop, $amount);
}
}
 }


Code:
#item 1289, 1 charge, 100% chance
plugin::AddLoot(1289, 1, 100);


Will give 100% chance to give item 1289  and since I have $tries set to 2 ... it will try the loot code twice and the NPC will spawn with 2


Seems to work decently... just tested it a bit heh


Or could write something yourself.. but this gives you an idea of what can be done..  (im sure there are other ways too)




Side note ... not rushing you on this or anything.. just shooting out ideas lol   (For next double lootz)
« Last Edit: May 24, 2013, 10:35:07 pm by Paldail » Logged

Natedog
Master
******
Posts: 830


View Profile
« Reply #18 on: May 25, 2013, 09:50:11 am »

Here is the better version I just wrote.... works much easier and allows for random loot from a List of items!


Code:
# AddLoot(amount, chance, @itemarray)  -- array can be 1 item or more!
 sub AddLoot {
my $amount = shift;
my $chance = shift;
my @itemdrop = @_;


#Set to 2 for double lootz!
my $tries = 2;

for($i = 1; $i <= $tries; $i++)
{
my $random_number = int(rand(100)+1);
if($random_number <= $chance)
{
my $itemz = $itemdrop[ rand @itemdrop ];
quest::addloot($itemz, $amount);
}
}
}



Here is how it is being used in a zone... (or an NPC)


Code:
sub EVENT_SPAWN {
my @itemz = ("1001", #Cloth helm
"1002",  #Cloth Veil
"1003",  #Cloth Choker
"1004",  #Cloth Shirt
"1005"); #Cloth Shawl

 plugin::AddLoot(1, 50, @itemz);

}



50% chance to drop 1 of those 5 items ..... also with $tries set to 2 in the Plugin ... it would allow for Double chances (Double lootz)
Logged

Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #19 on: May 25, 2013, 05:42:48 pm »

That code is very strait forward and simple to understand.

Was going to ask for random off list but seems we already thought of that too with array.

Seems it might be worth to go back over my code and re-write stuff. Won't be able to do a mass copy and replace due to chance to drop, and list of items to drop. Still copy and paste will go just as fast here, and future code this will work nicely.

Now double loot off the database tables is like double chance, so a loot that has 50% drop rate might end up dropping 0, 1, or 2 loots. Edit: Perl plugin code should work the same when chance is done inside the plugin instead of outside the plugin.
« Last Edit: May 25, 2013, 05:44:37 pm by Hunter » Logged

Hunter - EZ Server GM
Fugitive
Legend
*******
Posts: 1807


TROLL KING


View Profile
« Reply #20 on: May 25, 2013, 05:52:14 pm »

/cheer
Logged


Quoted for the Brotherhood of Warriors
"I want my wizard to cast Fugitives instead of fireballs.
We can't always get what we want. ;-)"
-Hate"
Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #21 on: May 27, 2013, 03:26:09 am »

Here is the better version I just wrote.... works much easier and allows for random loot from a List of items!


Code:
# AddLoot(amount, chance, @itemarray)  -- array can be 1 item or more!
 sub AddLoot {
my $amount = shift;
my $chance = shift;
my @itemdrop = @_;


#Set to 2 for double lootz!
my $tries = 2;

for($i = 1; $i <= $tries; $i++)
{
my $random_number = int(rand(100)+1);
if($random_number <= $chance)
{
my $itemz = $itemdrop[ rand @itemdrop ];
quest::addloot($itemz, $amount);
}
}
}



Here is how it is being used in a zone... (or an NPC)


Code:
sub EVENT_SPAWN {
my @itemz = ("1001", #Cloth helm
"1002",  #Cloth Veil
"1003",  #Cloth Choker
"1004",  #Cloth Shirt
"1005"); #Cloth Shawl

 plugin::AddLoot(1, 50, @itemz);

}



50% chance to drop 1 of those 5 items ..... also with $tries set to 2 in the Plugin ... it would allow for Double chances (Double lootz)

So how about if I want to do 1 out of 400 mobs, what chance do I put in?

Might be easier to just put in 1 of X and pass X as parameter.

i.e.  plugin::AddLoot(1, 500, @itemz); would have 1/500 chance to drop the item. Useful when I want to drop an 'average' of 1 item per killing all trash in the zone.

If we do plugin::AddLoot(2, 500, @itemz); then are we going to get 0, 1, or 2 items, or are we going to get 0 or 2 items?

Just need to tweak and rethink the code a bit. Very hopeful we can get it working and implemented by next double loot holiday.
Logged

Hunter - EZ Server GM
Natedog
Master
******
Posts: 830


View Profile
« Reply #22 on: May 27, 2013, 04:11:19 am »

So the 500 would be the random sounds like a nice idea... would be a simple tweak
Logged

Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #23 on: May 27, 2013, 04:20:03 am »

I modified the code from above post, tested and working.

Code:
# AddLoot(amount, chance, @itemarray)  -- array can be 1 item or more!
sub EZAddLoot
{
my $amount = shift;
my $chance = shift;
my @itemdrop = @_;

#Set to 2 for double lootz!
my $Double_Loot = 1; # 1 = Normal 1x loot, 2 = Double Loot, etc

for($n = 1; $n <= $amount; $n++)
{
for($i = 1; $i <= $Double_Loot; $i++)
{
my $random_number = int(rand($chance)+1);
if($random_number == 1) # 1/chance to drop
{
my $itemz = $itemdrop[ rand @itemdrop ];
quest::addloot($itemz, 1); # 1 charge
}
}
}
}

Code:
sub EVENT_SPAWN 
{
my @itemz = ("1001", #Cloth helm
"1002",  #Cloth Veil
"1003",  #Cloth Choker
"1004",  #Cloth Shirt
"1005"); #Cloth Shawl

plugin::EZAddLoot(4, 2, @itemz); # Drop 4 from list, 1/2 Chance (50% chance per each of 4 items), from Array

}

Examples for EVENT_SPAWN:

# Drop up to 4 items from the list, 1/2 (aka 50%) Chance each, from Array
# Could drop 0, 1, 2, 3, or 4 items
plugin::EZAddLoot(4, 2, @itemz);

# Drop 1 item from the list, 1/1 (aka 100%) Chance, from Array
# Always drop 1 item from the list
plugin::EZAddLoot(1, 1, @itemz);

# Drop 1 item from the list, 1/500 Chance, from Array
# 1/500 chance to drop 1 item
plugin::EZAddLoot(1, 500, @itemz);

Would this still work in an Array with only 1 item in it? So choose 1 item from list of 1 items? Haven't tested that far yet.
Logged

Hunter - EZ Server GM
Natedog
Master
******
Posts: 830


View Profile
« Reply #24 on: May 27, 2013, 05:17:17 am »

Works very nice like that Hunter!
Logged

Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #25 on: May 27, 2013, 05:30:57 am »

Woot!
Logged

Hunter - EZ Server GM
Natedog
Master
******
Posts: 830


View Profile
« Reply #26 on: May 27, 2013, 05:47:59 am »

Code:
sub EVENT_SPAWN {
my @itemz = (1001,  #Cloth helm
1002,   #Cloth Veil
1003,   #Cloth Choker
1004,   #Cloth Shirt
1005);  #Cloth Shawl
my @stuff = (1006); #Cloth Cape

 plugin::AddLoot(4, 5, @itemz);
 plugin::AddLoot(1, 1, @stuff);

}


(4x) 1 / 5 Chance to Drop any of those top 5 items

100% chance to drop Cloth Cape (1 dropped)







(this is what I was testing while chatting with you in game and it works awesome!)
Logged

Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #27 on: May 27, 2013, 06:02:12 am »

Now to go through my old code and look for addloot to replace with the new code.
Logged

Hunter - EZ Server GM
Natedog
Master
******
Posts: 830


View Profile
« Reply #28 on: May 27, 2013, 07:01:22 am »

Now to go through my old code and look for addloot to replace with the new code.


open them all with Notepad ++

Do a search in all open files for "addloot" and bam you got all instances of that so you can easily modify them
Logged

Hunter
EZ Server GM
Legend
*******
Posts: 8100


EZ Server GM


View Profile
« Reply #29 on: May 27, 2013, 07:10:05 am »

Lots of npcs in lots of zones aka Lots of files in lots of folders.
Logged

Hunter - EZ Server GM
Pages: 1 [2] 3
Print
Jump to:  

Recent

Stats

Members
Stats
  • Total Posts: 65108
  • Total Topics: 5064
  • Online Today: 170
  • Online Ever: 8678
  • (December 19, 2022, 02:32:09 pm)
Users Online
Users: 1
Guests: 200
Total: 201
TinyPortal v1.0 beta 4 © Bloc