Giving a player stats
by Joobot · in General Discussion · 07/31/2005 (7:04 am) · 14 replies
I was wondering how I would go about making a stats/skills system for a game. Right now all I want is simply things like agility and accuracy. I imagine I'd have to make a datablock in player.cs for it, then in the spots that stats affect put like a multiplier there. How would I do this? How would it be associated with the player?
About the author
#2
07/31/2005 (10:07 am)
Do a search on the forums or resources. I remember a couple of good threads on this subject, along with examples of where and what to add to track such stats as "strength", "intelligence", etc.
#3
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2698
Perfect for me.
07/31/2005 (10:14 am)
Oh, stats didn't return anything useful in the resources, but speed did.http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2698
Perfect for me.
#4
Strength(how much u carry/melee attacks)
Agility(speed and jumping distnce)
Accuracy(weapon hit %)
Health(how much damage you can take)
for 1st/3rd person shooter/action game.
07/31/2005 (10:27 am)
Darn, that only explains speed. I want it to be like the HL1 mod Natural Selection where your experience allows you to upgrade midgame. Can't find any strength or intelligence examples. Right now I'm plannign to have Strength(how much u carry/melee attacks)
Agility(speed and jumping distnce)
Accuracy(weapon hit %)
Health(how much damage you can take)
for 1st/3rd person shooter/action game.
#5
07/31/2005 (10:29 am)
You have to code it. It's highly specific to your game.
#6
07/31/2005 (12:05 pm)
K, I'll keep looking.
#7
08/01/2005 (8:48 am)
Would this be a good way to do it? Add my attributes to PlayerData then simply make them multiply where they are used? Like maxForwardSpeed = 10 * (agility / 10). But then it wouldn't change if I changed the value of agility. So should I make an UpdateAttributeModifiers function or something. Seems logical to me.
#8
But just to let ya know, those formulae can get tricky.. I was havin a hell of a time pickin ones that kept things balanced.
08/01/2005 (9:17 am)
I jsut recently did this actually. I put the default start values to the player's datablock, then on the onAdd function, i initially set his speed, run force, etc. However this is all I have to do because my player's stats won't change much, if ever. But what you would want to do is just have an Update function like ya said and just recalculate your stats through your formula and set everything.But just to let ya know, those formulae can get tricky.. I was havin a hell of a time pickin ones that kept things balanced.
#9
08/01/2005 (9:31 am)
I know what you mean. I once made a Pong clone and it took so long to get hte physics equations just right, and those variables weren't even dynamic.
#10
08/01/2005 (11:51 am)
Agh, changing those variables don't seem to have ANY affect. How do I change the speed at all?
#11
maxBackwardSpeed = maxForwardSpeed; I can't move backward. The reason I want to do this is so I can have one agility value that affects all the speed values.
08/01/2005 (2:29 pm)
Oh, heh. the values in player.cs are overriding it. But now it's really weird. Any time I try to make a value equal to another value int he same datablock, it won't let me me. For example, if I try tomaxBackwardSpeed = maxForwardSpeed; I can't move backward. The reason I want to do this is so I can have one agility value that affects all the speed values.
#12
function Player::incAgility(%this, %value)
{
%this.getDataBlock().agility += %value;
%agility = %this.getDataBlock().agility;
%this.getDataBlock().runForce = 48 * 90 * (%agility / 10);
%this.getDataBlock().maxForwardSpeed = 14 * (%agility / 10);
%this.getDataBlock().maxBackwardSpeed = 13 * (%agility / 10);
%this.getDataBlock().maxSideSpeed = 13 * (%agility / 10);
%this.getDataBlock().maxUnderwaterForwardSpeed = 8.4 * (%agility / 10);
%this.getDataBlock().maxUnderwaterBackwardSpeed = 7.8 * (%agility / 10);
%this.getDataBlock().maxUnderwaterSideSpeed = 7.8 * (%agility / 10);
%this.getDataBlock().jumpForce = 8.3 * 90 * (%agility / 10);
}
08/02/2005 (7:30 am)
Okay, I finally managed to do this by creating a function:function Player::incAgility(%this, %value)
{
%this.getDataBlock().agility += %value;
%agility = %this.getDataBlock().agility;
%this.getDataBlock().runForce = 48 * 90 * (%agility / 10);
%this.getDataBlock().maxForwardSpeed = 14 * (%agility / 10);
%this.getDataBlock().maxBackwardSpeed = 13 * (%agility / 10);
%this.getDataBlock().maxSideSpeed = 13 * (%agility / 10);
%this.getDataBlock().maxUnderwaterForwardSpeed = 8.4 * (%agility / 10);
%this.getDataBlock().maxUnderwaterBackwardSpeed = 7.8 * (%agility / 10);
%this.getDataBlock().maxUnderwaterSideSpeed = 7.8 * (%agility / 10);
%this.getDataBlock().jumpForce = 8.3 * 90 * (%agility / 10);
}
#13
01/04/2008 (6:19 am)
Hopefully this method should work for taking from my "stat screen" and updating character info based on the "stat screen" variables... ill let you know if it works cause ive been having problems with ingame updating also.
#14
%this.getDataBlock().maxDamage = %this.maxHP;
%this.getDataBlock().maxEnergy = %this.maxMP;
%this.getDataBlock().jumpforce = %this.getDataBlock().jumpforce * 2;
for my project this is all i needed however i will add a more elaborate system like yours later
01/09/2008 (2:55 am)
Thanks for the code i managed:%this.getDataBlock().maxDamage = %this.maxHP;
%this.getDataBlock().maxEnergy = %this.maxMP;
%this.getDataBlock().jumpforce = %this.getDataBlock().jumpforce * 2;
for my project this is all i needed however i will add a more elaborate system like yours later
Torque Owner Brian "Bazz" Staudinger
export("$stat::*", "server/stats.cs", False);
apply them with something like %obj.setenergylevel($stat::tom::energy)