2010-09-07 07:25:40 +02:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
|
|
|
|
//
|
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_SKILLTYPE_H_
|
|
|
|
|
#define _GLEST_GAME_SKILLTYPE_H_
|
|
|
|
|
|
|
|
|
|
#include "sound.h"
|
|
|
|
|
#include "vec.h"
|
|
|
|
|
#include "model.h"
|
|
|
|
|
#include "xml_parser.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "damage_multiplier.h"
|
|
|
|
|
#include "element_type.h"
|
|
|
|
|
#include "factory.h"
|
|
|
|
|
#include "sound_container.h"
|
|
|
|
|
#include "particle.h"
|
2011-06-25 09:31:01 +02:00
|
|
|
|
#include "upgrade_type.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
|
|
|
|
|
|
using Shared::Sound::StaticSound;
|
|
|
|
|
using Shared::Xml::XmlNode;
|
|
|
|
|
using Shared::Graphics::Vec3f;
|
|
|
|
|
using Shared::Graphics::Model;
|
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
using Shared::Util::MultiFactory;
|
|
|
|
|
|
|
|
|
|
class ParticleSystemTypeProjectile;
|
|
|
|
|
class ParticleSystemTypeSplash;
|
|
|
|
|
class UnitParticleSystemType;
|
|
|
|
|
class FactionType;
|
|
|
|
|
class TechTree;
|
|
|
|
|
class Lang;
|
|
|
|
|
class TotalUpgrade;
|
2011-06-25 10:53:53 +02:00
|
|
|
|
class Unit;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum Field{
|
|
|
|
|
fLand,
|
|
|
|
|
fAir,
|
|
|
|
|
|
|
|
|
|
fieldCount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum SkillClass{
|
|
|
|
|
scStop,
|
|
|
|
|
scMove,
|
|
|
|
|
scAttack,
|
|
|
|
|
scBuild,
|
|
|
|
|
scHarvest,
|
|
|
|
|
scRepair,
|
|
|
|
|
scBeBuilt,
|
|
|
|
|
scProduce,
|
|
|
|
|
scUpgrade,
|
|
|
|
|
scMorph,
|
|
|
|
|
scDie,
|
|
|
|
|
|
|
|
|
|
scCount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef list<UnitParticleSystemType*> UnitParticleSystemTypes;
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class SkillType
|
|
|
|
|
//
|
|
|
|
|
/// A basic action that an unit can perform
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
|
enum AttackBoostTargetType {
|
|
|
|
|
abtAlly,
|
|
|
|
|
abtFoe,
|
|
|
|
|
abtFaction,
|
|
|
|
|
abtUnitTypes,
|
|
|
|
|
abtAll
|
|
|
|
|
};
|
|
|
|
|
|
2011-06-25 09:31:01 +02:00
|
|
|
|
class AttackBoost {
|
|
|
|
|
public:
|
2011-06-25 10:53:53 +02:00
|
|
|
|
AttackBoost();
|
2011-06-25 22:44:46 +02:00
|
|
|
|
~AttackBoost();
|
2011-06-25 09:31:01 +02:00
|
|
|
|
bool enabled;
|
2011-06-25 22:44:46 +02:00
|
|
|
|
bool allowMultipleBoosts;
|
2011-06-25 09:31:01 +02:00
|
|
|
|
int radius;
|
2011-06-25 22:44:46 +02:00
|
|
|
|
AttackBoostTargetType targetType;
|
2011-06-25 09:31:01 +02:00
|
|
|
|
vector<const UnitType *> boostUnitList;
|
|
|
|
|
UpgradeTypeBase boostUpgrade;
|
2011-06-25 10:53:53 +02:00
|
|
|
|
|
2011-06-25 22:44:46 +02:00
|
|
|
|
UnitParticleSystemType *unitParticleSystemTypeForSourceUnit;
|
|
|
|
|
UnitParticleSystemType *unitParticleSystemTypeForAffectedUnit;
|
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
|
bool isAffected(const Unit *source, const Unit *dest) const;
|
2011-06-25 09:31:01 +02:00
|
|
|
|
};
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
2011-06-25 17:30:18 +02:00
|
|
|
|
class AnimationAttributes {
|
|
|
|
|
public:
|
|
|
|
|
AnimationAttributes() {
|
|
|
|
|
fromHp = 0;
|
|
|
|
|
toHp = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int fromHp;
|
|
|
|
|
int toHp;
|
|
|
|
|
};
|
|
|
|
|
|
2011-06-25 09:31:01 +02:00
|
|
|
|
class SkillType {
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
SkillClass skillClass;
|
|
|
|
|
string name;
|
|
|
|
|
int mpCost;
|
2011-02-06 19:33:49 +01:00
|
|
|
|
int hpCost;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
int speed;
|
|
|
|
|
int animSpeed;
|
2011-06-25 23:40:27 +02:00
|
|
|
|
|
|
|
|
|
int animationRandomCycleMaxcount;
|
2011-06-25 07:23:41 +02:00
|
|
|
|
vector<Model *> animations;
|
2011-06-25 17:30:18 +02:00
|
|
|
|
vector<AnimationAttributes> animationAttributes;
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
SoundContainer sounds;
|
|
|
|
|
float soundStartTime;
|
2011-06-25 07:23:41 +02:00
|
|
|
|
RandomGen random;
|
2011-06-25 09:31:01 +02:00
|
|
|
|
AttackBoost attackBoost;
|
2011-06-25 07:23:41 +02:00
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
public:
|
|
|
|
|
UnitParticleSystemTypes unitParticleSystemTypes;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
//varios
|
|
|
|
|
virtual ~SkillType();
|
2011-03-15 16:30:28 +01:00
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
2011-05-06 09:47:31 +02:00
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
2011-05-05 22:18:38 +02:00
|
|
|
|
string parentLoader);
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
2011-06-25 23:40:27 +02:00
|
|
|
|
bool CanCycleNextRandomAnimation(const int *animationRandomCycleCount) const;
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
//get
|
|
|
|
|
const string &getName() const {return name;}
|
|
|
|
|
SkillClass getClass() const {return skillClass;}
|
|
|
|
|
int getEpCost() const {return mpCost;}
|
2011-02-06 19:33:49 +01:00
|
|
|
|
int getHpCost() const {return hpCost;}
|
2010-09-07 07:25:40 +02:00
|
|
|
|
int getSpeed() const {return speed;}
|
|
|
|
|
int getAnimSpeed() const {return animSpeed;}
|
2011-06-25 23:40:27 +02:00
|
|
|
|
Model *getAnimation(float animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
StaticSound *getSound() const {return sounds.getRandSound();}
|
|
|
|
|
float getSoundStartTime() const {return soundStartTime;}
|
|
|
|
|
|
2011-06-25 10:53:53 +02:00
|
|
|
|
bool isAttackBoostEnabled() const { return attackBoost.enabled; }
|
|
|
|
|
const AttackBoost * getAttackBoost() const { return &attackBoost; }
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
//other
|
|
|
|
|
virtual string toString() const= 0;
|
|
|
|
|
virtual int getTotalSpeed(const TotalUpgrade *) const {return speed;}
|
|
|
|
|
static string skillClassToStr(SkillClass skillClass);
|
|
|
|
|
static string fieldToStr(Field field);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class StopSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class StopSkillType: public SkillType{
|
|
|
|
|
public:
|
|
|
|
|
StopSkillType();
|
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class MoveSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class MoveSkillType: public SkillType{
|
|
|
|
|
public:
|
|
|
|
|
MoveSkillType();
|
|
|
|
|
virtual string toString() const;
|
|
|
|
|
|
|
|
|
|
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class AttackSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class AttackSkillType: public SkillType{
|
|
|
|
|
private:
|
|
|
|
|
int attackStrength;
|
|
|
|
|
int attackVar;
|
|
|
|
|
int attackRange;
|
|
|
|
|
const AttackType *attackType;
|
|
|
|
|
bool attackFields[fieldCount];
|
|
|
|
|
float attackStartTime;
|
|
|
|
|
|
2011-02-06 19:33:49 +01:00
|
|
|
|
string spawnUnit;
|
|
|
|
|
int spawnUnitcount;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
bool projectile;
|
|
|
|
|
ParticleSystemTypeProjectile* projectileParticleSystemType;
|
|
|
|
|
SoundContainer projSounds;
|
|
|
|
|
|
|
|
|
|
bool splash;
|
|
|
|
|
int splashRadius;
|
|
|
|
|
bool splashDamageAll;
|
|
|
|
|
ParticleSystemTypeSplash* splashParticleSystemType;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AttackSkillType();
|
|
|
|
|
~AttackSkillType();
|
2011-03-15 16:30:28 +01:00
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
2011-05-06 09:47:31 +02:00
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
2011-05-05 22:18:38 +02:00
|
|
|
|
string parentLoader);
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual string toString() const;
|
|
|
|
|
|
|
|
|
|
//get
|
|
|
|
|
int getAttackStrength() const {return attackStrength;}
|
|
|
|
|
int getAttackVar() const {return attackVar;}
|
|
|
|
|
int getAttackRange() const {return attackRange;}
|
|
|
|
|
const AttackType *getAttackType() const {return attackType;}
|
|
|
|
|
bool getAttackField(Field field) const {return attackFields[field];}
|
|
|
|
|
float getAttackStartTime() const {return attackStartTime;}
|
2011-02-06 19:33:49 +01:00
|
|
|
|
string getSpawnUnit() const {return spawnUnit;}
|
2011-02-11 08:39:58 +01:00
|
|
|
|
int getSpawnUnitCount() const {return spawnUnitcount;}
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
|
|
|
|
//get proj
|
|
|
|
|
bool getProjectile() const {return projectile;}
|
|
|
|
|
ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;}
|
|
|
|
|
StaticSound *getProjSound() const {return projSounds.getRandSound();}
|
|
|
|
|
|
|
|
|
|
//get splash
|
|
|
|
|
bool getSplash() const {return splash;}
|
|
|
|
|
int getSplashRadius() const {return splashRadius;}
|
|
|
|
|
bool getSplashDamageAll() const {return splashDamageAll;}
|
|
|
|
|
ParticleSystemTypeSplash * getSplashParticleType() const {return splashParticleSystemType;}
|
|
|
|
|
|
|
|
|
|
//misc
|
|
|
|
|
int getTotalAttackStrength(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
int getTotalAttackRange(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class BuildSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class BuildSkillType: public SkillType{
|
|
|
|
|
public:
|
|
|
|
|
BuildSkillType();
|
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class HarvestSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class HarvestSkillType: public SkillType{
|
|
|
|
|
public:
|
|
|
|
|
HarvestSkillType();
|
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class RepairSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class RepairSkillType: public SkillType{
|
|
|
|
|
public:
|
|
|
|
|
RepairSkillType();
|
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class ProduceSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class ProduceSkillType: public SkillType{
|
2011-07-08 01:02:46 +02:00
|
|
|
|
private:
|
|
|
|
|
bool animProgressBound;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
public:
|
|
|
|
|
ProduceSkillType();
|
2011-07-08 01:02:46 +02:00
|
|
|
|
bool getAnimProgressBound() const {return animProgressBound;}
|
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
|
|
|
|
string parentLoader);
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual string toString() const;
|
|
|
|
|
|
|
|
|
|
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class UpgradeSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class UpgradeSkillType: public SkillType{
|
2011-07-08 01:02:46 +02:00
|
|
|
|
private:
|
|
|
|
|
bool animProgressBound;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
public:
|
|
|
|
|
UpgradeSkillType();
|
2011-07-08 01:02:46 +02:00
|
|
|
|
bool getAnimProgressBound() const {return animProgressBound;}
|
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
|
|
|
|
string parentLoader);
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual string toString() const;
|
|
|
|
|
|
|
|
|
|
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class BeBuiltSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class BeBuiltSkillType: public SkillType{
|
2011-07-02 18:07:04 +02:00
|
|
|
|
private:
|
2011-07-08 01:02:46 +02:00
|
|
|
|
bool animProgressBound;
|
2011-07-02 18:07:04 +02:00
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
public:
|
|
|
|
|
BeBuiltSkillType();
|
2011-07-08 01:02:46 +02:00
|
|
|
|
bool getAnimProgressBound() const {return animProgressBound;}
|
2011-07-02 21:02:25 +02:00
|
|
|
|
|
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
|
|
|
|
string parentLoader);
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class MorphSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class MorphSkillType: public SkillType{
|
2011-07-08 01:02:46 +02:00
|
|
|
|
private:
|
|
|
|
|
bool animProgressBound;
|
|
|
|
|
|
2010-09-07 07:25:40 +02:00
|
|
|
|
public:
|
|
|
|
|
MorphSkillType();
|
2011-07-08 01:02:46 +02:00
|
|
|
|
bool getAnimProgressBound() const {return animProgressBound;}
|
2010-09-07 07:25:40 +02:00
|
|
|
|
|
2011-07-08 01:02:46 +02:00
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
|
|
|
|
string parentLoader);
|
|
|
|
|
|
|
|
|
|
virtual string toString() const;
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class DieSkillType
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class DieSkillType: public SkillType{
|
|
|
|
|
private:
|
|
|
|
|
bool fade;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
DieSkillType();
|
|
|
|
|
bool getFade() const {return fade;}
|
|
|
|
|
|
2011-03-15 16:30:28 +01:00
|
|
|
|
virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt,
|
2011-05-06 09:47:31 +02:00
|
|
|
|
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
|
2011-05-05 22:18:38 +02:00
|
|
|
|
string parentLoader);
|
2010-09-07 07:25:40 +02:00
|
|
|
|
virtual string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class SkillFactory
|
|
|
|
|
// ===============================
|
|
|
|
|
|
|
|
|
|
class SkillTypeFactory: public MultiFactory<SkillType>{
|
|
|
|
|
private:
|
|
|
|
|
SkillTypeFactory();
|
|
|
|
|
public:
|
|
|
|
|
static SkillTypeFactory &getInstance();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
|
|
#endif
|