29 #include "saga2/objects.h" 30 #include "saga2/saveload.h" 34 class ActorAssignment;
39 const int kBandingDist = kSectorSize * 2;
40 const int kActorScriptVars = 4;
65 enum ArmorObjectTypes {
82 uint8 damageAbsorbtion,
98 kSkillBasePercent = 100,
99 kSkillFracPointsPerLevel = 5,
101 kSkillMaxLevel = kSkillFracPointsPerLevel * kSkillLevels
139 uint8 &skill(int16
id) {
141 case kSkillIDArchery:
return archery;
142 case kSkillIDSwordcraft:
return swordcraft;
143 case kSkillIDShieldcraft:
return shieldcraft;
144 case kSkillIDBludgeon:
return bludgeon;
145 case kSkillIDThrowing:
return throwing;
146 case kSkillIDSpellcraft:
return spellcraft;
147 case kSkillIDStealth:
return stealth;
148 case kSkillIDAgility:
return agility;
149 case kSkillIDBrawn:
return brawn;
150 case kSkillIDLockpick:
return lockpick;
151 case kSkillIDPilfer:
return pilfer;
152 case kSkillIDFirstAid:
return firstAid;
153 case kSkillIDSpotHidden:
return spotHidden;
155 error(
"Incorrect skill id: %d",
id);
157 int16 &mana(int16
id) {
159 case kManaIDRed:
return redMana;
160 case kManaIDOrange:
return orangeMana;
161 case kManaIDYellow:
return yellowMana;
162 case kManaIDGreen:
return greenMana;
163 case kManaIDBlue:
return blueMana;
164 case kManaIDViolet:
return violetMana;
166 error(
"Incorrect mana id: %d",
id);
169 uint8 getSkillLevel(int16
id) {
170 return skill(
id) / kSkillFracPointsPerLevel + 1;
223 const int kBaseCarryingCapacity = 100;
224 const int kCarryingCapacityBonusPerBrawn = 200 / ActorAttributes::kSkillLevels;
230 enum combatBehaviorTypes {
243 uint8 combatBehavior;
246 uint32 baseEffectFlags;
250 memset(&baseStats, 0,
sizeof(baseStats));
263 baseStats.read(stream);
264 combatBehavior = stream->
readByte();
306 virtual uint16 containmentSet();
309 virtual bool canContain(ObjectID dObj, ObjectID item);
313 virtual bool canContainAt(
318 weaponID getWeaponID();
321 bool useAction(ObjectID dObj, ObjectID enactor);
324 bool canOpen(ObjectID dObj, ObjectID enactor);
325 bool openAction(ObjectID dObj, ObjectID enactor);
328 bool closeAction(ObjectID dObj, ObjectID enactor);
341 bool acceptDropAction(
348 bool acceptDamageAction(
352 effectDamageTypes dType,
358 bool acceptHealingAction(ObjectID dObj, ObjectID enactor, int8 healing);
362 bool acceptStrikeAction(
365 ObjectID strikingObj,
370 bool acceptInsertionAtAction(
378 virtual void initiateAttack(ObjectID attacker, ObjectID target);
388 void applySkillGrowth(ObjectID enactor, uint8 points = 1);
395 virtual uint16 getViewableRows() {
396 return kViewableRows;
398 virtual uint16 getViewableCols() {
399 return kViewableCols;
401 virtual uint16 getMaxRows() {
404 virtual uint16 getMaxCols() {
411 virtual uint16 massCapacity(
GameObject *container);
412 virtual uint16 bulkCapacity(
GameObject *container);
419 enum actorCreationFlags {
420 kActorPermanent = (1 << 0)
423 enum DispositionType {
424 kDispositionFriendly,
430 enum actionSequenceOptions {
433 kAnimateRepeat = (1 << 0),
434 kAnimateReverse = (1 << 1),
435 kAnimateAlternate = (1 << 2),
436 kAnimateRandom = (1 << 3),
437 kAnimateNoRestart = (1 << 4),
441 kAnimateOnHold = (1 << 5),
445 kAnimateFinished = (1 << 6),
449 kAnimateNotLoaded = (1 << 7)
455 enum ActorAnimationTypes {
459 kActionWaitAgressive,
460 kActionWaitImpatient,
473 kActionFreeFallRunning,
489 kActionTwoHandSwingHigh,
490 kActionTwoHandSwingLow,
491 kActionTwoHandSwingLeftHigh,
492 kActionTwoHandSwingLeftLow,
493 kActionTwoHandSwingRightHigh,
494 kActionTwoHandSwingRightLow,
533 enum ActorGoalTypes {
534 kActorGoalFollowAssignment,
535 kActorGoalPreserveSelf,
536 kActorGoalAttackEnemy,
537 kActorGoalFollowLeader,
538 kActorGoalAvoidEnemies
566 Direction currentFacing;
574 ObjectID leftHandObject,
578 uint16 knowledge[16];
616 Direction _currentFacing;
624 ObjectID _leftHandObject,
628 uint16 _knowledge[16];
635 uint8 _conversationMemory[4];
638 uint8 _currentAnimation,
644 kAFLobotomized = (1 << 0),
645 kAFTemporary = (1 << 1),
646 kAFAfraid = (1 << 2),
647 kAFHasAssignment = (1 << 3),
648 kAFSpecialAttack = (1 << 4),
649 kAFFightStance = (1 << 5)
664 uint32 _enchantmentFlags;
677 uint8 _deactivationCounter;
686 uint8 _actionCounter;
688 uint16 _effectiveResistance;
689 uint16 _effectiveImmunity;
691 int16 _recPointsPerUpdate;
693 int16 _currentRecoveryPoints;
695 enum vitalityRecovery {
696 kRecPointsPerVitality = 10
705 ObjectID _armorObjects[ARMOR_COUNT];
708 ObjectID _currentTargetID;
710 int16 _scriptVar[kActorScriptVars];
721 uint8 colorSchemeIndex,
742 static Actor *newActor(
747 uint8 colorSchemeIndex,
756 void turn(Direction targetDir) {
757 Direction relativeDir = (targetDir - _currentFacing) & 0x7;
762 : _currentFacing - 1)
775 void imNotQuiteDead();
778 void vitalityUpdate();
781 void activateActor();
784 void deactivateActor();
794 return _flags & kAFHasAssignment
803 return actorProp.operator()(
this);
814 return _effectiveStats.vitality <= 0;
850 int16 offenseScore();
854 int16 defenseScore();
857 void handleSuccessfulStrike(
GameObject *weapon) {
858 weapon->proto()->applySkillGrowth(thisID());
862 int16 getDisposition() {
867 int16 setDisposition(int16 newDisp) {
868 int16 oldDisp = _disposition;
869 if (newDisp < kDispositionPlayer)
870 _disposition = newDisp;
876 return &_effectiveStats;
883 void getColorTranslation(ColorTable map);
886 bool isInterruptable() {
887 return _actionCounter == 0;
891 bool isPermanentlyUninterruptable() {
892 return _actionCounter == maxuint8;
896 void setInterruptablity(
bool val) {
897 _actionCounter = val ? 0 : maxuint8;
903 void setActionPoints(uint8 points) {
904 _actionCounter = points;
908 void dropInventory();
911 void holdInRightHand(ObjectID objID);
912 void holdInLeftHand(ObjectID objID);
915 void wear(ObjectID objID, uint8 where);
918 void updateAppearance(int32 deltaTime);
921 bool setAvailableAction(int16 action1, int16 action2, int16 action3, int16 actiondefault);
926 int16 setAction(int16 newState, int16 flags);
930 bool isActionAvailable(int16 newState,
bool anyDir =
false);
934 int16 animationFrames(int16 actionType, Direction dir);
937 bool nextAnimationFrame();
941 bool calcSpriteFrames();
953 void setGoal(uint8 newGoal);
956 void evaluateNeeds();
961 void handleTaskCompletion(TaskResult result);
962 void handleOffensiveAct(
Actor *attacker);
963 void handleDamageTaken(uint8 damage);
964 void handleSuccessfulStrike(
Actor *target, int8 damage);
965 void handleSuccessfulKill(
Actor *target);
968 static bool canBlockWith(
GameObject *defenseObj, Direction relativeDir);
970 void evaluateMeleeAttack(
Actor *attacker);
973 void bandWith(
Actor *newLeader);
976 bool inBandingRange() {
977 assert(_leader != NULL);
979 return _leader->IDParent() == IDParent()
980 && (_leader->getLocation() - getLocation()).quickHDistance()
985 bool addFollower(
Actor *newBandMember);
986 void removeFollower(
Actor *bandMember);
989 uint8 evaluateFollowerNeeds(
Actor *follower);
993 bool addKnowledge(uint16 kID);
994 bool removeKnowledge(uint16 kID);
995 void clearKnowledge();
998 bool canSenseProtaganistIndirectly(
SenseInfo &info, int16 range);
999 bool canSenseSpecificActorIndirectly(
1003 bool canSenseSpecificObjectIndirectly(
1007 bool canSenseActorPropertyIndirectly(
1010 ActorPropertyID prop);
1011 bool canSenseObjectPropertyIndirectly(
1014 ObjectPropertyID prop);
1017 bool takeMana(ActorManaID i, int8 dMana);
1019 bool hasMana(ActorManaID i, int8 dMana);
1021 uint32 getBaseEnchantmentEffects();
1022 uint16 getBaseResistance();
1023 uint16 getBaseImmunity();
1024 uint16 getBaseRecovery();
1026 bool resists(effectResistTypes r) {
1027 return _effectiveResistance & (1 << r);
1029 bool isImmuneTo(effectImmuneTypes r) {
1030 return _effectiveImmunity & (1 << r);
1032 bool hasEffect(effectOthersTypes e) {
1033 return (_enchantmentFlags & (1 << e)) != 0;
1036 void setResist(effectResistTypes r,
bool on) {
1037 _effectiveResistance = on ?
1038 _effectiveResistance | (1 << r) :
1039 _effectiveResistance & ~(1 << r);
1042 void setImmune(effectImmuneTypes r,
bool on) {
1043 _effectiveImmunity = on ?
1044 _effectiveImmunity | (1 << r) :
1045 _effectiveImmunity & ~(1 << r);
1048 void setEffect(effectOthersTypes e,
bool on) {
1049 _enchantmentFlags = on ?
1050 _enchantmentFlags | (1 << e) :
1051 _enchantmentFlags & ~(1 << e);
1054 bool makeSavingThrow();
1056 void setFightStance(
bool val) {
1058 _flags |= kAFFightStance;
1060 _flags &= ~kAFFightStance;
1064 inline bool isPlayerActor(
Actor *a) {
1065 return a->_disposition >= kDispositionPlayer;
1068 inline bool isPlayerActor(ObjectID obj) {
1070 && isPlayerActor((
Actor *)GameObject::objectAddress(obj));
1073 inline bool isEnemy(
Actor *a) {
1074 return !a->isDead() && a->_disposition == kDispositionEnemy;
1077 inline bool isEnemy(ObjectID obj) {
1079 && isEnemy((
Actor *)GameObject::objectAddress(obj));
1082 void updateActorStates();
1084 void pauseActorStates();
1085 void resumeActorStates();
1087 void setCombatBehavior(
bool enabled);
1090 bool areActorsInitialized();
1092 void clearEnchantments(
Actor *a);
1093 void addEnchantment(
Actor *a, uint16 enchantmentID);
1099 enum factionTallyTypes {
1100 kFactionNumKills = 0,
1108 int16 GetFactionTally(
int faction,
enum factionTallyTypes act);
1115 int16 AddFactionTally(
int faction,
enum factionTallyTypes act,
int amt);
1118 void initFactionTallies();
1127 inline void cleanupFactionTallies() { }
1134 kEvalRateMask = kEvalRate - 1
1139 int32 _updatesViaScript;
1140 int32 _baseActorIndex;
1141 int16 _factionTable[kMaxFactions][kFactionNumColumns];
1142 bool _actorStatesPaused;
1143 bool _combatBehaviorEnabled;
1146 _updatesViaScript = 0;
1147 _baseActorIndex = kEvalRateMask;
1149 memset(_factionTable, 0,
sizeof(_factionTable));
1151 _actorStatesPaused =
false;
1152 _combatBehaviorEnabled =
false;
Definition: objproto.h:371
Definition: savefile.h:54
uint32 readUint32LE()
Definition: stream.h:473
Definition: memstream.h:194
Definition: tcoords.h:127
byte readByte()
Definition: stream.h:434
Definition: objects.h:118
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
FORCEINLINE int16 readSint16LE()
Definition: stream.h:543
FORCEINLINE void writeSint16LE(int16 value)
Definition: stream.h:194
FORCEINLINE int8 readSByte()
Definition: stream.h:447
Definition: objproto.h:173
Definition: objects.h:1291
void writeSByte(int8 value)
Definition: stream.h:146
Definition: property.h:45
void writeByte(byte value)
Definition: stream.h:140