Commit Graph
100 Commits
Author SHA1 Message Date
Pasi Kallinen 074476758c Change map terrain changing from macro to function
The function handles setting lava lit, and removing ice melt timers.
2022-03-16 20:59:58 +02:00
Pasi Kallinen 811299edaf Lua: allow calling impossible 2022-03-16 16:58:42 +02:00
Pasi Kallinen d1ca594d1c Remove melting ice timeouts when terrain changes
If special level lua code creates a melting ice timeout, but
later in the code places stairs, or a trap which might change
the ice to room floor, the timer sanity checking doesn't
like that.
2022-03-16 16:51:53 +02:00
Pasi Kallinen 49b26dbe99 Simplify abscoord code
No need to call get_location_coord, as we're never dealing with
random coordinates or rooms.
2022-03-16 16:46:10 +02:00
Pasi Kallinen d76cf9377d Unhide monster when rolling boulder explodes 2022-03-16 16:43:42 +02:00
Pasi Kallinen 38924002e0 Lua: ice theme room and melting ice
Allow the ice theme room to occasionally have melting ice.
Add nh.abscoord() to convert room-relative to map-absolute coords.
2022-03-15 22:05:36 +02:00
Pasi Kallinen bdc81ab389 Lua: allow obj chain iteration 2022-03-15 18:24:49 +02:00
Pasi Kallinen e33dd11e99 Document the lua object class 2022-03-15 14:17:46 +02:00
Pasi Kallinen 957c0fbee0 Lua: location-specific timers
Expose map-location specific timers to lua scripts. For example:

  nh.start_timer_at(x,y, "melt-ice", 10);

Currently only available timer type is "melt-ice".
2022-03-15 13:46:56 +02:00
Pasi Kallinen 006ae67029 Fix autowielding tools taking no time
When applying some tools (whips, polearms, grapples), or rubbing
a lamp, or when fireassist is on and you fire something without
wielded launcher, the automatic wielding should take as much time
as wielding the item normally does.

Fixes #696
2022-03-15 11:34:48 +02:00
Pasi Kallinen b271826147 Add test for selection subtraction 2022-03-14 19:06:51 +02:00
Pasi Kallinen 9dd69f4b88 Fix potentially uninitialized variables 2022-03-14 10:06:23 +02:00
Pasi Kallinen 39f3988f76 Lua: object bury method 2022-03-13 18:38:23 +02:00
Pasi Kallinen 20f214592a Lua: object timers
Expose object timers to lua scripts. For example:

   local o = obj.new("cockatrice egg");
   o:placeobj(5, 5);
   o:start_timer("hatch-egg", 3);

Available methods are:

- obj.has_timer("rot-corpse")
    returns true if object has attached timer, false otherwise.

- obj.peek_timer("hatch-egg")
    returns an integer value, which is the turn when the timer
    attached to the object would trigger. returns 0 if no such timer.

- obj.stop_timer("shrink-glob")
    stops attached timer, or if no timer type is given, stops all
    timers attached to the object.

- obj.start_timer("zombify-mon", 15)
    starts a timer with a trigger time in that many turns in the future.
    replaces any previous timer of the same type.

Valid timers are "rot-organic", "rot-corpse", "revive-mon",
"zombify-mon", "burn-obj", "hatch-egg", "fig-transform",
and "shrink-glob". Also "melt-ice" is recognized, but does nothing
to objects.
2022-03-13 14:50:07 +02:00
Pasi Kallinen 4be6fb0df9 Rolling boulder launch coordinates
Allow defining rolling boulder launching location in special level
lua scripts:

 des.trap({ type="rolling boulder", coord={7, 5}, launchfrom={-2, -2} });

launchfrom is relative to the trap coord.
2022-03-12 18:34:44 +02:00
Pasi Kallinen 625571062e Separate function for finding random launch coordinate 2022-03-12 18:04:29 +02:00
Pasi Kallinen ea52bacfce Unhide monster hiding under shrinking glob 2022-03-11 17:34:26 +02:00
Pasi Kallinen 785463ba31 Can't swallow trapped monsters
Gulping can move the trapped monster to another location, while
still being marked as trapped.  I don't want to deal with this,
so just say purple worms can't swallow trapped monsters...
2022-03-05 18:30:36 +02:00
Pasi Kallinen 0dec6cad34 Illiterate and blank spellbooks from gods
Make gods avoid giving blank spellbooks as gifts, if you're
illiterate.  But if you do get a blank spellbook as a gift,
don't force-learn that non-existent spell.
2022-03-05 16:42:46 +02:00
Pasi Kallinen 71fe55eba8 Reset next_boulder when boulder was pushed 2022-03-05 16:36:26 +02:00
Pasi Kallinen 3834bb2ca0 Get out of moverock correctly, so we clear next_boulder 2022-03-05 15:46:16 +02:00
Pasi Kallinen d2efae280a Fix monster trapped in nonexistent trap, pt 2
Monster hiding under an item on a location with a land mine,
a rolling boulder trap launches a boulder which blows up the mine,
and all the items scatter away. If the hider survived that, it
was still hiding.
2022-03-05 13:42:28 +02:00
Pasi Kallinen 4c1d1a0666 Fix monster trapped in nonexistent trap
A monster trapped in a bear trap on ice, exploding fiery monster
turned the ice into water turning the trap into object, the trapped
monster claimed to be still trapped in the nonexistent trap.
2022-03-05 11:29:06 +02:00
Pasi Kallinen fab1048f2f Fix segfault with uball
Drowning in a pool while punished and carrying the ball,
and the only available space to crawl back on dry land
has a magic trap, which unpunishes you.
2022-03-05 10:09:54 +02:00
Pasi Kallinen 7a1db1d0bd Fix couple cases of unhiding monsters
Hidden monster might be forced to move to a location where it
can't hide, perhaps because it's mostly surrounded by other monsters.

Hidden monster in a pit under items, getting hit by a rolling boulder,
the boulder will fill the pit burying the items, making the monster
unable to hide there.
2022-03-04 19:58:24 +02:00
Pasi Kallinen 7c2ffaa8c5 More trap sanity 2022-03-04 17:18:05 +02:00
Pasi Kallinen 62906e732e Trap sanity checking 2022-03-04 16:54:43 +02:00
Pasi Kallinen 2cdd8f8dcb Fix checking monster moving into a trap return value
When I added a new trap return value, this was one place that
should've checked it.

This was really annoying to debug - it manifested as a temp level
file loading error, because a monster moved on to a level teleport
trap, which zeroes out (mx, my), then later in the monster movement,
a web spinner created a web at (0,0), and then hero leaving the level,
the traps were saved into the level file ... and when loaded, the code
thought a trap with x == 0 meant there were no more traps.
2022-03-04 16:42:15 +02:00
Pasi Kallinen ab8a18d1f0 Unhide monster when boulder rolls away 2022-03-04 10:48:38 +02:00
Pasi Kallinen 70795fa124 Prevent monster hurtling outside map 2022-03-03 22:24:17 +02:00
Pasi Kallinen 13d85abde5 Fix uninitialized variables
... as found by valgrind
2022-03-02 13:31:18 +02:00
Pasi Kallinen e83917bbf3 Unhide monster hiding under chain when unpunished 2022-03-01 16:14:07 +02:00
Pasi Kallinen 473ae4a6a0 Prevent segfault trying to make non-existent trap seen 2022-03-01 15:31:22 +02:00
Pasi Kallinen b172957831 Use macro for spell pw cost per spell level 2022-02-28 22:21:37 +02:00
Pasi Kallinen 6a65b41270 Using magic portals and level teleporters stuns for a few turns
It's taxing to teleport long distances.

Yes, this makes the entrance to the planes and the quest more
dangerous, and nerfs portal dancing Fort Ludios.
2022-02-27 11:25:58 +02:00
Pasi Kallinen 1d4d0f4b0e Use more u_locomotion
... and make it autocapitalize the first letter, just like locomotion
2022-02-27 11:07:31 +02:00
Pasi Kallinen 9e666b75f6 Make rope golem have some death drops 2022-02-26 23:46:55 +02:00
Pasi Kallinen d0f349cbd1 Use find_mid finding the leashed mon 2022-02-26 22:42:37 +02:00
Pasi Kallinen f8cb7ae0b8 Unify shopkeeper/guard/priest bit in m_move 2022-02-26 18:05:43 +02:00
Pasi Kallinen 7523623d95 Make m_move return defines instead of magic numbers 2022-02-26 17:40:17 +02:00
Pasi Kallinen 4b6b976e3b Split escaping from sticking monster check out of domove 2022-02-25 22:26:12 +02:00
Pasi Kallinen f88dce6970 Unify domove and lookaround trap/liquid avoidance code
Nearly same code was in two places - the only difference was
how g.context.run == 1 was handled.  Previously, if you were
blind, and knew about the water or lava, you still ran into it.
Now, we always avoid the dunking if running/rushing.
2022-02-25 21:52:52 +02:00
Pasi Kallinen e57c631ef9 Minor code clarification 2022-02-25 19:48:17 +02:00
Pasi Kallinen 86bc0a2633 Split movement out of bounds check out of domove 2022-02-25 18:33:50 +02:00
Pasi Kallinen 4e11a85fb7 Split carrying too much check out of domove 2022-02-25 18:12:55 +02:00
Pasi Kallinen 2012254c39 Split impaired movement code out of domove 2022-02-25 17:06:25 +02:00
Pasi Kallinen 7733cbe399 Split water turbulence code out of domove 2022-02-25 16:59:52 +02:00
Pasi Kallinen 7a29110514 Split ice fumbling code out of domove 2022-02-25 16:43:09 +02:00
Pasi Kallinen 1cc79b7156 Wizard-mode wishing for (melting) ice 2022-02-25 16:42:08 +02:00
Pasi Kallinen cb5ca657ed Split air turbulence code out of domove 2022-02-25 16:13:27 +02:00
Pasi Kallinen d617875a82 Split force-fighting empty square out of domove 2022-02-25 15:19:51 +02:00
Pasi Kallinen 48cd81dbfd Split swapping places with pet code out of domove 2022-02-25 15:09:56 +02:00
Pasi Kallinen f44a4b0485 Change unknown mintrap result into impossible 2022-02-25 14:57:03 +02:00
Pasi Kallinen 3b521aa955 Split force-fight iron bars code out of domove 2022-02-25 14:54:33 +02:00
Pasi Kallinen 57f55f5ca6 Split some code out of domove
Should have no change in behaviour.
2022-02-25 14:46:45 +02:00
Pasi Kallinen 6fa4fd46f7 Move output delay from walk_path to mhurtle_step
... in case walk_path is ever used for something that
doesn't need the delay.  The hero hurtling already had
delay, so it was done twice.
2022-02-24 19:50:37 +02:00
Pasi Kallinen 0c20bf116c Moving a monster with telekinesis hurles it through the air
... and at the end of the flight, it can't avoid a trap, if it
lands on one.
2022-02-24 19:27:59 +02:00
Pasi Kallinen 9ae2ec1f98 Most traps now require touching the floor to trigger
It was silly how some clearly mechanical traps didn't consider
flight or levitation when to trigger.  Do those checks in dotrap/mintrap
making hero and monster trap triggering match more closely.
2022-02-24 18:55:14 +02:00
Pasi Kallinen 2777f45bd5 Get rid of force_mintrap, allow passing flags to mintrap
It uses the same flags as dotrap, so simulate force_mintrap
by passing FORCETRAP flag.
2022-02-24 17:13:23 +02:00
Pasi Kallinen 9716f22851 Make trap return values more consistent
Instead of returning monster's mtrapped-state, return specific
trap return values.
Add one extra trap return value, for when a monster was
moved by the trap.
2022-02-24 16:24:02 +02:00
Pasi Kallinen 547f6e9244 Remove forced trap activation from mhurtle 2022-02-24 15:18:00 +02:00
Pasi Kallinen 16a8caac97 Allow using #wiztelekinesis on yourself 2022-02-24 15:10:39 +02:00
Pasi Kallinen 8e91320d2f Use u_at macro 2022-02-23 20:28:55 +02:00
Pasi Kallinen 645720d1bc Fix the force_mintrap 2022-02-23 19:11:32 +02:00
Pasi Kallinen 9ad1e7e620 Hurtling monster always triggers a trap 2022-02-23 18:59:57 +02:00
Pasi Kallinen 60642a8876 Wall of water stops monster hurtling 2022-02-23 13:54:07 +02:00
Pasi Kallinen e965f6cf44 Give message trying to hurtle immovable monster
If the monster is too big, stuck to hero, or trapped.
2022-02-23 13:42:08 +02:00
Pasi Kallinen 5786ddadbb Use IS_WATERWALL and is_waterwall 2022-02-23 12:53:09 +02:00
Pasi Kallinen 362cb4a317 Fix comment, mhurtle now handles pools and lava 2022-02-23 11:34:35 +02:00
Pasi Kallinen 4eaa8cd055 Make minliquid handle walls of water 2022-02-23 11:30:51 +02:00
Pasi Kallinen e0a83630e1 Some spell code reorg
Keep the internal spell array index inside spell.c,
and refer to spells outside of it with the otyp id.
2022-02-23 10:52:10 +02:00
Pasi Kallinen 462e13f07b Handle water and lava when hurtling a monster
Also delay the output, showing the hurtle animation.
2022-02-22 16:51:18 +02:00
Pasi Kallinen 268022e5de Add #wiztelekinesis for testing purposes
For testing mhurtle, which is used for jousting or
bare-handed combat.

Improve mhurtle_step to handle bumping into another monster,
and when the monster gets killed or stuck in a trap.
2022-02-22 16:00:05 +02:00
Pasi Kallinen e5c73d01fe Make wood golem death drops more varied 2022-02-22 14:57:41 +02:00
Pasi Kallinen 4866182a02 Change kitchen sink glyph and color
The default sink glyph is already used for many other things:
iron bars, trees, corridors, drawbridges, and clouds.

Change the glyph to {, and change the color to white.
The glyph is only used for fountains, so it makes "safe"
water-related glyphs match.
2022-02-22 14:41:20 +02:00
Pasi Kallinen cf58d09fa6 Huge monsters easily climb out of pits
Also, give a message when a monster trapped in a pit, a web,
or a bear trap frees itself.
2022-02-22 13:08:03 +02:00
Pasi Kallinen 33556788c3 Start with a level 1 spell and enough power
Ensure the first spell - if any - given to the hero in initial
inventory is level 1 - otherwise you can end up with a situation
where the hero knows level 3 spells, but won't have enough power
to cast them.

If the hero starts out with a spell, ensure enough power (5)
to cast that level 1 spell.
2022-02-22 12:26:06 +02:00
Pasi Kallinen 78f7df9a51 Casting a forgotten spell uses some random amount of power
... in addition to the confusion/stunning it does.
2022-02-22 11:32:08 +02:00
Pasi Kallinen d1dbed95f3 Elves and rangers get alignment penalty for cutting down trees 2022-02-22 11:13:59 +02:00
Pasi Kallinen 51a5550a51 Hobbits getting a sling also get some ammo 2022-02-22 10:01:55 +02:00
Pasi Kallinen 733fc84934 Flint and hard gems break less often when thrown 2022-02-22 10:01:17 +02:00
Pasi Kallinen d452242af4 Adjust sleep spell, and monk starting spell
Tone down sleep level to 3 (hitting a monster does tend to wake
it up), and replace the random monk starting sleep spell with
confuse monster, which fits nicely with monk's bare-handed
fighting style.
2022-02-22 09:13:32 +02:00
Pasi Kallinen ef6a88e1e1 Chargeable rings may get charged when hit with electricity
... instead of being destroyed. Normal charging limits apply.
2022-02-21 21:06:29 +02:00
Pasi Kallinen c73595cc96 Adjust enchantment spell levels
The enchantment spells were skewed towards lower spell levels,
and didn't seem to correspond with the spell effectiveness or
power.  Adjust the spell levels:

- Confuse monster is probably the least powerful enchantment, and
  also requires touch to work, so make it the new level 1 spell.

- Sleep is quite powerful, and ray, bump it to level 4.

- Charm monster is even more powerful so make it level 5.
  (Considering that create familiar is level 6)

                 old   new
sleep             1     4
confuse monster   2     1
slow monster      2     2
cause fear        3     3
charm monster     3     5

Also swap sleep and confuse monster generation probability.
2022-02-21 19:49:04 +02:00
Pasi Kallinen 4a61602436 Illiterate hero will learn spells directly from deity
... instead of receiving a spellbook.
2022-02-20 22:05:33 +02:00
Pasi Kallinen fcdae54173 Fix old-style function def 2022-02-20 21:18:03 +02:00
Pasi Kallinen 038ae7f984 Clean up some spell-related code
Add two helper functions and use those outside of spell.c,
instead of iterating through all the spells.
2022-02-20 21:12:26 +02:00
Pasi Kallinen 041a07468a Always give a message when monster changes form via polytrap
... if the hero can see it.  This was an accessibility issue.
2022-02-20 19:40:55 +02:00
Pasi Kallinen fc19d1b453 Make looting less tedious
I've seen complaints how looting containers is tedious, and
since multiple containers in the same location are now (and have
been for a while) handled with a menu, the yes-no-quit prompt
for a single container doesn't really mean anything.

Remove that prompt, and remove the "open carefully" message too,
so when you're looting a location with a single container, the
command will drop straight into the loot-in-out -menu.  Also
adjust one looting message to explicitly mention the container
if there are other objects on top of it.

Removing the prompt means you can't loot a saddle from a tame
monster with plain loot when standing on a container - you need
to prefix the loot command with 'm' prefix in that case.
2022-02-20 18:39:52 +02:00
Pasi Kallinen 74296c3213 Split sitting code into smaller parts
Split sitting on a throne and laying an egg into their
own functions.  No changes to behaviour.
2022-02-20 17:29:37 +02:00
Pasi Kallinen 928677c810 Engraving with Fire Brand burns the text on the floor 2022-02-20 15:59:33 +02:00
Pasi Kallinen a78419c52a Thrown items can get stuck in webs 2022-02-20 12:23:00 +02:00
Pasi Kallinen 70dafd658d Imps and others cussing the hero wake up nearby monsters 2022-02-19 17:18:07 +02:00
Pasi Kallinen 5e26589fa7 Make killer bee - queen bee transformation apply to hero
if they've polyformed to a killer bee and eat royal jelly.
2022-02-19 17:06:36 +02:00
Pasi Kallinen 26ea5824c1 Reading a magic marker shows the specific red ink color 2022-02-19 13:11:24 +02:00
Pasi Kallinen c434236f1e Allow creating unhidden traps in special levels
des.trap({ type = "rust", seen = true });
2022-02-19 12:38:28 +02:00
Pasi Kallinen a1d5464fa7 Knight quest home level has some saddled warhorses
Also, when creating a saddle in a monster inventory in special
level lua code, automatically saddle the monster, if possible.
2022-02-19 11:51:10 +02:00
Pasi Kallinen 04756b5d34 Towels should weigh more than blindfolds
There's more cloth in a towel than in a blindfold.
2022-02-19 10:32:57 +02:00
Pasi Kallinen 41ae240cad Candy bars are bright blue in text mode
There's lots of brown comestibles, but no bright blue.
2022-02-19 10:28:06 +02:00
Pasi Kallinen cd14456b02 Knights get no caitiff penalty against undead 2022-02-18 21:29:31 +02:00