Actor.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2007 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef ACTOR_H
00020 #define ACTOR_H
00021 
00022 #include "Container.h"
00023 #include "intrinsics.h"
00024 #include "Animation.h"
00025 
00026 class ActorAnimProcess;
00027 struct PathfindingState;
00028 class CombatProcess;
00029 
00030 class Actor : public Container
00031 {
00032         friend class ActorAnimProcess;
00033         friend class AnimationTracker;
00034 public:
00035         Actor();
00036         ~Actor();
00037 
00038         sint16 getStr() const { return strength; }
00039         void setStr(sint16 str) { strength = str; }
00040         sint16 getDex() const { return dexterity; }
00041         void setDex(sint16 dex) { dexterity = dex; }
00042         sint16 getInt() const { return intelligence; }
00043         void setInt(sint16 int_) { intelligence = int_; }
00044         uint16 getHP() const { return hitpoints; }
00045         void setHP(uint16 hp) { hitpoints = hp; }
00046         sint16 getMana() const { return mana; }
00047         void setMana(sint16 mp) { mana = mp; }
00048 
00049         sint16 getMaxMana() const;
00050         uint16 getMaxHP() const;
00051 
00052         bool isDead() const { return (actorflags & ACT_DEAD) != 0; }
00053 
00054         bool isInCombat() const { return (actorflags & ACT_INCOMBAT) != 0; }
00055         void toggleInCombat() {
00056                 if (isInCombat()) clearInCombat(); else setInCombat();
00057         }
00058 
00059         CombatProcess* getCombatProcess();
00060         virtual void setInCombat();
00061         virtual void clearInCombat();
00062 
00063         uint16 getAlignment() const { return alignment; }
00064         void setAlignment(uint16 a) { alignment = a; }
00065         uint16 getEnemyAlignment() const { return enemyalignment; }
00066         void setEnemyAlignment(uint16 a) { enemyalignment = a; }
00067 
00068         Animation::Sequence getLastAnim() const { return lastanim; }
00069         void setLastAnim(Animation::Sequence anim) { lastanim = anim; }
00070         uint16 getDir() const { return direction; }
00071         void setDir(uint16 dir) { direction = dir; }
00072         sint32 getFallStart() const { return fallstart; }
00073         void setFallStart(sint32 z) { fallstart = z; }
00074         void setUnk0C(uint8 b) { unk0C = b; }
00075 
00076         uint32 getActorFlags() const { return actorflags; }
00077         void setActorFlag(uint32 mask) { actorflags |= mask; }
00078         void clearActorFlag(uint32 mask) { actorflags &= ~mask; }
00079 
00082         bool loadMonsterStats();
00083 
00086         bool giveTreasure();
00087 
00088         virtual void teleport(int mapnum, sint32 x, sint32 y, sint32 z);
00089 
00090         virtual bool removeItem(Item* item);
00091 
00093         uint16 schedule(uint32 time);
00094 
00095         bool setEquip(Item* item, bool checkwghtvol=false);
00096         uint16 getEquip(uint32 type);
00097 
00098         virtual uint32 getArmourClass();
00099         virtual uint16 getDefenseType();
00100         virtual sint16 getAttackingDex();
00101         virtual sint16 getDefendingDex();
00102 
00103         virtual uint16 getDamageType();
00104         virtual int getDamageAmount();
00105 
00111         int calculateAttackDamage(uint16 other, int damage, uint16 type);
00112 
00116         virtual void receiveHit(uint16 other, int dir, int damage, uint16 type);
00117 
00121         virtual ProcId die(uint16 damageType);
00122 
00124         void killAllButCombatProcesses();
00125 
00128         ProcId killAllButFallAnims(bool death);
00129 
00131         bool areEnemiesNear();
00132 
00135         uint16 cSetActivity(int activity);
00136 
00139         uint16 doAnim(Animation::Sequence anim, int dir, unsigned int steps=0);
00140 
00142         bool hasAnim(Animation::Sequence anim);
00143 
00151         Animation::Result tryAnim(Animation::Sequence anim, int dir, unsigned int steps=0, PathfindingState* state=0);
00152 
00154         static Actor* createActor(uint32 shape, uint32 frame);
00155 
00156         virtual uint16 assignObjId(); // assign an NPC objid
00157 
00158         virtual void dumpInfo();
00159 
00160         bool loadData(IDataSource* ids, uint32 version);
00161 
00162         // p_dynamic_cast stuff
00163         ENABLE_RUNTIME_CLASSTYPE();
00164 
00165         INTRINSIC(I_isNPC);
00166         INTRINSIC(I_getDir);
00167         INTRINSIC(I_getLastAnimSet);
00168         INTRINSIC(I_pathfindToItem);
00169         INTRINSIC(I_pathfindToPoint);
00170         INTRINSIC(I_getStr);
00171         INTRINSIC(I_getDex);
00172         INTRINSIC(I_getInt);
00173         INTRINSIC(I_getHp);
00174         INTRINSIC(I_getMana);
00175         INTRINSIC(I_getAlignment);
00176         INTRINSIC(I_getEnemyAlignment);
00177         INTRINSIC(I_setStr);
00178         INTRINSIC(I_setDex);
00179         INTRINSIC(I_setInt);
00180         INTRINSIC(I_setHp);
00181         INTRINSIC(I_setMana);
00182         INTRINSIC(I_setAlignment);
00183         INTRINSIC(I_setEnemyAlignment);
00184         INTRINSIC(I_getMap);
00185         INTRINSIC(I_teleport);
00186         INTRINSIC(I_doAnim);
00187         INTRINSIC(I_isInCombat);
00188         INTRINSIC(I_setInCombat);
00189         INTRINSIC(I_clrInCombat);
00190         INTRINSIC(I_setTarget);
00191         INTRINSIC(I_getTarget);
00192         INTRINSIC(I_isEnemy);
00193         INTRINSIC(I_isDead);
00194         INTRINSIC(I_setDead);
00195         INTRINSIC(I_clrDead);
00196         INTRINSIC(I_isImmortal);
00197         INTRINSIC(I_setImmortal);
00198         INTRINSIC(I_clrImmortal);
00199         INTRINSIC(I_isWithstandDeath);
00200         INTRINSIC(I_setWithstandDeath);
00201         INTRINSIC(I_clrWithstandDeath);
00202         INTRINSIC(I_isFeignDeath);
00203         INTRINSIC(I_setFeignDeath);
00204         INTRINSIC(I_clrFeignDeath);
00205         INTRINSIC(I_areEnemiesNear);
00206         INTRINSIC(I_isBusy);
00207         INTRINSIC(I_createActor);
00208         INTRINSIC(I_cSetActivity);
00209         INTRINSIC(I_setAirWalkEnabled);
00210         INTRINSIC(I_getAirWalkEnabled);
00211         INTRINSIC(I_schedule);
00212         INTRINSIC(I_getEquip);
00213         INTRINSIC(I_setEquip);
00214 
00215         enum ActorFlags {
00216                 ACT_INVINCIBLE     = 0x000001, // flags from npcdata byte 0x1B
00217                 ACT_ASCENDING      = 0x000002,
00218                 ACT_DESCENDING     = 0x000004,
00219                 ACT_ANIMLOCK       = 0x000008,
00220 
00221                 ACT_FIRSTSTEP      = 0x000400, // flags from npcdata byte 0x2F
00222                 ACT_INCOMBAT       = 0x000800,
00223                 ACT_DEAD           = 0x001000,
00224                 ACT_COMBATRUN      = 0x008000,
00225                 
00226                 ACT_AIRWALK        = 0x010000, // flags from npcdata byte 0x30
00227                 ACT_IMMORTAL       = 0x040000,
00228                 ACT_WITHSTANDDEATH = 0x080000,
00229                 ACT_FEIGNDEATH     = 0x100000,
00230                 ACT_STUNNED        = 0x200000,
00231                 ACT_POISONED       = 0x400000,
00232                 ACT_PATHFINDING    = 0x800000
00233         };
00234 
00235 protected:
00236         virtual void saveData(ODataSource* ods);
00237 
00238         sint16 strength;
00239         sint16 dexterity;
00240         sint16 intelligence;
00241         uint16 hitpoints;
00242         sint16 mana;
00243 
00244         uint16 alignment, enemyalignment;
00245 
00246         Animation::Sequence lastanim;
00247         uint16 animframe;
00248         uint16 direction;
00249 
00250         sint32 fallstart;
00251         uint8 unk0C; // unknown byte 0x0C from npcdata.dat
00252 
00253         uint32 actorflags;
00254 };
00255 
00256 
00257 #endif

Generated on Fri Jul 27 22:27:08 2007 for pentagram by  doxygen 1.4.7