Skip to content

Commit

Permalink
Tidying up the actor and sound code. Adds EXT_ACTOR_DICT.
Browse files Browse the repository at this point in the history
  • Loading branch information
torg_el committed Nov 2, 2008
1 parent 74e046c commit 0b11daf
Show file tree
Hide file tree
Showing 14 changed files with 958 additions and 1,777 deletions.
2,041 changes: 570 additions & 1,471 deletions actor_scripts.c

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,12 +1255,6 @@ void add_actor_from_server (const char *in_data, int len)
short max_health;
short cur_health;
short actor_type;
//char remapable;
//char skin;
//char hair;
//char shirt;
//char pants;
//char boots;
char frame;
int i;
int dead=0;
Expand Down Expand Up @@ -1434,7 +1428,7 @@ void add_actor_from_server (const char *in_data, int len)
if(actors_list[i]->calmodel){
model_attach_mesh(actors_list[i], actors_defs[actor_type].shirt[0].mesh_index);
if(dead){
cal_actor_set_anim(i, actors_defs[actors_list[i]->actor_type].cal_die1_frame);
cal_actor_set_anim(i, actors_defs[actors_list[i]->actor_type].cal_frames[cal_actor_die1_frame]);
actors_list[i]->stop_animation=1;
CalModel_Update(actors_list[i]->calmodel,1000);
}
Expand Down
121 changes: 29 additions & 92 deletions actors.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ typedef struct
int glow;
int mesh_index;
#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -183,7 +183,7 @@ typedef struct
int missile_type; /*!< The type of equipped missiles (>=0 if a quiver is equipped, -1 if a regular shield is equipped) */

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -201,35 +201,10 @@ typedef struct
int glow;
int mesh_index;

struct cal_anim cal_range_in_frame;
struct cal_anim cal_range_out_frame;
struct cal_anim cal_range_idle_frame;
struct cal_anim cal_range_fire_frame;
struct cal_anim cal_range_fire_out_frame;

struct cal_anim cal_attack_up_1_frame;
struct cal_anim cal_attack_up_2_frame;
struct cal_anim cal_attack_up_3_frame;
struct cal_anim cal_attack_up_4_frame;
struct cal_anim cal_attack_up_5_frame;
struct cal_anim cal_attack_up_6_frame;
struct cal_anim cal_attack_up_7_frame;
struct cal_anim cal_attack_up_8_frame;
struct cal_anim cal_attack_up_9_frame;
struct cal_anim cal_attack_up_10_frame;
struct cal_anim cal_attack_down_1_frame;
struct cal_anim cal_attack_down_2_frame;
struct cal_anim cal_attack_down_3_frame;
struct cal_anim cal_attack_down_4_frame;
struct cal_anim cal_attack_down_5_frame;
struct cal_anim cal_attack_down_6_frame;
struct cal_anim cal_attack_down_7_frame;
struct cal_anim cal_attack_down_8_frame;
struct cal_anim cal_attack_down_9_frame;
struct cal_anim cal_attack_down_10_frame;
struct cal_anim cal_frames[NUM_WEAPON_FRAMES];

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -249,7 +224,7 @@ typedef struct
int mesh_index;

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -270,7 +245,7 @@ typedef struct
int mesh_index;

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -286,7 +261,7 @@ typedef struct
int mesh_index;

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -304,7 +279,7 @@ typedef struct
int mesh_index;

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand All @@ -323,7 +298,7 @@ typedef struct
int mesh_index;

#ifdef NEW_LIGHTING
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat ambient[4]; /*!< The lighting for when the texture is in shadow */
GLfloat diffuse[4]; /*!< The lighting for when the object is lit, but not reflecting */
GLfloat specular[4]; /*!< The lighting for when the object is reflecting */
GLfloat emission[4]; /*!< The lighting for if the object glows */
Expand Down Expand Up @@ -357,9 +332,7 @@ typedef struct
int parent_bone_id; /*!< The bone to use on the actor to which it is attached */
int local_bone_id; /*!< The bone to use on the actor that is attached */
float shift[3]; /*!< The shift to apply to the actor that is held */
struct cal_anim cal_walk_frame; /*!< walk animation to use for the held actor */
struct cal_anim cal_idle_frame; /*!< idle animation to use for the held actor */
struct cal_anim cal_pain_frame; /*!< pain animation to use for the held actor */
struct cal_anim cal_frames[NUM_ATTACHED_ACTOR_FRAMES];
} attachment_props;

/*!
Expand All @@ -371,7 +344,20 @@ typedef struct
} attached_actors_types;
#endif // ATTACHED_ACTORS

// TODO: would be nice to make these dynamic
#ifdef EXT_ACTOR_DICT
typedef enum {
ACTOR_HEAD_SIZE = 0,
ACTOR_SHIELD_SIZE,
ACTOR_CAPE_SIZE,
ACTOR_HELMET_SIZE,
ACTOR_WEAPON_SIZE,
ACTOR_SHIRT_SIZE,
ACTOR_SKIN_SIZE,
ACTOR_HAIR_SIZE,
ACTOR_BOOTS_SIZE,
ACTOR_LEGS_SIZE,
} actor_parts_enum;
#else // EXT_ACTOR_DICT
#define ACTOR_HEAD_SIZE 10
#define ACTOR_SHIELD_SIZE 40
#define ACTOR_CAPE_SIZE 50
Expand All @@ -382,6 +368,7 @@ typedef struct
#define ACTOR_HAIR_SIZE 20
#define ACTOR_BOOTS_SIZE 40
#define ACTOR_LEGS_SIZE 60
#endif // EXT_ACTOR_DICT

typedef struct
{
Expand All @@ -408,58 +395,8 @@ typedef struct
struct cal_anim_group idle_group[16];//16 animation groups
int group_count;

struct cal_anim cal_walk_frame;
struct cal_anim cal_run_frame;
struct cal_anim cal_die1_frame;
struct cal_anim cal_die2_frame;
struct cal_anim cal_pain1_frame;
struct cal_anim cal_pain2_frame;
struct cal_anim cal_pick_frame;
struct cal_anim cal_drop_frame;
struct cal_anim cal_idle1_frame;
struct cal_anim cal_idle2_frame;
struct cal_anim cal_idle_sit_frame;
struct cal_anim cal_harvest_frame;
struct cal_anim cal_attack_cast_frame;
struct cal_anim cal_attack_ranged_frame;
struct cal_anim cal_sit_down_frame;
struct cal_anim cal_stand_up_frame;
struct cal_anim cal_in_combat_frame;
struct cal_anim cal_out_combat_frame;
struct cal_anim cal_combat_idle_frame;
struct cal_anim cal_attack_up_1_frame;
struct cal_anim cal_attack_up_2_frame;
struct cal_anim cal_attack_up_3_frame;
struct cal_anim cal_attack_up_4_frame;
struct cal_anim cal_attack_up_5_frame;
struct cal_anim cal_attack_up_6_frame;
struct cal_anim cal_attack_up_7_frame;
struct cal_anim cal_attack_up_8_frame;
struct cal_anim cal_attack_up_9_frame;
struct cal_anim cal_attack_up_10_frame;
struct cal_anim cal_attack_down_1_frame;
struct cal_anim cal_attack_down_2_frame;
struct cal_anim cal_attack_down_3_frame;
struct cal_anim cal_attack_down_4_frame;
struct cal_anim cal_attack_down_5_frame;
struct cal_anim cal_attack_down_6_frame;
struct cal_anim cal_attack_down_7_frame;
struct cal_anim cal_attack_down_8_frame;
struct cal_anim cal_attack_down_9_frame;
struct cal_anim cal_attack_down_10_frame;

#ifdef EMOTES
struct cal_anim cal_emote_wave_frame;
struct cal_anim cal_emote_nod_head_frame;
struct cal_anim cal_emote_shake_head_frame;
struct cal_anim cal_emote_clap_hands_frame;
struct cal_anim cal_emote_shrug_frame;
struct cal_anim cal_emote_scratch_head_frame;
struct cal_anim cal_emote_jump_frame;
struct cal_anim cal_emote_stretch_frame;
struct cal_anim cal_emote_bow_frame;
#endif // EMOTES

struct cal_anim cal_frames[NUM_ACTOR_FRAMES];

int skeleton_type;

#ifdef NEW_SOUND
Expand Down Expand Up @@ -911,8 +848,8 @@ void draw_actor_without_banner(actor * actor_id, Uint32 use_lightning, Uint32 us
#ifdef ATTACHED_ACTORS
static __inline__ int is_actor_held(actor *act)
{
return (act->attached_actor >= 0 &&
((act->actor_id < 0 && // the actor is the attachment
return ((act->attached_actor >= 0) &&
((act->actor_id < 0 && // the actor is the attachment
!attached_actors_defs[act->actor_type].actor_type[actors_list[act->attached_actor]->actor_type].is_holder) ||
(act->actor_id >= 0 && // the actor is the parent of the attachment
attached_actors_defs[actors_list[act->attached_actor]->actor_type].actor_type[act->actor_type].is_holder)));
Expand Down
2 changes: 1 addition & 1 deletion asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void get_string_digest(const Uint8 * string, Uint8 digest[16])

int find_description_index (const dict_elem dict[], const char *elem, const char *desc) {
int idx = 0;
char *key;
const char *key;

while ((key = dict[idx].desc) != NULL) {
if (strcasecmp (key, elem) == 0)
Expand Down
4 changes: 4 additions & 0 deletions asc.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ void get_string_digest(const char*, Uint8[16]);

// Element type and dictionaries for actor definitions
typedef struct {
#ifndef EXT_ACTOR_DICT
char *desc;
#else
char desc[100];
#endif
int index;
} dict_elem;

Expand Down
12 changes: 6 additions & 6 deletions cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ void cal_actor_set_anim_delay(int id, struct cal_anim anim, float delay)
att_props = get_attachment_props_if_held(pActor);
if (att_props)
{
anim.anim_index = att_props->cal_idle_frame.anim_index;
anim.duration = att_props->cal_idle_frame.duration;
anim.duration_scale = att_props->cal_idle_frame.duration_scale;
anim.anim_index = att_props->cal_frames[cal_attached_idle_frame].anim_index;
anim.duration = att_props->cal_frames[cal_attached_idle_frame].duration;
anim.duration_scale = att_props->cal_frames[cal_attached_idle_frame].duration_scale;
}
else
{
#endif // ATTACHED_ACTORS
anim.anim_index = actors_defs[pActor->actor_type].cal_idle1_frame.anim_index;
anim.duration = actors_defs[pActor->actor_type].cal_idle1_frame.duration;
anim.duration_scale = actors_defs[pActor->actor_type].cal_idle1_frame.duration_scale;
anim.anim_index = actors_defs[pActor->actor_type].cal_frames[cal_actor_idle1_frame].anim_index;
anim.duration = actors_defs[pActor->actor_type].cal_frames[cal_actor_idle1_frame].duration;
anim.duration_scale = actors_defs[pActor->actor_type].cal_frames[cal_actor_idle1_frame].duration_scale;
#ifdef ATTACHED_ACTORS
}
#endif // ATTACHED_ACTORS
Expand Down
96 changes: 95 additions & 1 deletion cal_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,102 @@ struct cal_anim
#endif //NEW_SOUND
};

enum {
cal_actor_walk_frame = 0,
cal_actor_run_frame = 1,
cal_actor_die1_frame = 2,
cal_actor_die2_frame = 3,
cal_actor_pain1_frame = 4,
cal_actor_pain2_frame = 5,
cal_actor_pick_frame = 6,
cal_actor_drop_frame = 7,
cal_actor_idle1_frame = 8,
cal_actor_idle2_frame = 9,
cal_actor_idle_sit_frame = 10,
cal_actor_harvest_frame = 11,
cal_actor_attack_cast_frame = 12,
cal_actor_attack_ranged_frame = 13,
cal_actor_sit_down_frame = 14,
cal_actor_stand_up_frame = 15,
cal_actor_in_combat_frame = 16,
cal_actor_out_combat_frame = 17,
cal_actor_combat_idle_frame = 18,
cal_actor_attack_up_1_frame = 19,
cal_actor_attack_up_2_frame = 20,
cal_actor_attack_up_3_frame = 21,
cal_actor_attack_up_4_frame = 22,
cal_actor_attack_up_5_frame = 23,
cal_actor_attack_up_6_frame = 24,
cal_actor_attack_up_7_frame = 25,
cal_actor_attack_up_8_frame = 26,
cal_actor_attack_up_9_frame = 27,
cal_actor_attack_up_10_frame = 28,
cal_actor_attack_down_1_frame = 29,
cal_actor_attack_down_2_frame = 30,
cal_actor_attack_down_3_frame = 31,
cal_actor_attack_down_4_frame = 32,
cal_actor_attack_down_5_frame = 33,
cal_actor_attack_down_6_frame = 34,
cal_actor_attack_down_7_frame = 35,
cal_actor_attack_down_8_frame = 36,
cal_actor_attack_down_9_frame = 37,
cal_actor_attack_down_10_frame = 38,
#ifndef EMOTES
NUM_ACTOR_FRAMES = 39
#else // EMOTES
cal_actor_emote_wave_frame = 39,
cal_actor_emote_nod_head_frame = 40,
cal_actor_emote_shake_head_frame = 41,
cal_actor_emote_clap_hands_frame = 42,
cal_actor_emote_shrug_frame = 43,
cal_actor_emote_scratch_head_frame = 44,
cal_actor_emote_jump_frame = 45,
cal_actor_emote_stretch_frame = 46,
cal_actor_emote_bow_frame = 47,
NUM_ACTOR_FRAMES = 48
#endif // EMOTES
};

enum {
cal_weapon_attack_up_1_frame = 0,
cal_weapon_attack_up_2_frame = 1,
cal_weapon_attack_up_3_frame = 2,
cal_weapon_attack_up_4_frame = 3,
cal_weapon_attack_up_5_frame = 4,
cal_weapon_attack_up_6_frame = 5,
cal_weapon_attack_up_7_frame = 6,
cal_weapon_attack_up_8_frame = 7,
cal_weapon_attack_up_9_frame = 8,
cal_weapon_attack_up_10_frame = 9,
cal_weapon_attack_down_1_frame = 10,
cal_weapon_attack_down_2_frame = 11,
cal_weapon_attack_down_3_frame = 12,
cal_weapon_attack_down_4_frame = 13,
cal_weapon_attack_down_5_frame = 14,
cal_weapon_attack_down_6_frame = 15,
cal_weapon_attack_down_7_frame = 16,
cal_weapon_attack_down_8_frame = 17,
cal_weapon_attack_down_9_frame = 18,
cal_weapon_attack_down_10_frame = 19,
cal_weapon_range_in_frame = 20,
cal_weapon_range_out_frame = 21,
cal_weapon_range_idle_frame = 22,
cal_weapon_range_fire_frame = 23,
cal_weapon_range_fire_out_frame = 24,
NUM_WEAPON_FRAMES = 25
};

#ifdef ATTACHED_ACTORS
enum {
cal_attached_walk_frame = 0, /*!< walk animation to use for the held actor */
cal_attached_idle_frame = 1, /*!< idle animation to use for the held actor */
cal_attached_pain_frame = 2, /*!< pain animation to use for the held actor */
NUM_ATTACHED_ACTOR_FRAMES = 3
};
#endif // ATTACHED_ACTORS

#ifdef __cplusplus
} // extern "C"
#endif

#endif
#endif // __CAL_TYPES_H__
Loading

0 comments on commit 0b11daf

Please sign in to comment.