The Daily Click ::. Forums ::. Klik Coding Help ::. Picking up items
 

Post Reply  Post Oekaki 
 

Posted By Message

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
13th November, 2009 at 15:55:13 -

Okay, I've decided to start working on a fairly oldish/recent game again that had been dropped back in May (The month I've now noticed to be when 3/4 of my games are dropped ). The game features a huge selection of weapons that can be spawned at certain areas on each game map. Here's my desired result and setup...

Setup: Firearms and Blades are set to 2 different groups, but each weapon from either of the groups are set in groups "1", "2", or "3", depending on the player's power level.

Desired result: To collect weapons that you've picked up and to store them into your inventory as long as the player's power level is high enough, and to be able to scroll through your weapon inventory by pressing certain buttons. Maybe U and I for Blades, O and P for Firearms.

I was just wondering if anybody knew how to do this. Any help is highly appreciated.

 
An old and washed up once-kid

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
14th November, 2009 at 05:03:49 -

It doesn't sound so hard. What are you trying to do exactly? If you're just picking up things, you could just set an alterable value to be what you're picking up. Just assign a different number to each type of weapon, e.g:
0 - nothing
1 - handgun
2 - shotgun
3 - assault rifle
10 - knife
11 - sword
12 - chainsaw

Weapon slot 1-26 -> Alterable value A-Y


If you have 26 inventory slots, you can represent a different weapon in each slot. Like if you had a shotgun in slot 1, set Alterable Value A to 2.

Add another condition to check the power level before you pick up. Like if "Player sprite overlaps shotgun", add another condition that "Power level > 1" or something.

For inventory switching, let's say you start off with slot 1 open. Set a 'slot counter' to 1. The weapon in hand is whatever is in Alterable value A. Following the simple numbering system I mentioned earlier, all values greater or equal to 10 are blades, all values more than 0 and less than 10 are firearms.

When you press I, you start a "check_blade" loop 26 times. Add one to the 'slot counter'. If counter is 2, check if the value in Alterable Value B is >= 10 (if it's a blade). If it is, then stop the "check_blade" loop. The slot number will stop at the slot with the blade. If the slot counter goes over 26 (or whatever max slots), set it back to 1. If it goes below one, set it to the maximum number of slots.

Then add a loop that goes backwards to check for blades by subtracting from slot number (checking backwards). Do the same with firearms; just change the condition to check between 0 and 10 (if it's a firearm).

Edited by Muz

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  374

VIP MemberCardboard BoxThe Cake is a Lie
14th November, 2009 at 07:28:56 -

I would've never thought of that. I guess my mind hasn't quite expanded that far into Klik coding yet. I see where you're going with it though, but I'm not sure whether we're on the same track. Here's a tiny little illustration I did. (Sorry, I just draw things out for some reason. )

1: When a player kills another player, the dead player drops all of his (quickly drawn) weapons, which the killer can pick up as long as his Power level is high enough. A Player's Power increases with each [certain number of kills], but moves back down to power level 1 when he is killed, and of course, he drops all of his weapons for others to take.

2: When the player picks up a weapon, it is either stored in the Fireams inventory, or Blades inventory, depending of course whether it's a blade, gun or what. However, neither inventories are visible.

3...: Well... it's online, which means it won't live long and you may wait months trying to find somebody to play against. Code-wise, I don't know if this changes anything, but I'll leave the online stuff to when I find a Lacewing coder.

Image

I'll try out your method tomorrow morning. Thanks for the help!

 
An old and washed up once-kid

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
16th November, 2009 at 05:33:40 -

Still can't see which part you're having trouble with exactly. If it still doesn't work, lemme know what exactly you're having trouble with, so I could write in more detail. Otherwise all we can do is give a general outline

Dropping weapons:
Upon death, scan to every Slot that contains a weapon. If the weapon is in a category that's higher than the power level he should be using, empty the Slot (Alterable Value ___ = 0) and drop the weapon (create weapon near <dead position>

Item displaying:
If you want to display 3 items at once, you can use that thing I mentioned with inventory switching.. but in the display code, show picture of shotgun if Alterable Value __ = 2. Showing the next/previous pictures is a bit more complicated.. you have to do a loop which searches through all the slots before or after the one it's centered on, to make sure it's not empty or doesn't contain an item you don't want. Then you display the first "next" or the first "previous" item that the loop finds. Code is similar to before, just that the Q/E isn't a condition for the code and the loop doesn't actually change weapons.. it just displays the different weapons.

Doing it online:
..changes a lot Do single player first, then only make it online once you could code it in your sleep. I'm sure some people would suggest otherwise, but I see it as an easier way. You'd do the same things, but you can't rely on Always conditions for data stuff, because that eats bandwidth and doesn't take lag into account, etc. It's like the same thing, just more efficient

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image
   

Post Reply



 



Advertisement

Worth A Click