2007-06-08 22:56:35 +03:00
# ifndef CCREATUREHANDLER_H
# define CCREATUREHANDLER_H
2008-04-11 20:41:02 +03:00
# include "../CPlayerInterface.h"
2007-06-08 22:56:35 +03:00
# include <string>
# include <vector>
2007-07-28 18:23:15 +03:00
# include <map>
2008-01-06 20:07:03 +02:00
# include "CDefHandler.h"
2007-11-19 00:58:28 +02:00
class CDefHandler ;
struct SDL_Surface ;
2007-06-08 22:56:35 +03:00
class CCreature
{
public :
2007-10-15 23:59:17 +03:00
std : : string namePl , nameSing , nameRef ; //name in singular and plural form; and reference name
2008-04-04 20:30:53 +03:00
std : : vector < int > cost ; //cost[res_id] - amount of that resource
int fightValue , AIValue , growth , hordeGrowth , hitPoints , speed , attack , defence , shots , spells ;
2007-06-08 22:56:35 +03:00
int low1 , low2 , high1 , high2 ; //TODO - co to w og�le jest???
2008-02-05 05:56:45 +02:00
int level ; // 0 - unknown
2007-06-08 22:56:35 +03:00
std : : string abilityText ; //description of abilities
std : : string abilityRefs ; //references to abilities, in textformat
2008-03-05 19:01:41 +02:00
std : : string animDefName ;
2007-06-08 22:56:35 +03:00
int idNumber ;
2008-04-04 20:30:53 +03:00
int faction ; //-1 = neutral
2007-06-18 13:49:06 +03:00
///animation info
float timeBetweenFidgets , walkAnimationTime , attackAnimationTime , flightAnimationDistance ;
int upperRightMissleOffsetX , rightMissleOffsetX , lowerRightMissleOffsetX , upperRightMissleOffsetY , rightMissleOffsetY , lowerRightMissleOffsetY ;
float missleFrameAngles [ 12 ] ;
int troopCountLocationOffset , attackClimaxFrame ;
///end of anim info
2007-07-12 21:04:02 +03:00
//for some types of towns
bool isDefinite ; //if the creature type is wotn dependent, it should be true
int indefLevel ; //only if indefinite
bool indefUpgraded ; //onlu if inddefinite
//end
2007-07-17 18:13:46 +03:00
CDefHandler * battleAnimation ;
2007-06-08 22:56:35 +03:00
//TODO - zdolno�ci - na typie wyliczeniowym czy czym�
2008-02-25 01:06:27 +02:00
static int getQuantityID ( int quantity ) ; //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion
2007-06-08 22:56:35 +03:00
} ;
2007-06-11 20:21:27 +03:00
class CCreatureSet //seven combined creatures
{
2007-06-13 23:17:48 +03:00
public :
2007-07-28 18:23:15 +03:00
std : : map < int , std : : pair < CCreature * , int > > slots ;
//CCreature * slot1, * slot2, * slot3, * slot4, * slot5, * slot6, * slot7; //types of creatures on each slot
//unsigned int s1, s2, s3, s4, s5, s6, s7; //amounts of units in slots
2007-06-11 20:21:27 +03:00
bool formation ; //false - wide, true - tight
} ;
2007-06-08 22:56:35 +03:00
class CCreatureHandler
{
public :
2007-10-17 01:39:11 +03:00
std : : map < int , SDL_Surface * > smallImgs ; //creature ID -> small 32x32 img of creature; //ID=-2 is for blank (black) img; -1 for the border
2008-01-12 13:32:40 +02:00
std : : map < int , SDL_Surface * > bigImgs ; //creature ID -> big 58x64 img of creature; //ID=-2 is for blank (black) img; -1 for the border
2008-04-04 20:30:53 +03:00
std : : map < int , SDL_Surface * > backgrounds ; //castle ID -> 100x130 background creature image // -1 is for neutral
2007-06-08 22:56:35 +03:00
std : : vector < CCreature > creatures ;
2008-02-05 05:56:45 +02:00
std : : map < int , std : : vector < CCreature * > > levelCreatures ; //level -> list of creatures
2007-10-15 23:59:17 +03:00
std : : map < std : : string , int > nameToID ;
2007-06-08 22:56:35 +03:00
void loadCreatures ( ) ;
2007-06-18 13:49:06 +03:00
void loadAnimationInfo ( ) ;
void loadUnitAnimInfo ( CCreature & unit , std : : string & src , int & i ) ;
2007-07-17 18:13:46 +03:00
void loadUnitAnimations ( ) ;
2007-06-08 22:56:35 +03:00
} ;
2008-04-07 20:51:46 +03:00
class CCreatureAnimation : public CIntObject
2008-01-06 20:07:03 +02:00
{
private :
2008-04-07 20:51:46 +03:00
int totalEntries , DEFType , totalBlocks ;
2008-01-06 20:07:03 +02:00
bool allowRepaint ;
int length ;
BMPPalette palette [ 256 ] ;
unsigned int * RWEntries ;
int * RLEntries ;
struct SEntry
{
std : : string name ;
int offset ;
int group ;
} ;
std : : vector < SEntry > SEntries ;
char id [ 2 ] ;
std : : string defName , curDir ;
int readNormalNr ( int pos , int bytCon , unsigned char * str = NULL , bool cyclic = false ) ;
2008-03-23 19:25:38 +02:00
void putPixel ( SDL_Surface * dest , const int & ftcp , const BMPPalette & color , const unsigned char & palc , const bool & yellowBorder ) const ;
2008-01-06 20:07:03 +02:00
////////////
unsigned char * FDef ; //animation raw data
unsigned int curFrame ; //number of currently displayed frame
unsigned int frames ; //number of frames
int type ; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
public :
2008-04-07 20:51:46 +03:00
int fullWidth , fullHeight ; //read-only, please!
2008-01-06 20:07:03 +02:00
CCreatureAnimation ( std : : string name ) ; //c-tor
2008-03-05 19:01:41 +02:00
~ CCreatureAnimation ( ) ; //d-tor //not necessery ATM
2008-01-06 20:07:03 +02:00
void setType ( int type ) ; //sets type of animation and cleares framecount
int getType ( ) const ; //returns type of animation
2008-03-23 19:25:38 +02:00
int nextFrame ( SDL_Surface * dest , int x , int y , bool attacker , bool incrementFrame = true , bool yellowBorder = false ) ; //0 - success, any other - error //print next
2008-04-04 20:30:53 +03:00
int nextFrameMiddle ( SDL_Surface * dest , int x , int y , bool attacker , bool incrementFrame = true , bool yellowBorder = false ) ; //0 - success, any other - error //print next
2008-01-06 20:07:03 +02:00
} ;
2007-06-08 22:56:35 +03:00
# endif //CCREATUREHANDLER_H