version 1.145 | | version 1.146 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.145 2005/10/16 22:32:46 qal21 Exp $"; | | * "$Id: apply.c,v 1.146 2005/10/18 16:54:31 gros Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
| | |
int esrv_apply_container (object *op, object *sack) | | int esrv_apply_container (object *op, object *sack) |
{ | | { |
event *evt; | | |
object *tmp=op->container; | | object *tmp=op->container; |
| | |
if(op->type!=PLAYER) | | if(op->type!=PLAYER) |
return 0; /* This might change */ | | return 0; /* This might change */ |
| | |
if (sack==NULL || sack->type != CONTAINER) { | | if (sack==NULL || sack->type != CONTAINER) { |
LOG (llevError, "esrv_apply_container: %s is not container!\n",sack?sack->name:"NULL"); | | LOG (llevError, |
| | "esrv_apply_container: %s is not container!\n",sack?sack->name:"NULL"); |
return 0; | | return 0; |
} | | } |
| | |
| | |
CLEAR_FLAG (op->container, FLAG_WALK_OFF); | | CLEAR_FLAG (op->container, FLAG_WALK_OFF); |
CLEAR_FLAG (op->container, FLAG_FLY_OFF); | | CLEAR_FLAG (op->container, FLAG_FLY_OFF); |
} | | } |
/* GROS: Handle for plugin close event */ | | /* Lauwenmark: Handle for plugin close event */ |
if ((evt = find_event(tmp, EVENT_CLOSE)) != NULL) | | if (execute_event(tmp, EVENT_CLOSE,op,NULL,NULL,SCRIPT_FIX_ALL)!=0) |
{ | | return 1; |
CFParm CFP; | | |
CFParm* CFR; | | |
int k, l, m; | | |
uint32 n; | | |
int rtn_script = 0; | | |
m = 0; | | |
n = 0; | | |
k = EVENT_CLOSE; | | |
l = SCRIPT_FIX_ALL; | | |
CFP.Value[0] = &k; | | |
CFP.Value[1] = op; | | |
CFP.Value[2] = tmp; | | |
CFP.Value[3] = NULL; | | |
CFP.Value[4] = NULL; | | |
CFP.Value[5] = &n; | | |
CFP.Value[6] = &m; | | |
CFP.Value[7] = &m; | | |
CFP.Value[8] = &l; | | |
CFP.Value[9] = (void*)evt->hook; | | |
CFP.Value[10]= (void*)evt->options; | | |
if (findPlugin(evt->plugin)>=0) | | |
{ | | |
CFR = (PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP); | | |
rtn_script = *(int *)(CFR->Value[0]); | | |
if (rtn_script!=0) return 1; | | |
} | | |
} | | |
new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.", | | new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.", |
query_name(op->container)); | | query_name(op->container)); |
CLEAR_FLAG(op->container, FLAG_APPLIED); | | CLEAR_FLAG(op->container, FLAG_APPLIED); |
| | |
void move_apply (object *trap, object *victim, object *originator) | | void move_apply (object *trap, object *victim, object *originator) |
{ | | { |
static int recursion_depth = 0; | | static int recursion_depth = 0; |
event *evt; | | |
| | |
/* move_apply() is the most likely candidate for causing unwanted and | | /* move_apply() is the most likely candidate for causing unwanted and |
* possibly unlimited recursion. */ | | * possibly unlimited recursion. */ |
/* The following was changed because it was causing perfeclty correct | | /* The following was changed because it was causing perfeclty correct |
| | |
return; | | return; |
} | | } |
recursion_depth++; | | recursion_depth++; |
if (trap->head) trap=trap->head; | | if (trap->head) |
/* GROS: Handle for plugin close event */ | | trap=trap->head; |
if ((evt = find_event(trap, EVENT_TRIGGER))!=NULL) | | /* Lauwenmark: Handle for plugin trigger event */ |
{ | | if (execute_event(trap, EVENT_TRIGGER,originator,victim,NULL,SCRIPT_FIX_ALL)!=0) |
CFParm CFP; | | return; |
CFParm* CFR; | | |
int k, l, m; | | |
uint32 n; | | |
int rtn_script = 0; | | |
m = 0; | | |
n = 0; | | |
k = EVENT_TRIGGER; | | |
l = SCRIPT_FIX_ALL; | | |
CFP.Value[0] = &k; | | |
CFP.Value[1] = trap; | | |
CFP.Value[2] = originator; | | |
CFP.Value[3] = victim; | | |
CFP.Value[4] = NULL; | | |
CFP.Value[5] = &n; | | |
CFP.Value[6] = &m; | | |
CFP.Value[7] = &m; | | |
CFP.Value[8] = &l; | | |
CFP.Value[9] = (void*)evt->hook; | | |
CFP.Value[10]= (void*)evt->options; | | |
if (findPlugin(evt->plugin)>=0) | | |
{ | | |
CFR = (PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP); | | |
rtn_script = *(int *)(CFR->Value[0]); | | |
if (rtn_script!=0) return; | | |
} | | |
} | | |
switch (trap->type) | | switch (trap->type) |
{ | | { |
case PLAYERMOVER: | | case PLAYERMOVER: |
if (trap->attacktype && (trap->level || victim->type!=PLAYER) && !should_director_abort(trap, victim)) { | | if (trap->attacktype && (trap->level || victim->type!=PLAYER) && |
| | !should_director_abort(trap, victim)) { |
if (!trap->stats.maxsp) trap->stats.maxsp=2.0; | | if (!trap->stats.maxsp) trap->stats.maxsp=2.0; |
/* Is this correct? From the docs, it doesn't look like it | | /* Is this correct? From the docs, it doesn't look like it |
* should be divided by trap->speed | | * should be divided by trap->speed |
| | |
* getting permanently paralyzed. | | * getting permanently paralyzed. |
*/ | | */ |
if (victim->speed_left<-50.0) victim->speed_left=-50.0; | | if (victim->speed_left<-50.0) victim->speed_left=-50.0; |
/* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", victim->speed_left);*/ | | /* LOG(llevDebug, "apply, playermove, player speed_left=%f\n", |
| | victim->speed_left);*/ |
} | | } |
goto leave; | | goto leave; |
| | |
| | |
goto leave; | | goto leave; |
/* fallthrough */ | | /* fallthrough */ |
case ARROW: | | case ARROW: |
| | |
/* bad bug: monster throw a object, make a step forwards, step on object , | | /* bad bug: monster throw a object, make a step forwards, step on object , |
* trigger this here and get hit by own missile - and will be own enemy. | | * trigger this here and get hit by own missile - and will be own enemy. |
* Victim then is his own enemy and will start to kill herself (this is | | * Victim then is his own enemy and will start to kill herself (this is |
* removed) but we have not synced victim and his missile. To avoid senseless | | * removed) but we have not synced victim and his missile. To avoid senseless |
* action, we avoid hits here */ | | * action, we avoid hits here */ |
if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && trap->owner != victim) | | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->speed) && |
| | trap->owner != victim) |
hit_with_arrow (trap, victim); | | hit_with_arrow (trap, victim); |
goto leave; | | goto leave; |
| | |
| | |
if (convert_item (victim, trap) < 0) { | | if (convert_item (victim, trap) < 0) { |
object *op; | | object *op; |
| | |
new_draw_info_format(NDI_UNIQUE, 0, originator, "The %s seems to be broken!", query_name(trap)); | | new_draw_info_format(NDI_UNIQUE, 0, originator, |
| | "The %s seems to be broken!", |
| | query_name(trap)); |
| | |
op = get_archetype("burnout"); | | op = get_archetype("burnout"); |
if (op != NULL) { | | if (op != NULL) { |
| | |
/* Basically, don't show exits leading to random maps the | | /* Basically, don't show exits leading to random maps the |
* players output. | | * players output. |
*/ | | */ |
if (trap->msg && strncmp(EXIT_PATH(trap),"/!",2) && strncmp(EXIT_PATH(trap), "/random/", 8)) | | if (trap->msg && strncmp(EXIT_PATH(trap),"/!",2) |
| | && strncmp(EXIT_PATH(trap), "/random/", 8)) |
new_draw_info (NDI_NAVY, 0, victim, trap->msg); | | new_draw_info (NDI_NAVY, 0, victim, trap->msg); |
enter_exit (victim, trap); | | enter_exit (victim, trap); |
} | | } |
| | |
case RUNE: | | case RUNE: |
case TRAP: | | case TRAP: |
if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) | | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
{ | | |
spring_trap(trap, victim); | | spring_trap(trap, victim); |
}; | | |
goto leave; | | goto leave; |
| | |
default: | | default: |
| | |
{ | | { |
int lev_diff; | | int lev_diff; |
object *skill_ob; | | object *skill_ob; |
event *evt; | | |
| | |
if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) { | | if(QUERY_FLAG(op, FLAG_BLIND)&&!QUERY_FLAG(op,FLAG_WIZ)) { |
new_draw_info(NDI_UNIQUE, 0,op,"You are unable to read while blind."); | | new_draw_info(NDI_UNIQUE, 0,op,"You are unable to read while blind."); |
| | |
} | | } |
| | |
| | |
/* GROS: Handle for plugin trigger event */ | | /* Lauwenmark: Handle for plugin book event */ |
if ((evt = find_event(tmp, EVENT_APPLY)) != NULL) | | /*printf("Book apply: %s\n", tmp->name); |
| | execute_event(tmp, EVENT_APPLY,op,NULL,SCRIPT_FIX_ALL); |
| | printf("Book applied: %s\n", tmp->name);*/ |
| | /*if ((evt = find_event(tmp, EVENT_APPLY)) != NULL) |
{ | | { |
CFParm CFP; | | CFParm CFP; |
int k, l, m; | | int k, l, m; |
| | |
if (findPlugin(evt->plugin)>=0) | | if (findPlugin(evt->plugin)>=0) |
((PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP)); | | ((PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP)); |
} | | } |
else{ | | else*/{ |
readable_message_type* msgType = get_readable_message_type(tmp); | | readable_message_type* msgType = get_readable_message_type(tmp); |
draw_ext_info_format(NDI_UNIQUE | NDI_NAVY, 0, op, | | draw_ext_info_format(NDI_UNIQUE | NDI_NAVY, 0, op, |
msgType->message_type, msgType->message_subtype, | | msgType->message_type, msgType->message_subtype, |
| | |
| | |
int manual_apply (object *op, object *tmp, int aflag) | | int manual_apply (object *op, object *tmp, int aflag) |
{ | | { |
int rtn_script; | | |
event *evt; | | |
| | |
if (tmp->head) tmp=tmp->head; | | if (tmp->head) tmp=tmp->head; |
| | |
if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) { | | if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) { |
| | |
if (op->type != PLAYER && tmp->type == TREASURE) | | if (op->type != PLAYER && tmp->type == TREASURE) |
return 0; | | return 0; |
| | |
/* GROS: Handle for plugin trigger event */ | | /* Lauwenmark: Handle for plugin apply event */ |
if ((evt = find_event(tmp, EVENT_APPLY)) != NULL) | | if (execute_event(tmp, EVENT_APPLY,op,NULL,NULL,SCRIPT_FIX_ALL)!=0) |
{ | | return 1; |
CFParm CFP; | | |
CFParm* CFR; | | |
int k, l, m; | | |
uint32 n; | | |
m = 0; | | |
n = aflag; | | |
k = EVENT_APPLY; | | |
l = SCRIPT_FIX_ALL; | | |
CFP.Value[0] = &k; | | |
CFP.Value[1] = op; | | |
CFP.Value[2] = tmp; | | |
CFP.Value[3] = NULL; | | |
CFP.Value[4] = NULL; | | |
CFP.Value[5] = &n; | | |
CFP.Value[6] = &m; | | |
CFP.Value[7] = &m; | | |
CFP.Value[8] = &l; | | |
CFP.Value[9] = (void*)evt->hook; | | |
CFP.Value[10]= (void*)evt->options; | | |
if (findPlugin(evt->plugin)>=0) | | |
{ | | |
CFR = (PlugList[findPlugin(evt->plugin)].eventfunc) (&CFP); | | |
rtn_script = *(int *)(CFR->Value[0]); | | |
if (rtn_script!=0) return 1; | | |
} | | |
} | | |
switch (tmp->type) | | switch (tmp->type) |
{ | | { |
case CF_HANDLE: | | case CF_HANDLE: |
| | |
if (op->type != PLAYER) | | if (op->type != PLAYER) |
return 0; | | return 0; |
if( ! EXIT_PATH (tmp) || !is_legal_2ways_exit(op,tmp)) { | | if( ! EXIT_PATH (tmp) || !is_legal_2ways_exit(op,tmp)) { |
new_draw_info_format(NDI_UNIQUE, 0, op, | | new_draw_info_format(NDI_UNIQUE, 0, op, "The %s is closed.", |
"The %s is closed.",query_name(tmp)); | | query_name(tmp)); |
} else { | | } else { |
/* Don't display messages for random maps. */ | | /* Don't display messages for random maps. */ |
if (tmp->msg && strncmp(EXIT_PATH(tmp),"/!",2) && strncmp(EXIT_PATH(tmp), "/random/", 8)) | | if (tmp->msg && strncmp(EXIT_PATH(tmp),"/!",2) && |
| | strncmp(EXIT_PATH(tmp), "/random/", 8)) |
new_draw_info (NDI_NAVY, 0, op, tmp->msg); | | new_draw_info (NDI_NAVY, 0, op, tmp->msg); |
enter_exit(op,tmp); | | enter_exit(op,tmp); |
} | | } |
| | |
{ | | { |
int basic_flag = aflags & AP_BASIC_FLAGS; | | int basic_flag = aflags & AP_BASIC_FLAGS; |
object *tmp, *tmp2, *skop=NULL; | | object *tmp, *tmp2, *skop=NULL; |
event *evt; | | |
int i; | | int i; |
| | |
if(who==NULL) { | | if(who==NULL) { |
| | |
| | |
(void) change_abil (who,op); | | (void) change_abil (who,op); |
/* GROS: update the current_weapon_script field (used with EVENT_ATTACK for weapons) */ | | /* GROS: update the current_weapon_script field (used with EVENT_ATTACK for weapons) */ |
if ((evt = find_event(op, EVENT_ATTACK)) != NULL) { | | /*if ((evt = find_event(op, EVENT_ATTACK)) != NULL) { |
LOG(llevDebug, "Scripting Weapon wielded\n"); | | LOG(llevDebug, "Scripting Weapon wielded\n"); |
if (who->current_weapon_script) free_string(who->current_weapon_script); | | if (who->current_weapon_script) free_string(who->current_weapon_script); |
who->current_weapon_script=add_string(query_name(op)); | | who->current_weapon_script=add_string(query_name(op)); |
} | | } |
who->current_weapon = op; | | who->current_weapon = op;*/ |
break; | | break; |
| | |
case ARMOUR: | | case ARMOUR: |