login

Author Topic: M&B Quirks and Idiosyncrasies  (Read 8465 times)

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
M&B Quirks and Idiosyncrasies
« on: January 12, 2007, 08:30:17 PM »
The M&B engine often behaves in unusual and unexpected ways. You think something should work one way, but something ELSE happens!

This thread is a compilation of all these unexpected and unintuitive things. Post your discoveries here and help your friends navigate the bizarre and ununsual.
« Last Edit: February 04, 2007, 11:22:59 AM by Fisheye »

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
General Wisdom
« Reply #1 on: January 12, 2007, 10:52:25 PM »
M&B Rider AI is slow:

I tried to make an anti-horse archer force by putting my knights (riding skill 9) on super fast horses (speed 25, maneuver 16).

They totally and utterly failed to match pace with my level 1 character (riding skill 4) on a modified courser (speed 15). I left them far far behind while riding in a dead straight line. I was the only opponent on the scene.

Apparently the mounted AI is, how you say, a bit "slow", as in their speed is deliberately "retarded".

« Last Edit: January 13, 2007, 10:16:43 PM by Winter »

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
General Wisdom
« Reply #2 on: January 13, 2007, 05:57:53 PM »
Can call start_encounter after map_conversation:

Your encounter will happen right after the conversation ends. Might be obvious to some but took a week to occur to me to do it that way.
« Last Edit: January 13, 2007, 10:15:50 PM by Winter »

Offline Winter

  • I am Tek Jansen!
  • Administrator
  • *****
  • Posts: 476
  • MBX Forum owner
    • View Profile
    • Street of Eyes: The Writing of Ryan A. Span
Re: General Wisdom
« Reply #3 on: January 21, 2007, 01:15:26 PM »
Empty Strings: Your enemy!

Allowing an empty string ( "" ) to exist anywhere in your module files can cause you many hours of bughunting. It is an insidious error; it will not be noticed by the compiler, but it will crash the game every time whenever the offending bit of code called.

The error "Unexpected EOF (End of File)" on game load can be caused by having an empty string in one of your module files.

Traversingly,
Winter

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
Re: General Wisdom
« Reply #4 on: January 21, 2007, 04:19:58 PM »
Addendum to above for newbies: FYI the underscore "_" is invisible and looks just like a space when you need an empty string.

Offline Fisheye

  • Blues Brother
  • Moderator
  • *****
  • Posts: 427
  • My scalp's so bright, I gotta wear shades.
    • View Profile
Re: M&B Quirks and Idiosyncrasies
« Reply #5 on: September 05, 2007, 08:50:37 AM »
(thanks to NotTotti for this nugget)

Upgrading a troop to another troop with ID >= 256 won't compile. This is because only 8 bits are available for storing the upgrade_to troop ID.

So put all your regulars at the beginning of the troops file and your heroes and NPCs after.
« Last Edit: September 05, 2007, 08:53:35 AM by Fisheye »

Mordachai

  • Guest
Re: M&B Quirks and Idiosyncrasies
« Reply #6 on: March 29, 2009, 06:08:07 PM »

Ok, being a programmer, I generally assume I can mess with loop variables to control a loop.

But I am quite certain at this point that M&B's (try_for_range, ":index", ":start", ":one_past_end") construct overwrites ":index" on every iteration, so you cannot break out of the loop by setting its value to past the end, nor can your force it to loop over the same index a second time by subtracting one from it, &c.

But what does work is messing with the termination value ":one_past_end".  If you reset this to a lower number, say set it to ":index", then you force the loop to stop.

This is far less useful than being able to mess with ":index", but this appears to be another limitation of their engine.

Make a note of this, and avoid bugs :D

G/L

Offline Winter

  • I am Tek Jansen!
  • Administrator
  • *****
  • Posts: 476
  • MBX Forum owner
    • View Profile
    • Street of Eyes: The Writing of Ryan A. Span
Re: M&B Quirks and Idiosyncrasies
« Reply #7 on: March 30, 2009, 03:42:51 AM »

Ok, being a programmer, I generally assume I can mess with loop variables to control a loop.

But I am quite certain at this point that M&B's (try_for_range, ":index", ":start", ":one_past_end") construct overwrites ":index" on every iteration, so you cannot break out of the loop by setting its value to past the end, nor can your force it to loop over the same index a second time by subtracting one from it, &c.

But what does work is messing with the termination value ":one_past_end".  If you reset this to a lower number, say set it to ":index", then you force the loop to stop.

This is far less useful than being able to mess with ":index", but this appears to be another limitation of their engine.

Make a note of this, and avoid bugs :D

G/L


This is true, but you can change the value of ":index" while inside an iteration, and you can use a variable or script that isn't ":index" (but may or may not take its value from ":index") inside the loop, which will not reset with each iteration. You can also keep the loop going as long as you need it to by increasing ":one_past_end". So, if as you say you want to loop over an index again, use a different variable from ":index" for determining which value to use.

For example:

(assign,":low",0),
(assign,":high",1),
(assign,":index",0),
(try_for_range,":range",":low",":high"),
-use ":index" here-
-THEN-
(val_add,":index",1),
(val_add,":high",1),
 (try_begin),
 (eq,":example",":repeat_last"), # If you want to repeat the previous index
 (val_sub,":index",-2), # Repeat previous index
 (else_try),
 (eq,":end",":now"), # If end is now
 (assign,":high",":range"), # End loop
 (try_end),
(try_end),

Regards,
Ryan