Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Item system (https://forums.graalonline.com/forums/showthread.php?t=134258144)

Jman9912 02-23-2010 05:30 PM

Item system
 
Alright guys. I need to start the daunting task of coding an item system. I've gone over the couple of examples in the forum already. Pretty complex. Right now, I am focusing on storing an item and it's quantity.

Any tips, input, etc would be greatly appreciated it.

fowlplay4 02-23-2010 05:40 PM

If it's just a simple weapon-script based item system.

PHP Code:

function addItem(itemnamequantity) {
  
player.addweapon(itemname);
  
clientr.item.(@itemname) += quantity;


Otherwise you're going the MUDLib route, and Ziro has one posted in the code gallery.

Jman9912 02-23-2010 05:53 PM

It's gonna be sort of a MUDlib

coreys 02-23-2010 06:26 PM

Until you're a fairly experienced scripter you'd probably do best to use the one Ziro posted. Actually, it's always best to use something already made unless you, for whatever reason, have some reason that it is necessary to have a new system. (Different design specifications, etc)

Jman9912 02-23-2010 06:31 PM

That's true. But I can read and work with my own code easier than someone elses. I'll check Ziro's out again, but i'm not sure that I want all that it has.

Chompy 02-23-2010 06:39 PM

I think there needs to be a more scripter-friendly item system released (A plain one, with the fundamental and 'base' functions included), so others can easily add their own stuff to it.

Immolate 02-23-2010 07:05 PM

Quote:

Originally Posted by Chompy (Post 1558196)
I think there needs to be a more scripter-friendly item system released (A plain one, with the fundamental and 'base' functions included), so others can easily add their own stuff to it.

I had one made on my own server that was fairly simple but at the same time allowed a lot of flexibility. Shame I lost the backups :( I'll start rescripting with public release intended.

Tigairius 02-23-2010 07:07 PM

Quote:

Originally Posted by Jman9912 (Post 1558195)
That's true. But I can read and work with my own code easier than someone elses. I'll check Ziro's out again, but i'm not sure that I want all that it has.

I think you should go off of coreys' advice, however, instead of directly using Ziro's item system, simply model yours after his and then when you get stuck, take a peak at how he did it.

Jman9912 02-23-2010 07:14 PM

Quote:

Originally Posted by Tigairius (Post 1558207)
I think you should go off of coreys' advice, however, instead of directly using Ziro's item system, simply model yours after his and then when you get stuck, take a peak at how he did it.

Thats not a bad idea at all. I think that's what i'll do.

xXziroXx 02-23-2010 10:04 PM

Speaking of which, I should really clean up and release the newest version of it, the one on the forums is extremely outdated and inefficient comparing to it.

cbk1994 02-23-2010 11:00 PM

Assuming you go with a MUDLIB a few things to keep in mind:
  • Is it going to be a full MUDLIB? In other words, are you going to have it possible to dynamically create new instances of unique items, or are items static and created once, then players have a quantity of that item?
  • How are you going to store the item data? If you go with a full MUDLIB, your best bet is probably text files, but there are also other options like SQL which may work for you. If you go with a non-MUDLIB and just use text files (or other storage) for items, you will need a way to store the amount of items players have (SQL, client flags both work well)
  • Are you going to cache the item database in memory? This improves performance, but is only really possible when not using a full MUDLIB.
  • If you go with a full MUDLIB, how will you handle stacking? For example, if you create 5 platinum coins, these should technically be 5 unique objects, so they can't stack in your inventory.
  • How will you deal with getting item data clientside? Will you send it all on login or send it as needed and store it clientside then?


All times are GMT +2. The time now is 08:00 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.