Inventory and equip.

I know how to make stats lvl up’s and that stuff, but how to make rpg inventory. There is staff on the boxes how can i take the staff. Then it will go in to inventory and then i can wear it ?
Pic (texture with gimp)

http://aycu35.webshots.com/image/18474/2003221428742446215_rs.jpg

lovely screenshot! I love that you have a farmer race in a RPG.

So basically I would do this with python and a list.


# Make a list when you set up your game, this will hold strings of the objectnames
GameLogic.inventory = []   #a global list


it seemed easiest to me to have every game item have a little script like this:


cont = GameLogic.getCurrentController()
own = cont.getOwner()

nearPlayer = cont.getSensor("nearPlayer")  #a collision or near sensor
pickUpKey = cont.getSensor("pickUpKey") # if the player wants to try to pick up
#this would be a collision sensor that checks for property 

endObject = cont.getActuator("endObject")

if nearPlayer.isPositive() and pickUpKey.isPositive()
        if len(GameLogic.inventory) < 10:   #or whatever your maximum number of items
               GameLogic.addActiveActuator(endObject) #remove item from level
               GameLogic.inventory.append(own.getName() )
               # now you have a list of objectnames
               

Now you would probably want to write a section in your hud layer that uses GameLogic.inventory to pop the items into the slots. I am doing this part right now in my game, and its kind of messy.

basically I would put empties in every slot. Then in another layer have a properly scaled model of every game object (or little pictures of them)


# each empty has an addObject actuator that is hooked into this script
slot1 = GameLogic.getActuator("slot1")
slot2 = GameLogic.getActuator("slot2")
# ect...

slots = [slot1, slot2]
counter = 0
for x in GameLogic.inventory:
       slots[counter].setObject(x)
       GameLogic.addActiveActuator(slots[counter])
       counter += 1

I would use this script once, to load up the inventory. When you pick things up i would restart the hud scene to load the changes. You will also have to play with the strings in the inventory. most items you use in the game will have names like OBstaff.001 so you would need to strip off certain parts. so if item = “OBstaff.001” then item[2:-4] will return “staff”

I am having troubles designing this so i hope you have some luck. This is a very tricky thing to do.

All this code is formatted with spaces instead of tabs so reformat it. Good Luck!:wink:

Ok,thanks. I’l go try. I will say if i don’t get it work.

Edit: god.!!!, can you give/make me .blend ?
All is messy.

My staff is already in inventory. It needs 5 Str so the Farmer can wear it, but how i can get it into inventory and if i press it then it disapears and go to the sword place or somthing ? :stuck_out_tongue:

http://aycu20.webshots.com/image/15539/2001944066773673147_rs.jpg

well in the games/demos sticky there is a link to this inventory tut:

you seem to have the hang of things so I think you will find a way to do it. Remember that lists can store more than just strings, like other lists or dicts - heres a hint:
inventory = [ {‘name’:‘staff’, ‘minSTR’:5},{‘name’:‘stick’, ‘minSTR’:1} ]

I have tryd it but it didn’t work. Thats why i made this Thread.

Haiya!! Man, I’m looking everywhere about the exp sistem, and now EST mention it!
Well EST, would yo be so kind to tell how to do it, or if you don’t mind, send me some .blend showing about it, please…:o

Why not, look your mail. Azazel made it.

Good, good now if I take the item it will go into my inventory (yay).:eyebrowlift:
But if i press UpArrow or DownArrow then it dissapears why?:no:
I used file: “simpledemo”.:spin:

Edit: Yess…find it out !!! I was just stupid.
Now only one thing more.(Its on the pic red arrow shows it).
If somebody knows then tell me, Ok ?!

EST, do u think u can post a blend with your inventory. I would just love to study since I want to make one that is similar to yours in my game.

Look all my last Thread’s. With “rpg, xp, and that stuff” then find all posts by Azazel In my Thread’s.
And you will get most of the inportant parts of inventory, lvl’s and xp.

Omg! Looks good!
Jõudu! :smiley:

Jõudu tarvis ! :eyebrowlift: LOL

Haia EST!!
Thanks a lot for the .blend, I just have download it today, and may be it will help me a lot to, so I just thank to you and Azazel now. So, you don’t mind if sometimes I asking again about “rpg”, “xp” etc.? I’m still a newbie you know…:o
But anyway, the sword in the .blend, does it have to be shown or what?.. Coz it doesn’t show up:( , I really don’t know what to do, so may be I need some help again… Thanks!

The sword works only if u have “5” Str . You need to take “5” cube’s. Then go to stats and press one more str. Then go into inventory and click on sword. And you wear it !

EST,
For your question on the staff goes to the right spot in inventory, do you want to click, drag and drop to get it to the weapon spot, or just clikc and it goes to the weapon spot? Same question with the shield.

Wind_of_2105,
If there is anything that I can help with let me know.

Drag and Drop is better i think.

No problem EST. I will see what I can do. I am at work right now, when I get home I will begin working on it for you.

Ok, i have time :P. :smiley:

EST,
I have made it so that when you collide with the shield it goes into you inventory. I am working on the equip item spot for now. As for the attack setup, what are you looking for? Is it all random damage? Like the staff does, say 1-6 damage? Is there a chance to miss in the attack? Let me know.

Yes, its better if the staff makes random damage. And if it is easy to make miss hit then you can make it too.
But why is the shield?
Better defense. Maby you you know how to make it too? Like if you have shield defense 3 then the staff only hits 1-3.

You are bretty smart in python it must by easy for you !?:rolleyes: