version 1.46 | | version 1.47 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.46 2001/09/26 21:34:08 garbled Exp $"; | | * "$Id: apply.c,v 1.47 2001/10/14 07:57:14 gros Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
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); |
} | | } |
| | #ifdef PLUGINS |
| | /* GROS: Handle for plugin close event */ |
| | if(tmp->event_hook[EVENT_CLOSE] != NULL) |
| | { |
| | CFParm CFP; |
| | CFParm* CFR; |
| | int k, l, m; |
| | int rtn_script = 0; |
| | m = 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] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = tmp->event_hook[k]; |
| | CFP.Value[10]= tmp->event_options[k]; |
| | if (findPlugin(tmp->event_plugin[k])>=0) |
| | { |
| | CFR = (PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP); |
| | rtn_script = *(int *)(CFR->Value[0]); |
| | if (rtn_script!=0) return 1; |
| | } |
| | } |
| | #endif |
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); |
| | |
return; | | return; |
} | | } |
recursion_depth++; | | recursion_depth++; |
| | |
if (trap->head) trap=trap->head; | | if (trap->head) trap=trap->head; |
| | #ifdef PLUGINS |
| | /* GROS: Handle for plugin close event */ |
| | if(trap->event_hook[EVENT_TRIGGER] != NULL) |
| | { |
| | CFParm CFP; |
| | CFParm* CFR; |
| | int k, l, m; |
| | int rtn_script = 0; |
| | m = 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] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = trap->event_hook[k]; |
| | CFP.Value[10]= trap->event_options[k]; |
| | if (findPlugin(trap->event_plugin[k])>=0) |
| | { |
| | CFR = (PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP); |
| | rtn_script = *(int *)(CFR->Value[0]); |
| | if (rtn_script!=0) return; |
| | } |
| | } |
| | #endif |
switch (trap->type) | | switch (trap->type) |
{ | | { |
case PLAYERMOVER: | | case PLAYERMOVER: |
| | |
case TRIGGER_BUTTON: | | case TRIGGER_BUTTON: |
case TRIGGER_PEDESTAL: | | case TRIGGER_PEDESTAL: |
case TRIGGER_ALTAR: | | case TRIGGER_ALTAR: |
/* GROS: Handle for script_trigger event */ | | #ifdef PLUGINS |
if (trap->script_trigger != NULL) | | /* GROS: Handle for plugin trigger event */ |
{ | | if(trap->event_hook[EVENT_TRIGGER] != NULL) |
guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL); | | { |
} | | CFParm CFP; |
else | | int k, l, m; |
{ | | k = EVENT_TRIGGER; |
if (trap->script_str_trigger != NULL) | | l = SCRIPT_FIX_ALL; |
{ | | m = 0; |
guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL); | | CFP.Value[0] = &k; |
| | CFP.Value[1] = victim; |
| | CFP.Value[2] = trap; |
| | CFP.Value[3] = NULL; |
| | CFP.Value[4] = NULL; |
| | CFP.Value[5] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = trap->event_hook[EVENT_TRIGGER]; |
| | CFP.Value[10]= trap->event_options[EVENT_TRIGGER]; |
| | if (findPlugin(trap->event_plugin[k])>=0) |
| | ((PlugList[findPlugin(trap->event_plugin[EVENT_TRIGGER])].eventfunc) (&CFP)); |
} | | } |
else | | else |
{ | | #endif |
check_trigger (trap, victim); | | check_trigger (trap, victim); |
} | | |
}; | | |
goto leave; | | goto leave; |
| | |
case DEEP_SWAMP: | | case DEEP_SWAMP: |
| | |
goto leave; | | goto leave; |
| | |
case CHECK_INV: | | case CHECK_INV: |
/* GROS: Handle for script_trigger event */ | | #ifdef PLUGINS |
if (trap->script_trigger != NULL) | | /* GROS: Handle for plugin trigger event */ |
{ | | if(trap->event_hook[EVENT_TRIGGER] != NULL) |
guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL); | | { |
} | | CFParm CFP; |
else | | int k, l, m; |
{ | | k = EVENT_TRIGGER; |
if (trap->script_str_trigger != NULL) | | l = SCRIPT_FIX_ALL; |
{ | | m = 0; |
guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL); | | CFP.Value[0] = &k; |
| | CFP.Value[1] = victim; |
| | CFP.Value[2] = trap; |
| | CFP.Value[3] = NULL; |
| | CFP.Value[4] = NULL; |
| | CFP.Value[5] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = trap->event_hook[k]; |
| | CFP.Value[10]= trap->event_options[k]; |
| | if (findPlugin(trap->event_plugin[k])>=0) |
| | ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP)); |
} | | } |
else | | else |
{ | | #endif |
check_inv (victim, trap); | | check_inv (victim, trap); |
} | | |
}; | | |
goto leave; | | goto leave; |
| | |
case HOLE: | | case HOLE: |
| | |
*/ | | */ |
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); |
/* GROS: Handle for script_trigger event */ | | #ifdef PLUGINS |
if (trap->script_trigger != NULL) | | /* GROS: Handle for plugin trigger event */ |
{ | | if(trap->event_hook[EVENT_TRIGGER] != NULL) |
guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL); | | { |
} | | CFParm CFP; |
else | | int k, l, m; |
{ | | k = EVENT_TRIGGER; |
if (trap->script_str_trigger != NULL) | | l = SCRIPT_FIX_ALL; |
{ | | m = 0; |
guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL); | | CFP.Value[0] = &k; |
| | CFP.Value[1] = victim; |
| | CFP.Value[2] = trap; |
| | CFP.Value[3] = NULL; |
| | CFP.Value[4] = NULL; |
| | CFP.Value[5] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = trap->event_hook[k]; |
| | CFP.Value[10]= trap->event_options[k]; |
| | if (findPlugin(trap->event_plugin[k])>=0) |
| | ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP)); |
} | | } |
}; | | #endif |
enter_exit (victim, trap); | | enter_exit (victim, trap); |
} | | } |
goto leave; | | goto leave; |
| | |
case RUNE: | | case RUNE: |
if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) | | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
{ | | { |
/* GROS: Handle for script_trigger event */ | | #ifdef PLUGINS |
if (trap->script_trigger != NULL) | | /* GROS: Handle for plugin trigger event */ |
{ | | if(trap->event_hook[EVENT_TRIGGER] != NULL) |
guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL); | | { |
| | CFParm CFP; |
| | int k, l, m; |
| | k = EVENT_TRIGGER; |
| | l = SCRIPT_FIX_ALL; |
| | m = 0; |
| | CFP.Value[0] = &k; |
| | CFP.Value[1] = victim; |
| | CFP.Value[2] = trap; |
| | CFP.Value[3] = NULL; |
| | CFP.Value[4] = NULL; |
| | CFP.Value[5] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = trap->event_hook[k]; |
| | CFP.Value[10]= trap->event_options[k]; |
| | if (findPlugin(trap->event_plugin[k])>=0) |
| | ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP)); |
} | | } |
else | | else |
{ | | #endif |
if (trap->script_str_trigger != NULL) | | |
{ | | |
guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL); | | |
} | | |
else | | |
{ | | |
spring_trap(trap, victim); | | spring_trap(trap, victim); |
} | | |
}; | | |
}; | | }; |
goto leave; | | goto leave; |
| | |
| | |
| | |
new_draw_info_format (NDI_UNIQUE, 0, op, | | new_draw_info_format (NDI_UNIQUE, 0, op, |
"You open the %s and start reading.", tmp->name); | | "You open the %s and start reading.", tmp->name); |
| | #ifdef PLUGINS |
/* GROS: Handling for reading scripted books */ | | /* GROS: Handle for plugin trigger event */ |
if (tmp->script_apply != NULL) | | if(tmp->event_hook[EVENT_APPLY] != NULL) |
{ | | { |
guile_call_event(op,tmp, NULL, 0, NULL,0,0,tmp->script_apply, SCRIPT_FIX_ALL); | | CFParm CFP; |
} | | int k, l, m; |
else | | k = EVENT_APPLY; |
{ | | l = SCRIPT_FIX_ALL; |
if (tmp->script_str_apply != NULL) | | m = 0; |
{ | | CFP.Value[0] = &k; |
guile_call_event_str(op,tmp, NULL, 0, NULL,0,0,tmp->script_str_apply, SCRIPT_FIX_ALL); | | CFP.Value[1] = op; |
| | CFP.Value[2] = tmp; |
| | CFP.Value[3] = NULL; |
| | CFP.Value[4] = NULL; |
| | CFP.Value[5] = &m; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = tmp->event_hook[k]; |
| | CFP.Value[10]= tmp->event_options[k]; |
| | if (findPlugin(tmp->event_plugin[k])>=0) |
| | ((PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP)); |
} | | } |
else | | else |
| | #endif |
new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg); | | new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg); |
}; | | |
| | |
/* gain xp from reading */ | | /* gain xp from reading */ |
if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */ | | if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */ |
| | |
return 0; /* monsters just skip unpaid items */ | | return 0; /* monsters just skip unpaid items */ |
} | | } |
} | | } |
/* GROS: This is used to handle apply scripts */ | | #ifdef PLUGINS |
if (tmp->script_apply!=NULL) | | /* GROS: Handle for plugin trigger event */ |
{ | | if(tmp->event_hook[EVENT_APPLY] != NULL) |
rtn_script = guile_call_event(op,tmp, NULL, aflag, NULL,0,0,tmp->script_apply, SCRIPT_FIX_ALL); | | { |
if (rtn_script!=0) return 1; | | CFParm CFP; |
}; | | CFParm* CFR; |
if (tmp->script_str_apply!=NULL) | | int k, l, m; |
| | m = 0; |
| | 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] = &aflag; |
| | CFP.Value[6] = &m; |
| | CFP.Value[7] = &m; |
| | CFP.Value[8] = &l; |
| | CFP.Value[9] = tmp->event_hook[k]; |
| | CFP.Value[10]= tmp->event_options[k]; |
| | if (findPlugin(tmp->event_plugin[k])>=0) |
{ | | { |
rtn_script = guile_call_event_str(op,tmp, NULL, aflag, NULL,0,0,tmp->script_str_apply, SCRIPT_FIX_ALL); | | CFR = (PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP); |
| | rtn_script = *(int *)(CFR->Value[0]); |
if (rtn_script!=0) return 1; | | if (rtn_script!=0) return 1; |
}; | | } |
| | } |
| | #endif |
switch (tmp->type) | | switch (tmp->type) |
{ | | { |
case CF_HANDLE: | | case CF_HANDLE: |
| | |
if(op->env!=who) | | if(op->env!=who) |
return 1; /* op is not in inventory */ | | return 1; /* op is not in inventory */ |
| | |
/* GROS: This is used to handle apply scripts */ | | |
if (op->script_apply!=NULL) | | |
{ | | |
guile_call_event(who,op, NULL, aflags, NULL,0,0,op->script_apply, SCRIPT_FIX_ALL); | | |
}; | | |
if (op->script_str_apply!=NULL) | | |
{ | | |
guile_call_event_str(who,op, NULL, aflags, NULL,0,0,op->script_str_apply, SCRIPT_FIX_ALL); | | |
}; | | |
| | |
buf[0]='\0'; /* Needs to be initialized */ | | buf[0]='\0'; /* Needs to be initialized */ |
if (QUERY_FLAG(op,FLAG_APPLIED)) { | | if (QUERY_FLAG(op,FLAG_APPLIED)) { |
/* always apply, so no reason to unapply */ | | /* always apply, so no reason to unapply */ |
| | |
SET_FLAG(who, FLAG_READY_WEAPON); | | SET_FLAG(who, FLAG_READY_WEAPON); |
| | |
(void) change_abil (who,op); | | (void) change_abil (who,op); |
/* GROS: update the current_weapon_script field (used with script_attack for weapons) */ | | #ifdef PLUGINS |
if ((op->script_attack != NULL)|(op->script_str_attack != NULL)) | | /* GROS: update the current_weapon_script field (used with EVENT_ATTACK for weapons) */ |
| | if (op->event_hook[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; |
}; | | }; |
| | #endif |
sprintf(buf,"You wield %s.",query_name(op)); | | sprintf(buf,"You wield %s.",query_name(op)); |
break; | | break; |
} | | } |