Equip/Unequip Items, Spells, and Weapons

Game Editor comments and discussion.

Equip/Unequip Items, Spells, and Weapons

Postby BlenderFreak » Fri Jan 07, 2011 5:06 pm

Been a while since I've paid a visit to the forums, but I've been working on the sprites and such for my game. I've got another question/dilemma that I thought of though.
While working with the Blender 2.49 game engine, i was able to easily create the ability to equip and remove items, spells, and weaponry by using states. This way, for example, you could only use a particular spell if it was equipped to your character at the time - you would have to return to inventory menu if you desired to equip and use a different spell.
I've tried a few things here and there but nothing seems to really work in GE that I know of (but I'm very new to actual coding. With the BGE I just used logic bricks). So if someone could explain, provide a zip file, or link me to a tutorial that does the following things, that would be very helpful:

- create an inventory menu that scrolls down over your camera view from the top view while suspending the main game
- any collected items and spells will be located in your inventory
- upon clicking on an inventory item/spell, you may choose to "discard" or "equip" or "cancel" .
- if you equip the inventory item, it replaces whatever was equipped before and its avatar (say a potion) will appear in a small box in the lower right-hand corner, letting you know that it is equipped.
- Only when an item is equipped may it be used

I can handle the other things (like how the item functions, limiting the number of items your inventory can hold, etc), I'm just having a hard time coming up with a simple way to do all of this. Any help you can offer me will be greatly appreciated. Hopefully I'll be able to get around to the real game-making some time soon, letting me implement all of this knowledge you guys have helped me gain so far!

Sincerely,
BlenderFreak
There's not much there yet, but you can find information on my current projects here.

https://sites.google.com/site/darkst3am/
User avatar
BlenderFreak
 
Posts: 55
Joined: Sun Sep 26, 2010 5:46 am
Location: His Computer
Score: 2 Give a positive score

Re: Equip/Unequip Items, Spells, and Weapons

Postby skydereign » Sat Jan 08, 2011 8:49 am

Well I can't do all of this for you, but I can explain how you can go about it. First you need to know how to create an inventory, there are a couple good inventory tutorials on the forums, which you've probably seen if you're asking this question.

Pausing the game can be a bit tricky without the PauseGameOn function, but mostly depends on the type of game. If they're aren't a lot of moving actors, just pause the current ones, or if they use draw, have a gameState variable dictating movement. Example, enemies move if gameState==1, and don't do anything when gameState==2. The menu actors would not be stopped by pause of course.

Adding items collected should be covered in your inventory tutorial. Mainly it should be an addItem function.

Simple ui to choose what to do with an item when you are looking at the inventory. Now... if you have a working inventory, all you need after that is an equipable item variable. This would hold the array index of the equipped item, and you would use it to check what item it is, and allow you to use it. You would set this to -1 or similar when no item is equipped, or always leave space 0 empty (or even make space 0 the equipped item).

The reequipping and display should be pretty standard too. Either use a switch items type function, or add and delete. If there aren't any, I can help you write one.

The equipped item to be used would just require you to only allow the player to use it if it is the current item, or in [0], whichever you chose. A simple if could do that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Equip/Unequip Items, Spells, and Weapons

Postby BlenderFreak » Sat Jan 08, 2011 7:40 pm

Hm alright - thanks, Sky! I'll have to look around and see what I can find tutorial-wise. I think I might have started tackling a project that's a bit more difficult than I had anticipated ;) Thanks for all the help and advice you've been giving me!
There's not much there yet, but you can find information on my current projects here.

https://sites.google.com/site/darkst3am/
User avatar
BlenderFreak
 
Posts: 55
Joined: Sun Sep 26, 2010 5:46 am
Location: His Computer
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron