diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-13 14:35:40 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-13 14:35:40 +0000 |
commit | f48cb619b22ecd68a58ccd896cb553c53850dc38 (patch) | |
tree | b470e2939e85bf671d71a2dd822df3963d94af77 /crawl-ref/source | |
parent | 9b3b399350ef28d68a1098e47651664c705d055b (diff) | |
download | crawl-ref-f48cb619b22ecd68a58ccd896cb553c53850dc38.tar.gz crawl-ref-f48cb619b22ecd68a58ccd896cb553c53850dc38.zip |
Give amphibians movement speed boost in water, give deep elf master archers a very fast missile attack.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6526 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/mon-data.h | 25 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 14 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.h | 46 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 16 |
4 files changed, 86 insertions, 15 deletions
diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h index bfd9e3746b..1caaacdeab 100644 --- a/crawl-ref/source/mon-data.h +++ b/crawl-ref/source/mon-data.h @@ -135,8 +135,25 @@ */ -#define DEFAULT_ENERGY {10, 10, 10, 10, 10, 10, 10, 100} -#define MOVE_ENERGY(x) {(x), (x), 10, 10, 10, 10, 10, 100} +const mon_energy_usage DEFAULT_ENERGY; + +static inline mon_energy_usage MOVE_ENERGY(int me) +{ + return mon_energy_usage::move_cost(me, me); +} + +static inline mon_energy_usage ATTACK_ENERGY(int ae) +{ + return mon_energy_usage::attack_cost(ae); +} + +static inline mon_energy_usage MISSILE_ENERGY(int ae) +{ + return mon_energy_usage::missile_cost(ae); +} + + +static monsterentry mondata[] = { // monster 250: The Thing That Should Not Be(tm) // do not remove, or seekmonster will crash on unknown mc request @@ -501,7 +518,7 @@ { {AT_SHOOT, AF_PLAIN, 25}, {AT_HIT, AF_PLAIN, 5}, AT_NO_ATK, AT_NO_ATK }, { 15, 4, 2, 0 }, 0, 15, MST_NO_SPELLS, CE_CONTAMINATED, Z_NOZOMBIE, S_SHOUT, I_HIGH, - HT_LAND, 11, DEFAULT_ENERGY, MONUSE_WEAPONS_ARMOUR, SIZE_MEDIUM + HT_LAND, 11, MISSILE_ENERGY(4), MONUSE_WEAPONS_ARMOUR, SIZE_MEDIUM }, { @@ -4299,3 +4316,5 @@ - row 8: habitat, speed, energy_usage, gmon_use class, body size */ #endif + +}; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index ba81b53e8a..e063531424 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -78,9 +78,7 @@ FixedVector < unsigned short, 1000 > mcolour; static bool initialized_randmons = false; static std::vector<monster_type> monsters_by_habitat[NUM_HABITATS]; -static monsterentry mondata[] = { #include "mon-data.h" -}; #define MONDATASIZE ARRAYSZ(mondata) @@ -6344,7 +6342,17 @@ int monsters::action_energy(energy_use_type et) const switch (et) { case EUT_MOVE: return mu.move; - case EUT_SWIM: return mu.swim; + case EUT_SWIM: + // [ds] Amphibious monsters get a significant speed boost + // when swimming, as discussed with dpeg. We do not + // distinguish between amphibians that favour land + // (HT_LAND, such as hydras) and those that favour water + // (HT_WATER, such as merfolk), but that's something we + // can think about. + if (mons_class_flag(type, M_AMPHIBIOUS)) + return div_rand_round(mu.swim * 7, 10); + else + return mu.swim; case EUT_MISSILE: return mu.missile; case EUT_ITEM: return mu.item; case EUT_SPECIAL: return mu.special; diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index f5189ca2a6..06e5040b34 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -271,6 +271,7 @@ struct mon_attack_def // to 10. struct mon_energy_usage { +public: char move; char swim; char attack; @@ -282,6 +283,51 @@ struct mon_energy_usage // Percent of monster->speed used when picking up an item; defaults // to 100% char pickup_percent; + +public: + mon_energy_usage(int mv = 10, int sw = 10, int att = 10, int miss = 10, + int spl = 10, int spc = 10, int itm = 10, int pick = 100) + : move(mv), swim(sw), attack(att), missile(miss), + spell(spl), special(spc), item(itm), pickup_percent(pick) + { + } + + static mon_energy_usage attack_cost(int cost) + { + mon_energy_usage me; + me.attack = cost; + return me; + } + + static mon_energy_usage missile_cost(int cost) + { + mon_energy_usage me; + me.missile = cost; + return me; + } + + static mon_energy_usage move_cost(int mv, int sw = 10) + { + const mon_energy_usage me(mv, sw); + return me; + } + + mon_energy_usage operator | (const mon_energy_usage &o) const + { + return mon_energy_usage( combine(move, o.move), + combine(swim, o.swim), + combine(attack, o.attack), + combine(missile, o.missile), + combine(spell, o.spell), + combine(special, o.special), + combine(item, o.item), + combine(pickup_percent, o.pickup_percent, + 100) ); + } +private: + char combine(char a, char b, char def = 10) const { + return (b != def? b : a); + } }; struct mon_resist_def diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 02aaf1d4c5..3d7a55c6ac 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -5583,15 +5583,13 @@ static bool _handle_monster_spell(monsters *monster, bolt &beem) // Give the monster its action energy (aka speed_increment). static void _monster_add_energy(monsters *monster) { - int energy_gained = (monster->speed * you.time_taken) / 10; - - // Slow monsters might get 0 here. Maybe we should factor in - // *how* slow it is...but a 10-to-1 move ratio seems more than - // enough. - if (energy_gained == 0 && monster->speed != 0) - energy_gained = 1; - - monster->speed_increment += energy_gained; + if (monster->speed > 0) + { + // Randomise to make counting off monster moves harder: + const int energy_gained = + std::max(1, div_rand_round(monster->speed * you.time_taken, 10)); + monster->speed_increment += energy_gained; + } } int mons_natural_regen_rate(monsters *monster) |