[Release] Item dropping (for events/gm command)

01/14/2010 18:07 pro4never#1
So I was bored and figured I might finish my random event code for 1.0 and in the process realized just how much better alot of what I had could be written so I'm in the process of re-writing it all to use voids, switch and all that good stuff.

During that, for my random drop event I decided to write a little command/void to handle dropping items. This can be used however you wish. Maybe you want a gm command to drop x number of db's in twin city, a random event or anything else you want really.


NOTE: Coded for CoFuture 1.0 server, SUPER easy to convert to CoEmu and I'm sure a lotf version would be very easy to make.

Enjoy


For my version I created a new class file under handlers but you could obviously pack this in somewhere else (although there is no reason to)

Right click handles>Add>Class and name it w/e you want, mine is ItemDrop1.cs but it makes no real diff

replace the entire new file with this



Notice I just stole the existing item drop code from monsters and modified it to use a new void. As the drop code already seems to work perfectly fine I felt no need to change it.

Now for implimentation of it

under Commands.cs place

Code:
if (Splitter[0] == "/itemdrop")
                    {
                        try
                        {
                            Handler.ItemDrop(Client.Char.ID, Convert.ToInt32(Splitter[1]), Convert.ToInt32(Splitter[2]), Convert.ToInt32(Splitter[3]), Convert.ToUInt16(Splitter[4]), Convert.ToUInt16(Splitter[5]));
                        }
                        catch
                        {
                            Console.WriteLine("Error! Failed to drop item!");
                        }

                        return 2;
                    }

The way this works is very simple.

The item permission (who can grab item) is set to the person using the command (this way the gm could grab if he made a mistake but ppl in server have to wait a while to grab them!)

Everything else is set through the command.


Eg:
/itemdrop 1088001 10 1002 515 422 would drop 10 meteors at 515 422 twin city

And that's all there is to it. You can invoke the command anywhere in the source for any use where you want multiple (or even single) items dropping at a specific place.

All you have to do for that is

Handler.ItemDrop(Client.Char.ID, itemId#, Amount, Map, x, y);

Please let me know if I made any mistakes as I haven't really tested this much (Note! This would need to be changed if you wanted to deal with item quality/+/gem/etc! This is for mets/db mainly, or + stones if using a higher patched source.)

Enjoy,
P4N


Ooh: and a screenshot just so you have an example

[Only registered and activated users can see links. Click Here To Register...]

Edit: bahh I realized when posting this that it only will drop 9 items due to the limitations of the system I used... I have no reason to fix it right now but feel free if you want to post the correction and obviously all credit will go to you.
01/14/2010 18:26 .Kob#2
=0 thats cool. Can you translate to 5165 xD
01/14/2010 18:26 Fleaman#3
This is a very nice release.
Thanks!
01/14/2010 19:27 pro4never#4
I don't use lotf so I don't know the syntax properly. It's simple enough to convert though. Just change around the drop structure to be the same as lotf and look at how handlers are done in lotf.

Fairly simple conversion (although the code in itself is quite simple).
01/14/2010 19:39 .Ryu#5
Chris is only into this COFuture source because its co 1.0 :)
Goodjob chris =P
01/14/2010 19:43 Cassiuss#6
yes converting to 5156 would be nice =p
01/14/2010 19:43 pro4never#7
Naw actually I like CoFuture just because it's fairly complete and stable/well coded source. I'm also a big fan of CoEmu but I have no time or desire to re-write all the features required for it.

This was for CoFuture just cause I had a half finished system for it and in the process of re-writing the coding found this necessary. Seeing as I had finished it I thought I'd share it with people.


@Fox, do you guys have a forum up for development of the 1.0 server? If so lemme know so I can start working on some stuff.
01/14/2010 19:45 .Ryu#8
Quote:
Originally Posted by pro4never View Post
Naw actually I like CoFuture just because it's fairly complete and stable/well coded source. I'm also a big fan of CoEmu but I have no time or desire to re-write all the features required for it.

This was for CoFuture just cause I had a half finished system for it and in the process of re-writing the coding found this necessary. Seeing as I had finished it I thought I'd share it with people.


@Fox, do you guys have a forum up for development of the 1.0 server? If so lemme know so I can start working on some stuff.
I have the website up im working on the forum but it wont let me do phpbb... So i gotta fix this i would go with punbb but nah that sucks to much but ill get this fix in no time
01/14/2010 19:47 pro4never#9
:O why wouldn't phpbb work? All it should require is mysql and php functionality which any web server should have (if it doesn't you are gonna have alot of problems with other features anyways)

Anyways lemme know when the forum is up. Things will be getting busy for me soon but till then this is a way for me to waste some time and be semi-productive at the same time.
01/14/2010 19:50 .Ryu#10
Quote:
Originally Posted by pro4never View Post
:O why wouldn't phpbb work? All it should require is mysql and php functionality which any web server should have (if it doesn't you are gonna have alot of problems with other features anyways)

Anyways lemme know when the forum is up. Things will be getting busy for me soon but till then this is a way for me to waste some time and be semi-productive at the same time.
Well im using x10hosting and for some reason it doesent let me install phpbb...
And ive made a site there befor but it wont let me =\
It doesent have the installation no more...

But anyways pm if you wanna check out the site
01/16/2010 07:51 gulpi_de_gulat#11
Quote:
Originally Posted by Cassiuss View Post
yes converting to 5156 would be nice =p
drop event is already there in 5165 source