Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-15-2010, 01:19 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Creating Stackable Items?

What would be the best way to create stackable items while still having different ID numbers on the items? I can't seem to figure out a way to do this, any ideas? Should I stack by name? I'm not really worried so much about weapons but things like lets say arrows, bullets, or whatever else that is stackable that you can't just put 1 in each inventory slot. I'm sure there is a way to do it, I'm just clueless on how. I haven't started scripting anything yet because I wanted to get all the details first so I don't get stuck half way through and have to start over. I'm currently just making something simple with no real purpose to learn from and expand on until I feel comfortable enough to do something for real. Any ideas on what the most efficient way would be to solve this?

Edit: Corrected some of my wording.

Last edited by Cubical; 03-15-2010 at 01:30 PM..
Reply With Quote
  #2  
Old 03-15-2010, 02:34 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I have thought about doing this, something like
NPC Code:

clientr.item_241234412414 = type,name,quanity, then whatever else;


241234412414 being the ID.

The only problem I see with doing it like that is if someone picks up more of an item they already have with a different ID how could I get it to stack?
Reply With Quote
  #3  
Old 03-15-2010, 02:54 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Why have a different ID for all items when you could just store type and quantity like normal people?
Reply With Quote
  #4  
Old 03-15-2010, 03:02 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Oh O figured having unique ID's prevented duping, I guess I could just check the quantity of the item before dropping and such. From what I have seen a lot of people use ID's for items. If they can just check to see the quantity why do servers make ID's for items?
Reply With Quote
  #5  
Old 03-15-2010, 03:18 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by Cubical View Post
Oh O figured having unique ID's prevented duping, I guess I could just check the quantity of the item before dropping and such. From what I have seen a lot of people use ID's for items. If they can just check to see the quantity why do servers make ID's for items?
I dunno, but Maloria did it to support custom weapons that you didn't have to create a new archetype for. It was very complicated and in the end the feature was never used.
Reply With Quote
  #6  
Old 03-15-2010, 03:30 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
so doing something like clientr.item.itemname = itemtype, quantity would be fine?

edit: also is it better to load all the item information for an item on login or as the player needs it?
Reply With Quote
  #7  
Old 03-15-2010, 03:39 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
Quote:
Originally Posted by Cubical View Post
so doing something like clientr.item.itemname = itemtype, quantity would be fine?
Or possibly clientr.item.itemtype = quantity, but yeah.

Quote:
Originally Posted by Cubical View Post
edit: also is it better to load all the item information for an item on login or as the player needs it?
If you're going to have lots of items it's better to grab them as needed, but if you only have a few right now it's easier to load on login.
Just make sure if you change it later that it won't break scripts that assume that all items are already loaded.
Reply With Quote
  #8  
Old 03-15-2010, 03:50 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
On Zodiac V2, I use a variable in my arcs called stackable as well as stack size.

If it's stackable, look for an empty stack based on the archetype and add to it taking into account max stack size, and creating a new stack if necessary.
__________________
Quote:
Reply With Quote
  #9  
Old 03-15-2010, 03:57 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
@mallard: I'll probably just do it when needed if it's not really that big of a deal. Thanks for the help.


Quote:
Originally Posted by fowlplay4 View Post
On Zodiac V2, I use a variable in my arcs called stackable as well as stack size.

If it's stackable, look for an empty stack based on the archetype and add to it taking into account max stack size, and creating a new stack if necessary.
That's a good idea.
Reply With Quote
  #10  
Old 03-15-2010, 04:00 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
But it's kind of useless doing stacks if you don't implement a items held / bag restriction so that should be something else to consider before bothering with it.
__________________
Quote:
Reply With Quote
  #11  
Old 03-15-2010, 04:06 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Well, it could also be used to limit the amount of 1 item you can have couldn't it? like say you can have a maximum of 20 potions or something you could set the max stack. Also I had planned implementing a maximum amount of items held.
Reply With Quote
  #12  
Old 03-15-2010, 04:37 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Yeah it could, so yeah you'll be fine
__________________
Quote:
Reply With Quote
  #13  
Old 03-15-2010, 04:51 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Alright, thanks to both of you.
Reply With Quote
  #14  
Old 03-15-2010, 06:38 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Could someone tell me which one of these is right, or if both of them are wrong?

NPC Code:

("clientr.type." @ itemrealname)[2] + quanity;



NPC Code:

("clientr.type." @ itemrealname[2]) + quanity;

Reply With Quote
  #15  
Old 03-15-2010, 06:59 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Cubical View Post
Could someone tell me which one of these is right, or if both of them are wrong?

NPC Code:

("clientr.type." @ itemrealname)[2] + quanity;



NPC Code:

("clientr.type." @ itemrealname[2]) + quanity;

First of all, I wouldn't use type because it may be reserved. I'd use something like itemtype instead.

If the player you want to manipulate has focus you would do something like this:

PHP Code:
clientr.(@ itemtype).(@ itemrealname)[2] += quantity;
// assuming your setup is something like
// clientr.grenade.flashbang = {some_var, some_var, QUANTITY, etc}
// or clientr.gun.famas = {some_var, some_var, QUANTITY, etc}

//Remember:
temp.foo += 2
//is a shorter way of doing
temp.foo temp.foo 2
You should also be very careful when dealing with important things like items that all of your data is verified on the serverside. How are you getting "quantity"? Trust nothing from the client because it can always be changed if the person knows what they're doing.

edit:
Ideally it would probably be better to have the itemtype in the array, and have clientr.items.itemname = {itemtype, etc, etc};
That way, you can easily get all of the players items doing something like temp.items = clientr.items.getDynamicVarNames();

I have to go to class, hope this helped.
Reply With Quote
  #16  
Old 03-15-2010, 07:17 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Oh that was a typo, it was itemtype but i changed it to this clientr.item.(@ itemrealname) right after I posted because I thought of what you just mentioned. Also everything is currently serverside and everything is loading from an array.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:12 AM.


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