46 if (!strcmp(name,
"north"))
48 if (!strcmp(name,
"north_east"))
50 if (!strcmp(name,
"east"))
52 if (!strcmp(name,
"south_east"))
54 if (!strcmp(name,
"south"))
56 if (!strcmp(name,
"south_west"))
58 if (!strcmp(name,
"west"))
60 if (!strcmp(name,
"north_west"))
74 object *op = animation->
victim;
110 object *op = animation->
victim;
146 cf_log(
llevDebug,
"CFAnim: Error in animation - possible values for 'invisible' are 'yes' and 'no'\n");
162 cf_log(
llevDebug,
"CFAnim: Error in animation - possible values for 'wizard' are 'yes' and 'no'\n");
179 cf_log(
llevDebug,
"CFAnim: init say: parameters: %s\n", parameters ? parameters :
"null");
188 cf_log(
llevDebug,
"CFAnim: Error in animation: nothing to say with say function\n");
197 object *current_container;
220 if (current->
name == parameters)
223 for (current = animation->
victim->
inv; current; current = current->
below)
224 if (current->
name == parameters)
274 if (current->
name == parameters)
287 cf_log(
llevDebug,
"CFAnim: Error in animation: possible values for 'ghosted' are 'yes' and 'no'\n");
295 || (!
id && !animation->
ghosted))
303 corpse->
contr = NULL;
307 animation->
corpse = corpse;
339 mapname = strstr(parameters,
" ");
344 mapx = atoi(parameters);
346 parameters = mapname;
348 cf_log(
llevDebug,
"CFAnim: Error - not enough parameters for teleport\n");
352 mapname = strstr(parameters,
" ");
357 mapy = atoi(parameters);
359 if (mapname[0] ==
'\0')
363 teleport->
mapx = mapx;
364 teleport->
mapy = mapy;
412 if (sscanf(parameters,
"%d %d", &x, &y) != 2)
452 if (parameters && animation->
victim->
map) {
520 ordered_commands = 1;
526 dummy.
name = command;
527 if (!ordered_commands)
552 while (fgets(buffer, buffer_size, fichier)) {
553 if (buffer[0] ==
'[')
555 if (buffer[0] ==
'#')
557 buffer[strlen(buffer)-strlen(
"\n")] =
'\0';
558 while (buffer[strlen(buffer)-1] ==
' ')
559 buffer[strlen(buffer)-1] =
'\0';
560 if (strlen(buffer) <= 0)
564 name = strstr(buffer,
" ");
576 parameters = strstr(name,
" ");
580 while (*parameters ==
' ')
582 if (*parameters ==
'\0')
592 if (!animationhook) {
605 next->
id = animationhook->
funcinit(name, parameters, next);
608 current->
next = next;
627 if (!strcmp(&buffer[strlen(buffer)-strlen(
"\n")],
"\n"))
628 buffer[strlen(buffer)-strlen(
"\n")] =
'\0';
629 *value = strstr(buffer,
"=");
635 while ((strlen(*variable) > 0) && ((*variable)[strlen(*variable)-1] ==
' '))
636 (*variable)[strlen(*variable)-1] =
'\0';
637 while ((strlen(*value) > 0) && ((*value)[strlen(*value)-1] ==
' '))
638 (*value)[strlen(*value)-1] =
'\0';
639 while (**value ==
' ')
641 if ((**variable ==
'\0') || (**value ==
'\0'))
658 if (!strncmp(strg,
"y", 1))
660 else if (!strncmp(strg,
"n", 1))
662 else if (!strncmp(strg,
"Y", 1))
664 else if (!strncmp(strg,
"N", 1))
666 else if (!strncmp(strg,
"1", 1))
668 else if (!strncmp(strg,
"0", 1))
683 for (current = first_animation; current; current++)
705 new->nextmovement = NULL;
706 new->nextanimation = NULL;
710 first_animation =
new;
726 while (origin && !origin->
map)
727 origin = origin->
env;
729 if (!origin || !origin->
map)
737 for (x = 0; x < w; x++) {
738 for (y = 0; y < h; y++) {
740 if (ob->
name == sname)
760 static int start_animation(
object *who,
object *activator,
object *event,
const char *file,
const char *message) {
764 object *victim = NULL;
766 int always_delete = 0;
772 int errors_allowed = 0;
774 const char *animationitem;
778 int errors_found = 0;
781 fichier = fopen(file,
"r");
782 if (fichier == NULL) {
786 while (fgets(buffer,
HUGE_BUF, fichier)) {
787 if (buffer[0] ==
'[')
789 if (buffer[0] ==
'#')
791 if (!strcmp(buffer,
"\n"))
798 if (strncmp(buffer,
"[Config]", 8)) {
799 cf_log(
llevDebug,
"CFAnim: Fatal error in %s: [Config] must be the first group defined.\n", file);
802 while (fgets(buffer,
HUGE_BUF, fichier)) {
803 if (buffer[0] ==
'[')
805 if (buffer[0] ==
'#')
807 if (!strcmp(buffer,
"\n"))
812 if (!strcmp(variable,
"name")) {
815 if (value[strlen(value)-1] ==
'"')
816 value[strlen(value)-1] =
'\0';
818 }
else if (!strcmp(variable,
"victimtype")) {
819 if (!strcmp(value,
"player"))
821 else if (!strcmp(value,
"object"))
823 else if (!strcmp(value,
"any"))
825 else if (!strcmp(value,
"byname"))
829 }
else if (!strcmp(variable,
"victim")) {
831 if (!strcmp(value,
"who"))
833 else if (!strcmp(value,
"activator"))
835 else if (!strcmp(value,
"who_owner"))
838 cf_log(
llevDebug,
"CFAnim: Warning: object \"who\" doesn't exist and you're victimized it's owner\n");
841 else if (!strcmp(value,
"activator_owner"))
844 cf_log(
llevDebug,
"CFAnim: Warning: object \"activator\" doesn't exist and you're victimized it's owner\n");
847 victim = activator->
env;
848 else if (victimtype == 3) {
852 }
else if (!strcmp(variable,
"unique")) {
855 }
else if (!strcmp(variable,
"always_delete")) {
858 }
else if (!strcmp(variable,
"parallel")) {
861 }
else if (!strcmp(variable,
"paralyzed")) {
864 }
else if (!strcmp(variable,
"invisible")) {
867 }
else if (!strcmp(variable,
"wizard")) {
870 }
else if (!strcmp(variable,
"errors_allowed")) {
873 }
else if (!strcmp(variable,
"verbose")) {
876 }
else if (!strcmp(variable,
"time_representation")) {
877 if (!strcmp(value,
"second"))
879 else if (!strcmp(value,
"tick"))
883 }
else if (!strcmp(variable,
"animation")) {
890 if (message && message[0] !=
'\0') {
895 if (buffer[0] ==
'\0') {
898 cf_log(
llevDebug,
"CFAnim: Errors occurred during the parsing of %s\n", file);
917 if (((victim->
type ==
PLAYER) && (victimtype == 1))
918 || ((victim->
type !=
PLAYER) && (victimtype == 0))
919 || (errors_found && !errors_allowed)) {
921 cf_log(
llevDebug,
"CFAnim: No correct victim found or errors found, aborting.\n");
926 if (unique && !always_delete) {
930 current_anim->
name = name;
931 current_anim->
victim = victim;
934 current_anim->
wizard = wizard;
935 current_anim->
unique = unique;
937 current_anim->
corpse = NULL;
939 current_anim->
verbose = verbose;
943 while (buffer[0] ==
'[') {
944 while (strncmp(&buffer[1], animationitem, strlen(animationitem))) {
945 while ((value = fgets(buffer,
HUGE_BUF, fichier)) != NULL)
946 if (buffer[0] ==
'[')
949 cf_log(
llevDebug,
"CFAnim: no matching animation %s in file.\n", animationitem);
1025 static struct timeval yesterday;
1026 static int already_passed = 0;
1027 long int delta_milli;
1030 if (!already_passed) {
1032 memcpy(&yesterday, &now,
sizeof(
struct timeval));
1035 delta_milli = (now.tv_sec-yesterday.tv_sec)*1000+(now.tv_usec/1000-yesterday.tv_usec/1000);
1037 memcpy(&yesterday, &now,
sizeof(
struct timeval));
1038 for (current = first_animation; current; current = current->
nextanimation)
1046 if (first_animation == current)
1047 first_animation = next;
1052 free(current->
name);
1056 previous_anim = current;
1078 const char *propname;
1082 va_start(args, type);
1083 propname = va_arg(args,
const char *);
1085 if (!strcmp(propname,
"Identification")) {
1086 buf = va_arg(args,
char *);
1087 size = va_arg(args,
int);
1091 }
else if (!strcmp(propname,
"FullName")) {
1092 buf = va_arg(args,
char *);
1093 size = va_arg(args,
int);
1118 va_start(args, type);
1119 event_code = va_arg(args,
int);
1133 object *who, *activator, *third, *event;
1135 va_start(args, type);
1137 who = va_arg(args,
object *);
1138 activator = va_arg(args,
object *);
1139 third = va_arg(args,
object *);
1140 buf = va_arg(args,
char *);
1143 strcpy(message, buf);
1148 event = va_arg(args,
object *);
1155 if (activator != NULL) {
1157 }
else if (who != NULL) {
static long int initteleport(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static int get_dir_from_name(const char *name)
CF_PLUGIN void * cfanim_globalEventListener(int *type,...)
#define CFAPI_OBJECT_PROP_ANIMATION
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr)
void cf_map_message(mapstruct *m, const char *msg, int color)
int teleport(object *teleporter, uint8 tele_type, object *user)
static CFmovement * parse_animation_block(char *buffer, size_t buffer_size, FILE *fichier, CFanimation *parent)
static long int initnotice(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initmovement(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_free_string(sstring str)
static int start_animation(object *who, object *activator, object *event, const char *file, const char *message)
CF_PLUGIN anim_move_result cfanim_runPluginCommand(object *op, char *params)
static int get_boolean(const char *strg, int *bl)
static object * find_by_name(object *origin, const char *name)
CF_PLUGIN int postInitPlugin(void)
void cf_object_set_flag(object *ob, int flag, int value)
static long int initapply(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initfire(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static void animate(void)
static long int initmoveto(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static void animate_one(CFanimation *animation, long int milliseconds)
static long int initturn(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void *(* f_plug_api)(int *type,...)
int cf_map_get_height(mapstruct *map)
static anim_move_result runturn(struct CFanimation_struct *animation, long int id, void *parameters)
void cf_object_apply_below(object *pl)
void cf_object_update(object *op, int flags)
int cf_player_move(player *pl, int dir)
static int ordered_commands
static anim_move_result runghosted(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runstop(struct CFanimation_struct *animation, long int id, void *parameters)
void cf_system_register_global_event(int event, const char *name, f_plug_api hook)
sstring cf_add_string(const char *str)
enum time_enum time_representation
static anim_move_result runmessage(struct CFanimation_struct *animation, long int id, void *parameters)
static CFanimationHook * get_command(char *command)
CF_PLUGIN void * eventListener(int *type,...)
void cf_log(LogLevel logLevel, const char *format,...)
static long int initcamera(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static int is_animated_player(object *pl)
static anim_move_result runvisible(struct CFanimation_struct *animation, long int id, void *parameters)
char * cf_strdup_local(const char *str)
int cf_init_plugin(f_plug_api getHooks)
struct CFanimation_struct * parent
void cf_object_set_int_property(object *op, int propcode, int value)
static long int initghosted(const char *name, char *parameters, struct CFmovement_struct *move_entity)
CF_PLUGIN void * getPluginProperty(int *type,...)
static anim_move_result runmovement(struct CFanimation_struct *animation, long int id, void *parameters)
mapstruct * cf_map_get_map(const char *name, int flags)
sstring cf_find_string(const char *str)
static long int initpickup(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_object_say(object *op, char *msg)
static int equality_split(char *buffer, char **variable, char **value)
static anim_move_result runnotice(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runteleport(struct CFanimation_struct *animation, long int id, void *parameters)
struct CFanimation_struct * nextanimation
static anim_move_result runwizard(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result runsay(struct CFanimation_struct *animation, long int id, void *parameters)
char * cf_get_maps_directory(const char *name, char *buf, int size)
static CFanimation * create_animation(void)
#define CLEAR_FLAG(xyz, p)
static anim_move_result runfire(struct CFanimation_struct *animation, long int id, void *parameters)
static anim_move_result rundropobject(struct CFanimation_struct *animation, long int id, void *parameters)
void cf_object_remove(object *op)
static long int initvisible(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initmessage(const char *name, char *parameters, struct CFmovement_struct *move_entity)
int cf_object_apply(object *op, object *author, int flags)
struct CFmovement_struct * nextmovement
int snprintf(char *dest, int max, const char *format,...)
void cf_player_message(object *op, char *txt, int flags)
static int compareAnims(const void *a, const void *b)
int cf_object_move(object *op, int dir, object *originator)
static long int initpickupobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_object_pickup(object *op, object *what)
void cf_object_drop(object *op, object *author)
static CFanimation * first_animation
CF_PLUGIN int closePlugin(void)
static anim_move_result runapplyobject(struct CFanimation_struct *animation, long int id, void *parameters)
static long int initwizard(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static long int initapplyobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)
#define GETTIMEOFDAY(last_time)
CFanimationHook animationbox[]
static anim_move_result runapply(struct CFanimation_struct *animation, long int id, void *parameters)
#define GET_MAP_OB(M, X, Y)
static anim_move_result runpickup(struct CFanimation_struct *animation, long int id, void *parameters)
int cf_object_teleport(object *ob, mapstruct *map, int x, int y)
static void prepare_commands(void)
object * cf_object_clone(object *op, int clonetype)
static anim_move_result runcamera(struct CFanimation_struct *animation, long int id, void *parameters)
struct CFmovement_struct * next
static long int initsay(const char *name, char *parameters, struct CFmovement_struct *move_entity)
static anim_move_result runmoveto(struct CFanimation_struct *animation, long int id, void *parameters)
static long int initstop(const char *name, char *parameters, struct CFmovement_struct *move_entity)
void cf_object_free(object *ob)
object * cf_map_insert_object_there(object *op, mapstruct *m, object *originator, int flag)
int cf_map_get_width(mapstruct *map)
int cf_object_move_to(object *op, int x, int y)
static anim_move_result runpickupobject(struct CFanimation_struct *animation, long int id, void *parameters)
static long int initdropobject(const char *name, char *parameters, struct CFmovement_struct *move_entity)