Some modifications to the pathfind travel_cost function.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5491 c06c8d41-db1a-0410-9941-cceddc491573
D7SLVLRNCYCBDYYRANHDG3JYEF25CFCSUY5FMF5KXVD5D4UZSDDAC
L5H6B2WM4OOVGVCZOT3Z7DC2MOUVDLZ4DWRA6L6J3EUXF55USTZQC
Y4NA3JSN63RLATF4NNBPSR5CWF5Z7UEMWCGVX4B6NOAR47CGM4GQC
3HGELZU7NELOQ635HZO6IJIYLBSNCJ5VPH46IE22KA3OSLEFK7AQC
KAOE5HB3THUKVGFZRO5EZESHEB3Q34WUO5DFMLWIKOBF47LZTIYAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
3OFG2YD2UOHC6UA7H7LWKOWCNFFSTDOXAA6L3KC335OF5RV3YOYQC
NW6P7VRKBFBQ2FRDZBXN7APJZPYC4SYCIA3MOOE2KZGX43IXNK2AC
LTX72QGIPNUGWQN5ULPOMFCOPZTK7472DQY4AYX5WM3WHSUVXI5QC
RBAGQ2PB7V5YAM5KSHSZR2E3MLKDSRVM5XYGI2TIXP5QMVBOQHDQC
PM65H4V4GNPVIJFUQW57DC3VDB7TRUUNXKVZONQKEFZSK3AXX5GQC
NNG27Y5ZQAZX6UD7F7M4F6KEZBEDFXPEEC3LFUSX4ESKT7K6UJQAC
DQUTMKIMQUJDOAC3YHRK5W4PDCOKVPQFSV7OWWS75CCUMC5B2PGAC
TAJUWPR2BXNVKYH4CN4WN3OR2Z2NESJBEDUB2P2PE6YLX64FQTRAC
ZNI3CWU5DWBFSULG4UWOW7AGV2JIBLXE5U3EOF6ESZDLFO2ZDT7QC
SJDOBXECX7F3ZPPVR7FPURE53D47PP2TFIF4SB6XPS456PZV3DQAC
MDFQRJ6QZNFUBVSFWLXUJ6EBXOU47T3CVDI2XKBGNNRF4DXDKESQC
GPEJOT73KMACP33IPAKFR5ROGHCOIP22VXZMQNYTGLEA2OSZUM2AC
FLDIOEND63BONSOAIZ7WYAVNQLJ35O3VFY3PTVRWWYOJL4JXREHAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
P5TRGRH7XMQSPCZKM5IEEO34TY6WMLGHHX7BU6Y453JFRXLUR2VQC
I7NXCEKCEBDWOGO7EDNRZ36GELP3P5GTOOXQG2YS5TXZTCNN7CDQC
B7MSPF6X2RLGWN4M6ZZF3WSOPKGYPTTD7LIJVST7DXN27DG6JHNAC
JDM27QE4HR52AYFSQE763BFF57ANOTF5MXKMO377PP5EXMN7SAOAC
NVSFIV2ZKP44XHCSCXG6OZVGL67OIFINC34J2EMKTA4KULCERUEAC
45EMD3KLQPMERNMIKU5G76H6556XOMIW352TSBP7VLWJX2YYGS7AC
// Returns true for monsters that obviously (to the player) feel
// "thematically at home" in a branch. Currently used for native
// monsters recognizing traps and patrolling branch entrances.
static bool _is_native_in_branch(const monsters *monster,
const branch_type branch)
{
switch (branch)
{
case BRANCH_ELVEN_HALLS:
return (mons_species(monster->type) == MONS_ELF);
case BRANCH_ORCISH_MINES:
return (mons_species(monster->type) == MONS_ORC);
case BRANCH_SHOALS:
return (mons_species(monster->type) == MONS_CYCLOPS
|| mons_species(monster->type) == MONS_MERFOLK
|| mons_species(monster->type) == MONS_MERMAID);
case BRANCH_SLIME_PITS:
return (mons_species(monster->type) == MONS_JELLY);
case BRANCH_SNAKE_PIT:
return (mons_species(monster->type) == MONS_NAGA
|| mons_species(monster->type) == MONS_SNAKE);
case BRANCH_HALL_OF_ZOT:
return (mons_species(monster->type) == MONS_DRACONIAN);
case BRANCH_TOMB:
return (mons_species(monster->type) == MONS_MUMMY);
case BRANCH_HIVE:
return (monster->type == MONS_KILLER_BEE_LARVA
|| monster->type == MONS_KILLER_BEE
|| monster->type == MONS_QUEEN_BEE);
case BRANCH_HALL_OF_BLADES:
return (monster->type == MONS_DANCING_WEAPON);
default:
return false;
}
}
// randomize potential damage
// Randomize potential damage.
// mprf("Feature %d is not a habitable grid.", grd(p));
return (false);
}
// Your friends only know about doors you know about, unless they feel
// at home in this branch.
if (grd(p) == DNGN_SECRET_DOOR && mons_friendly(mons)
&& (mons_intel(mons->type) < I_NORMAL
|| !mons_is_native_in_branch(mons, you.where_are_you)))
{
// TODO: Make traps/shallow water more expensive, etc.
// Moving from floor to water (or vice versa) is a bit more expensive.
// The deep water checks are only done in case of amphibious monsters.
if ((grd(pos) == DNGN_SHALLOW_WATER || grd(pos) == DNGN_DEEP_WATER)
&& grid_compatible(grd(npos), DNGN_FLOOR)
|| (grd(npos) == DNGN_SHALLOW_WATER || grd(npos) == DNGN_DEEP_WATER)
&& grid_compatible(grd(pos), DNGN_FLOOR))
{
return 2;
}
// Try to avoid (known) traps.
//
const int trap = trap_at_xy(npos.x, npos.y);
if (trap >= 0)
{
// A monster can be considered to know a trap if
// a) they're hostile
// b) they're friendly and *you* know about the trap (and told them)
// c) they're friendly and know the terrain
bool knows_trap = (!mons_friendly(mons)
|| grd(npos) != DNGN_UNDISCOVERED_TRAP
|| mons_intel(mons->type) >= I_NORMAL
&& mons_is_native_in_branch(mons,
you.where_are_you));
trap_type tt = env.trap[trap].type;
if (tt == TRAP_ALARM || tt == TRAP_ZOT)
{
// Your allies take extra precautions to avoid known alarm traps.
if (knows_trap && mons_friendly(mons))
return (3);
// To hostile monsters, these traps are completely harmless.
return 1;
}
if (knows_trap)
{
const int montype = mons_is_zombified(mons) ? mons_zombie_base(mons)
: mons->type;
// Mechanical traps can be avoided by flying, as can shafts, and
// tele traps are never traversable anyway.
if (!_mons_airborne(montype, -1, false))
return 2;
}
return 1;
}
}
// Returns true for monsters that obviously (to the player) feel
// "thematically at home" in a branch. Currently used for native
// monsters recognizing traps and patrolling branch entrances.
bool mons_is_native_in_branch(const monsters *monster,
const branch_type branch)
{
switch (branch)
{
case BRANCH_ELVEN_HALLS:
return (mons_species(monster->type) == MONS_ELF);
case BRANCH_ORCISH_MINES:
return (mons_species(monster->type) == MONS_ORC);
case BRANCH_SHOALS:
return (mons_species(monster->type) == MONS_CYCLOPS
|| mons_species(monster->type) == MONS_MERFOLK
|| mons_species(monster->type) == MONS_MERMAID);
case BRANCH_SLIME_PITS:
return (mons_species(monster->type) == MONS_JELLY);
case BRANCH_SNAKE_PIT:
return (mons_species(monster->type) == MONS_NAGA
|| mons_species(monster->type) == MONS_SNAKE);
case BRANCH_HALL_OF_ZOT:
return (mons_species(monster->type) == MONS_DRACONIAN);
case BRANCH_TOMB:
return (mons_species(monster->type) == MONS_MUMMY);
case BRANCH_HIVE:
return (monster->type == MONS_KILLER_BEE_LARVA
|| monster->type == MONS_KILLER_BEE
|| monster->type == MONS_QUEEN_BEE);
case BRANCH_HALL_OF_BLADES:
return (monster->type == MONS_DANCING_WEAPON);
default:
return (false);
}