… | |
… | |
706 | return 1; |
706 | return 1; |
707 | |
707 | |
708 | /* check all the parts of ob2 - just because we can't get to |
708 | /* check all the parts of ob2 - just because we can't get to |
709 | * its head doesn't mean we don't want to pound its feet |
709 | * its head doesn't mean we don't want to pound its feet |
710 | */ |
710 | */ |
711 | for (more = ob2->more; more != NULL; more = more->more) |
711 | for (more = ob2->more; more; more = more->more) |
712 | { |
712 | { |
713 | get_rangevector (ob1, more, &rv1, 0); |
713 | get_rangevector (ob1, more, &rv1, 0); |
714 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
714 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
715 | return 1; |
715 | return 1; |
716 | } |
716 | } |
… | |
… | |
1197 | flag = 1; |
1197 | flag = 1; |
1198 | |
1198 | |
1199 | else |
1199 | else |
1200 | switch (item->type) |
1200 | switch (item->type) |
1201 | { |
1201 | { |
1202 | case MONEY: |
1202 | case MONEY: |
1203 | case GEM: |
1203 | case GEM: |
1204 | flag = monster->pick_up & 2; |
1204 | flag = monster->pick_up & 2; |
1205 | break; |
1205 | break; |
1206 | |
1206 | |
1207 | case FOOD: |
1207 | case FOOD: |
1208 | flag = monster->pick_up & 4; |
1208 | flag = monster->pick_up & 4; |
1209 | break; |
1209 | break; |
1210 | |
1210 | |
1211 | case WEAPON: |
1211 | case WEAPON: |
1212 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1212 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1213 | break; |
1213 | break; |
1214 | |
1214 | |
1215 | case ARMOUR: |
1215 | case ARMOUR: |
1216 | case SHIELD: |
1216 | case SHIELD: |
1217 | case HELMET: |
1217 | case HELMET: |
1218 | case BOOTS: |
1218 | case BOOTS: |
1219 | case GLOVES: |
1219 | case GLOVES: |
1220 | case GIRDLE: |
1220 | case GIRDLE: |
1221 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1221 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1222 | break; |
1222 | break; |
1223 | |
1223 | |
1224 | case SKILL: |
1224 | case SKILL: |
1225 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1225 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1226 | break; |
1226 | break; |
1227 | |
1227 | |
1228 | case RING: |
1228 | case RING: |
1229 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1229 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1230 | break; |
1230 | break; |
1231 | |
1231 | |
1232 | case WAND: |
1232 | case WAND: |
1233 | case HORN: |
1233 | case HORN: |
1234 | case ROD: |
1234 | case ROD: |
1235 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1235 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1236 | break; |
1236 | break; |
1237 | |
1237 | |
1238 | case SPELLBOOK: |
1238 | case SPELLBOOK: |
1239 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1239 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1240 | break; |
1240 | break; |
1241 | |
1241 | |
1242 | case SCROLL: |
1242 | case SCROLL: |
1243 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1243 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1244 | break; |
1244 | break; |
1245 | |
1245 | |
1246 | case BOW: |
1246 | case BOW: |
1247 | case ARROW: |
1247 | case ARROW: |
1248 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1248 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1249 | break; |
1249 | break; |
1250 | } |
1250 | } |
1251 | |
1251 | |
1252 | /* Simplistic check - if the monster has a location to equip it, he will |
1252 | /* Simplistic check - if the monster has a location to equip it, he will |
1253 | * pick it up. Note that this doesn't handle cases where an item may |
1253 | * pick it up. Note that this doesn't handle cases where an item may |
1254 | * use several locations. |
1254 | * use several locations. |
… | |
… | |
1499 | * the creature should run away (dir+4) |
1499 | * the creature should run away (dir+4) |
1500 | * I think its wrong for a creature to have a zero maxhp value, but |
1500 | * I think its wrong for a creature to have a zero maxhp value, but |
1501 | * at least one map has this set, and whatever the map contains, the |
1501 | * at least one map has this set, and whatever the map contains, the |
1502 | * server should try to be resilant enough to avoid the problem |
1502 | * server should try to be resilant enough to avoid the problem |
1503 | */ |
1503 | */ |
1504 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1504 | if (ob->stats.hp * 100 < ob->stats.maxhp * ob->run_away) |
1505 | return absdir (dir + 4); |
1505 | return absdir (dir + 4); |
1506 | |
1506 | |
1507 | return dist_att (dir, ob, enemy, part, rv); |
1507 | return dist_att (dir, ob, enemy, part, rv); |
1508 | } |
1508 | } |
1509 | |
1509 | |