2022-05-19 01:51:26 -07:00
|
|
|
#include "animation.h"
|
|
|
|
|
2022-09-15 02:38:23 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2022-06-18 05:27:54 -07:00
|
|
|
#include "art.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "color.h"
|
|
|
|
#include "combat.h"
|
|
|
|
#include "combat_ai.h"
|
|
|
|
#include "critter.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "display_monitor.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "game_mouse.h"
|
|
|
|
#include "game_sound.h"
|
|
|
|
#include "geometry.h"
|
2022-10-04 23:23:27 -07:00
|
|
|
#include "input.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "interface.h"
|
|
|
|
#include "item.h"
|
2022-10-03 06:42:34 -07:00
|
|
|
#include "kb.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "map.h"
|
2022-10-03 02:41:33 -07:00
|
|
|
#include "mouse.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "object.h"
|
2022-06-19 02:00:14 -07:00
|
|
|
#include "party_member.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "perk.h"
|
|
|
|
#include "proto.h"
|
|
|
|
#include "proto_instance.h"
|
|
|
|
#include "random.h"
|
|
|
|
#include "scripts.h"
|
2022-10-06 06:32:46 -07:00
|
|
|
#include "settings.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "stat.h"
|
2022-10-05 00:35:05 -07:00
|
|
|
#include "svga.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
#include "text_object.h"
|
|
|
|
#include "tile.h"
|
|
|
|
#include "trait.h"
|
2022-10-02 23:37:05 -07:00
|
|
|
#include "vcr.h"
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-23 05:43:44 -07:00
|
|
|
namespace fallout {
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
#define ANIMATION_SEQUENCE_LIST_CAPACITY 32
|
|
|
|
#define ANIMATION_DESCRIPTION_LIST_CAPACITY 55
|
|
|
|
#define ANIMATION_SAD_LIST_CAPACITY 24
|
2022-06-18 05:27:54 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
#define ANIMATION_SEQUENCE_FORCED 0x01
|
|
|
|
|
|
|
|
typedef enum AnimationKind {
|
|
|
|
ANIM_KIND_MOVE_TO_OBJECT = 0,
|
|
|
|
ANIM_KIND_MOVE_TO_TILE = 1,
|
|
|
|
ANIM_KIND_MOVE_TO_TILE_STRAIGHT = 2,
|
|
|
|
ANIM_KIND_MOVE_TO_TILE_STRAIGHT_AND_WAIT_FOR_COMPLETE = 3,
|
|
|
|
ANIM_KIND_ANIMATE = 4,
|
|
|
|
ANIM_KIND_ANIMATE_REVERSED = 5,
|
|
|
|
ANIM_KIND_ANIMATE_AND_HIDE = 6,
|
|
|
|
ANIM_KIND_ROTATE_TO_TILE = 7,
|
|
|
|
ANIM_KIND_ROTATE_CLOCKWISE = 8,
|
|
|
|
ANIM_KIND_ROTATE_COUNTER_CLOCKWISE = 9,
|
|
|
|
ANIM_KIND_HIDE = 10,
|
|
|
|
ANIM_KIND_CALLBACK = 11,
|
|
|
|
ANIM_KIND_CALLBACK3 = 12,
|
|
|
|
ANIM_KIND_SET_FLAG = 14,
|
|
|
|
ANIM_KIND_UNSET_FLAG = 15,
|
|
|
|
ANIM_KIND_TOGGLE_FLAT = 16,
|
|
|
|
ANIM_KIND_SET_FID = 17,
|
|
|
|
ANIM_KIND_TAKE_OUT_WEAPON = 18,
|
|
|
|
ANIM_KIND_SET_LIGHT_DISTANCE = 19,
|
2022-09-01 08:41:37 -07:00
|
|
|
ANIM_KIND_MOVE_ON_STAIRS = 20,
|
|
|
|
ANIM_KIND_CHECK_FALLING = 23,
|
2022-07-29 06:04:05 -07:00
|
|
|
ANIM_KIND_TOGGLE_OUTLINE = 24,
|
|
|
|
ANIM_KIND_ANIMATE_FOREVER = 25,
|
|
|
|
ANIM_KIND_26 = 26,
|
|
|
|
ANIM_KIND_27 = 27,
|
|
|
|
ANIM_KIND_NOOP = 28,
|
2022-08-05 07:43:00 -07:00
|
|
|
|
|
|
|
// New animation to update both light distance and intensity. Required to
|
|
|
|
// impement Sfall's explosion light effects without resorting to hackery.
|
|
|
|
ANIM_KIND_SET_LIGHT_INTENSITY,
|
2022-07-29 06:04:05 -07:00
|
|
|
} AnimationKind;
|
|
|
|
|
|
|
|
typedef enum AnimationSequenceFlags {
|
|
|
|
// Specifies that the animation sequence has high priority, it cannot be
|
|
|
|
// cleared.
|
|
|
|
ANIM_SEQ_PRIORITIZED = 0x01,
|
|
|
|
|
|
|
|
// Specifies that the animation sequence started combat animation mode and
|
|
|
|
// therefore should balance it with appropriate finish call.
|
|
|
|
ANIM_SEQ_COMBAT_ANIM_STARTED = 0x02,
|
|
|
|
|
|
|
|
// Specifies that the animation sequence is reserved (TODO: explain what it
|
|
|
|
// actually means).
|
|
|
|
ANIM_SEQ_RESERVED = 0x04,
|
|
|
|
|
|
|
|
// Specifies that the animation sequence is in the process of adding actions
|
|
|
|
// to it (that is in the middle of begin/end calls).
|
|
|
|
ANIM_SEQ_ACCUMULATING = 0x08,
|
|
|
|
|
|
|
|
// TODO: Add description.
|
|
|
|
ANIM_SEQ_0x10 = 0x10,
|
|
|
|
|
|
|
|
// TODO: Add description.
|
|
|
|
ANIM_SEQ_0x20 = 0x20,
|
|
|
|
|
|
|
|
// Specifies that the animation sequence is negligible and will be end
|
|
|
|
// immediately when a new animation sequence is requested for the same
|
|
|
|
// object.
|
|
|
|
ANIM_SEQ_INSIGNIFICANT = 0x40,
|
|
|
|
|
|
|
|
// Specifies that the animation sequence should not return to ANIM_STAND
|
|
|
|
// when it's completed.
|
|
|
|
ANIM_SEQ_NO_STAND = 0x80,
|
|
|
|
} AnimationSequenceFlags;
|
|
|
|
|
|
|
|
typedef enum AnimationSadFlags {
|
|
|
|
// Specifies that the animation should play from end to start.
|
|
|
|
ANIM_SAD_REVERSE = 0x01,
|
|
|
|
|
|
|
|
// Specifies that the animation should use straight movement mode (as
|
|
|
|
// opposed to normal movement mode).
|
|
|
|
ANIM_SAD_STRAIGHT = 0x02,
|
|
|
|
|
|
|
|
// Specifies that no frame change should occur during animation.
|
|
|
|
ANIM_SAD_NO_ANIM = 0x04,
|
|
|
|
|
|
|
|
// Specifies that the animation should be played fully from start to finish.
|
|
|
|
//
|
|
|
|
// NOTE: This flag is only used together with straight movement mode to
|
|
|
|
// implement knockdown. Without this flag when the knockdown distance is
|
|
|
|
// short, say 1 or 2 tiles, knockdown animation might not be completed by
|
|
|
|
// the time critter reached it's destination. With this flag set animation
|
|
|
|
// will be played to it's final frame.
|
|
|
|
ANIM_SAD_WAIT_FOR_COMPLETION = 0x10,
|
|
|
|
|
|
|
|
// Unknown, set once, never read.
|
|
|
|
ANIM_SAD_0x20 = 0x20,
|
|
|
|
|
|
|
|
// Specifies that the owner of the animation should be hidden when animation
|
|
|
|
// is completed.
|
|
|
|
ANIM_SAD_HIDE_ON_END = 0x40,
|
|
|
|
|
|
|
|
// Specifies that the animation should never end.
|
|
|
|
ANIM_SAD_FOREVER = 0x80,
|
|
|
|
} AnimationSadFlags;
|
|
|
|
|
2022-06-18 05:27:54 -07:00
|
|
|
typedef struct AnimationDescription {
|
2022-07-29 06:04:05 -07:00
|
|
|
int kind;
|
2022-06-18 05:27:54 -07:00
|
|
|
union {
|
2022-07-29 06:04:05 -07:00
|
|
|
Object* owner;
|
|
|
|
|
|
|
|
// - ANIM_KIND_CALLBACK
|
|
|
|
// - ANIM_KIND_CALLBACK3
|
|
|
|
void* param2;
|
2022-06-18 05:27:54 -07:00
|
|
|
};
|
2022-07-29 06:04:05 -07:00
|
|
|
|
2022-06-18 05:27:54 -07:00
|
|
|
union {
|
2022-07-29 06:04:05 -07:00
|
|
|
// - ANIM_KIND_MOVE_TO_OBJECT
|
|
|
|
Object* destination;
|
|
|
|
|
|
|
|
// - ANIM_KIND_CALLBACK
|
|
|
|
void* param1;
|
2022-06-18 05:27:54 -07:00
|
|
|
};
|
|
|
|
union {
|
2022-07-29 06:04:05 -07:00
|
|
|
// - ANIM_KIND_MOVE_TO_TILE
|
|
|
|
// - ANIM_KIND_ANIMATE_AND_MOVE_TO_TILE_STRAIGHT
|
|
|
|
// - ANIM_KIND_MOVE_TO_TILE_STRAIGHT
|
|
|
|
struct {
|
|
|
|
int tile;
|
|
|
|
int elevation;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ANIM_KIND_SET_FID
|
|
|
|
int fid;
|
|
|
|
|
|
|
|
// ANIM_KIND_TAKE_OUT_WEAPON
|
|
|
|
int weaponAnimationCode;
|
|
|
|
|
|
|
|
// ANIM_KIND_SET_LIGHT_DISTANCE
|
|
|
|
int lightDistance;
|
|
|
|
|
|
|
|
// ANIM_KIND_TOGGLE_OUTLINE
|
|
|
|
bool outline;
|
2022-06-18 05:27:54 -07:00
|
|
|
};
|
2022-07-29 06:04:05 -07:00
|
|
|
int anim;
|
|
|
|
int delay;
|
|
|
|
|
|
|
|
// ANIM_KIND_CALLBACK
|
|
|
|
AnimationCallback* callback;
|
|
|
|
|
|
|
|
// ANIM_KIND_CALLBACK3
|
|
|
|
AnimationCallback3* callback3;
|
|
|
|
|
2022-06-18 05:27:54 -07:00
|
|
|
union {
|
2022-07-29 06:04:05 -07:00
|
|
|
// - ANIM_KIND_SET_FLAG
|
|
|
|
// - ANIM_KIND_UNSET_FLAG
|
|
|
|
unsigned int objectFlag;
|
|
|
|
|
|
|
|
// - ANIM_KIND_HIDE
|
|
|
|
// - ANIM_KIND_CALLBACK
|
|
|
|
unsigned int extendedFlags;
|
2022-06-18 05:27:54 -07:00
|
|
|
};
|
2022-07-29 06:04:05 -07:00
|
|
|
|
|
|
|
union {
|
|
|
|
// - ANIM_KIND_MOVE_TO_TILE
|
|
|
|
// - ANIM_KIND_MOVE_TO_OBJECT
|
|
|
|
int actionPoints;
|
|
|
|
|
|
|
|
// ANIM_KIND_26
|
|
|
|
int animationSequenceIndex;
|
|
|
|
|
|
|
|
// ANIM_KIND_CALLBACK3
|
|
|
|
void* param3;
|
2022-08-05 07:43:00 -07:00
|
|
|
|
|
|
|
// ANIM_KIND_SET_LIGHT_INTENSITY
|
|
|
|
int lightIntensity;
|
2022-07-29 06:04:05 -07:00
|
|
|
};
|
|
|
|
CacheEntry* artCacheKey;
|
2022-06-18 05:27:54 -07:00
|
|
|
} AnimationDescription;
|
|
|
|
|
|
|
|
typedef struct AnimationSequence {
|
|
|
|
int field_0;
|
|
|
|
// Index of current animation in [animations] array or -1 if animations in
|
|
|
|
// this sequence is not playing.
|
|
|
|
int animationIndex;
|
|
|
|
// Number of scheduled animations in [animations] array.
|
|
|
|
int length;
|
2022-07-29 06:04:05 -07:00
|
|
|
unsigned int flags;
|
2022-06-18 05:27:54 -07:00
|
|
|
AnimationDescription animations[ANIMATION_DESCRIPTION_LIST_CAPACITY];
|
|
|
|
} AnimationSequence;
|
|
|
|
|
|
|
|
typedef struct PathNode {
|
|
|
|
int tile;
|
|
|
|
int from;
|
|
|
|
// actual type is likely char
|
|
|
|
int rotation;
|
|
|
|
int field_C;
|
|
|
|
int field_10;
|
|
|
|
} PathNode;
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
// TODO: I don't know what `sad` means, but it's definitely better than
|
|
|
|
// `STRUCT_530014`. Find a better name.
|
|
|
|
typedef struct AnimationSad {
|
2022-07-29 06:04:05 -07:00
|
|
|
unsigned int flags;
|
2022-06-18 05:27:54 -07:00
|
|
|
Object* obj;
|
|
|
|
int fid; // fid
|
2022-07-07 01:28:21 -07:00
|
|
|
int anim;
|
|
|
|
|
|
|
|
// Timestamp (in game ticks) when animation last occurred.
|
|
|
|
unsigned int animationTimestamp;
|
|
|
|
|
|
|
|
// Number of ticks per frame (taking art's fps and overall animation speed
|
|
|
|
// settings into account).
|
|
|
|
unsigned int ticksPerFrame;
|
|
|
|
|
2022-06-18 05:27:54 -07:00
|
|
|
int animationSequenceIndex;
|
|
|
|
int field_1C; // length of field_28
|
|
|
|
int field_20; // current index in field_28
|
|
|
|
int field_24;
|
|
|
|
union {
|
|
|
|
unsigned char rotations[3200];
|
|
|
|
STRUCT_530014_28 field_28[200];
|
|
|
|
};
|
2022-07-07 01:28:21 -07:00
|
|
|
} AnimationSad;
|
2022-06-18 05:27:54 -07:00
|
|
|
|
|
|
|
static int _anim_free_slot(int a1);
|
2022-09-01 08:41:37 -07:00
|
|
|
static int _anim_preload(Object* object, int fid, CacheEntry** cacheEntryPtr);
|
2022-06-18 05:27:54 -07:00
|
|
|
static void _anim_cleanup();
|
|
|
|
static int _check_registry(Object* obj);
|
|
|
|
static int animationRunSequence(int a1);
|
|
|
|
static int _anim_set_continue(int a1, int a2);
|
|
|
|
static int _anim_set_end(int a1);
|
|
|
|
static bool canUseDoor(Object* critter, Object* door);
|
|
|
|
static int _idist(int a1, int a2, int a3, int a4);
|
|
|
|
static int _tile_idistance(int tile1, int tile2);
|
|
|
|
static int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim, int animationSequenceIndex);
|
|
|
|
static int animateMoveObjectToTile(Object* obj, int tile_num, int elev, int a4, int anim, int animationSequenceIndex);
|
|
|
|
static int _anim_move(Object* obj, int tile, int elev, int a3, int anim, int a5, int animationSequenceIndex);
|
2022-07-29 06:04:05 -07:00
|
|
|
static int animateMoveObjectToTileStraight(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex, int flags);
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_move_on_stairs(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex);
|
|
|
|
static int _check_for_falling(Object* obj, int anim, int a3);
|
|
|
|
static void _object_move(int index);
|
|
|
|
static void _object_straight_move(int index);
|
|
|
|
static int _anim_animate(Object* obj, int anim, int animationSequenceIndex, int flags);
|
|
|
|
static void _object_anim_compact();
|
|
|
|
static int actionRotate(Object* obj, int delta, int animationSequenceIndex);
|
2022-09-01 08:41:37 -07:00
|
|
|
static int _anim_hide(Object* object, int animationSequenceIndex);
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_change_fid(Object* obj, int animationSequenceIndex, int fid);
|
|
|
|
static int _check_gravity(int tile, int elevation);
|
2022-07-07 01:28:21 -07:00
|
|
|
static unsigned int animationComputeTicksPerFrame(Object* object, int fid);
|
2022-06-18 05:27:54 -07:00
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x510718
|
2022-07-07 01:28:21 -07:00
|
|
|
static int gAnimationCurrentSad = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x51071C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int gAnimationSequenceCurrentIndex = -1;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x510720
|
2022-07-07 01:28:21 -07:00
|
|
|
static bool gAnimationInInit = false;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x510724
|
2022-07-07 01:28:21 -07:00
|
|
|
static bool gAnimationInStop = false;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x510728
|
2022-06-18 05:27:54 -07:00
|
|
|
static bool _anim_in_bk = false;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x51072C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _lastDestination = -2;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x510730
|
2022-06-18 05:27:54 -07:00
|
|
|
static unsigned int _last_time_ = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x510734
|
2022-06-18 05:27:54 -07:00
|
|
|
static unsigned int _next_time = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x530014
|
2022-07-07 01:28:21 -07:00
|
|
|
static AnimationSad gAnimationSads[ANIMATION_SAD_LIST_CAPACITY];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x542FD4
|
2022-06-18 05:27:54 -07:00
|
|
|
static PathNode gClosedPathNodeList[2000];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x54CC14
|
2022-06-18 05:27:54 -07:00
|
|
|
static AnimationSequence gAnimationSequences[32];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x561814
|
2022-06-18 05:27:54 -07:00
|
|
|
static unsigned char gPathfinderProcessedTiles[5000];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x562B9C
|
2022-06-18 05:27:54 -07:00
|
|
|
static PathNode gOpenPathNodeList[2000];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x56C7DC
|
2022-06-18 05:27:54 -07:00
|
|
|
static int gAnimationDescriptionCurrentIndex;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// 0x56C7E0
|
2022-06-18 05:27:54 -07:00
|
|
|
static Object* dword_56C7E0[100];
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
// anim_init
|
|
|
|
// 0x413A20
|
|
|
|
void animationInit()
|
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationInInit = true;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationReset();
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationInInit = false;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413A40
|
|
|
|
void animationReset()
|
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (!gAnimationInInit) {
|
2022-05-19 01:51:26 -07:00
|
|
|
// NOTE: Uninline.
|
2022-07-07 01:28:21 -07:00
|
|
|
animationStop();
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationSequenceCurrentIndex = -1;
|
|
|
|
|
|
|
|
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
|
|
|
|
gAnimationSequences[index].field_0 = -1000;
|
|
|
|
gAnimationSequences[index].flags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413AB8
|
|
|
|
void animationExit()
|
|
|
|
{
|
|
|
|
// NOTE: Uninline.
|
2022-07-07 01:28:21 -07:00
|
|
|
animationStop();
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413AF4
|
2022-07-29 06:04:05 -07:00
|
|
|
int reg_anim_begin(int requestOptions)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (gAnimationSequenceCurrentIndex != -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationInStop) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int v1 = _anim_free_slot(requestOptions);
|
2022-05-19 01:51:26 -07:00
|
|
|
if (v1 == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[v1]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationSequence->flags |= ANIM_SEQ_ACCUMULATING;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((requestOptions & ANIMATION_REQUEST_RESERVED) != 0) {
|
|
|
|
animationSequence->flags |= ANIM_SEQ_RESERVED;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((requestOptions & ANIMATION_REQUEST_INSIGNIFICANT) != 0) {
|
|
|
|
animationSequence->flags |= ANIM_SEQ_INSIGNIFICANT;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((requestOptions & ANIMATION_REQUEST_NO_STAND) != 0) {
|
|
|
|
animationSequence->flags |= ANIM_SEQ_NO_STAND;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationSequenceCurrentIndex = v1;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413B80
|
2022-07-29 06:04:05 -07:00
|
|
|
static int _anim_free_slot(int requestOptions)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
int v1 = -1;
|
|
|
|
int v2 = 0;
|
|
|
|
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
|
2022-07-29 06:04:05 -07:00
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[index]);
|
|
|
|
if (animationSequence->field_0 != -1000 || (animationSequence->flags & ANIM_SEQ_ACCUMULATING) != 0 || (animationSequence->flags & ANIM_SEQ_0x20) != 0) {
|
|
|
|
if (!(animationSequence->flags & ANIM_SEQ_RESERVED)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
v2++;
|
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
} else if (v1 == -1 && ((requestOptions & ANIMATION_REQUEST_0x100) == 0 || (animationSequence->flags & ANIM_SEQ_0x10) == 0)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
v1 = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v1 == -1) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((requestOptions & ANIMATION_REQUEST_RESERVED) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
debugPrint("Unable to begin reserved animation!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
} else if ((requestOptions & ANIMATION_REQUEST_RESERVED) != 0 || v2 < 20) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413C20
|
|
|
|
int _register_priority(int a1)
|
|
|
|
{
|
|
|
|
if (gAnimationSequenceCurrentIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a1 == 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
gAnimationSequences[gAnimationSequenceCurrentIndex].flags |= ANIM_SEQ_PRIORITIZED;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413C4C
|
|
|
|
int reg_anim_clear(Object* a1)
|
|
|
|
{
|
|
|
|
for (int animationSequenceIndex = 0; animationSequenceIndex < ANIMATION_SEQUENCE_LIST_CAPACITY; animationSequenceIndex++) {
|
2022-07-29 06:04:05 -07:00
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
if (animationSequence->field_0 == -1000) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
int animationDescriptionIndex;
|
2022-07-29 06:04:05 -07:00
|
|
|
for (animationDescriptionIndex = 0; animationDescriptionIndex < animationSequence->length; animationDescriptionIndex++) {
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[animationDescriptionIndex]);
|
|
|
|
if (a1 != animationDescription->owner || animationDescription->kind == 11) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescriptionIndex == animationSequence->length) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((animationSequence->flags & ANIM_SEQ_PRIORITIZED) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_set_end(animationSequenceIndex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413CCC
|
|
|
|
int reg_anim_end()
|
|
|
|
{
|
|
|
|
if (gAnimationSequenceCurrentIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
animationSequence->field_0 = 0;
|
|
|
|
animationSequence->length = gAnimationDescriptionCurrentIndex;
|
|
|
|
animationSequence->animationIndex = -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationSequence->flags &= ~ANIM_SEQ_ACCUMULATING;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationSequence->animations[0].delay = 0;
|
|
|
|
if (isInCombat()) {
|
|
|
|
_combat_anim_begin();
|
2022-07-29 06:04:05 -07:00
|
|
|
animationSequence->flags |= ANIM_SEQ_COMBAT_ANIM_STARTED;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int v1 = gAnimationSequenceCurrentIndex;
|
|
|
|
gAnimationSequenceCurrentIndex = -1;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (!(animationSequence->flags & ANIM_SEQ_0x10)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_set_continue(v1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Inlined.
|
|
|
|
//
|
|
|
|
// 0x413D6C
|
|
|
|
static int _anim_preload(Object* object, int fid, CacheEntry** cacheEntryPtr)
|
|
|
|
{
|
|
|
|
*cacheEntryPtr = NULL;
|
|
|
|
|
|
|
|
if (artLock(fid, cacheEntryPtr) != NULL) {
|
|
|
|
artUnlock(*cacheEntryPtr);
|
|
|
|
*cacheEntryPtr = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x413D98
|
2022-06-18 05:27:54 -07:00
|
|
|
static void _anim_cleanup()
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (gAnimationSequenceCurrentIndex == -1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
|
2022-07-29 06:04:05 -07:00
|
|
|
gAnimationSequences[index].flags &= ~(ANIM_SEQ_ACCUMULATING | ANIM_SEQ_0x10);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
for (int index = 0; index < gAnimationDescriptionCurrentIndex; index++) {
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[index]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->artCacheKey != NULL) {
|
|
|
|
artUnlock(animationDescription->artCacheKey);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind == ANIM_KIND_CALLBACK && animationDescription->callback == (AnimationCallback*)_gsnd_anim_sound) {
|
|
|
|
soundEffectDelete((Sound*)animationDescription->param1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationSequenceCurrentIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413E2C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _check_registry(Object* obj)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (gAnimationSequenceCurrentIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (gAnimationDescriptionCurrentIndex >= ANIMATION_DESCRIPTION_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int animationSequenceIndex = 0; animationSequenceIndex < ANIMATION_SEQUENCE_LIST_CAPACITY; animationSequenceIndex++) {
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
|
|
|
|
if (animationSequenceIndex != gAnimationSequenceCurrentIndex && animationSequence->field_0 != -1000) {
|
|
|
|
for (int animationDescriptionIndex = 0; animationDescriptionIndex < animationSequence->length; animationDescriptionIndex++) {
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[animationDescriptionIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if (obj == animationDescription->owner && animationDescription->kind != 11) {
|
|
|
|
if ((animationSequence->flags & ANIM_SEQ_INSIGNIFICANT) == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_set_end(animationSequenceIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns -1 if object is playing some animation.
|
|
|
|
//
|
|
|
|
// 0x413EC8
|
|
|
|
int animationIsBusy(Object* a1)
|
|
|
|
{
|
|
|
|
if (gAnimationDescriptionCurrentIndex >= ANIMATION_DESCRIPTION_LIST_CAPACITY || a1 == NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int animationSequenceIndex = 0; animationSequenceIndex < ANIMATION_SEQUENCE_LIST_CAPACITY; animationSequenceIndex++) {
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
if (animationSequenceIndex != gAnimationSequenceCurrentIndex && animationSequence->field_0 != -1000) {
|
|
|
|
for (int animationDescriptionIndex = 0; animationDescriptionIndex < animationSequence->length; animationDescriptionIndex++) {
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[animationDescriptionIndex]);
|
|
|
|
if (a1 != animationDescription->owner) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind == ANIM_KIND_CALLBACK) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animationSequence->length == 1 && animationDescription->anim == ANIM_STAND) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x413F5C
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterMoveToObject(Object* owner, Object* destination, int actionPoints, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1 || actionPoints == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (owner->tile == destination->tile && owner->elevation == destination->elevation) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationDescription* animationDescription = &(gAnimationSequences[gAnimationSequenceCurrentIndex].animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_OBJECT;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = ANIM_WALK;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->owner = owner;
|
|
|
|
animationDescription->destination = destination;
|
|
|
|
animationDescription->actionPoints = actionPoints;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
return animationRegisterRotateToTile(owner, destination->tile);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x41405C
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterRunToObject(Object* owner, Object* destination, int actionPoints, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (_check_registry(owner) == -1 || actionPoints == 0) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (owner->tile == destination->tile && owner->elevation == destination->elevation) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (critterIsEncumbered(owner)) {
|
|
|
|
if (objectIsPartyMember(owner)) {
|
2022-07-29 06:04:05 -07:00
|
|
|
char formattedText[92];
|
|
|
|
MessageListItem messageListItem;
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
if (owner == gDude) {
|
|
|
|
// You are overloaded.
|
2022-07-29 06:04:05 -07:00
|
|
|
strcpy(formattedText, getmsg(&gMiscMessageList, &messageListItem, 8000));
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
// %s is overloaded.
|
2022-07-29 06:04:05 -07:00
|
|
|
sprintf(formattedText,
|
|
|
|
getmsg(&gMiscMessageList, &messageListItem, 8001),
|
|
|
|
critterGetName(owner));
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
displayMonitorAddMessage(formattedText);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
return animationRegisterMoveToObject(owner, destination, actionPoints, delay);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
AnimationDescription* animationDescription = &(gAnimationSequences[gAnimationSequenceCurrentIndex].animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_OBJECT;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->owner = owner;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->destination = destination;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-08-01 09:47:09 -07:00
|
|
|
if ((FID_TYPE(owner->fid) == OBJ_TYPE_CRITTER && (owner->data.critter.combat.results & DAM_CRIP_LEG_ANY) != 0)
|
|
|
|
|| (owner == gDude && dudeHasState(0) && !perkGetRank(gDude, PERK_SILENT_RUNNING))
|
2022-07-29 06:04:05 -07:00
|
|
|
|| !artExists(buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, ANIM_RUNNING, 0, owner->rotation + 1))) {
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = ANIM_WALK;
|
|
|
|
} else {
|
|
|
|
animationDescription->anim = ANIM_RUNNING;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->actionPoints = actionPoints;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
2022-07-29 06:04:05 -07:00
|
|
|
return animationRegisterRotateToTile(owner, destination->tile);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414294
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterMoveToTile(Object* owner, int tile, int elevation, int actionPoints, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1 || actionPoints == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (tile == owner->tile && elevation == owner->elevation) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
AnimationDescription* animationDescription = &(gAnimationSequences[gAnimationSequenceCurrentIndex].animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_TILE;
|
|
|
|
animationDescription->anim = ANIM_WALK;
|
|
|
|
animationDescription->owner = owner;
|
|
|
|
animationDescription->tile = tile;
|
|
|
|
animationDescription->elevation = elevation;
|
|
|
|
animationDescription->actionPoints = actionPoints;
|
|
|
|
animationDescription->delay = delay;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414394
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterRunToTile(Object* owner, int tile, int elevation, int actionPoints, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1 || actionPoints == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (tile == owner->tile && elevation == owner->elevation) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (critterIsEncumbered(owner)) {
|
|
|
|
if (objectIsPartyMember(owner)) {
|
|
|
|
MessageListItem messageListItem;
|
|
|
|
char formattedText[72];
|
|
|
|
|
|
|
|
if (owner == gDude) {
|
2022-05-19 01:51:26 -07:00
|
|
|
// You are overloaded.
|
2022-07-29 06:04:05 -07:00
|
|
|
strcpy(formattedText, getmsg(&gMiscMessageList, &messageListItem, 8000));
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
// %s is overloaded.
|
2022-07-29 06:04:05 -07:00
|
|
|
sprintf(formattedText,
|
|
|
|
getmsg(&gMiscMessageList, &messageListItem, 8001),
|
|
|
|
critterGetName(owner));
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
displayMonitorAddMessage(formattedText);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
return animationRegisterMoveToTile(owner, tile, elevation, actionPoints, delay);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
AnimationDescription* animationDescription = &(gAnimationSequences[gAnimationSequenceCurrentIndex].animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_TILE;
|
|
|
|
animationDescription->owner = owner;
|
|
|
|
animationDescription->tile = tile;
|
|
|
|
animationDescription->elevation = elevation;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-08-01 09:47:09 -07:00
|
|
|
if ((FID_TYPE(owner->fid) == OBJ_TYPE_CRITTER && (owner->data.critter.combat.results & DAM_CRIP_LEG_ANY) != 0)
|
|
|
|
|| (owner == gDude && dudeHasState(0) && !perkGetRank(gDude, PERK_SILENT_RUNNING))
|
2022-07-29 06:04:05 -07:00
|
|
|
|| !artExists(buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, ANIM_RUNNING, 0, owner->rotation + 1))) {
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = ANIM_WALK;
|
|
|
|
} else {
|
|
|
|
animationDescription->anim = ANIM_RUNNING;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->actionPoints = actionPoints;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4145D0
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterMoveToTileStraight(Object* object, int tile, int elevation, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(object) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (tile == object->tile && elevation == object->elevation) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_TILE_STRAIGHT;
|
|
|
|
animationDescription->owner = object;
|
|
|
|
animationDescription->tile = tile;
|
|
|
|
animationDescription->elevation = elevation;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(object->fid), object->fid & 0xFFF, animationDescription->anim, (object->fid & 0xF000) >> 12, object->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(object, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4146C4
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterMoveToTileStraightAndWaitForComplete(Object* owner, int tile, int elevation, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (tile == owner->tile && elevation == owner->elevation) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_MOVE_TO_TILE_STRAIGHT_AND_WAIT_FOR_COMPLETE;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->tile = tile;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->elevation = elevation;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4149D0
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterAnimate(Object* owner, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ANIMATE;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414AA8
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterAnimateReversed(Object* owner, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ANIMATE_REVERSED;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414B7C
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterAnimateAndHide(Object* owner, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ANIMATE_AND_HIDE;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414C50
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterRotateToTile(Object* owner, int tile)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (_check_registry(owner) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ROTATE_TO_TILE;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->owner = owner;
|
|
|
|
animationDescription->tile = tile;
|
2022-07-29 06:04:05 -07:00
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414CC8
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterRotateClockwise(Object* owner)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ROTATE_CLOCKWISE;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = owner;
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414D38
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterRotateCounterClockwise(Object* owner)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ROTATE_COUNTER_CLOCKWISE;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = owner;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Unused.
|
|
|
|
//
|
|
|
|
// 0x414DA8
|
|
|
|
int animationRegisterHideObject(Object* object)
|
|
|
|
{
|
|
|
|
if (_check_registry(object) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_HIDE;
|
|
|
|
animationDescription->delay = -1;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->extendedFlags = 0;
|
|
|
|
animationDescription->owner = object;
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414E20
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterHideObjectForced(Object* object)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(object) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_HIDE;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = -1;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->extendedFlags = ANIMATION_SEQUENCE_FORCED;
|
|
|
|
animationDescription->owner = object;
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414E98
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterCallback(void* a1, void* a2, AnimationCallback* proc, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (_check_registry(NULL) == -1 || proc == NULL) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_CALLBACK;
|
|
|
|
animationDescription->extendedFlags = 0;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->param2 = a2;
|
|
|
|
animationDescription->param1 = a1;
|
|
|
|
animationDescription->callback = proc;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
// Same as `animationRegisterCallback` but accepting 3 parameters.
|
|
|
|
//
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x414F20
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterCallback3(void* a1, void* a2, void* a3, AnimationCallback3* proc, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(NULL) == -1 || proc == NULL) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_CALLBACK3;
|
|
|
|
animationDescription->extendedFlags = 0;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->param2 = a2;
|
|
|
|
animationDescription->param1 = a1;
|
|
|
|
animationDescription->callback3 = proc;
|
|
|
|
animationDescription->param3 = a3;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x414FAC
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterCallbackForced(void* a1, void* a2, AnimationCallback* proc, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (_check_registry(NULL) == -1 || proc == NULL) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_CALLBACK;
|
|
|
|
animationDescription->extendedFlags = ANIMATION_SEQUENCE_FORCED;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->param2 = a2;
|
|
|
|
animationDescription->param1 = a1;
|
|
|
|
animationDescription->callback = proc;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Unused.
|
|
|
|
//
|
|
|
|
// The [flag] parameter should be one of OBJECT_* flags. The way it's handled
|
|
|
|
// down the road implies it should not be a group of flags (joined with bitwise
|
|
|
|
// OR), but a one particular flag.
|
|
|
|
//
|
|
|
|
// 0x415034
|
|
|
|
int animationRegisterSetFlag(Object* object, int flag, int delay)
|
|
|
|
{
|
|
|
|
if (_check_registry(object) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_SET_FLAG;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = object;
|
|
|
|
animationDescription->objectFlag = flag;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
// The [flag] parameter should be one of OBJECT_* flags. The way it's handled
|
|
|
|
// down the road implies it should not be a group of flags (joined with bitwise
|
|
|
|
// OR), but a one particular flag.
|
|
|
|
//
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x4150A8
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterUnsetFlag(Object* object, int flag, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(object) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_UNSET_FLAG;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = object;
|
|
|
|
animationDescription->objectFlag = flag;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x41518C
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterSetFid(Object* owner, int fid, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_SET_FID;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->fid = fid;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415238
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterTakeOutWeapon(Object* owner, int weaponAnimationCode, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
const char* sfx = sfxBuildCharName(owner, ANIM_TAKE_OUT, weaponAnimationCode);
|
|
|
|
if (animationRegisterPlaySoundEffect(owner, sfx, delay) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_TAKE_OUT_WEAPON;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = ANIM_TAKE_OUT;
|
|
|
|
animationDescription->delay = 0;
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->weaponAnimationCode = weaponAnimationCode;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, ANIM_TAKE_OUT, weaponAnimationCode, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415334
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterSetLightDistance(Object* owner, int lightDistance, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_SET_LIGHT_DISTANCE;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->lightDistance = lightDistance;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
// NOTE: Unused.
|
|
|
|
//
|
|
|
|
// 0x4153A8
|
|
|
|
int animationRegisterToggleOutline(Object* object, bool outline, int delay)
|
|
|
|
{
|
|
|
|
if (_check_registry(object) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_TOGGLE_OUTLINE;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = object;
|
|
|
|
animationDescription->outline = outline;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x41541C
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterPlaySoundEffect(Object* owner, const char* soundEffectName, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_CALLBACK;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
if (soundEffectName != NULL) {
|
2022-07-29 06:04:05 -07:00
|
|
|
int volume = _gsound_compute_relative_volume(owner);
|
|
|
|
animationDescription->param1 = soundEffectLoadWithVolume(soundEffectName, owner, volume);
|
|
|
|
if (animationDescription->param1 != NULL) {
|
|
|
|
animationDescription->callback = (AnimationCallback*)_gsnd_anim_sound;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_NOOP;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_NOOP;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->artCacheKey = NULL;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4154C4
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationRegisterAnimateForever(Object* owner, int anim, int delay)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
if (_check_registry(owner) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->kind = ANIM_KIND_ANIMATE_FOREVER;
|
|
|
|
animationDescription->owner = owner;
|
2022-05-19 01:51:26 -07:00
|
|
|
animationDescription->anim = anim;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
|
2022-09-01 08:41:37 -07:00
|
|
|
|
|
|
|
// NOTE: Uninline.
|
|
|
|
if (_anim_preload(owner, fid, &(animationDescription->artCacheKey)) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415598
|
|
|
|
int reg_anim_26(int a1, int delay)
|
|
|
|
{
|
|
|
|
if (_check_registry(NULL) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int animationSequenceIndex = _anim_free_slot(a1 | ANIMATION_REQUEST_0x100);
|
|
|
|
if (animationSequenceIndex == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
gAnimationSequences[animationSequenceIndex].flags = ANIM_SEQ_0x10;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->owner = NULL;
|
|
|
|
animationDescription->kind = ANIM_KIND_26;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->animationSequenceIndex = animationSequenceIndex;
|
|
|
|
animationDescription->delay = delay;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4156A8
|
2022-06-18 05:27:54 -07:00
|
|
|
static int animationRunSequence(int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (animationSequenceIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
if (animationSequence->field_0 == -1000) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (animationSequence->field_0 >= animationSequence->length) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animationSequence->field_0 > animationSequence->animationIndex) {
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[animationSequence->field_0]);
|
|
|
|
if (animationDescription->delay < 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animationDescription->delay > 0) {
|
|
|
|
animationDescription->delay--;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[animationSequence->field_0++]);
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
Rect rect;
|
2022-07-29 06:04:05 -07:00
|
|
|
switch (animationDescription->kind) {
|
|
|
|
case ANIM_KIND_MOVE_TO_OBJECT:
|
|
|
|
rc = animateMoveObjectToObject(animationDescription->owner, animationDescription->destination, animationDescription->actionPoints, animationDescription->anim, animationSequenceIndex);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_MOVE_TO_TILE:
|
|
|
|
rc = animateMoveObjectToTile(animationDescription->owner, animationDescription->tile, animationDescription->elevation, animationDescription->actionPoints, animationDescription->anim, animationSequenceIndex);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_MOVE_TO_TILE_STRAIGHT:
|
|
|
|
rc = animateMoveObjectToTileStraight(animationDescription->owner, animationDescription->tile, animationDescription->elevation, animationDescription->anim, animationSequenceIndex, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_MOVE_TO_TILE_STRAIGHT_AND_WAIT_FOR_COMPLETE:
|
|
|
|
rc = animateMoveObjectToTileStraight(animationDescription->owner, animationDescription->tile, animationDescription->elevation, animationDescription->anim, animationSequenceIndex, ANIM_SAD_WAIT_FOR_COMPLETION);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
case ANIM_KIND_ANIMATE:
|
|
|
|
rc = _anim_animate(animationDescription->owner, animationDescription->anim, animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_ANIMATE_REVERSED:
|
|
|
|
rc = _anim_animate(animationDescription->owner, animationDescription->anim, animationSequenceIndex, ANIM_SAD_REVERSE);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_ANIMATE_AND_HIDE:
|
|
|
|
rc = _anim_animate(animationDescription->owner, animationDescription->anim, animationSequenceIndex, ANIM_SAD_HIDE_ON_END);
|
2022-05-19 01:51:26 -07:00
|
|
|
if (rc == -1) {
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
rc = _anim_hide(animationDescription->owner, animationSequenceIndex);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ANIM_KIND_ANIMATE_FOREVER:
|
2022-07-29 06:04:05 -07:00
|
|
|
rc = _anim_animate(animationDescription->owner, animationDescription->anim, animationSequenceIndex, ANIM_SAD_FOREVER);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_ROTATE_TO_TILE:
|
2022-05-19 01:51:26 -07:00
|
|
|
if (!_critter_is_prone(animationDescription->owner)) {
|
|
|
|
int rotation = tileGetRotationTo(animationDescription->owner->tile, animationDescription->tile);
|
|
|
|
_dude_stand(animationDescription->owner, rotation, -1);
|
|
|
|
}
|
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
rc = 0;
|
|
|
|
break;
|
|
|
|
case ANIM_KIND_ROTATE_CLOCKWISE:
|
|
|
|
rc = actionRotate(animationDescription->owner, 1, animationSequenceIndex);
|
|
|
|
break;
|
|
|
|
case ANIM_KIND_ROTATE_COUNTER_CLOCKWISE:
|
|
|
|
rc = actionRotate(animationDescription->owner, -1, animationSequenceIndex);
|
|
|
|
break;
|
|
|
|
case ANIM_KIND_HIDE:
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
rc = _anim_hide(animationDescription->owner, animationSequenceIndex);
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_CALLBACK:
|
|
|
|
rc = animationDescription->callback(animationDescription->param1, animationDescription->param2);
|
2022-05-19 01:51:26 -07:00
|
|
|
if (rc == 0) {
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_CALLBACK3:
|
|
|
|
rc = animationDescription->callback3(animationDescription->param1, animationDescription->param2, animationDescription->param3);
|
2022-05-19 01:51:26 -07:00
|
|
|
if (rc == 0) {
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_SET_FLAG:
|
|
|
|
if (animationDescription->objectFlag == OBJECT_LIGHTING) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (_obj_turn_on_light(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
} else if (animationDescription->objectFlag == OBJECT_HIDDEN) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (objectHide(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->owner->flags |= animationDescription->objectFlag;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_UNSET_FLAG:
|
|
|
|
if (animationDescription->objectFlag == OBJECT_LIGHTING) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (_obj_turn_off_light(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
} else if (animationDescription->objectFlag == OBJECT_HIDDEN) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (objectShow(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
animationDescription->owner->flags &= ~animationDescription->objectFlag;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_TOGGLE_FLAT:
|
2022-05-19 01:51:26 -07:00
|
|
|
if (_obj_toggle_flat(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_SET_FID:
|
2022-05-19 01:51:26 -07:00
|
|
|
rc = _anim_change_fid(animationDescription->owner, animationSequenceIndex, animationDescription->fid);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_TAKE_OUT_WEAPON:
|
2022-05-19 01:51:26 -07:00
|
|
|
rc = _anim_animate(animationDescription->owner, ANIM_TAKE_OUT, animationSequenceIndex, animationDescription->tile);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_SET_LIGHT_DISTANCE:
|
2022-05-19 01:51:26 -07:00
|
|
|
objectSetLight(animationDescription->owner, animationDescription->lightDistance, animationDescription->owner->lightIntensity, &rect);
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-08-05 07:43:00 -07:00
|
|
|
case ANIM_KIND_SET_LIGHT_INTENSITY:
|
|
|
|
objectSetLight(animationDescription->owner, animationDescription->lightDistance, animationDescription->lightIntensity, &rect);
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
2022-09-01 08:41:37 -07:00
|
|
|
case ANIM_KIND_MOVE_ON_STAIRS:
|
2022-05-19 01:51:26 -07:00
|
|
|
rc = _anim_move_on_stairs(animationDescription->owner, animationDescription->tile, animationDescription->elevation, animationDescription->anim, animationSequenceIndex);
|
|
|
|
break;
|
2022-09-01 08:41:37 -07:00
|
|
|
case ANIM_KIND_CHECK_FALLING:
|
2022-05-19 01:51:26 -07:00
|
|
|
rc = _check_for_falling(animationDescription->owner, animationDescription->anim, animationSequenceIndex);
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_TOGGLE_OUTLINE:
|
|
|
|
if (animationDescription->outline) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (objectEnableOutline(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (objectDisableOutline(animationDescription->owner, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
|
|
|
case ANIM_KIND_26:
|
2022-07-29 06:04:05 -07:00
|
|
|
gAnimationSequences[animationDescription->animationSequenceIndex].flags &= ~ANIM_SEQ_0x10;
|
|
|
|
rc = _anim_set_continue(animationDescription->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
if (rc != -1) {
|
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
break;
|
2022-07-29 06:04:05 -07:00
|
|
|
case ANIM_KIND_NOOP:
|
2022-05-19 01:51:26 -07:00
|
|
|
rc = _anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == -1) {
|
|
|
|
_anim_set_end(animationSequenceIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animationSequence->field_0 == -1000) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415B44
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_set_continue(int animationSequenceIndex, int a2)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (animationSequenceIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
if (animationSequence->field_0 == -1000) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
animationSequence->animationIndex++;
|
|
|
|
if (animationSequence->animationIndex == animationSequence->length) {
|
|
|
|
return _anim_set_end(animationSequenceIndex);
|
|
|
|
} else {
|
|
|
|
if (a2) {
|
|
|
|
return animationRunSequence(animationSequenceIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415B9C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_set_end(int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
AnimationSequence* animationSequence;
|
|
|
|
AnimationDescription* animationDescription;
|
|
|
|
int i;
|
|
|
|
Rect v27;
|
|
|
|
|
|
|
|
if (animationSequenceIndex == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
animationSequence = &(gAnimationSequences[animationSequenceIndex]);
|
|
|
|
if (animationSequence->field_0 == -1000) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
for (i = 0; i < gAnimationCurrentSad; i++) {
|
|
|
|
AnimationSad* sad = &(gAnimationSads[i]);
|
|
|
|
if (sad->animationSequenceIndex == animationSequenceIndex) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < animationSequence->length; i++) {
|
|
|
|
animationDescription = &(animationSequence->animations[i]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind == ANIM_KIND_HIDE && ((i < animationSequence->animationIndex) || (animationDescription->extendedFlags & ANIMATION_SEQUENCE_FORCED))) {
|
2022-05-19 01:51:26 -07:00
|
|
|
objectDestroy(animationDescription->owner, &v27);
|
|
|
|
tileWindowRefreshRect(&v27, animationDescription->owner->elevation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < animationSequence->length; i++) {
|
|
|
|
animationDescription = &(animationSequence->animations[i]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->artCacheKey) {
|
|
|
|
artUnlock(animationDescription->artCacheKey);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind != 11 && animationDescription->kind != 12) {
|
2022-05-19 01:51:26 -07:00
|
|
|
// TODO: Check.
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind != ANIM_KIND_26) {
|
2022-05-19 01:51:26 -07:00
|
|
|
Object* owner = animationDescription->owner;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_TYPE(owner->fid) == OBJ_TYPE_CRITTER) {
|
2022-05-19 01:51:26 -07:00
|
|
|
int j = 0;
|
|
|
|
for (; j < i; j++) {
|
|
|
|
AnimationDescription* ad = &(animationSequence->animations[j]);
|
|
|
|
if (owner == ad->owner) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if (ad->kind != ANIM_KIND_CALLBACK && ad->kind != ANIM_KIND_CALLBACK3) {
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == j) {
|
|
|
|
int k = 0;
|
|
|
|
for (; k < animationSequence->animationIndex; k++) {
|
|
|
|
AnimationDescription* ad = &(animationSequence->animations[k]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if (ad->kind == ANIM_KIND_HIDE && ad->owner == owner) {
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k == animationSequence->animationIndex) {
|
2022-07-07 01:28:21 -07:00
|
|
|
for (int m = 0; m < gAnimationCurrentSad; m++) {
|
|
|
|
if (gAnimationSads[m].obj == owner) {
|
|
|
|
gAnimationSads[m].field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((animationSequence->flags & ANIM_SEQ_NO_STAND) == 0 && !_critter_is_prone(owner)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_dude_stand(owner, owner->rotation, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (i >= animationSequence->field_0) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->extendedFlags & ANIMATION_SEQUENCE_FORCED) {
|
|
|
|
animationDescription->callback(animationDescription->param1, animationDescription->param2);
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
if (animationDescription->kind == ANIM_KIND_CALLBACK && animationDescription->callback == (AnimationCallback*)_gsnd_anim_sound) {
|
|
|
|
soundEffectDelete((Sound*)animationDescription->param1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
animationSequence->animationIndex = -1;
|
|
|
|
animationSequence->field_0 = -1000;
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((animationSequence->flags & ANIM_SEQ_COMBAT_ANIM_STARTED) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_combat_anim_finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_anim_in_bk) {
|
2022-07-29 06:04:05 -07:00
|
|
|
animationSequence->flags = ANIM_SEQ_0x20;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
animationSequence->flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415E24
|
2022-06-18 05:27:54 -07:00
|
|
|
static bool canUseDoor(Object* critter, Object* door)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (critter == gDude) {
|
|
|
|
if (!_obj_portal_is_walk_thru(door)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_TYPE(critter->fid) != OBJ_TYPE_CRITTER) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_TYPE(door->fid) != OBJ_TYPE_SCENERY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bodyType = critterGetBodyType(critter);
|
|
|
|
if (bodyType != BODY_TYPE_BIPED && bodyType != BODY_TYPE_ROBOTIC) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Proto* proto;
|
|
|
|
if (protoGetProto(door->pid, &proto) == -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proto->scenery.type != SCENERY_TYPE_DOOR) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (objectIsLocked(door)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (critterGetKillType(critter) == KILL_TYPE_GECKO) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415EE8
|
|
|
|
int _make_path(Object* object, int from, int to, unsigned char* rotations, int a5)
|
|
|
|
{
|
|
|
|
return pathfinderFindPath(object, from, to, rotations, a5, _obj_blocking_at);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x415EFC
|
|
|
|
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback)
|
|
|
|
{
|
|
|
|
if (a5) {
|
|
|
|
if (callback(object, to, object->elevation) != NULL) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isCritter = false;
|
|
|
|
int kt = 0;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (PID_TYPE(object->pid) == OBJ_TYPE_CRITTER) {
|
2022-05-19 01:51:26 -07:00
|
|
|
isCritter = true;
|
|
|
|
kt = critterGetKillType(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNotInCombat = !isInCombat();
|
|
|
|
|
|
|
|
memset(gPathfinderProcessedTiles, 0, sizeof(gPathfinderProcessedTiles));
|
|
|
|
|
|
|
|
gPathfinderProcessedTiles[from / 8] |= 1 << (from & 7);
|
|
|
|
|
|
|
|
gOpenPathNodeList[0].tile = from;
|
|
|
|
gOpenPathNodeList[0].from = -1;
|
|
|
|
gOpenPathNodeList[0].rotation = 0;
|
|
|
|
gOpenPathNodeList[0].field_C = _tile_idistance(from, to);
|
|
|
|
gOpenPathNodeList[0].field_10 = 0;
|
|
|
|
|
|
|
|
for (int index = 1; index < 2000; index += 1) {
|
|
|
|
gOpenPathNodeList[index].tile = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int toScreenX;
|
|
|
|
int toScreenY;
|
|
|
|
tileToScreenXY(to, &toScreenX, &toScreenY, object->elevation);
|
|
|
|
|
|
|
|
int closedPathNodeListLength = 0;
|
|
|
|
int openPathNodeListLength = 1;
|
|
|
|
PathNode temp;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
int v63 = -1;
|
|
|
|
|
|
|
|
PathNode* prev = NULL;
|
|
|
|
int v12 = 0;
|
|
|
|
for (int index = 0; v12 < openPathNodeListLength; index += 1) {
|
|
|
|
PathNode* curr = &(gOpenPathNodeList[index]);
|
|
|
|
if (curr->tile != -1) {
|
|
|
|
v12++;
|
|
|
|
if (v63 == -1 || (curr->field_C + curr->field_10) < (prev->field_C + prev->field_10)) {
|
|
|
|
prev = curr;
|
|
|
|
v63 = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PathNode* curr = &(gOpenPathNodeList[v63]);
|
|
|
|
|
|
|
|
memcpy(&temp, curr, sizeof(temp));
|
|
|
|
|
|
|
|
openPathNodeListLength -= 1;
|
|
|
|
|
|
|
|
curr->tile = -1;
|
|
|
|
|
|
|
|
if (temp.tile == to) {
|
|
|
|
if (openPathNodeListLength == 0) {
|
|
|
|
openPathNodeListLength = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
PathNode* curr1 = &(gClosedPathNodeList[closedPathNodeListLength]);
|
|
|
|
memcpy(curr1, &temp, sizeof(temp));
|
|
|
|
|
|
|
|
closedPathNodeListLength += 1;
|
|
|
|
|
|
|
|
if (closedPathNodeListLength == 2000) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
|
|
|
|
int tile = tileGetTileInDirection(temp.tile, rotation, 1);
|
|
|
|
int bit = 1 << (tile & 7);
|
|
|
|
if ((gPathfinderProcessedTiles[tile / 8] & bit) != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tile != to) {
|
|
|
|
Object* v24 = callback(object, tile, object->elevation);
|
|
|
|
if (v24 != NULL) {
|
|
|
|
if (!canUseDoor(object, v24)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int v25 = 0;
|
|
|
|
for (; v25 < 2000; v25++) {
|
|
|
|
if (gOpenPathNodeList[v25].tile == -1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openPathNodeListLength += 1;
|
|
|
|
|
|
|
|
if (openPathNodeListLength == 2000) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gPathfinderProcessedTiles[tile / 8] |= bit;
|
|
|
|
|
|
|
|
PathNode* v27 = &(gOpenPathNodeList[v25]);
|
|
|
|
v27->tile = tile;
|
|
|
|
v27->from = temp.tile;
|
|
|
|
v27->rotation = rotation;
|
|
|
|
|
|
|
|
int newX;
|
|
|
|
int newY;
|
|
|
|
tileToScreenXY(tile, &newX, &newY, object->elevation);
|
|
|
|
|
|
|
|
v27->field_C = _idist(newX, newY, toScreenX, toScreenY);
|
|
|
|
v27->field_10 = temp.field_10 + 50;
|
|
|
|
|
|
|
|
if (isNotInCombat && temp.rotation != rotation) {
|
|
|
|
v27->field_10 += 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCritter) {
|
|
|
|
Object* o = objectFindFirstAtLocation(object->elevation, v27->tile);
|
|
|
|
while (o != NULL) {
|
|
|
|
if (o->pid >= 0x20003D9 && o->pid <= 0x20003DC) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
o = objectFindNextAtLocation();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (o != NULL) {
|
|
|
|
if (kt == KILL_TYPE_GECKO) {
|
|
|
|
v27->field_10 += 100;
|
|
|
|
} else {
|
|
|
|
v27->field_10 += 400;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (openPathNodeListLength == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (openPathNodeListLength != 0) {
|
|
|
|
unsigned char* v39 = rotations;
|
|
|
|
int index = 0;
|
|
|
|
for (; index < 800; index++) {
|
|
|
|
if (temp.tile == from) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v39 != NULL) {
|
|
|
|
*v39 = temp.rotation & 0xFF;
|
|
|
|
v39 += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int j = 0;
|
|
|
|
while (gClosedPathNodeList[j].tile != temp.from) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
PathNode* v36 = &(gClosedPathNodeList[j]);
|
|
|
|
memcpy(&temp, v36, sizeof(temp));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rotations != NULL) {
|
|
|
|
// Looks like array resevering, probably because A* finishes it's path from end to start,
|
|
|
|
// this probably reverses it start-to-end.
|
|
|
|
unsigned char* beginning = rotations;
|
|
|
|
unsigned char* ending = rotations + index - 1;
|
|
|
|
int middle = index / 2;
|
|
|
|
for (int index = 0; index < middle; index++) {
|
|
|
|
unsigned char rotation = *ending;
|
|
|
|
*ending = *beginning;
|
|
|
|
*beginning = rotation;
|
|
|
|
|
|
|
|
ending -= 1;
|
|
|
|
beginning += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x41633C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _idist(int x1, int y1, int x2, int y2)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
int dx = x2 - x1;
|
|
|
|
if (dx < 0) {
|
|
|
|
dx = -dx;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dy = y2 - y1;
|
|
|
|
if (dy < 0) {
|
|
|
|
dy = -dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dm = (dx <= dy) ? dx : dy;
|
|
|
|
|
|
|
|
return dx + dy - (dm / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x416360
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _tile_idistance(int tile1, int tile2)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
int x1;
|
|
|
|
int y1;
|
|
|
|
tileToScreenXY(tile1, &x1, &y1, gElevation);
|
|
|
|
|
|
|
|
int x2;
|
|
|
|
int y2;
|
|
|
|
tileToScreenXY(tile2, &x2, &y2, gElevation);
|
|
|
|
|
|
|
|
return _idist(x1, y1, x2, y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4163AC
|
|
|
|
int _make_straight_path(Object* a1, int from, int to, STRUCT_530014_28* pathNodes, Object** a5, int a6)
|
|
|
|
{
|
|
|
|
return _make_straight_path_func(a1, from, to, pathNodes, a5, a6, _obj_blocking_at);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Rather complex, but understandable, needs testing.
|
|
|
|
//
|
|
|
|
// 0x4163C8
|
|
|
|
int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4, Object** a5, int a6, Object* (*a7)(Object*, int, int))
|
|
|
|
{
|
|
|
|
if (a5 != NULL) {
|
|
|
|
Object* v11 = a7(a1, from, a1->elevation);
|
|
|
|
if (v11 != NULL) {
|
2022-06-08 10:38:46 -07:00
|
|
|
if (v11 != *a5 && (a6 != 32 || (v11->flags & OBJECT_SHOOT_THRU) == 0)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
*a5 = v11;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int fromX;
|
|
|
|
int fromY;
|
|
|
|
tileToScreenXY(from, &fromX, &fromY, a1->elevation);
|
|
|
|
fromX += 16;
|
|
|
|
fromY += 8;
|
|
|
|
|
|
|
|
int toX;
|
|
|
|
int toY;
|
|
|
|
tileToScreenXY(to, &toX, &toY, a1->elevation);
|
|
|
|
toX += 16;
|
|
|
|
toY += 8;
|
|
|
|
|
|
|
|
int stepX;
|
|
|
|
int deltaX = toX - fromX;
|
|
|
|
if (deltaX > 0)
|
|
|
|
stepX = 1;
|
|
|
|
else if (deltaX < 0)
|
|
|
|
stepX = -1;
|
|
|
|
else
|
|
|
|
stepX = 0;
|
|
|
|
|
|
|
|
int stepY;
|
|
|
|
int deltaY = toY - fromY;
|
|
|
|
if (deltaY > 0)
|
|
|
|
stepY = 1;
|
|
|
|
else if (deltaY < 0)
|
|
|
|
stepY = -1;
|
|
|
|
else
|
|
|
|
stepY = 0;
|
|
|
|
|
|
|
|
int v48 = 2 * abs(toX - fromX);
|
|
|
|
int v47 = 2 * abs(toY - fromY);
|
|
|
|
|
|
|
|
int tileX = fromX;
|
|
|
|
int tileY = fromY;
|
|
|
|
|
|
|
|
int pathNodeIndex = 0;
|
2022-06-04 15:01:49 -07:00
|
|
|
int prevTile = from;
|
2022-05-19 01:51:26 -07:00
|
|
|
int v22 = 0;
|
|
|
|
int tile;
|
|
|
|
|
|
|
|
if (v48 <= v47) {
|
|
|
|
int middle = v48 - v47 / 2;
|
|
|
|
while (true) {
|
|
|
|
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
|
|
|
|
|
|
|
|
v22 += 1;
|
|
|
|
if (v22 == a6) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a4 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a4[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = a1->elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
v22 = 0;
|
|
|
|
pathNodeIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileY == toY) {
|
|
|
|
if (a5 != NULL) {
|
|
|
|
*a5 = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (middle >= 0) {
|
|
|
|
tileX += stepX;
|
|
|
|
middle -= v47;
|
|
|
|
}
|
|
|
|
|
|
|
|
tileY += stepY;
|
|
|
|
middle += v48;
|
|
|
|
|
2022-06-04 15:01:49 -07:00
|
|
|
if (tile != prevTile) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (a5 != NULL) {
|
|
|
|
Object* obj = a7(a1, tile, a1->elevation);
|
|
|
|
if (obj != NULL) {
|
2022-06-08 10:38:46 -07:00
|
|
|
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
*a5 = obj;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-04 15:01:49 -07:00
|
|
|
prevTile = tile;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int middle = v47 - v48 / 2;
|
|
|
|
while (true) {
|
|
|
|
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
|
|
|
|
|
|
|
|
v22 += 1;
|
|
|
|
if (v22 == a6) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a4 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a4[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = a1->elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
v22 = 0;
|
|
|
|
pathNodeIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileX == toX) {
|
|
|
|
if (a5 != NULL) {
|
|
|
|
*a5 = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (middle >= 0) {
|
|
|
|
tileY += stepY;
|
|
|
|
middle -= v48;
|
|
|
|
}
|
|
|
|
|
|
|
|
tileX += stepX;
|
|
|
|
middle += v47;
|
|
|
|
|
2022-06-04 15:01:49 -07:00
|
|
|
if (tile != prevTile) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (a5 != NULL) {
|
|
|
|
Object* obj = a7(a1, tile, a1->elevation);
|
|
|
|
if (obj != NULL) {
|
2022-06-08 10:38:46 -07:00
|
|
|
if (obj != *a5 && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
*a5 = obj;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-04 15:01:49 -07:00
|
|
|
prevTile = tile;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v22 != 0) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a4 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a4[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = a1->elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
pathNodeIndex += 1;
|
|
|
|
} else {
|
|
|
|
if (pathNodeIndex > 0 && a4 != NULL) {
|
|
|
|
a4[pathNodeIndex - 1].elevation = a1->elevation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pathNodeIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4167F8
|
2022-06-18 05:27:54 -07:00
|
|
|
static int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim, int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-06-09 23:23:43 -07:00
|
|
|
bool hidden = (to->flags & OBJECT_HIDDEN);
|
2022-06-08 10:38:46 -07:00
|
|
|
to->flags |= OBJECT_HIDDEN;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-06-10 00:40:22 -07:00
|
|
|
int moveSadIndex = _anim_move(from, to->tile, to->elevation, -1, anim, 0, animationSequenceIndex);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-06-09 23:23:43 -07:00
|
|
|
if (!hidden) {
|
2022-06-08 10:38:46 -07:00
|
|
|
to->flags &= ~OBJECT_HIDDEN;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-06-10 00:40:22 -07:00
|
|
|
if (moveSadIndex == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[moveSadIndex]);
|
2022-06-10 00:40:22 -07:00
|
|
|
// NOTE: Original code is somewhat different. Due to some kind of
|
|
|
|
// optimization this value is either 1 or 2, which is later used in
|
|
|
|
// subsequent calculations and rotations array lookup.
|
|
|
|
bool isMultihex = (from->flags & OBJECT_MULTIHEX);
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_1C -= (isMultihex ? 2 : 1);
|
|
|
|
if (sad->field_1C <= 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_24 = tileGetTileInDirection(to->tile, sad->rotations[isMultihex ? sad->field_1C + 1 : sad->field_1C], 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-06-10 00:40:22 -07:00
|
|
|
if (isMultihex) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_24 = tileGetTileInDirection(sad->field_24, sad->rotations[sad->field_1C], 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (a3 != -1 && a3 < sad->field_1C) {
|
|
|
|
sad->field_1C = a3;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
// 0x41695C
|
|
|
|
int _make_stair_path(Object* object, int from, int fromElevation, int to, int toElevation, STRUCT_530014_28* a6, Object** obstaclePtr)
|
|
|
|
{
|
|
|
|
int elevation = fromElevation;
|
|
|
|
if (elevation > toElevation) {
|
|
|
|
elevation = toElevation;
|
|
|
|
}
|
|
|
|
|
|
|
|
int fromX;
|
|
|
|
int fromY;
|
|
|
|
tileToScreenXY(from, &fromX, &fromY, fromElevation);
|
|
|
|
fromX += 16;
|
|
|
|
fromY += 8;
|
|
|
|
|
|
|
|
int toX;
|
|
|
|
int toY;
|
|
|
|
tileToScreenXY(to, &toX, &toY, toElevation);
|
|
|
|
toX += 16;
|
|
|
|
toY += 8;
|
|
|
|
|
|
|
|
if (obstaclePtr != NULL) {
|
|
|
|
*obstaclePtr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ddx = 2 * abs(toX - fromX);
|
|
|
|
|
|
|
|
int stepX;
|
|
|
|
int deltaX = toX - fromX;
|
|
|
|
if (deltaX > 0) {
|
|
|
|
stepX = 1;
|
|
|
|
} else if (deltaX < 0) {
|
|
|
|
stepX = -1;
|
|
|
|
} else {
|
|
|
|
stepX = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ddy = 2 * abs(toY - fromY);
|
|
|
|
|
|
|
|
int stepY;
|
|
|
|
int deltaY = toY - fromY;
|
|
|
|
if (deltaY > 0) {
|
|
|
|
stepY = 1;
|
|
|
|
} else if (deltaY < 0) {
|
|
|
|
stepY = -1;
|
|
|
|
} else {
|
|
|
|
stepY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tileX = fromX;
|
|
|
|
int tileY = fromY;
|
|
|
|
|
|
|
|
int pathNodeIndex = 0;
|
|
|
|
int prevTile = from;
|
|
|
|
int iteration = 0;
|
|
|
|
int tile;
|
|
|
|
|
|
|
|
if (ddx > ddy) {
|
|
|
|
int middle = ddy - ddx / 2;
|
|
|
|
while (true) {
|
|
|
|
tile = tileFromScreenXY(tileX, tileY, elevation);
|
|
|
|
|
|
|
|
iteration += 1;
|
|
|
|
if (iteration == 16) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a6 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a6[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
iteration = 0;
|
|
|
|
pathNodeIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileX == toX) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (middle >= 0) {
|
|
|
|
tileY += stepY;
|
|
|
|
middle -= ddx;
|
|
|
|
}
|
|
|
|
|
|
|
|
tileX += stepX;
|
|
|
|
middle += ddy;
|
|
|
|
|
|
|
|
if (tile != prevTile) {
|
|
|
|
if (obstaclePtr != NULL) {
|
|
|
|
*obstaclePtr = _obj_blocking_at(object, tile, object->elevation);
|
|
|
|
if (*obstaclePtr != NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prevTile = tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int middle = ddx - ddy / 2;
|
|
|
|
while (true) {
|
|
|
|
tile = tileFromScreenXY(tileX, tileY, elevation);
|
|
|
|
|
|
|
|
iteration += 1;
|
|
|
|
if (iteration == 16) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a6 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a6[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
iteration = 0;
|
|
|
|
pathNodeIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tileY == toY) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (middle >= 0) {
|
|
|
|
tileX += stepX;
|
|
|
|
middle -= ddy;
|
|
|
|
}
|
|
|
|
|
|
|
|
tileY += stepY;
|
|
|
|
middle += ddx;
|
|
|
|
|
|
|
|
if (tile != prevTile) {
|
|
|
|
if (obstaclePtr != NULL) {
|
|
|
|
*obstaclePtr = _obj_blocking_at(object, tile, object->elevation);
|
|
|
|
if (*obstaclePtr != NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prevTile = tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iteration != 0) {
|
|
|
|
if (pathNodeIndex >= 200) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a6 != NULL) {
|
|
|
|
STRUCT_530014_28* pathNode = &(a6[pathNodeIndex]);
|
|
|
|
pathNode->tile = tile;
|
|
|
|
pathNode->elevation = elevation;
|
|
|
|
|
|
|
|
tileToScreenXY(tile, &fromX, &fromY, elevation);
|
|
|
|
pathNode->x = tileX - fromX - 16;
|
|
|
|
pathNode->y = tileY - fromY - 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
pathNodeIndex++;
|
|
|
|
} else {
|
|
|
|
if (pathNodeIndex > 0) {
|
|
|
|
if (a6 != NULL) {
|
|
|
|
a6[pathNodeIndex - 1].elevation = toElevation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pathNodeIndex;
|
|
|
|
}
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x416CFC
|
2022-06-18 05:27:54 -07:00
|
|
|
static int animateMoveObjectToTile(Object* obj, int tile, int elev, int a4, int anim, int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
int v1;
|
|
|
|
|
|
|
|
v1 = _anim_move(obj, tile, elev, -1, anim, 0, animationSequenceIndex);
|
|
|
|
if (v1 == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_obj_blocking_at(obj, tile, elev)) {
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[v1]);
|
|
|
|
sad->field_1C--;
|
|
|
|
if (sad->field_1C <= 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_24 = tileGetTileInDirection(tile, sad->rotations[sad->field_1C], 1);
|
|
|
|
if (a4 != -1 && a4 < sad->field_1C) {
|
|
|
|
sad->field_1C = a4;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x416DFC
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_move(Object* obj, int tile, int elev, int a3, int anim, int a5, int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
|
|
|
|
sad->obj = obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
if (a5) {
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags = ANIM_SAD_0x20;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->flags = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -2000;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->animationTimestamp = 0;
|
|
|
|
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
|
|
|
|
sad->field_24 = tile;
|
|
|
|
sad->animationSequenceIndex = animationSequenceIndex;
|
|
|
|
sad->anim = anim;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_1C = _make_path(obj, obj->tile, tile, sad->rotations, a5);
|
|
|
|
if (sad->field_1C == 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (a3 != -1 && sad->field_1C > a3) {
|
|
|
|
sad->field_1C = a3;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
return gAnimationCurrentSad++;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x416F54
|
2022-07-29 06:04:05 -07:00
|
|
|
static int animateMoveObjectToTileStraight(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex, int flags)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
|
|
|
|
sad->obj = obj;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags = flags | ANIM_SAD_STRAIGHT;
|
2022-05-19 01:51:26 -07:00
|
|
|
if (anim == -1) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->fid = obj->fid;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags |= ANIM_SAD_NO_ANIM;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -2000;
|
|
|
|
sad->animationTimestamp = 0;
|
|
|
|
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
|
|
|
|
sad->animationSequenceIndex = animationSequenceIndex;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
int v15;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_TYPE(obj->fid) == OBJ_TYPE_CRITTER) {
|
|
|
|
if (FID_ANIM_TYPE(obj->fid) == ANIM_JUMP_BEGIN)
|
2022-05-19 01:51:26 -07:00
|
|
|
v15 = 16;
|
|
|
|
else
|
|
|
|
v15 = 4;
|
|
|
|
} else {
|
|
|
|
v15 = 32;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_1C = _make_straight_path(obj, obj->tile, tile, sad->field_28, NULL, v15);
|
|
|
|
if (sad->field_1C == 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad++;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x41712C
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_move_on_stairs(Object* obj, int tile, int elevation, int anim, int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags = ANIM_SAD_STRAIGHT;
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->obj = obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
if (anim == -1) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->fid = obj->fid;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags |= ANIM_SAD_NO_ANIM;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -2000;
|
|
|
|
sad->animationTimestamp = 0;
|
|
|
|
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
|
|
|
|
sad->animationSequenceIndex = animationSequenceIndex;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->field_1C = _make_stair_path(obj, obj->tile, obj->elevation, tile, elevation, sad->field_28, NULL);
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_1C == 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad++;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x417248
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _check_for_falling(Object* obj, int anim, int a3)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_check_gravity(obj->tile, obj->elevation) == obj->elevation) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags = ANIM_SAD_STRAIGHT;
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->obj = obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
if (anim == -1) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->fid = obj->fid;
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->flags |= ANIM_SAD_NO_ANIM;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-29 06:04:05 -07:00
|
|
|
sad->fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -2000;
|
|
|
|
sad->animationTimestamp = 0;
|
|
|
|
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
|
|
|
|
sad->animationSequenceIndex = a3;
|
|
|
|
sad->field_1C = _make_straight_path_func(obj, obj->tile, obj->tile, sad->field_28, 0, 16, _obj_blocking_at);
|
|
|
|
if (sad->field_1C == 0) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad++;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x417360
|
2022-06-18 05:27:54 -07:00
|
|
|
static void _object_move(int index)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[index]);
|
|
|
|
Object* object = sad->obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
Rect dirty;
|
|
|
|
Rect temp;
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == -2000) {
|
2022-05-19 01:51:26 -07:00
|
|
|
objectSetLocation(object, object->tile, object->elevation, &dirty);
|
|
|
|
|
|
|
|
objectSetFrame(object, 0, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
objectSetRotation(object, sad->rotations[0], &temp);
|
2022-05-19 01:51:26 -07:00
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(FID_TYPE(object->fid), object->fid & 0xFFF, sad->anim, (object->fid & 0xF000) >> 12, object->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
objectSetFid(object, fid, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
objectSetNextFrame(object, &dirty);
|
|
|
|
}
|
|
|
|
|
|
|
|
int frameX;
|
|
|
|
int frameY;
|
|
|
|
|
|
|
|
CacheEntry* cacheHandle;
|
|
|
|
Art* art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
|
|
|
artGetFrameOffsets(art, object->frame, object->rotation, &frameX, &frameY);
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
} else {
|
|
|
|
frameX = 0;
|
|
|
|
frameY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_obj_offset(object, frameX, frameY, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
int rotation = sad->rotations[sad->field_20];
|
2022-05-19 01:51:26 -07:00
|
|
|
int y = dword_51D984[rotation];
|
|
|
|
int x = _off_tile[rotation];
|
2022-08-01 09:47:09 -07:00
|
|
|
if ((x > 0 && x <= object->x) || (x < 0 && x >= object->x) || (y > 0 && y <= object->y) || (y < 0 && y >= object->y)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
x = object->x - x;
|
|
|
|
y = object->y - y;
|
|
|
|
|
|
|
|
int v10 = tileGetTileInDirection(object->tile, rotation, 1);
|
|
|
|
Object* v12 = _obj_blocking_at(object, v10, object->elevation);
|
|
|
|
if (v12 != NULL) {
|
|
|
|
if (!canUseDoor(object, v12)) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_1C = _make_path(object, object->tile, sad->field_24, sad->rotations, 1);
|
|
|
|
if (sad->field_1C != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
objectSetLocation(object, object->tile, object->elevation, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
|
|
|
objectSetFrame(object, 0, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
objectSetRotation(object, sad->rotations[0], &temp);
|
2022-05-19 01:51:26 -07:00
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
v10 = -1;
|
|
|
|
} else {
|
|
|
|
_obj_use_door(object, v12, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v10 != -1) {
|
|
|
|
objectSetLocation(object, v10, object->elevation, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
|
|
|
int v17 = 0;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (isInCombat() && FID_TYPE(object->fid) == OBJ_TYPE_CRITTER) {
|
2022-05-19 01:51:26 -07:00
|
|
|
int v18 = critterGetMovementPointCostAdjustedForCrippledLegs(object, 1);
|
|
|
|
if (_combat_free_move < v18) {
|
|
|
|
int ap = object->data.critter.combat.ap;
|
|
|
|
int v20 = v18 - _combat_free_move;
|
|
|
|
_combat_free_move = 0;
|
|
|
|
if (v20 > ap) {
|
|
|
|
object->data.critter.combat.ap = 0;
|
|
|
|
} else {
|
|
|
|
object->data.critter.combat.ap = ap - v20;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_combat_free_move -= v18;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (object == gDude) {
|
|
|
|
interfaceRenderActionPoints(gDude->data.critter.combat.ap, _combat_free_move);
|
|
|
|
}
|
|
|
|
|
|
|
|
v17 = (object->data.critter.combat.ap + _combat_free_move) <= 0;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 += 1;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == sad->field_1C || v17) {
|
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-07 01:28:21 -07:00
|
|
|
objectSetRotation(object, sad->rotations[sad->field_20], &temp);
|
2022-05-19 01:51:26 -07:00
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
|
|
|
|
_obj_offset(object, x, y, &temp);
|
|
|
|
rectUnion(&dirty, &temp, &dirty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tileWindowRefreshRect(&dirty, object->elevation);
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == -1000) {
|
|
|
|
_anim_set_continue(sad->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4177C0
|
2022-06-18 05:27:54 -07:00
|
|
|
static void _object_straight_move(int index)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[index]);
|
|
|
|
Object* object = sad->obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
Rect dirtyRect;
|
|
|
|
Rect temp;
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == -2000) {
|
|
|
|
objectSetFid(object, sad->fid, &dirtyRect);
|
|
|
|
sad->field_20 = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
objectGetRect(object, &dirtyRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
CacheEntry* cacheHandle;
|
|
|
|
Art* art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
|
|
|
int lastFrame = artGetFrameCount(art) - 1;
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_NO_ANIM) == 0) {
|
|
|
|
if ((sad->flags & ANIM_SAD_WAIT_FOR_COMPLETION) == 0 || object->frame < lastFrame) {
|
|
|
|
objectSetNextFrame(object, &temp);
|
|
|
|
rectUnion(&dirtyRect, &temp, &dirtyRect);
|
|
|
|
}
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 < sad->field_1C) {
|
|
|
|
STRUCT_530014_28* v12 = &(sad->field_28[sad->field_20]);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
objectSetLocation(object, v12->tile, v12->elevation, &temp);
|
|
|
|
rectUnion(&dirtyRect, &temp, &dirtyRect);
|
|
|
|
|
|
|
|
_obj_offset(object, v12->x, v12->y, &temp);
|
|
|
|
rectUnion(&dirtyRect, &temp, &dirtyRect);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20++;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (sad->field_20 == sad->field_1C) {
|
|
|
|
if ((sad->flags & ANIM_SAD_WAIT_FOR_COMPLETION) == 0 || object->frame == lastFrame) {
|
|
|
|
sad->field_20 = -1000;
|
|
|
|
}
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
tileWindowRefreshRect(&dirtyRect, sad->obj->elevation);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == -1000) {
|
|
|
|
_anim_set_continue(sad->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4179B8
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_animate(Object* obj, int anim, int animationSequenceIndex, int flags)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == ANIMATION_SAD_LIST_CAPACITY) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
AnimationSad* sad = &(gAnimationSads[gAnimationCurrentSad]);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
int fid;
|
|
|
|
if (anim == ANIM_TAKE_OUT) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->flags = 0;
|
2022-07-29 06:04:05 -07:00
|
|
|
fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_TAKE_OUT, flags, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->flags = flags;
|
2022-07-29 06:04:05 -07:00
|
|
|
fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!artExists(fid)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->obj = obj;
|
|
|
|
sad->fid = fid;
|
|
|
|
sad->animationSequenceIndex = animationSequenceIndex;
|
|
|
|
sad->animationTimestamp = 0;
|
|
|
|
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
|
|
|
|
sad->field_20 = 0;
|
|
|
|
sad->field_1C = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad++;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x417B30
|
|
|
|
void _object_animate()
|
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
if (gAnimationCurrentSad == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_in_bk = 1;
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
for (int index = 0; index < gAnimationCurrentSad; index++) {
|
|
|
|
AnimationSad* sad = &(gAnimationSads[index]);
|
|
|
|
if (sad->field_20 == -1000) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
Object* object = sad->obj;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-10-05 00:11:47 -07:00
|
|
|
unsigned int time = getTicks();
|
2022-07-07 01:28:21 -07:00
|
|
|
if (getTicksBetween(time, sad->animationTimestamp) < sad->ticksPerFrame) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->animationTimestamp = time;
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (animationRunSequence(sad->animationSequenceIndex) == -1) {
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_1C > 0) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_STRAIGHT) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
_object_straight_move(index);
|
|
|
|
} else {
|
|
|
|
int savedTile = object->tile;
|
|
|
|
_object_move(index);
|
|
|
|
if (savedTile != object->tile) {
|
|
|
|
scriptsExecSpatialProc(object, object->tile, object->elevation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (sad->field_20 == 0) {
|
|
|
|
for (int index = 0; index < gAnimationCurrentSad; index++) {
|
|
|
|
AnimationSad* otherSad = &(gAnimationSads[index]);
|
|
|
|
if (object == otherSad->obj && otherSad->field_20 == -2000) {
|
|
|
|
otherSad->field_20 = -1000;
|
|
|
|
_anim_set_continue(otherSad->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -2000;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Rect dirtyRect;
|
|
|
|
Rect tempRect;
|
|
|
|
|
|
|
|
objectGetRect(object, &dirtyRect);
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (object->fid == sad->fid) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_REVERSE) == 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
CacheEntry* cacheHandle;
|
|
|
|
Art* art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_FOREVER) == 0 && object->frame == artGetFrameCount(art) - 1) {
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -1000;
|
2022-05-19 01:51:26 -07:00
|
|
|
artUnlock(cacheHandle);
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_HIDE_ON_END) != 0) {
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Uninline.
|
|
|
|
_anim_hide(object, -1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
_anim_set_continue(sad->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
objectSetNextFrame(object, &tempRect);
|
|
|
|
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
|
|
|
|
|
|
|
|
int frameX;
|
|
|
|
int frameY;
|
|
|
|
artGetFrameOffsets(art, object->frame, object->rotation, &frameX, &frameY);
|
|
|
|
|
|
|
|
_obj_offset(object, frameX, frameY, &tempRect);
|
|
|
|
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
|
|
|
|
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tileWindowRefreshRect(&dirtyRect, gElevation);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_FOREVER) != 0 || object->frame != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
CacheEntry* cacheHandle;
|
|
|
|
Art* art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
|
|
|
artGetFrameOffsets(art, object->frame, object->rotation, &x, &y);
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
}
|
|
|
|
|
|
|
|
objectSetPrevFrame(object, &tempRect);
|
|
|
|
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
|
|
|
|
|
|
|
|
_obj_offset(object, -x, -y, &tempRect);
|
|
|
|
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
|
|
|
|
|
|
|
|
tileWindowRefreshRect(&dirtyRect, gElevation);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
sad->field_20 = -1000;
|
|
|
|
_anim_set_continue(sad->animationSequenceIndex, 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
} else {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
CacheEntry* cacheHandle;
|
|
|
|
Art* art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
|
|
|
artGetRotationOffsets(art, object->rotation, &x, &y);
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
} else {
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect v29;
|
2022-07-07 01:28:21 -07:00
|
|
|
objectSetFid(object, sad->fid, &v29);
|
2022-05-19 01:51:26 -07:00
|
|
|
rectUnion(&dirtyRect, &v29, &dirtyRect);
|
|
|
|
|
|
|
|
art = artLock(object->fid, &cacheHandle);
|
|
|
|
if (art != NULL) {
|
|
|
|
int frame;
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((sad->flags & ANIM_SAD_REVERSE) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
frame = artGetFrameCount(art) - 1;
|
|
|
|
} else {
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
objectSetFrame(object, frame, &v29);
|
|
|
|
rectUnion(&dirtyRect, &v29, &dirtyRect);
|
|
|
|
|
|
|
|
int frameX;
|
|
|
|
int frameY;
|
|
|
|
artGetFrameOffsets(art, object->frame, object->rotation, &frameX, &frameY);
|
|
|
|
|
|
|
|
Rect v19;
|
|
|
|
_obj_offset(object, x + frameX, y + frameY, &v19);
|
|
|
|
rectUnion(&dirtyRect, &v19, &dirtyRect);
|
|
|
|
|
|
|
|
artUnlock(cacheHandle);
|
|
|
|
} else {
|
|
|
|
objectSetFrame(object, 0, &v29);
|
|
|
|
rectUnion(&dirtyRect, &v29, &dirtyRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
tileWindowRefreshRect(&dirtyRect, gElevation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_in_bk = 0;
|
|
|
|
|
|
|
|
_object_anim_compact();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x417F18
|
2022-06-18 05:27:54 -07:00
|
|
|
static void _object_anim_compact()
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[index]);
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((animationSequence->flags & ANIM_SEQ_0x20) != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
animationSequence->flags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = 0;
|
2022-07-07 01:28:21 -07:00
|
|
|
for (; index < gAnimationCurrentSad; index++) {
|
|
|
|
if (gAnimationSads[index].field_20 == -1000) {
|
2022-05-19 01:51:26 -07:00
|
|
|
int v2 = index + 1;
|
2022-07-07 01:28:21 -07:00
|
|
|
for (; v2 < gAnimationCurrentSad; v2++) {
|
|
|
|
if (gAnimationSads[v2].field_20 != -1000) {
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
if (v2 == gAnimationCurrentSad) {
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index != v2) {
|
2022-07-07 01:28:21 -07:00
|
|
|
memcpy(&(gAnimationSads[index]), &(gAnimationSads[v2]), sizeof(AnimationSad));
|
|
|
|
gAnimationSads[v2].field_20 = -1000;
|
|
|
|
gAnimationSads[v2].flags = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationCurrentSad = index;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x417FFC
|
|
|
|
int _check_move(int* a1)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
mouseGetPosition(&x, &y);
|
|
|
|
|
|
|
|
int tile = tileFromScreenXY(x, y, gElevation);
|
|
|
|
if (tile == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isInCombat()) {
|
|
|
|
if (*a1 != -1) {
|
2022-05-23 01:44:49 -07:00
|
|
|
if (gPressedPhysicalKeys[SDL_SCANCODE_RCTRL] || gPressedPhysicalKeys[SDL_SCANCODE_LCTRL]) {
|
2022-05-19 01:51:26 -07:00
|
|
|
int hitMode;
|
|
|
|
bool aiming;
|
|
|
|
interfaceGetCurrentHitMode(&hitMode, &aiming);
|
|
|
|
|
2022-08-17 22:41:15 -07:00
|
|
|
int v6 = itemGetActionPointCost(gDude, hitMode, aiming);
|
2022-05-19 01:51:26 -07:00
|
|
|
*a1 = *a1 - v6;
|
|
|
|
if (*a1 <= 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2022-10-06 06:32:46 -07:00
|
|
|
if (settings.system.interrupt_walk) {
|
2022-05-19 01:51:26 -07:00
|
|
|
reg_anim_clear(gDude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4180B4
|
|
|
|
int _dude_move(int a1)
|
|
|
|
{
|
|
|
|
int v1;
|
|
|
|
int tile = _check_move(&v1);
|
|
|
|
if (tile == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_lastDestination == tile) {
|
|
|
|
return _dude_run(a1);
|
|
|
|
}
|
|
|
|
|
|
|
|
_lastDestination = tile;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationRegisterMoveToTile(gDude, tile, gDude->elevation, a1, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return reg_anim_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x41810C
|
|
|
|
int _dude_run(int a1)
|
|
|
|
{
|
|
|
|
int a4;
|
|
|
|
int tile_num;
|
|
|
|
|
|
|
|
a4 = a1;
|
|
|
|
tile_num = _check_move(&a4);
|
|
|
|
if (tile_num == -1) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!perkGetRank(gDude, PERK_SILENT_RUNNING)) {
|
|
|
|
dudeDisableState(0);
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationRegisterRunToTile(gDude, tile_num, gDude->elevation, a4, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
return reg_anim_end();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x418168
|
|
|
|
void _dude_fidget()
|
|
|
|
{
|
|
|
|
if (_game_user_wants_to_quit != 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isInCombat()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (vcrGetState() != VCR_STATE_TURNED_OFF) {
|
2022-05-19 01:51:26 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((gDude->flags & OBJECT_HIDDEN) != 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int v0 = _get_bk_time();
|
|
|
|
if (getTicksBetween(v0, _last_time_) <= _next_time) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_last_time_ = v0;
|
|
|
|
|
|
|
|
int v5 = 0;
|
|
|
|
Object* object = objectFindFirstAtElevation(gDude->elevation);
|
|
|
|
while (object != NULL) {
|
|
|
|
if (v5 >= 100) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if ((object->flags & OBJECT_HIDDEN) == 0 && FID_TYPE(object->fid) == OBJ_TYPE_CRITTER && FID_ANIM_TYPE(object->fid) == ANIM_STAND && !critterIsDead(object)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
Rect rect;
|
|
|
|
objectGetRect(object, &rect);
|
|
|
|
|
|
|
|
Rect intersection;
|
|
|
|
if (rectIntersection(&rect, &_scr_size, &intersection) == 0 && (gMapHeader.field_34 != 97 || object->pid != 0x10000FA)) {
|
|
|
|
dword_56C7E0[v5++] = object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object = objectFindNextAtElevation();
|
|
|
|
}
|
|
|
|
|
|
|
|
int v13;
|
|
|
|
if (v5 != 0) {
|
|
|
|
int r = randomBetween(0, v5 - 1);
|
|
|
|
Object* object = dword_56C7E0[r];
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
reg_anim_begin(ANIMATION_REQUEST_UNRESERVED | ANIMATION_REQUEST_INSIGNIFICANT);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
bool v8 = false;
|
|
|
|
if (object == gDude) {
|
|
|
|
v8 = true;
|
|
|
|
} else {
|
|
|
|
char v15[16];
|
|
|
|
v15[0] = '\0';
|
|
|
|
artCopyFileName(1, object->fid & 0xFFF, v15);
|
|
|
|
if (v15[0] == 'm' || v15[0] == 'M') {
|
|
|
|
if (objectGetDistanceBetween(object, gDude) < critterGetStat(gDude, STAT_PERCEPTION) * 2) {
|
|
|
|
v8 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v8) {
|
|
|
|
const char* sfx = sfxBuildCharName(object, ANIM_STAND, CHARACTER_SOUND_EFFECT_UNUSED);
|
2022-07-29 06:04:05 -07:00
|
|
|
animationRegisterPlaySoundEffect(object, sfx, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationRegisterAnimate(object, ANIM_STAND, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
reg_anim_end();
|
|
|
|
|
|
|
|
v13 = 20 / v5;
|
|
|
|
} else {
|
|
|
|
v13 = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v13 < 1) {
|
|
|
|
v13 = 1;
|
|
|
|
} else if (v13 > 7) {
|
|
|
|
v13 = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
_next_time = randomBetween(0, 3000) + 1000 * v13;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x418378
|
|
|
|
void _dude_stand(Object* obj, int rotation, int fid)
|
|
|
|
{
|
|
|
|
Rect rect;
|
|
|
|
|
|
|
|
objectSetRotation(obj, rotation, &rect);
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
int weaponAnimationCode = (obj->fid & 0xF000) >> 12;
|
|
|
|
if (weaponAnimationCode != 0) {
|
2022-05-19 01:51:26 -07:00
|
|
|
if (fid == -1) {
|
2022-07-29 06:04:05 -07:00
|
|
|
int takeOutFid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_TAKE_OUT, weaponAnimationCode, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
CacheEntry* takeOutFrmHandle;
|
|
|
|
Art* takeOutFrm = artLock(takeOutFid, &takeOutFrmHandle);
|
|
|
|
if (takeOutFrm != NULL) {
|
|
|
|
int frameCount = artGetFrameCount(takeOutFrm);
|
|
|
|
for (int frame = 0; frame < frameCount; frame++) {
|
|
|
|
int offsetX;
|
|
|
|
int offsetY;
|
|
|
|
artGetFrameOffsets(takeOutFrm, frame, obj->rotation, &offsetX, &offsetY);
|
|
|
|
x += offsetX;
|
|
|
|
y += offsetY;
|
|
|
|
}
|
|
|
|
artUnlock(takeOutFrmHandle);
|
|
|
|
|
|
|
|
CacheEntry* standFrmHandle;
|
2022-07-29 06:04:05 -07:00
|
|
|
int standFid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_STAND, 0, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
Art* standFrm = artLock(standFid, &standFrmHandle);
|
|
|
|
if (standFrm != NULL) {
|
|
|
|
int offsetX;
|
|
|
|
int offsetY;
|
|
|
|
if (artGetRotationOffsets(standFrm, obj->rotation, &offsetX, &offsetY) == 0) {
|
|
|
|
x += offsetX;
|
|
|
|
y += offsetY;
|
|
|
|
}
|
|
|
|
artUnlock(standFrmHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fid == -1) {
|
|
|
|
int anim;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_ANIM_TYPE(obj->fid) == ANIM_FIRE_DANCE) {
|
2022-05-19 01:51:26 -07:00
|
|
|
anim = ANIM_FIRE_DANCE;
|
|
|
|
} else {
|
|
|
|
anim = ANIM_STAND;
|
|
|
|
}
|
2022-07-29 06:04:05 -07:00
|
|
|
fid = buildFid(FID_TYPE(obj->fid), (obj->fid & 0xFFF), anim, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Rect temp;
|
|
|
|
objectSetFid(obj, fid, &temp);
|
|
|
|
rectUnion(&rect, &temp, &rect);
|
|
|
|
|
|
|
|
objectSetLocation(obj, obj->tile, obj->elevation, &temp);
|
|
|
|
rectUnion(&rect, &temp, &rect);
|
|
|
|
|
|
|
|
objectSetFrame(obj, 0, &temp);
|
|
|
|
rectUnion(&rect, &temp, &rect);
|
|
|
|
|
|
|
|
_obj_offset(obj, x, y, &temp);
|
|
|
|
rectUnion(&rect, &temp, &rect);
|
|
|
|
|
|
|
|
tileWindowRefreshRect(&rect, obj->elevation);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x418574
|
|
|
|
void _dude_standup(Object* a1)
|
|
|
|
{
|
2022-07-29 06:04:05 -07:00
|
|
|
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
|
2022-05-19 01:51:26 -07:00
|
|
|
|
|
|
|
int anim;
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_ANIM_TYPE(a1->fid) == ANIM_FALL_BACK) {
|
2022-05-19 01:51:26 -07:00
|
|
|
anim = ANIM_BACK_TO_STANDING;
|
|
|
|
} else {
|
|
|
|
anim = ANIM_PRONE_TO_STANDING;
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
animationRegisterAnimate(a1, anim, 0);
|
2022-05-19 01:51:26 -07:00
|
|
|
reg_anim_end();
|
|
|
|
a1->data.critter.combat.results &= ~DAM_KNOCKED_DOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4185EC
|
2022-06-18 05:27:54 -07:00
|
|
|
static int actionRotate(Object* obj, int delta, int animationSequenceIndex)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
if (!_critter_is_prone(obj)) {
|
|
|
|
int rotation = obj->rotation + delta;
|
|
|
|
if (rotation >= ROTATION_COUNT) {
|
|
|
|
rotation = ROTATION_NE;
|
|
|
|
} else if (rotation < 0) {
|
|
|
|
rotation = ROTATION_NW;
|
|
|
|
}
|
|
|
|
|
|
|
|
_dude_stand(obj, rotation, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-01 08:41:37 -07:00
|
|
|
// NOTE: Inlined.
|
|
|
|
//
|
|
|
|
// 0x41862C
|
|
|
|
static int _anim_hide(Object* object, int animationSequenceIndex)
|
|
|
|
{
|
|
|
|
Rect rect;
|
|
|
|
|
|
|
|
if (objectHide(object, &rect) == 0) {
|
|
|
|
tileWindowRefreshRect(&rect, object->elevation);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animationSequenceIndex != -1) {
|
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-19 01:51:26 -07:00
|
|
|
// 0x418660
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _anim_change_fid(Object* obj, int animationSequenceIndex, int fid)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
Rect rect;
|
|
|
|
Rect v7;
|
|
|
|
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_ANIM_TYPE(fid)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
objectSetFid(obj, fid, &rect);
|
|
|
|
objectSetFrame(obj, 0, &v7);
|
|
|
|
rectUnion(&rect, &v7, &rect);
|
|
|
|
tileWindowRefreshRect(&rect, obj->elevation);
|
|
|
|
} else {
|
|
|
|
_dude_stand(obj, obj->rotation, fid);
|
|
|
|
}
|
|
|
|
|
|
|
|
_anim_set_continue(animationSequenceIndex, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x4186CC
|
2022-07-07 01:28:21 -07:00
|
|
|
void animationStop()
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationInStop = true;
|
2022-05-19 01:51:26 -07:00
|
|
|
gAnimationSequenceCurrentIndex = -1;
|
|
|
|
|
|
|
|
for (int index = 0; index < ANIMATION_SEQUENCE_LIST_CAPACITY; index++) {
|
|
|
|
_anim_set_end(index);
|
|
|
|
}
|
|
|
|
|
2022-07-07 01:28:21 -07:00
|
|
|
gAnimationInStop = false;
|
|
|
|
gAnimationCurrentSad = 0;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 0x418708
|
2022-06-18 05:27:54 -07:00
|
|
|
static int _check_gravity(int tile, int elevation)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
for (; elevation > 0; elevation--) {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
tileToScreenXY(tile, &x, &y, elevation);
|
|
|
|
|
2022-05-23 15:37:46 -07:00
|
|
|
int squareTile = squareTileFromScreenXY(x + 2, y + 8, elevation);
|
2022-07-29 06:04:05 -07:00
|
|
|
int fid = buildFid(OBJ_TYPE_TILE, _square[elevation]->field_0[squareTile] & 0xFFF, 0, 0, 0);
|
|
|
|
if (fid != buildFid(OBJ_TYPE_TILE, 1, 0, 0, 0)) {
|
2022-05-19 01:51:26 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return elevation;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 0x418794
|
2022-07-07 01:28:21 -07:00
|
|
|
static unsigned int animationComputeTicksPerFrame(Object* object, int fid)
|
2022-05-19 01:51:26 -07:00
|
|
|
{
|
|
|
|
int fps;
|
|
|
|
|
|
|
|
CacheEntry* handle;
|
|
|
|
Art* frm = artLock(fid, &handle);
|
|
|
|
if (frm != NULL) {
|
|
|
|
fps = artGetFramesPerSecond(frm);
|
|
|
|
artUnlock(handle);
|
|
|
|
} else {
|
|
|
|
fps = 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isInCombat()) {
|
2022-07-29 06:04:05 -07:00
|
|
|
if (FID_ANIM_TYPE(fid) == ANIM_WALK) {
|
2022-10-06 06:32:46 -07:00
|
|
|
if (object != gDude || settings.preferences.player_speedup) {
|
|
|
|
fps += settings.preferences.combat_speed;
|
2022-05-19 01:51:26 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1000 / fps;
|
|
|
|
}
|
2022-08-05 07:43:00 -07:00
|
|
|
|
|
|
|
int animationRegisterSetLightIntensity(Object* owner, int lightDistance, int lightIntensity, int delay)
|
|
|
|
{
|
|
|
|
if (_check_registry(owner) == -1) {
|
|
|
|
_anim_cleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
|
|
|
|
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
|
|
|
|
animationDescription->kind = ANIM_KIND_SET_LIGHT_INTENSITY;
|
|
|
|
animationDescription->artCacheKey = NULL;
|
|
|
|
animationDescription->owner = owner;
|
|
|
|
animationDescription->lightDistance = lightDistance;
|
|
|
|
animationDescription->lightIntensity = lightIntensity;
|
|
|
|
animationDescription->delay = delay;
|
|
|
|
|
|
|
|
gAnimationDescriptionCurrentIndex++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-09-23 05:43:44 -07:00
|
|
|
|
|
|
|
} // namespace fallout
|