Prevent Spell-casting by Certain Monsters

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Prevent Spell-casting by Certain Monsters

Post by Paul Stevens »

Code: Select all

  if (    (pmtDesc->word14_12_15() > 1) // ie: 3, 4, or 6
       && ((d.OrthogonalDistance2Party > 1) || (STRandomBool() != 0))   )
  {
    if ( (mtD7 == mon_Vexirk) || (mtD7 == mon_LordChaos) )
    {
      if (STRandomBool() != 0)
      {
        objD7 = RNFireball;
      }
      else
      {
        switch (STRandom0_3())
        {
        case 0: objD7 = RNDispellMissile; break;

        case 1: objD7 = RNLightning; break;

        case 2: objD7 = RNPoisonCloud; break;

        case 3: objD7 = RNZoSpell; break;
        }; //switch()
      };
    }
    else
    {
      switch (mtD7)
      {
      case mon_SlimeDevil:
          objD7 = RNPoison; break;
      case mon_FlyingEye:
          if (STRandom(8) != 0) objD7 = RNLightning;
          else objD7 = RNZoSpell;
          break;
      case mon_Zytaz:
          if (STRandomBool() != 0) objD7 = RNPoisonCloud;
          else objD7 = RNFireball;
          break;

      case mon_Demon:
      case mon_Dragon:
          objD7 = RNFireball;
          break;
      }; // switch
    };
    D4W = sw(pmtDesc->uByte8[4]/4 + 1);
    D4W = sw(D4W + STRandom(D4W));
    D4W = sw(D4W + STRandom(D4W));
    LaunchMissile(
                  objD7,       //parameter
                  mapX,
                  mapY,
                  D5W,        //position??
                  d.PrimaryDirectionToParty, //direction???
                  ApplyLimits(20, D4W, 255),
                  pmtDesc->uByte8[4],
                  8);
  }
 
Here is the code that decides when and if and what spell to cast.

Notice that it is all wired into the code. It starts by testing
word14 bits 12-15 to see if they are greater than 1. Any idea
what that test means? Also, it appears the spells are cast
if the distance to the party is greater than 1 or 50-50 probability
if the distance is 1. The spell's strength is also computed.

I suggest that we do with these things the same as we did for
party spells. We provide a mechanism for the designer to
write a "Monster Spell Filter". Then you can override the
up-front tests (should the monster cast a spell?) and provide
the name of the spell to be cast and its strength. Otherwise
you are going to be hounding me forever with requests like:
"Can you disable Vexirk Zo spells on level 5 if the third party
member has a broken apple in their shield hand?" Doing this
will also allow you to make Screamers that cast fireballs.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

I liek your suggestion as it opens up greater possibilities for monsters. I tried changing monster data structures in the graphics.dat using CSBedit but simply got into a mess, so maybe yours is a better way of customising them. I'd still need DSA docs though.... ;)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I'd still need DSA docs though...
Well, one of my plans was to make 'reusable' DSAs. We could
develp a kind of library. For example, the simplest DSA is a
"inter-level repeater". So that you can send messages between
levels easily (without teleporting rocks or something!). I could
build a generic "inter-level repeater" and put it into a library
where you could import it into your game. Then you could modify
it if that suited your needs (perhaps receive one message and send
two or perhaps repeat the message only if the party is on level 6.).
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

A monster attack filter is a powerful idea. HA! I naively thought that I was about to finish my dungeon...

Suggestion about the parameters:
# 0 - Action (spell or physical attack) Will it be possible to force a physical attack from a distance by this mean?
# 1 - Kind of Spell
# 2 - Monster Index
# 3 - Disable time
# 4 - Missile Type
# 5 - Monster Location in Dungeon
# 6 - Monster facing direction
# 7 - Monster ID
# 8 - Spell Byte 5
# 9 - Spell Class
# 10 - Hit points
# 11 - Distance to the party
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Thank you very much for thinking about these things for me.
Not all make sense right now. Monsters don't really cast
spells. They throw missiles. The code above is all that I
plan to change.

There are two parameters to the missile-casting code. I think
they are something like "range" and "damage". Don't know for sure.
Parameters 6 and 7 in the LaunchMissile() function call.
I naively thought that I was about to finish my dungeon
I humbly beseech thee not to release your dungeon for many
months. You are going to be coming up with new ideas
for a long, long time I am sure.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Monsters don't really cast spells
But, of course, you can cast a spell for it. You might
want a Screamer to cast a "Darkness" spell, for example.
You can do that sort of thing using the Spell-filtering capability.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

A Monster Attack Filter is described in a link you can reach from
dianneandpaul.net/CSBwin/documentation
An executable runtime is available at CSBtestAttack.exe.
CSBuild162.rar can be used to set the Attack Filter Location.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

I couldn't reach the monster types and missile types documentation. (can the missiles be rocks, arrows, darts, boulders, etc?)

What happens if a monster at a distance greater than one is changed to "should attack". It does nothing or it makes a physical attack with damage?

Could it be possible to know and alter the hitpoints of the monsters?
Could it be possible to change the location (including facing) of the monsters?
Could it be possible to change the location (including facing) of the party?
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Changing sound works. Changing a physical attack to a missile attack works.

I guessed the monster types list, but I would still have a use for the missile types list. (I discovered 65410 is a lightning, but those numbers are not obvious)

There is an error in the monster filter description: there are two parameters number 10, and after that all the numbers should be raised by one.

a 0L1 command doesn't store a value of 1, but 65509.

I have the problem that a monster like a scorpion never triggers the filter DSA from a distance, even if facing the party.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Yes. Those links do not yet exist. Currently the only missiles
are the spell missiles mentioned in the documentation. Rocks
and such really require two items to be created: the missile and
it contents. I imagine it could be done. Perhaps, however, it
should not be an 'Attack Filter' function. Perhaps it should be a
more general function to '&CreateMissile'. We already have a
mechanism for creating Rocks (used in the money changer, for example).
Didn't we make a way to launch such things a long time ago?
I forget.

There is no 'Should attack'. There is only 'Not Launch Missile' and
'Not Steal'. The combination of those two 'nots' means to attack
physically. Then the monster should attack physically just as if he
were at distance one.

Knowing monster hitpoints should be possible. There are two things
to know....the individual monster making the attack and the total of
the monster group. What do you want (besides everything? ;-) ).

Changing monster location is dangerous work. I am not volunteering
for this work. There can be several timer entries pointing to the
current monster location that need to be found (non-trivial) and
updated (easy) and several things I would have to test (don't put
monster on top of another monster, for example).

Changing party location is also non-trivial. Even the facing is a bit
intricate. For example, not all party members face the same way. And
an attack can easily cause a party member to turn. So, again, I am
not voluteering to do this.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Changing ...... works
That's good. Because I never tested any of this.

I'll get to the monster/missile list someday. I am
currently working on difficult bug for Antman.

Code: Select all

enum RNVAL
{
  RNeof             =0xfffe,
  RNnul             =0xffff,
  RNFireball        =0xff80, //fireball
  RNPoison          =0xff81,
  RNLightning       =0xff82,
  RNDispellMissile  =0xff83, //dispell - Damage non-Material
  RNZoSpell         =0xff84, //open door?
  RNPoisonBolt      =0xff86,
  RNPoisonCloud     =0xff87, //Poison Cloud
  RNMonsterDeath    =0xffa8, //MonsterDeath
  RNffe4            =0xffe4,
  RNempty           =0x0000
};
0L1 loads 65509????? What????? 0xfffe5?????
It certainly does not do this always. What does a 0L2 do?
If you cannot figure out what is happening you will have to
send a dungeon file that displays this anomaly.
have the problem that a monster like a scorpion never triggers the filter DSA from a distance
I knew you would ask this. I did not want to break that news to you
because i knew it would upset you. Here is the story:

The code I modified was very 'self-contained', unlike most of the monster code
which is totally incomprehensible. It has a finite number of operations,
a finite number of variables, and has a finite (and controlable) global
side-effects. We were very luck that this piece of code exists.

The fact is (I believe....don't know for sure) that this piece of code is
called only if there is an outside chance that the monster might attack the
party. A scorpion has no chance of attacking from a distance of 2 ( I think).
How this is determined I do not know. If you don't know and you need
to know then let me know and I will try to find out and let you know. But
I don't think I had better fool with it. (You shouldn't try to fool Mother Nature.)
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

unlike most of the monster code which is totally incomprehensible
Do you mean that it's incomprehensible through your translation, or generally would have been incomprehensible even with the original uncompiled sources (ie, it's not well designed)?

If the latter, this surprises me as I always got the impression FTL were better programmers than that! ;)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

the latter, this surprises me as I always got the impression FTL were better programmers than that
There is always the possibility that I am simply too dense to
see the beauty of it.

Actually, the code appears to be one of those very common
cases. It starts out nice. It gets modified relatively nicely.
It gets a few special cases thrown in. Bugs have to be repaired
without tearing the whole thing apart and starting over. Repeat
for a couple of generations. Do all of this under the constraint
that there is not a single byte of memory available and the CPU time
is already starting to make the game run sluggish. And the
last sector of the disk has been used. And it had to be out the
door and on the shelves yesterday. And some of it had to be
torn out to fit in in the available resources. And the holes had to
be filled in to keep it from crashing.

It got done and it worked and people liked it. It was quite an
accomplishment and required the very best efforts of very
bright people. But it is incomprehensible to me. I still have
the original code for anyone who would like to have
a go at understanding it. Your results will be welcome by all.
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Post by Gambit37 »

Heh, well that won't be done by me. I don't even understand DSAs... No, I'll stick to nice pretty pictures and simple dungeon building... ;)
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

>Didn't we make a way to launch such things a long time ago?
I don't think so.

>There is no 'Should attack'. There is only 'Not Launch Missile' and
>'Not Steal'. The combination of those two 'nots' means to attack
>physically. Then the monster should attack physically just as if he
>were at distance one.
Yes, it works! wonderful!

>Knowing monster hitpoints should be possible. There are two things
>to know....the individual monster making the attack and the total of
>the monster group. What do you want (besides everything? icon_wink.gif ).
Individual monster hitpoints please!

>0L1 loads 65509????? What????? 0xfffe5?????
>It certainly does not do this always. What does a 0L2 do?
0L1 loads 65509
0L2 loads 65509
1L1 loads 65510
No idea what's happening, so I'll send a savegame.

>I knew you would ask this.
I knew you would answer this. This conversation was scripted from the beginning. Anyway I have enough work to do with the possibilities left.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Is it possible to add deathclouds and fluxcages to the missile list?

I'd like to retrieve, (and the script says I'll end up asking for the possibility to modify too), some infomation about doors, like:
closed/opened
with switch/without
"permeable" to missiles (ie, portcullis)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

The clouds are clouds, not missiles. They would have to be special cases.
They have timers attached to remove them. A bit of work but doable.

Cellflag information and basic information about items such as teleporters,
doors, and such can be made available. Some of the flags are easy
to modify. I think we should attack them one at a time. Like removing
a switch from a door is not problem. Opening or closing a door is a
problem because, again, it requires a timer and I would have to worry
about whether it is already in the process of opening/closing. But, of
coure, you can open and close doors with standard messages. The 'static'
flags are generally easy.

I'll work on these things if I ever fix Antman's bug (or give up trying).
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

About monsters not attacking from afar, this can be changed with CSBedit, it's the "spell range" parameter. Just set it to a value above one. Ensure the targeted hero's index is not -1.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

CSBuild1.64 and CSBwin9.8v15 implement &CELL@ and &CELL!.
dianneandpaul.net/CSBwin/documentation describes the capability
in 'Cell Flag Manipulation'.

CSBwin is in Size4Demo.rar and includes an example of changing
the decoration on a door. Nothing else has been tested so I expect
bug reports over the next few days.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

I don't understand if it's a bug or darkness clouding my mind, but I do this on a door with a switch:
LOAD INTEGER 21 (12423 12487 2 12487 21)
LOAD INTEGER 5 (12423 12487 2 12487 21 5)
&Cell@ (12423 12487 2)
LOAD INTEGER 21 (12423 12487 2 21)
&Fetch (12423 12487 2 4)
LOAD INTEGER 4 (12423 12487 2 4 4)
&= (12423 12487 2 1)
QUESTION (true) Jump 32T3 (12423 12487 2)
LOAD INTEGER 22 (12423 12487 2 22)
&Fetch (12423 12487 2 7)

And this on the same door, without a switch:
LOAD INTEGER 21 (12423 12487 2 12487 21)
LOAD INTEGER 5 (12423 12487 2 12487 21 5)
&Cell@ (12423 12487 2)
LOAD INTEGER 21 (12423 12487 2 21)
&Fetch (12423 12487 2 4)
LOAD INTEGER 4 (12423 12487 2 4 4)
&= (12423 12487 2 1)
QUESTION (true) Jump 32T3 (12423 12487 2)
LOAD INTEGER 22 (12423 12487 2 22)
&Fetch (12423 12487 2 7)

In both case I get the value "7" for the second parameter (array 22). I would expect to see "3" and "7" because the bit flag is 04 for the switch, according to the documentation.
Also, the documentation says: "10 can destroy with axe". I guess it should say "16".
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Another request, too:
could the &param@ and &cell@ commands detail the values fetched in the timer trace for more transparency?

And what is "RNMonsterDeath =0xffa8, //MonsterDeath "?
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Cell Type 6 - A Removable Wall
[0] The cell type. 6.*
[1] Bit flags. Note that the wall is blocking if 'Visible' and not 'Trick'
01 'Trick wall'. Passable.
04 Visible
it should say: 04 Invisible (meaning that if this bit flag is set the wall is invisible)

For a teleporter, where is the bit flag for "Visible"?
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

CSBwin 9.8v17 plus the updated documentation
should answer your questions except for:
RNMonsterDeath =0xffa8, //MonsterDeath
Darned if I know. Sounds like a spell that kills monsters instantly.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Thank you for the updates.

For a door, the:
[2] Current open/closed state*
is unchangeable... why?

I don't remember if I already asked it, but could you provide an operation to retrieve the party coordinates at any time? (I tried with &param@ when no spell is cast and it just gives the parameters from the last spell)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

operation to retrieve the party coordinates at any time
Sure.

Door state. A lot of work. Timers are perhaps active. We can do
it if it is important to you. Especially if you are willing to do quite a bit
of playtesting......I am afraid of hard-to-find and hard-to-reproduce bugs.
Doors can be opened and closed with ordinary messages without fear
of crashes (without much fear anyway).
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

I am already playtesting a lot the new features in several different situations, so yes, I'm ready to keep doing it! In fact I wanted to switch between bashed and closed states.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Well, it willstart with some research on my part.
I do now know how the door opening/closing is handled.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

OK. Research has uncovered a lot of code having to do
with doors. THe biggest problem is the complication of
having a party or monster in a door that is trying to close.

How about these rules:
1-You can bash a door that is closed. I don't see any problem
unless a message is already queued to open the door. But that
may be handled properly because it seems it might be possible in
the original DM/CSB. Does anyone remember any 'bashable' doors
that can opened by monsters/pressure pads with delays or such?
So that the message to open the door is created before the door is
bashed but arrives after the door has been bashed?
At any rate, I'll try to test the most obvious cases.

2-You can open a door that is bashed. Then you can send it a standard
message to close it. I don't want to close a bashed door because there
is a big problem if the party or a monster is in the doorway.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

These rules are Ok for me.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Changing disabled time (param #3) when a spell is cast doesn't has any effect if there is no real spell corresponding to the runes.
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”