| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
#pragma once |
| 50 |
|
| 51 |
#include "ai_context.h" |
| 52 |
#include "animation.h" |
| 53 |
#include "emitter.h" |
| 54 |
#include "game_mode.h" |
| 55 |
#include "grafx.h" |
| 56 |
#include "mathc/mathc.h" |
| 57 |
#include "pickup.h" |
| 58 |
#include "player.h" |
| 59 |
#include "thing.h" |
| 60 |
#include "weapon.h" |
| 61 |
|
| 62 |
#define ACTOR_W 14 |
| 63 |
#define ACTOR_H 10 |
| 64 |
|
| 65 |
#define FLAGS_HURTALWAYS (1 << 2) |
| 66 |
|
| 67 |
|
| 68 |
#define FLAGS_DETOURING (1 << 5) |
| 69 |
#define FLAGS_TRYRIGHT (1 << 6) |
| 70 |
#define FLAGS_SLEEPING (1 << 7) |
| 71 |
#define FLAGS_VISIBLE (1 << 8) |
| 72 |
#define FLAGS_ASBESTOS (1 << 9) // Immune to fire |
| 73 |
#define FLAGS_IMMUNITY (1 << 10) // Immune to poison |
| 74 |
#define FLAGS_SEETHROUGH (1 << 11) // Almost transparent |
| 75 |
#define FLAGS_DEAF (1 << 12) |
| 76 |
#define FLAGS_ALL_SEEING (1 << 13) |
| 77 |
#define FLAGS_UNLOCK_DOORS (1 << 14) |
| 78 |
#define FLAGS_WAKING (1 << 15) |
| 79 |
|
| 80 |
|
| 81 |
#define FLAGS_RUNS_AWAY (1 << 16) // Move directly away from player |
| 82 |
#define FLAGS_GOOD_GUY (1 << 17) // Shots cannot hurt player |
| 83 |
#define FLAGS_PRISONER (1 << 18) // Won't move until touched by player |
| 84 |
#define FLAGS_INVULNERABLE (1 << 19) |
| 85 |
#define FLAGS_FOLLOWER (1 << 20) // Follows player |
| 86 |
#define FLAGS_PENALTY (1 << 21) // Big score penalty if shot |
| 87 |
#define FLAGS_VICTIM (1 << 22) // Can be shot by everyone |
| 88 |
#define FLAGS_SNEAKY (1 << 23) // Always shoot back when player shoots |
| 89 |
#define FLAGS_SLEEPALWAYS (1 << 24) |
| 90 |
#define FLAGS_AWAKEALWAYS (1 << 25) |
| 91 |
#define FLAGS_RESCUED (1 << 26) // Run towards exit |
| 92 |
#define FLAGS_MOVE_AND_SHOOT (1 << 27) // Can move and shoot at the same time |
| 93 |
|
| 94 |
typedef enum |
| 95 |
{ |
| 96 |
ACTORACTION_MOVING, |
| 97 |
ACTORACTION_EXITING |
| 98 |
} ActorAction; |
| 99 |
|
| 100 |
typedef struct Actor |
| 101 |
{ |
| 102 |
struct vec2 Pos; |
| 103 |
|
| 104 |
struct vec2 MoveVel; |
| 105 |
direction_e direction; |
| 106 |
|
| 107 |
|
| 108 |
float DrawRadians; |
| 109 |
Animation anim; |
| 110 |
int stateCounter; |
| 111 |
int lastCmd; |
| 112 |
|
| 113 |
|
| 114 |
bool hasCollided; |
| 115 |
|
| 116 |
|
| 117 |
bool specialCmdDir; |
| 118 |
|
| 119 |
|
| 120 |
bool PickupAll; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
bool CanPickupSpecial; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
int charId; |
| 130 |
int PlayerUID; |
| 131 |
int uid; |
| 132 |
int pilotUID; |
| 133 |
|
| 134 |
int vehicleUID; |
| 135 |
Weapon guns[MAX_WEAPONS]; |
| 136 |
CArray ammo; |
| 137 |
int gunIndex; |
| 138 |
int lastGunIdx; |
| 139 |
|
| 140 |
int health; |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
int dead; |
| 146 |
int flamed; |
| 147 |
int poisoned; |
| 148 |
int petrified; |
| 149 |
int confused; |
| 150 |
int flags; |
| 151 |
|
| 152 |
int turns; |
| 153 |
|
| 154 |
int slideLock; |
| 155 |
|
| 156 |
int accumulatedDamage; |
| 157 |
int damageCooldownTicks; |
| 158 |
|
| 159 |
int grimaceCounter; |
| 160 |
|
| 161 |
|
| 162 |
char Chatter[256]; |
| 163 |
int ChatterCounter; |
| 164 |
|
| 165 |
Emitter barrelSmoke; |
| 166 |
Emitter healEffect; |
| 167 |
|
| 168 |
|
| 169 |
Emitter blood1; |
| 170 |
Emitter blood2; |
| 171 |
Emitter blood3; |
| 172 |
int bleedCounter; |
| 173 |
|
| 174 |
color_t footprintMask; |
| 175 |
int footprintCounter; |
| 176 |
|
| 177 |
bool hasShot; |
| 178 |
|
| 179 |
|
| 180 |
struct |
| 181 |
{ |
| 182 |
const Pickup *pickup; |
| 183 |
const PickupEffect *effect; |
| 184 |
int index; |
| 185 |
} pickupMenu; |
| 186 |
|
| 187 |
|
| 188 |
ActorAction action; |
| 189 |
AIContext *aiContext; |
| 190 |
Thing thing; |
| 191 |
bool isInUse; |
| 192 |
} TActor; |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
extern CArray gActors; |
| 203 |
|
| 204 |
void ActorSetState(TActor *actor, const ActorAnimation state); |
| 205 |
void UpdateActorState(TActor *actor, int ticks); |
| 206 |
void ActorMove(const NActorMove am); |
| 207 |
int CommandActor(TActor *actor, int cmd, int ticks); |
| 208 |
void SlideActor(TActor *actor, int cmd); |
| 209 |
void UpdateAllActors(const int ticks); |
| 210 |
void ActorsPilotVehicles(void); |
| 211 |
void ActorHeal(TActor *actor, const int amount, const bool exceedMax); |
| 212 |
void InjureActor(TActor *actor, int injury); |
| 213 |
|
| 214 |
void ActorAddAmmo(TActor *actor, const int ammoId, const int amount); |
| 215 |
|
| 216 |
bool ActorUsesAmmo(const TActor *actor, const int ammoId); |
| 217 |
void ActorReplaceGun(const NActorReplaceGun rg); |
| 218 |
void ActorSetAIState(TActor *actor, const AIState s); |
| 219 |
void ActorPilot(const NActorPilot ap); |
| 220 |
|
| 221 |
void ActorsInit(void); |
| 222 |
void ActorsTerminate(void); |
| 223 |
int ActorsGetNextUID(void); |
| 224 |
int ActorsGetFreeIndex(void); |
| 225 |
TActor *ActorAdd(NActorAdd aa); |
| 226 |
void ActorDestroy(TActor *a); |
| 227 |
|
| 228 |
TActor *ActorGetByUID(const int uid); |
| 229 |
const Character *ActorGetCharacter(const TActor *a); |
| 230 |
#define ACTOR_GET_GUN(a) (&(a)->guns[(a)->gunIndex]) |
| 231 |
#define ACTOR_GET_GRENADE(a) (&(a)->guns[MAX_GUNS]) |
| 232 |
#define ACTOR_GET_WEAPON(a) \ |
| 233 |
(ACTOR_GET_GUN(a)->Gun != NULL ? ACTOR_GET_GUN(a) : ACTOR_GET_GRENADE(a)) |
| 234 |
struct vec2 ActorGetAverageWeaponMuzzleOffset(const TActor *a); |
| 235 |
struct vec2 ActorGetMuzzleOffset( |
| 236 |
const TActor *a, const Weapon *w, const int barrel); |
| 237 |
|
| 238 |
int ActorWeaponGetAmmo( |
| 239 |
const TActor *a, const WeaponClass *wc, const int barrel); |
| 240 |
|
| 241 |
int ActorGetCanFireBarrel(const TActor *a, const Weapon *w); |
| 242 |
bool ActorCanSwitchToWeapon(const TActor *a, const int slot); |
| 243 |
bool ActorTrySwitchWeapon(const TActor *a); |
| 244 |
|
| 245 |
int ActorFindGun(const TActor *a, const WeaponClass *wc); |
| 246 |
int ActorGetNumWeapons(const TActor *a); |
| 247 |
int ActorGetNumGuns(const TActor *a); |
| 248 |
int ActorGetNumGrenades(const TActor *a); |
| 249 |
void ActorSwitchGun(const NActorSwitchGun sg); |
| 250 |
void ActorPickupGun(const TActor *a, const WeaponClass *wc); |
| 251 |
bool ActorIsImmune(const TActor *actor, const special_damage_e damage); |
| 252 |
bool ActorTakesDamage(const TActor *actor, const special_damage_e damage); |
| 253 |
void ActorHit(const NThingDamage d); |
| 254 |
bool ActorIsInvulnerable( |
| 255 |
const TActor *a, const int flags, const int playerUID, const GameMode mode, |
| 256 |
const special_damage_e special); |
| 257 |
|
| 258 |
int ActorGetMaxHeal(const TActor *a, const bool exceedMax); |
| 259 |
int ActorGetHealthPercent(const TActor *a); |
| 260 |
bool ActorIsLowHealth(const TActor *a); |
| 261 |
bool ActorIsGrimacing(const TActor *a); |
| 262 |
|
| 263 |
bool ActorIsLocalPlayer(const int uid); |
| 264 |
void ActorPersistPlayerWeaponsAndAmmo(const TActor *a); |