Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualCRYP7IK

Posted 09 May 2012 - 09:57 PM

I'd like to know how you guys would go about coding the effects of skills without just plan coding them in a massive list. Right now, I have a bunch of .txt files with skill names, stats, levels etc stored in them, and I get that info via file i/o.


So I am assuming a skill is, more like an action or an ability. For example, Fly-kick (Melee) or Fireball (Projectile) but could also be passive, like Health Regeneration V.

This can get very, very complicated but if you want to keep the way you were doing it where skills are defined in some file: You can have a class for each type of skill, Projectile, Melee, Passive, AoE all of which inherit from a base Skill class with a bool update function. Now a Projectile would just move in a direction or at a target (set in the data) and do damage, damage type and whatnot and maybe even set off another skill etc.

e.g.

class Skill
{
	virtual bool Update(deltaTime);
	virtual void OnCollision(collisionData)
	void ActivateSkill() // Put the skill into the skill manager or something...
	Entity* user;
	string Name;
	string Description;
	Skill* skillToUpgradeTo;

};

class Projectile : public Skill
{
	bool usesTarget;
	Image* image;
	bool usesEntityDirection;
	Entity* target;
	unsigned int Speed;
	Skill* skillToActivateAtEnd;
	bool Update(deltaTime);
	vector3 Direction;
};

Then the data could be for Fireball:

Type: Projectile
Name: Fireball
Description: Shoots a flaming ball of fire at your foes.
Target: 0
usesEntityDirection: 1
Image: "media\images\fireball.png"
speed: 3
skill to upgrade to: Super Fireball
skill to activate at end: Explosion


So, you would have some SkillLibrary class that would read the file for all the skills and give them all their data. You would need a switch on all the different types. (For example you would need to switch the type and if it was projectile you would create a projectile object and read the data from file as if it was a projectile object.

Now, the way I would actually do it is have an Action class that can be extended in scripts which could then create actions that do whatever the hell they want, although that system above could do almost anything it would be convoluted and weird.

Obviously this is highly dependant on your collision system and what actual abilities you want and all that kind of jazz, if you give more info on what game you are making and what you want to do with the skills that would make it easier to help you. (So I assume this is turn based? You could remove direction and uses entity direction in that case because you know they would always require a target)

#1CRYP7IK

Posted 09 May 2012 - 09:55 PM

I'd like to know how you guys would go about coding the effects of skills without just plan coding them in a massive list. Right now, I have a bunch of .txt files with skill names, stats, levels etc stored in them, and I get that info via file i/o.


So I am assuming a skill is, more like an action or an ability. For example, Fly-kick (Melee) or Fireball (Projectile) but could also be passive, like Health Regeneration V.

This can get very, very complicated but if you want to keep the way you were doing it where skills are defined in some file: You can have a class for each type of skill, Projectile, Melee, Passive, AoE all of which inherit from a base Skill class with a bool update function. Now a Projectile would just move in a direction or at a target (set in the data) and do damage, damage type and whatnot and maybe even set off another skill etc.

e.g.

class Skill
{
	virtual bool Update(deltaTime);
    virtual void OnCollision(collisionData)
	void ActivateSkill() // Put the skill into the skill manager or something...
	Entity* user;
	string Name;
	string Description;
	Skill* skillToUpgradeTo;

};

class Projectile : public Skill
{
	bool usesTarget;
	Image* image;
	bool usesEntityDirection;
	Entity* target;
	unsigned int Speed;
	Skill* skillToActivateAtEnd;
	bool Update(deltaTime);
    vector3 Direction;
};

Then the data could be for Fireball:

Type: Projectile
Name: Fireball
Description: Shoots a flaming ball of fire at your foes.
Target: 0
usesEntityDirection: 1
Image: "media\images\fireball.png"
speed: 3
skill to upgrade to: Super Fireball
skill to activate at end: Explosion


So, you would have some SkillLibrary class that would read the file for all the skills and give them all their data. You would need a switch on all the different types. (For example you would need to switch the type and if it was projectile you would create a projectile object and read the data from file as if it was a projectile object.

Now, the way I would actually do it is have an Action class that can be extended in scripts which could then create actions that do whatever the hell they want, although that system above could do almost anything it would be convoluted and weird.

Obviously this is highly dependant on your collision system and what actual abilities you want and all that kind of jazz, if you give more info on what game you are making and what you want to do with the skills that would make it easier to help you.

PARTNERS