Forum

Inventory System?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Inventory System?

Postby ceriux » Sun May 15, 2011 7:55 pm

Can anyone take the time to explain an inventory system to me?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby toneddu2000 » Sun May 15, 2011 8:40 pm

yesterday I took a look at THC's one.
It seems very interesting (collecting items, assigning an item to left/right hand, switching items, etc.).

You can grab the source code there and test it
toneddu2000
 
Posts: 1352
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Postby ceriux » Mon May 16, 2011 4:22 pm

thanks ill try and look at this after work today. hopefully i can figure it out own my own.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby toneddu2000 » Mon May 16, 2011 6:52 pm

I'm sorry I can't be more of help, but I'm not a coder. For what I understood, Chris Page, the author of the code, made a massive work on csqc for the inventory part, maybe to lighten the ssqc amount of work.
I don't if source code reveals it, but in youtube videos Chris posted, there's a fantastic part where objects hovered with mouse became "glowish" and, clicking on it, the item appears on the inventory. Superb.
toneddu2000
 
Posts: 1352
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Postby ceriux » Mon May 16, 2011 7:51 pm

a lot of it ill have to do in csqc i'm already assuming. i just wonder if i will have to make items differently than how quake does and how might i store their values with in the inventory. hopefully some of his source has the answers and i can find them.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Spike » Mon May 16, 2011 8:10 pm

prydon gate has an inventory without csqc, but if you want it friendly and usable then you need something clientside.

even with a csqc gui, you need the info to be valid and known on the server or you open yourself to huge cheats.
the simplest way to get a robust inventory system is to put the swapping/obtaining/dropping code all on the server, and have the client code fairly stupid with it just drawing the slots/etc as the server tells it, and sending all commands to change various slots off to the server. its viable to leave the client code as purely a ui (note that in internet games, you might get some lag, but it shouldn't be unplayable, assuming any drag/drop is drawn fully clientside, with generated requests validated by the server).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Tue May 17, 2011 3:06 am

thanks spike. i was thinking that the inventory HAD to be server side. some frikfile i'm assuming is needed. The only thing i thought csqc would be used for is the UI. i'm hoping i can look at this source code and prydons and see how the information for the items is made and stored. i'v never touched anything like this. but i really want to try. if i can successfully get this working. i'll defiantly be continuing my project.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Error » Tue May 17, 2011 3:57 am

Prydon's inventory/item system is SICK!!!!!

It's the most ridiculously insanely QC I've found. (though twig deserves a very honorable mention)
User avatar
Error
InsideQC Staff
 
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA

Postby Spike » Tue May 17, 2011 4:48 am

lol, yeah, you really don't want to be using prydon gate's inventory as a base, it merely demonstrates that it can be done with no extensions at all, not that its an ideal way to do it.

both frikqcc and fteqcc support arrays. make an array of 30 fields, assosiate each field with a csqc stat, get the csqc to draw those stats. when the ssqc changes the stats, they'll get automatically replicated to the client and can just be drawn directly there. the exception is with any drag+drop functionality, but it might be enough to just track source slot and show whatever image is in that slot.
presumably if you have item attributes, you should encode that in each slot. decide on a number of bits for each attribute of a slot (like item id, ammo count, etc) and write some small functions to read/write the parts you need.

there are a lot of ways to write an inventory system. you could use csqc ents instead of stats, for instance, which would remove any limits associated with array elements or limited stat space. Which may also give benefits for lag free manipulation before the server responds.

if you use stats, you'll be limited to a specific number of slots (diablo-like). If you use ents, you can get much more items in there (fallout1/2-like), and more info per slot.
stats are simpler. :)

for reference, hexen2's inventory is split between two things. powerups and stuff take one stat slot per type, saying how much of each specific type you have. the puzzle pieces consist of a string stat per slot, naming the image to show
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby ceriux » Tue May 17, 2011 5:20 pm

i'm thinking ill use 'stats' because i wanted to limit the amount of items each person could hold either way. and im pretty sure i dont want too much of the item code handled with csqc. so that as mentioned above it's harder to cheat.
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest