Up to Main Index Up to Journal for July, 2022
JOURNAL FOR MONDAY 18TH JULY, 2022
______________________________________________________________________________
SUBJECT: Combat message magic
DATE: Mon 18 Jul 22:42:41 BST 2022
I’m slowly melting in the lab today, ambient temperature is 33°C due to a UK
heatwave. For the UK the highest temperature recorded was 38.1°C and it’s only
going to get hotter tomorrow…
Let’s get the really boring stuff out of the way first. Compiling Go 1.18.4 on
a Pi ZeroW I was bitten by issue #53814. Applying https://go.dev/cl/417655
manually fixed the issue. Then testing runtime/pprof failed due to it being
killed for taking too long to complete. I managed to get around that issue by
setting the default stacks to 1Mb instead of 8Mb using “ulimit -s 1024” and
reducing a lot of swapping to SDCard which sped thing up.
Now for the exciting boring stuff :) At the moment combat is very boring:
>HIT SLUG
You attack the giant fungus slug!
The giant fungus slug hits you doing 4 damage.
You hit the giant fungus slug doing 9 damage.
The giant fungus slug hits you doing 2 damage.
The giant fungus slug hits you doing 2 damage.
You hit the giant fungus slug doing 9 damage.
You hit the giant fungus slug doing 14 damage.
You kill a giant fungus slug!
Combat messages add variety to combat. Wouldn’t it be nicer to see:
>HIT SLUG
You attack the giant fungus slug!
A giant fungus slug spits at you covering you with a stinging slime.
You swing a sword at a giant fungus slug wounding it.
A giant fungus slug turns toward you knocking you back.
A giant fungus slug rears up over you and drops its body on you.
You lunge at a giant fungus slug with your sword wounding it.
You slash at a giant fungus slug with your sword.
You kill a giant fungus slug!
A little more dramatic if nothing else ;) Any observers watching the same
fight would see:
Diddymus attacks the giant fungus slug!
A giant fungus slug spits at Diddymus covering him with a stinging slime.
Diddymus swings his sword at a giant fungus slug wounding it.
A giant fungus slug turns toward Diddymus knocking him back.
A giant fungus slug rears up over Diddymus and drops its body on him.
Diddymus lunges at a giant fungus slug with his sword wounding it.
Diddymus slashes at a giant fungus slug with his sword.
Diddymus killed a giant fungus slug!
Defining and generating these messages can be a little problematic. Especially
for items, like the sword, that can be wielded by a male or female depending
on who picks it up. Yes, I need to work on my gender pronouns and sticking to
using ‘they’ and ‘their’ would solve some issues…
Take this simple message, from three different view points. The message is
spaced out to make it easier to see where they differ:
Attacker: You swing your sword at a giant fungus slug wounding it.
Defender: Diddymus swings his sword at you wounding you.
Observer: Diddymus swings his sword at a giant fungus slug wounding it.
The definition for the message is:
[%A] swing[/s] [your/%A] sword at [%D] wounding [%D].
The Java version was horrendous. The message still looked simple enough:
{0} lunge[/s] at {3} with a sword wounding {1}.
But then there was the ancillary lookup table you had to keep handy :(
Substitution Replaced By
Attacker's Viewpoint Defender's Viewpoint Viewer's Viewpoint
{0} YOU Defender's Name Defender's Name
{1} HIM, HER or IT DB YOU HIM, HER or IT DB
{2} Defender's Name + 'S YOUR Defender's Name + 'S
{3} Defender's Name YOU Defender's Name
{4} YOUR HIS, HER or ITS AB HIS, HER or ITS AB
{5} YOU HIM, HER or IT AB HIM, HER or IT AB
{6} HIS, HER or ITS DB YOUR HIS, HER or ITS DB
{7} YOU HE, SHE or IT AB HE, SHE or IT AB
DB = Defender Based, AB = Attacker Based
The combat messages will be derived from a new OnCombat field. For the slug:
OnCombat: [%A] spit[/s] at [%D] covering [%D] with a stinging slime.
: [%D] pound[s/] at [%A] to little effect.
: [%A] turn[/s] toward [%D] knocking [%D] back.
: [%A] rear[/s] up over [%D] and drop[/s] [%A][r/s] body on [%D].
For the sword Diddymus is using:
OnCombat: [%A] swing[/s] [your/%A] sword at [%D] wounding [%D].
: [%A] lunge[/s] at [%D] with [%A][r//] sword wounding [%D].
: [%A] slash[/es] at [%D] with [%A][r//] sword.
But what do all the funny bits mean? The square brackets contain up to three
substitution texts, separated by forward slashes ‘/’, in the order: Attacker,
Defender, Observer. For example, with this text:
You are [an attacker/a defender/an observer].
An attacker would see "You are an attacker.", a defender would see "You are a
defender" and observers would see "You are an observer". If only one or two
replacement texts are specified the last text is repeated. For example, with
this text:
You are [an attacker/not an attacker].
The "not an attacker" would be repeated as the third string.
There are two special substitutions ‘%A’ and ‘%D’. These are replacements for
the attacker ‘%A’ and defender ‘%D’. The first time either ‘%A’ or ‘%D’ are
seen the appropriate name is used. Subsequent uses use ‘you’ or ‘his/her/its’
depending on who the attacker and defender are and who the message is targeted
at. This is why you are asked for a gender when creating a character.
At the moment I haven’t actually implemented ‘OnCombat’ messages yet. I just
have a simple mock-up with some hard coded samples while I play around with
the code. The mock-up was used to generate all of the messages above. So far
I’ve managed to banish Java’s horrendous table and simplify the message syntax
which is a good start.
What do you think? Comments and suggestions welcome: diddymus@wolfmud.org
--
Diddymus
Up to Main Index Up to Journal for July, 2022