Game Development Community

Rpg Stats

by Wayne Eversole · in Torque Game Engine · 02/01/2005 (1:57 pm) · 27 replies

Anyone happen to have a RPG Stat's they could share?
Like just one stat of str or int that works with torque?
Im just needing an example to get started and to build upon.
Page «Previous 1 2
#1
02/01/2005 (2:24 pm)
You mean a system of keeping track of a player's levels and stuff? I don't think there's anything in the resources...however, if you have experience with mysql, you could probably find it useful to keep track of the stats there.
#2
02/09/2005 (10:13 am)
I am looking for more of a example on how to set up stats in torques default char. I just like an example on how to setup stats for the player that he can use and change as you fight.
ill worry about the other stuff when i get to that point :)
Thanks
#3
02/09/2005 (1:52 pm)
Search resources for character attributes and you should come upon the tutorial. It implements attributes that are different from player to player... HTH
#4
02/09/2005 (4:28 pm)
I have done some searching , i come up with nothing.
can someone post some links that might help?
Thanks
#5
02/09/2005 (5:57 pm)
I have done some searching , i come up with nothing.
can someone post some links that might help?
Thanks
#6
02/09/2005 (7:42 pm)
Wayne,

Here's one way
open Player.h

somehwere inside of struct PlayerData: public ShapeBaseData

add
//Player Abilities
   S32  ability_STRENGTH; ///< how strong your character is
   S32  ability_DEXTERITY;///< how dexterous your character is

open Player.cc
in PlayerData::PlayerData()
set them to their defaults like

ability_STRENGTH = 1; 
  ability_DEXTERITY = 1;

in void PlayerData::initPersistFields()
add
addField("ability_STRENGTH", TypeS32, Offset(ability_STRENGTH, PlayerData));
  addField("ability_DEXTERITY", TypeS32, Offset(ability_DEXTERITY, PlayerData));

in void PlayerData::packData(BitStream* stream)
add
stream->write(ability_STRENGTH);
   stream->write(ability_DEXTERITY);

in void PlayerData::unpackData(BitStream* stream)
add
stream->read(&ability_STRENGTH);
   stream->read(&ability_DEXTERITY);

make sure that the ordering of things in unpackData matches up with where you put things in packData

now you can access it in the game with
%player.getDataBlock().ability_STRENGTH;

and
%player.getDataBlock().ability_DEXTERITY;


you can initialize them to different values inside of the datablock for your player, for instance PlayerBody


of course there is lots more you will want to do with stats, but hopefully this will show you at least one way you could add a couple stats to your game.
good luck!
#7
02/09/2005 (8:41 pm)
This is terrific information, Clint, thanks for posting it! Just reading through that sample code, I've learned a lot about how the game architecture works.
#8
02/09/2005 (8:58 pm)
Great, thanks Clint, ill get right to work.
Thank you
#9
02/09/2005 (10:18 pm)
Very welcome, glad to help
now you better make me a fun rpg to play :)
#10
02/09/2005 (11:59 pm)
Clint, that's some very usefull information! Thanks for posting!

Nick
#11
02/10/2005 (9:35 am)
I picked up Torque with the fancy idea of giving my old text MUD a GUI interface. It's going to be a lot of work but I'm starting to see how the pieces will fit together. If the project ever gets off the ground I'll post about it. :)
#12
02/10/2005 (11:46 am)
Just wondering if I could get a example of a player.cs file with skills in place.
Thanks
#13
02/11/2005 (4:51 pm)
Ill take that as a no since no one has posted anything els.
when it comes to programming i am the biggest nob lol
#14
02/11/2005 (5:16 pm)
There's no general way of making stats, since it's so game dependant.

If you can't think of a way to do it, maybe you should reconsider it and start with something easier.
That's what I did when I wanted to start with the player levels and attributes. It's a very cool thing and you want to do it straight away :)

Clint shows a very good example, and it can be even easier than that. My advice would be to look at the two MySQL tutorials by me and Daniel Nielsen (might be more, haven't searched).. they will get you a good idea of how you access a database and storing it's tables and values as a variable.

Then mess around with datablocks and how they update, and learn how to access these values from the database.
Some values can be changed on the fly, some need you to destroy the player object and recreate it.

Someone recoded Torque to update these on the fly, but I can't remember his name. You should be able to find the thread by searching a bit though. Good luck.
#15
02/24/2005 (6:10 pm)
Im not claming to be a programmer and i would like a example of stats on a char with the other example above.
Trying to get an idea what all would be involed in programming character stats.
Thanks
#16
02/25/2005 (9:51 am)
Hey Wayne, where are you stuck? what have you tried so far? show us and maybe we can point you in the right direction.

once you have basic stats in place you simply access them in the script...hmm lets see.

how about this: (warning untested code just pulled out of my arse)

in game.cs in your starter.fps/server/scripts directory
function GameConnection::onClientEnterGame(%this)
{
   commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);

   // Create a new camera object.
   %this.camera = new Camera() {
      dataBlock = Observer;
   };
   MissionCleanup.add( %this.camera );
   %this.camera.scopeToClient(%this);

   // Setup game parameters, the onConnect method currently starts
   // everyone with a 0 score.
   %this.score = 0;

   // Create a player object.
   %this.spawnPlayer();
   
   ///NEW STUFF TESTING STATS 
   if(%this.player.getDataBlock().ability_STRENGTH > 10)
  {
      %text = "My what a strong player you are for entering this game, your muscles buldge with the power of 10 bears!";
  }
   else
  {
       %text = "You are a weakling, your puny arms are ALREADY TIRED how can you go on being so weak...go re-roll your strength!";
  }

   centerPrint( %this, %text, 5, 3 );
  
}


you might have to put the centerprint in a schedule to pop up a couple seconds later to get it to show I'm not sure....but that's the idea of one way you could use the stat like I showed above.
#17
03/27/2005 (5:31 pm)
What about the GUI? I tried putting %player.getDataBlock().attribute_STRENGTH (my variable) in the "variable" feild
#18
03/31/2005 (4:58 pm)
I don't think the client would be aware of that stat, maybe but it's doubtful.
Probably have to pass it via CommandToClient and store it clientside then access it.

CommandToClient("UpdateStats","STR",%player.getDataBlock().attribute_STRENGTH);
Then in the client somewhere have this.

ClientCmdUpdateStats(%stat,%value){
      $Stats[%stat] = %value;
}

Then in your GUI have the variable be $Stats['STR']; or whatever stat.
#19
04/03/2005 (9:30 pm)
For some reasion i get this error no matter where i put the CommandtoClient string
starter.fps/server/scripts/game.cs Line: 245 - Syntax error.
>>> Advanced script error report. Line 489.
>>> Some error context, with ## on sides of error halt:
CommandToClient("UpdateStats","ability_STRENGTH",%player.getDataBlock().ability_STRENGTH);

}
centerPrint( %this, %text, 5, 3 );
}##
##

im learning so be kind :)
Thanks
#20
04/04/2005 (10:25 pm)
Try using single quotes also a terminating semicolon may be needed.
Page «Previous 1 2