diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-07-18 23:01:55 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-07-18 23:11:01 +0200 |
commit | e51487d54455c7930ba10222bb55a32eb36f7674 (patch) | |
tree | dbf0108ddd64feff2f436ecbdd6fb49c6898564a /crawl-ref/source/fineff.cc | |
parent | 478b7bfc3f423d4071777d6a6a4f855303bd9f86 (diff) | |
download | crawl-ref-e51487d54455c7930ba10222bb55a32eb36f7674.tar.gz crawl-ref-e51487d54455c7930ba10222bb55a32eb36f7674.zip |
Delay Royal Jelly spawns until the end of an actor's turn.
This means they can't be damaged by the same attack or spell that spawned
them.
Also, use div_rand_round() instead of fixed thresholds every 12 hp. They
worked well when TRJ couldn't heal, but now it can repeatedly go over the
same threshold.
Diffstat (limited to 'crawl-ref/source/fineff.cc')
-rw-r--r-- | crawl-ref/source/fineff.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/crawl-ref/source/fineff.cc b/crawl-ref/source/fineff.cc index ec9524dd7a..6a4575df53 100644 --- a/crawl-ref/source/fineff.cc +++ b/crawl-ref/source/fineff.cc @@ -10,6 +10,8 @@ #include "env.h" #include "fineff.h" #include "libutil.h" +#include "mgen_data.h" +#include "mon-place.h" #include "ouch.h" #include "religion.h" #include "view.h" @@ -52,6 +54,64 @@ void add_final_effect(final_effect_flavour flavour, env.final_effects.push_back(fe); } +static void _trj_spawns(actor *attacker, actor *trj, coord_def pos, int damage) +{ + int tospawn = div_rand_round(damage, 12); + + if (tospawn <= 0) + return; + + dprf("Trying to spawn %d jellies.", tospawn); + + unsigned short foe = attacker ? attacker->mindex() : MHITNOT; + + int spawned = 0; + for (int i = 0; i < tospawn; ++i) + { + const monster_type jelly = royal_jelly_ejectable_monster(); + coord_def jpos = find_newmons_square_contiguous(jelly, pos); + if (!in_bounds(jpos)) + continue; + + if (monster *mons = mons_place( + mgen_data(jelly, BEH_HOSTILE, trj, 0, 0, + jpos, foe, MG_DONT_COME, GOD_JIYVA))) + { + // Don't allow milking the royal jelly. + mons->flags |= MF_NO_REWARD; + spawned++; + } + } + + if (!spawned || !you.see_cell(pos)) + return; + + if (trj) + { + const std::string monnam = trj->name(DESC_THE); + mprf("%s shudders%s.", monnam.c_str(), + spawned >= 5 ? " alarmingly" : + spawned >= 3 ? " violently" : + spawned > 1 ? " vigorously" : ""); + + if (spawned == 1) + mprf("%s spits out another jelly.", monnam.c_str()); + else + { + mprf("%s spits out %s more jellies.", + monnam.c_str(), + number_in_words(spawned).c_str()); + } + } + else if (spawned == 1) + mpr("One of the Royal Jelly's fragments survives."); + else + { + mprf("The dying Royal Jelly spits out %s more jellies.", + number_in_words(spawned).c_str()); + } +} + // Effects that occur after all other effects, even if the monster is dead. // For example, explosions that would hit other creatures, but we want // to deal with only one creature at a time, so that's handled last. @@ -124,6 +184,10 @@ void fire_final_effects() if (defender && defender->alive() && !defender->no_tele(true, false)) defender->teleport(true, one_chance_in(5)); break; + + case FINEFF_ROYAL_JELLY_SPAWN: + _trj_spawns(attacker, defender, fe.pos, fe.x); + break; } } env.final_effects.clear(); |