1 | /* |
1 | /* |
2 | * static char *rcsid_monster_c = |
2 | * static char *rcsid_monster_c = |
3 | * "$Id: monster.c,v 1.1 2006/02/03 07:14:33 root Exp $"; |
3 | * "$Id: monster.c,v 1.5 2006/03/31 22:04:03 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
379 | */ |
379 | */ |
380 | if(QUERY_FLAG(op, FLAG_SCARED) &&!(RANDOM()%20)) { |
380 | if(QUERY_FLAG(op, FLAG_SCARED) &&!(RANDOM()%20)) { |
381 | CLEAR_FLAG(op,FLAG_SCARED); /* Time to regain some "guts"... */ |
381 | CLEAR_FLAG(op,FLAG_SCARED); /* Time to regain some "guts"... */ |
382 | } |
382 | } |
383 | |
383 | |
|
|
384 | if (execute_event (op, EVENT_MOVE, op->enemy, 0, 0, SCRIPT_FIX_ALL)) |
|
|
385 | return 0; |
|
|
386 | |
384 | /* If we don't have an enemy, do special movement or the like */ |
387 | /* If we don't have an enemy, do special movement or the like */ |
385 | if(!enemy) { |
388 | if(!enemy) { |
386 | if(QUERY_FLAG(op, FLAG_ONLY_ATTACK)) { |
389 | if(QUERY_FLAG(op, FLAG_ONLY_ATTACK)) { |
387 | remove_ob(op); |
390 | remove_ob(op); |
388 | free_object(op); |
391 | free_object(op); |
… | |
… | |
1244 | |
1247 | |
1245 | if (item->type == TREASURE && mon->will_apply & WILL_APPLY_TREASURE) flag=1; |
1248 | if (item->type == TREASURE && mon->will_apply & WILL_APPLY_TREASURE) flag=1; |
1246 | /* Eating food gets hp back */ |
1249 | /* Eating food gets hp back */ |
1247 | else if (item->type == FOOD && mon->will_apply & WILL_APPLY_FOOD) flag=1; |
1250 | else if (item->type == FOOD && mon->will_apply & WILL_APPLY_FOOD) flag=1; |
1248 | else if (item->type == SCROLL && QUERY_FLAG(mon, FLAG_USE_SCROLL)) { |
1251 | else if (item->type == SCROLL && QUERY_FLAG(mon, FLAG_USE_SCROLL)) { |
|
|
1252 | if (!item->inv) |
|
|
1253 | LOG(llevDebug,"Monster %d having scroll %d with empty inventory!", mon->count, item->count); |
1249 | if (monster_should_cast_spell(mon, item->inv)) |
1254 | else if (monster_should_cast_spell(mon, item->inv)) |
1250 | SET_FLAG(mon, FLAG_READY_SCROLL); |
1255 | SET_FLAG(mon, FLAG_READY_SCROLL); |
1251 | /* Don't use it right now */ |
1256 | /* Don't use it right now */ |
1252 | return; |
1257 | return; |
1253 | } |
1258 | } |
1254 | else if (item->type == WEAPON) flag = check_good_weapon(mon,item); |
1259 | else if (item->type == WEAPON) flag = check_good_weapon(mon,item); |
1255 | else if (IS_ARMOR(item)) flag = check_good_armour(mon,item); |
1260 | else if (IS_ARMOR(item)) flag = check_good_armour(mon,item); |
1256 | /* Should do something more, like make sure this is a better item */ |
1261 | /* Should do something more, like make sure this is a better item */ |
1257 | else if (item->type == RING) |
1262 | else if (item->type == RING) |
… | |
… | |
1649 | return 0; |
1654 | return 0; |
1650 | /* Lauwenmark - Here we let the objects inside inventories hear and answer, too. */ |
1655 | /* Lauwenmark - Here we let the objects inside inventories hear and answer, too. */ |
1651 | /* This allows the existence of "intelligent" weapons you can discuss with */ |
1656 | /* This allows the existence of "intelligent" weapons you can discuss with */ |
1652 | for(cobj=npc->inv;cobj!=NULL; cobj = cobj->below) |
1657 | for(cobj=npc->inv;cobj!=NULL; cobj = cobj->below) |
1653 | { |
1658 | { |
1654 | if (execute_event(cobj, EVENT_SAY,npc,NULL,txt,SCRIPT_FIX_ALL)!=0) |
1659 | if (execute_event(cobj, EVENT_SAY,op,NULL,txt,SCRIPT_FIX_ALL)!=0) |
1655 | return 0; |
1660 | return 0; |
1656 | } |
1661 | } |
1657 | for ( cobj = npc->inv; cobj; cobj = cobj->below ) |
1662 | for ( cobj = npc->inv; cobj; cobj = cobj->below ) |
1658 | if ( quest_is_override_compatible( cobj, op ) ) |
1663 | if ( quest_is_override_compatible( cobj, op ) ) |
1659 | if ( do_talk_npc( op, npc, cobj, txt ) ) |
1664 | if ( do_talk_npc( op, npc, cobj, txt ) ) |