Skip to content

Instantly share code, notes, and snippets.

@takkaria
Last active August 29, 2015 14:05
Show Gist options
  • Save takkaria/d31caa45181b87bc1b8c to your computer and use it in GitHub Desktop.
Save takkaria/d31caa45181b87bc1b8c to your computer and use it in GitHub Desktop.
Trap effects being written fully in trap.txt...
#
# New things here:
# - New kind of effect parameter 'msg', which displays the given text when the effect
# is executed
# - Flow control in the effects code
# - A few new effects for effects.c (but not many)
#
# New flow control effect types:
# - 'CHECK_FEATHER_FALL' which checks the if the player has feather falling.
# If they do, display the message and abort execution of later effects
# - 'ONE_IN' which checks if one_in_(dice); aborts if false
# - 'TRAP_CHECK' which runs trap_check(dice); aborts if false
#
# I'd consider it a useful general rule that if a flow control effect aborts, then
# it displays the message attached to that effect.
#
# Other new effect types:
# - 'MESSAGE' which just displays the given message
# - 'INVEN_DAMAGE' which damages the player a given amount and also their
# stuff, with a given element
#
# Modified types:
# - 'DAMAGE' would have to not rely on there being a 'current monster' being set.
#
# This still doesn't implement the exact gameplay mechanics of the trap
# code, because the spiked pit code does stuff like this:
# int dam = effect_calculate_value(context, FALSE);
#
# /* Extra spike damage */
# if (one_in_(2)) {
# msg("You are impaled!");
# dam *= 2;
# (void)player_inc_timed(player, TMD_CUT, randint1(dam), TRUE, TRUE);
# }
#
# take_hit(player, dam, "a trap");
#
# I've wondered about introducing an effect type such as 'SET', which would
# set a local variable, so you could exactly reproduce the above effect:
#
# effect:MESSAGE
# msg:You fall into a spiked pit!
# effect:CHECK_FEATHER_FALL
# msg:You float gently to the bottom of the pit, avoiding the spikes.
# effect:SET_VALUE:d
# dice:2d6
# effect:DAMAGE
# dice:$d
# effect:ONE_IN
# dice:2
# effect:DAMAGE
# dice:$d
# effect:INC_TIMED:TMD_CUT
# msg:You are impaled!
# dice:1d$D
# expr:D:d:* 2
#
# But I think even having written that out makes me feel a bit icky.
# Another way would be to refer to previous calculations somehow.
# Maybe something like appending a variable name to 'dice', e.g.
#
# effect:DAMAGE
# dice:2d6:dam
#
# Would be sufficient to save it as a variable for later reference.
#
# I fear I'm in cloud cuckoo land here already and it's 2am so I'm not sure
# if anything I've written here would be that much of an improvement overall,
# even if it would add flexibility (with the cost being the hideousness of
# turning our relatively easy to read edit files into something approaching
# a Turing complete language). At least it's not Brainf*ck.
#
# One neat thing about using 'msg' is that it is potentially internationalisable
# quite easily. You could imagine msg:en:Blah followed by msg:de:Blüh. And it
# would be a lot easier than keeping that info in the code.
# Maybe it would be cleaner if the field was called 'text' and to use it to make
# a message you had to use the 'MESSAGE' effect, or one of the flow control effects.
# This might come in handy for use in other places in the future, when 33% of the
# game is written in this new colon-y frontier language.
#
diff --git a/lib/edit/trap.txt b/lib/edit/trap.txt
index 97d3f20..ae0e114 100644
--- a/lib/edit/trap.txt
+++ b/lib/edit/trap.txt
@@ -36,7 +36,11 @@ N:17:pit
G:^:s
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_PIT
+effect:MESSAGE
+msg:You fall into a pit!
+effect:CHECK_FEATHER_FALL
+msg:You float gently to the bottom of the pit.
+effect:DAMAGE
dice:2d6
D:A hole dug to snare the unwary.
@@ -45,8 +49,17 @@ D:A hole dug to snare the unwary.
N:18:pit
G:^:s
M:0:2:0
-effect:TRAP_PIT_SPIKES
+effect:MESSAGE
+msg:You fall into a spiked pit!
+effect:CHECK_FEATHER_FALL
+msg:You float gently to the bottom of the pit, avoiding the spikes.
+effect:DAMAGE
+dice:2d6
+effect:ONE_IN
+dice:2
+effect:INC_TIMED:TMD_CUT
+msg:You are impaled!
dice:2d6
D:A hole dug to snare the unwary, with spikes.
@@ -55,9 +68,21 @@ D:A hole dug to snare the unwary, with spikes.
N:19:pit
G:^:s
M:0:2:0
-F:TRAP | FLOOR
-effect:TRAP_PIT_POISON
+F:TRAP | FLOOR
+effect:MESSAGE
+msg:You fall into a spiked pit!
+effect:CHECK_FEATHER_FALL
+msg:You float gently to the bottom of the pit, avoiding the spikes.
+effect:DAMAGE
dice:2d6
+effect:ONE_IN
+dice:2
+effect:MESSAGE
+msg:You are impaled on poisonous spikes!
+effect:INC_TIMED:TMD_CUT
+dice:4d6
+effect:INC_TIMED:TMD_POISON
+dice:4d6
D:A hole dug to snare the unwary, with poisoned spikes.
# 0x14 --> visible trap -- rune -- summon
@@ -86,7 +111,9 @@ N:22:discolored spot
G:^:u
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_SPOT_FIRE
+effect:MESSAGE
+msg:You are enveloped in flames!
+effect:INVEN_DAMAGE:GF_FIRE
dice:4d6
D:A strange coloured spot on the ground - beware its fiery attack.
@@ -96,7 +123,9 @@ N:23:discolored spot
G:^:u
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_SPOT_ACID
+effect:MESSAGE
+msg:You are splashed with acid!
+effect:INVEN_DAMAGE:GF_ACID
dice:4d6
D:A strange coloured spot on the ground - beware its acidic attack.
@@ -106,7 +135,14 @@ N:24:dart trap
G:^:r
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_DART_SLOW
+effect:TRAP_CHECK
+dice:125
+msg:A small dart barely misses you.
+effect:DAMAGE
+msg:A small dart hits you!
+dice:1d4
+effect:INC_TIMED:TMD_SLOW
+dice:19+1d20
D:A trap which shoots slowing darts.
# 0x19 --> visible trap -- dart -- lose str
@@ -114,8 +150,15 @@ D:A trap which shoots slowing darts.
N:25:dart trap
G:^:r
M:0:2:0
-F:TRAP | FLOOR
-effect:TRAP_DART_LOSE_STR
+F:TRAP | FLOOR
+effect:TRAP_CHECK
+dice:125
+msg:A small dart barely misses you.
+effect:DAMAGE
+msg:A small dart hits you!
+dice:1d4
+effect:DRAIN_STAT:STR
+dice:1d4
D:A trap which shoots damaging darts.
# 0x1A --> visible trap -- dart -- lose dex
@@ -124,7 +167,14 @@ N:26:dart trap
G:^:r
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_DART_LOSE_DEX
+effect:TRAP_CHECK
+dice:125
+msg:A small dart barely misses you.
+effect:DAMAGE
+msg:A small dart hits you!
+dice:1d4
+effect:DRAIN_STAT:DEX
+dice:1d4
D:A trap which shoots damaging darts.
# 0x1B --> visible trap -- dart -- lose con
@@ -133,7 +183,14 @@ N:27:dart trap
G:^:r
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_DART_LOSE_CON
+effect:TRAP_CHECK
+dice:125
+msg:A small dart barely misses you.
+effect:DAMAGE
+msg:A small dart hits you!
+dice:1d4
+effect:DRAIN_STAT:CON
+dice:1d4
D:A trap which shoots damaging darts.
# 0x1C --> visible trap -- gas -- blind
@@ -142,7 +199,9 @@ N:28:gas trap
G:^:g
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_GAS_BLIND
+effect:INC_TIMED:TMD_BLIND
+dice:24+1d49
+msg:You are surrounded by a black gas!
D:A trap that releases gas to blind you.
# 0x1D --> visible trap -- gas -- confuse
@@ -150,8 +209,10 @@ D:A trap that releases gas to blind you.
N:29:gas trap
G:^:g
M:0:2:0
-F:TRAP | FLOOR
-effect:TRAP_GAS_CONFUSE
+F:TRAP | FLOOR
+effect:INC_TIMED:TMD_CONFUSED
+dice:9+1d19
+msg:You are surrounded by a gas of scintillating colors!
D:A trap that releases gas to confuse you.
# 0x1E --> visible trap -- gas -- poison
@@ -160,7 +221,9 @@ N:30:gas trap
G:^:g
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_GAS_POISON
+effect:INC_TIMED:TMD_POISON
+dice:9+1d19
+msg:You are surrounded by a pungent green gas!
D:A trap that releases gas to poison you.
# 0x1F --> visible trap -- gas -- sleep
@@ -169,7 +232,9 @@ N:31:gas trap
G:^:g
M:0:2:0
F:TRAP | FLOOR
-effect:TRAP_GAS_SLEEP
+effect:INC_TIMED:TMD_POISON
+dice:5+1d9
+msg:You are surrounded by a strange white mist!
D:A trap that releases gas to put you to sleep.
# ideas from v4:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment