The Daily Click ::. Forums ::. Klik Coding Help ::. How to deal with different weapons
 

Post Reply  Post Oekaki 
 

Posted By Message

Tar



Registered
  12/02/2005
Points
  13
20th October, 2006 at 10:40:03 -

How do you think will be better to deal with different kinds of weapons?,is a 4 player game, and each weapon should have damage,number of bullets in clip, rate of fire and all those things...
Should I make one alt value in each player to see what weapon he is carrying and make calculations for all the features of the weapon in the code?.
Or should I make a lot of variables in each player saying what kind of weapon he is carrying, what damage that weapon does...etc?.

In other forum someone told me that what I could do is: when player picks up a weapon, some group (old weapon) deactivates and the other (new weap) activates, and that group could manage all the weapon's features.
It's a good way, but there are 4 players, whould I make 4 different groups for each player for each weapon?.

Please help, thanks.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
20th October, 2006 at 10:53:36 -

Use one variable. It's totally unnecessary to have many different variables to store the damage and fire rate of the weapon, if it's always the same for the same weapon. And the group idea would also be stupid if you have more than one player. Just check the weapon variable when the player shoots, and then calculate all damage and stuff depending on the weapon he's holding.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
20th October, 2006 at 11:47:59 -

If by 'weapons' we're really just talking about different kinds of guns, then the variable option is ideal.

It's totally unnecessary to have many different variables to store the damage and fire rate of the weapon, if it's always the same for the same weapon.
No. Depends how many different weapons there are. I've got a game I'll probably never finish that stores a large number of different guns with a set of variables for stopping power, accuracy, clip size, reload rate, rate of fire, number of projectiles per shot and sound effect, plus another three for graphics, and two strings for in-game name and description.
For a small number of guns, it's fine to use a single variable (even though it's kind of stupid if you wind up repeating code), but for a larger number you could handle the whole thing with a couple of lines, plus it's extensible.

Now, if we're talking about a more varied arsenal with grenades and chicken launchers and stuff, the groups idea is okay. But in my case I'd put them all in a single group and just activate lines with the 'current weapon' alt value. Then you can copy and modify the group for each extra player. But the effect is the same, so whatever.
You could use an even more robust version of the value-based engine but that would kind of be overkill since most of the time since you rarely have more than a handful of 'special' weapons like that.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click