Creating player stats & skills for RPG game
by Bendik Stang · in Torque Game Engine · 04/14/2002 (3:32 am) · 6 replies
(I'm quite new to the torque engine and game programming in general.)
I'm trying to figure out how to create the stats and skills needed for a rpg type game.
I'd like to make the str/dex have an affect on the damage the player gives/takes, as well as skills that can affect other aspects of the gameplay.
So, where do I start? (I'm looking at the inventory class, considering using it as a reference for a stats/skill class)
If anyone feel like making a tutorial on this, I'm sure many others would appreciate this as well.
Any guidance would be deeply appreciated.
:)
....Edited:
I have created a skill.h from the inventory.h
Am I on the right track, or will this eventually lead to a dead end?
//////////////////////////////////////////////////////////////////////////////////////
// skills.h - Header File for the Skill Manager
//////////////////////////////////////////////////////////////////////////////////////
#ifndef _SKILL_H_
#define _SKILL_H_
#include "platform/platform.h"
class Skill {
public:
Skill();
~Skill();
void AddSkill(char* name, char* points, char* maxPoints, char* description);
// add skill (SkillName, SkillPoints, SkillMaxPoints, SkillDescription)
void RemoveSkill(char* name);
void GetSkill(char* type, char* rettype, char* retvalue);
// not sure what this does...
bool MoveCurrent(char* move); //move the currentpos pointer next, last, or first
bool IncPoints(char* name, char* fpoints);
bool DecPoints(char* name, char* fpoints);
bool SetPoints(char* name, char* fpoints);
void ClearSkill();
private:
struct SkillName {
char Name[256];
f32 Points;
//char Type[256]; //not needed?
char Description[256];
f32 MaxPoints;
};
struct SkillLink {
SkillName SkillData;
SkillLink* nextLink;
SkillLink* lastLink;
};
SkillLink* FirstSkillInList;
SkillLink* CurrentSkillInList;
void AddLink(char* name, char* points, char* maxPoints, char* description); //Add a link to the link list
void DeleteLink(char* name); //delete a link from the link list
bool NextLink(); //Go to the next link in the chain
bool LastLink(); //Go to the last link visited in the chain
SkillLink* GetLink(char* name); //get the link equal to the name
};
#endif
I'm trying to figure out how to create the stats and skills needed for a rpg type game.
I'd like to make the str/dex have an affect on the damage the player gives/takes, as well as skills that can affect other aspects of the gameplay.
So, where do I start? (I'm looking at the inventory class, considering using it as a reference for a stats/skill class)
If anyone feel like making a tutorial on this, I'm sure many others would appreciate this as well.
Any guidance would be deeply appreciated.
:)
....Edited:
I have created a skill.h from the inventory.h
Am I on the right track, or will this eventually lead to a dead end?
//////////////////////////////////////////////////////////////////////////////////////
// skills.h - Header File for the Skill Manager
//////////////////////////////////////////////////////////////////////////////////////
#ifndef _SKILL_H_
#define _SKILL_H_
#include "platform/platform.h"
class Skill {
public:
Skill();
~Skill();
void AddSkill(char* name, char* points, char* maxPoints, char* description);
// add skill (SkillName, SkillPoints, SkillMaxPoints, SkillDescription)
void RemoveSkill(char* name);
void GetSkill(char* type, char* rettype, char* retvalue);
// not sure what this does...
bool MoveCurrent(char* move); //move the currentpos pointer next, last, or first
bool IncPoints(char* name, char* fpoints);
bool DecPoints(char* name, char* fpoints);
bool SetPoints(char* name, char* fpoints);
void ClearSkill();
private:
struct SkillName {
char Name[256];
f32 Points;
//char Type[256]; //not needed?
char Description[256];
f32 MaxPoints;
};
struct SkillLink {
SkillName SkillData;
SkillLink* nextLink;
SkillLink* lastLink;
};
SkillLink* FirstSkillInList;
SkillLink* CurrentSkillInList;
void AddLink(char* name, char* points, char* maxPoints, char* description); //Add a link to the link list
void DeleteLink(char* name); //delete a link from the link list
bool NextLink(); //Go to the next link in the chain
bool LastLink(); //Go to the last link visited in the chain
SkillLink* GetLink(char* name); //get the link equal to the name
};
#endif
#3
With this approach, did you give these skills to everyone in script? Or do you mean the player class in C++(player.cc?)?
I am in the process of figuring out the best way to add dynamic skills for individual bots and players.
Thanks!
-Jeff
05/07/2003 (7:55 am)
@JoshWith this approach, did you give these skills to everyone in script? Or do you mean the player class in C++(player.cc?)?
I am in the process of figuring out the best way to add dynamic skills for individual bots and players.
Thanks!
-Jeff
#4
05/12/2003 (8:50 am)
Just out of curiousity how are you planning to "store" the player object so that skills/stats are persistent? I've been wondering if I need to write my own database for this or try to add access to MySQl (or any other database) to Torque. I would hate to just serialize the player object to a flat file because of potential character hacking. Any ideas?
#5
I'm currently putting the finishing touches on XML based persistance for Torque objects. Part of the implementation allows you to specify a storage medium (i.e "file://" or "db://") that'll get you a part of the way...
I'm not sure what your concern about hacking characters is. If you don't want them hacked store them on the server.
05/12/2003 (12:50 pm)
Cory,I'm currently putting the finishing touches on XML based persistance for Torque objects. Part of the implementation allows you to specify a storage medium (i.e "file://" or "db://") that'll get you a part of the way...
I'm not sure what your concern about hacking characters is. If you don't want them hacked store them on the server.
#6
$PlayerSkills =
%Pointer1 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer2 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer3 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer4 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4;
Then when I need to access a skill, I just scan for the pointer, and count over to the appropriate skill and grab the info. At least thats the theory, I am in the middle of implimenting this, so wish me luck.
EDIT: Clarity
-Jeff
05/13/2003 (4:18 am)
I am trying a 2D array method in script. First storing a pointer to the player, which is then followed by skill info for that player, then another pointer for another player, then more skills, etc... It looks something like this:$PlayerSkills =
%Pointer1 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer2 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer3 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4 @
%Pointer4 @ %Skill1 @ %Skill2 @ %Skill3 @ %Skill4;
Then when I need to access a skill, I just scan for the pointer, and count over to the appropriate skill and grab the info. At least thats the theory, I am in the middle of implimenting this, so wish me luck.
EDIT: Clarity
-Jeff
Torque Owner Josh Albrecht
Interesting approach to the skills. I had simply planned on giving EVERY skill to everyone, but giving them a rank of 0. Then it is a simple matter of skill++ to make them better at it. :) I wont have very many skills, so this seems the way to go about it to me. Using a linked list just feels like overkill.