1 | /* |
1 | /* |
2 | * static char *rcsid_apply_c = |
2 | * static char *rcsid_apply_c = |
3 | * "$Id: apply.C,v 1.9 2006/08/25 17:11:53 root Exp $"; |
3 | * "$Id: apply.C,v 1.12 2006/08/29 05:03:55 root Exp $"; |
4 | */ |
4 | */ |
5 | /* |
5 | /* |
6 | CrossFire, A Multiplayer game for X-windows |
6 | CrossFire, A Multiplayer game for X-windows |
7 | |
7 | |
8 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
8 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
… | |
… | |
1291 | |
1291 | |
1292 | if (op->container && QUERY_FLAG(sack, FLAG_APPLIED)) { |
1292 | if (op->container && QUERY_FLAG(sack, FLAG_APPLIED)) { |
1293 | if (op->container->env != op) { /* if container is on the ground */ |
1293 | if (op->container->env != op) { /* if container is on the ground */ |
1294 | op->container->move_off = 0; |
1294 | op->container->move_off = 0; |
1295 | } |
1295 | } |
1296 | /* Lauwenmark: Handle for plugin close event */ |
1296 | |
1297 | if (execute_event(tmp, EVENT_CLOSE,op,NULL,NULL,SCRIPT_FIX_ALL)!=0) |
1297 | if (INVOKE_OBJECT (CLOSE, op)) |
1298 | return 1; |
1298 | return 1; |
1299 | |
1299 | |
1300 | new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.", |
1300 | new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.", |
1301 | query_name(op->container)); |
1301 | query_name(op->container)); |
1302 | CLEAR_FLAG(op->container, FLAG_APPLIED); |
1302 | CLEAR_FLAG(op->container, FLAG_APPLIED); |
1303 | op->container=NULL; |
1303 | op->container=NULL; |
… | |
… | |
1576 | return; |
1576 | return; |
1577 | } |
1577 | } |
1578 | recursion_depth++; |
1578 | recursion_depth++; |
1579 | if (trap->head) trap=trap->head; |
1579 | if (trap->head) trap=trap->head; |
1580 | |
1580 | |
1581 | /* Lauwenmark: Handle for plugin trigger event */ |
1581 | if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) |
1582 | if (execute_event(trap, EVENT_TRIGGER,originator,victim,NULL,SCRIPT_FIX_ALL)!=0) |
|
|
1583 | goto leave; |
1582 | goto leave; |
1584 | |
1583 | |
1585 | switch (trap->type) { |
1584 | switch (trap->type) { |
1586 | case PLAYERMOVER: |
1585 | case PLAYERMOVER: |
1587 | if (trap->attacktype && (trap->level || victim->type!=PLAYER) && |
1586 | if (trap->attacktype && (trap->level || victim->type!=PLAYER) && |
… | |
… | |
2546 | } else { |
2545 | } else { |
2547 | return 0; /* monsters just skip unpaid items */ |
2546 | return 0; /* monsters just skip unpaid items */ |
2548 | } |
2547 | } |
2549 | } |
2548 | } |
2550 | |
2549 | |
2551 | |
|
|
2552 | /* Lauwenmark: Handle for plugin apply event */ |
|
|
2553 | //TODO: remove |
|
|
2554 | if (execute_event(tmp, EVENT_APPLY,op,NULL,NULL,SCRIPT_FIX_ALL)!=0) |
|
|
2555 | return 1; |
|
|
2556 | |
|
|
2557 | if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op))) |
2550 | if (INVOKE_OBJECT (APPLY, tmp, ARG_OBJECT (op))) |
2558 | return 1; |
2551 | return RESULT_INT (0); |
2559 | |
2552 | |
2560 | switch (tmp->type) { |
2553 | switch (tmp->type) { |
2561 | |
2554 | |
2562 | case TRANSPORT: |
2555 | case TRANSPORT: |
2563 | return apply_transport(op, tmp, aflag); |
2556 | return apply_transport(op, tmp, aflag); |
… | |
… | |
2856 | * Break this out of apply_special - this is just done |
2849 | * Break this out of apply_special - this is just done |
2857 | * to keep the size of apply_special to a more managable size. |
2850 | * to keep the size of apply_special to a more managable size. |
2858 | */ |
2851 | */ |
2859 | static int unapply_special (object *who, object *op, int aflags) |
2852 | static int unapply_special (object *who, object *op, int aflags) |
2860 | { |
2853 | { |
|
|
2854 | if (INVOKE_OBJECT (BE_UNREADY, op, ARG_OBJECT (who), ARG_INT (aflags)) |
|
|
2855 | || INVOKE_OBJECT (UNREADY, who, ARG_OBJECT (op), ARG_INT (aflags))) |
|
|
2856 | return RESULT_INT (0); |
|
|
2857 | |
2861 | object *tmp2; |
2858 | object *tmp2; |
2862 | |
2859 | |
2863 | CLEAR_FLAG(op, FLAG_APPLIED); |
2860 | CLEAR_FLAG(op, FLAG_APPLIED); |
2864 | switch(op->type) { |
2861 | switch(op->type) { |
2865 | case WEAPON: |
2862 | case WEAPON: |
2866 | new_draw_info_format(NDI_UNIQUE, 0, who, "You unwield %s.",query_name(op)); |
2863 | new_draw_info_format(NDI_UNIQUE, 0, who, "You unwield %s.",query_name(op)); |
2867 | |
2864 | |
2868 | (void) change_abil (who,op); |
2865 | (void) change_abil (who,op); |
2869 | if(QUERY_FLAG(who,FLAG_READY_WEAPON)) |
2866 | if(QUERY_FLAG(who,FLAG_READY_WEAPON)) |
2870 | CLEAR_FLAG(who,FLAG_READY_WEAPON); |
2867 | CLEAR_FLAG(who,FLAG_READY_WEAPON); |
2871 | /* GROS: update the current_weapon_script field (used with script_attack for weapons) */ |
|
|
2872 | who->current_weapon_script = NULL; |
|
|
2873 | who->current_weapon = NULL; |
|
|
2874 | clear_skill(who); |
2868 | clear_skill(who); |
2875 | break; |
2869 | break; |
2876 | |
2870 | |
2877 | case SKILL: /* allows objects to impart skills */ |
2871 | case SKILL: /* allows objects to impart skills */ |
2878 | case SKILL_TOOL: |
2872 | case SKILL_TOOL: |
… | |
… | |
3113 | * See include/define.h for detailed description of the meaning of |
3107 | * See include/define.h for detailed description of the meaning of |
3114 | * these return values. |
3108 | * these return values. |
3115 | */ |
3109 | */ |
3116 | int can_apply_object(object *who, object *op) |
3110 | int can_apply_object(object *who, object *op) |
3117 | { |
3111 | { |
|
|
3112 | if (INVOKE_OBJECT (CAN_BE_APPLIED, op, ARG_OBJECT (who)) |
|
|
3113 | || INVOKE_OBJECT (CAN_APPLY, who, ARG_OBJECT (op))) |
|
|
3114 | return RESULT_INT (0); |
|
|
3115 | |
3118 | int i, retval=0; |
3116 | int i, retval=0; |
3119 | object *tmp=NULL, *ws=NULL; |
3117 | object *tmp=NULL, *ws=NULL; |
3120 | |
3118 | |
3121 | /* Players have 2 'arm's, so they could in theory equip 2 shields or |
3119 | /* Players have 2 'arm's, so they could in theory equip 2 shields or |
3122 | * 2 weapons, but we don't want to let them do that. So if they are |
3120 | * 2 weapons, but we don't want to let them do that. So if they are |
… | |
… | |
3340 | if(op->nrof > 1) |
3338 | if(op->nrof > 1) |
3341 | tmp = get_split_ob(op,op->nrof - 1); |
3339 | tmp = get_split_ob(op,op->nrof - 1); |
3342 | else |
3340 | else |
3343 | tmp = NULL; |
3341 | tmp = NULL; |
3344 | |
3342 | |
|
|
3343 | if (INVOKE_OBJECT (BE_READY, op, ARG_OBJECT (who)) |
|
|
3344 | || INVOKE_OBJECT (READY, who, ARG_OBJECT (op))) |
|
|
3345 | return RESULT_INT (0); |
|
|
3346 | |
3345 | switch(op->type) { |
3347 | switch(op->type) { |
3346 | case WEAPON: |
3348 | case WEAPON: |
3347 | if (!check_weapon_power(who, op->last_eat)) { |
3349 | if (!check_weapon_power(who, op->last_eat)) { |
3348 | new_draw_info(NDI_UNIQUE, 0,who, |
3350 | new_draw_info(NDI_UNIQUE, 0,who, |
3349 | "That weapon is too powerful for you to use."); |
3351 | "That weapon is too powerful for you to use."); |
… | |
… | |
3367 | SET_FLAG(who, FLAG_READY_WEAPON); |
3369 | SET_FLAG(who, FLAG_READY_WEAPON); |
3368 | |
3370 | |
3369 | new_draw_info_format(NDI_UNIQUE, 0, who, "You wield %s.",query_name(op)); |
3371 | new_draw_info_format(NDI_UNIQUE, 0, who, "You wield %s.",query_name(op)); |
3370 | |
3372 | |
3371 | (void) change_abil (who,op); |
3373 | (void) change_abil (who,op); |
3372 | /* GROS: update the current_weapon_script field (used with EVENT_ATTACK for weapons) */ |
|
|
3373 | /*if ((evt = find_event(op, EVENT_ATTACK)) != NULL) { |
|
|
3374 | LOG(llevDebug, "Scripting Weapon wielded\n"); |
|
|
3375 | if (who->current_weapon_script) free_string(who->current_weapon_script); |
|
|
3376 | who->current_weapon_script=add_string(query_name(op)); |
|
|
3377 | } |
|
|
3378 | who->current_weapon = op;*/ |
|
|
3379 | break; |
3374 | break; |
3380 | |
3375 | |
3381 | case ARMOUR: |
3376 | case ARMOUR: |
3382 | case HELMET: |
3377 | case HELMET: |
3383 | case SHIELD: |
3378 | case SHIELD: |