Step macro issues

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

msallen

Step macro issues

Post by msallen »

Hi all. First, I came across ACK while I was reliving a little of my youth with ACS on an emulator. ACK is giving me that warm nostalgia I was looking for without all the aggravation of emulation or the horrible ACS interface. THANKS!

I am having a little trouble with macros and items that I wanted to run by y'all. I may be doing something wrong. I may also just be dissatisfied with some of the implementation.

What I would like to do is create a consumable object that provide a short, temporary buff. Here is my code for one that meets the following requirements:

1. Applies a 20 pt bonus to weapon skill for 10 turns
2. Only one buff can be active at a time
3. Applies buff on 'u'se and consumes an object if successful
4. If not successful, does not consume the object

Object 39: usage requires nothing, does not disappear, execute macro on use:
1: IF Z2 = 0 THEN 4 (allow use *only* if not buffed)
2: SMSG 40 (failure message)
3: STOP
4: SET Z2 = 10 (number of turns active)
5: SET WSK = WSK + 20 (buff)
6: SET INV[39] = INV[39] - 1 (consume if successful)
7: SMSG 42 (usage message)

Step macro:
1: IF Z2 = 0 THEN 6 (its not active, so ignore it)
2: SET Z2 = Z2 - 1 (decrement the time)
3: IF Z2 > 0 THEN 6 (still time left on the buff)
4: SET WSK = WSK - 20 (remove the buff)
5: SMSG 41 (expiration message)
6:

I have 2 problems:

1. Using the item takes 2 turns. I can't figure out why this happens. If, say, I use it in melee the monster will get 2 hits on me when I would only expect 1.

2. Every action decrements the counter even if it doesn't consume a turn of time. For instance, if I check my inventory 8 times, the buff expires.

I don't know if 1 is a bug or user error. 2 may not be a bug (I don't know if there are macros that need to be executed on every screen refresh). If its not a bug, it sure would be nice to have a macro that is executed with every action that consumes a game turn.

msa
Posts: 3
Joined: Sat Feb 21, 2009 10:57 am

Post by msa »

Quick update: I tried a activate-on-use item that doesn't use a macro in combat and it also took two turns. I guess that is just normal, so ignore problem 1.

Although it would be nice if we could specify how many turns using an item takes. Healing potions, for example, need to be a lot stronger to justify letting all attackers get 2 moves.

Chris H
Posts: 272
Joined: Sun Dec 02, 2007 4:07 pm
Location: California, USA

Post by Chris H »

Hi,

Those are both bugs, and on my list to address. Issue #2 is because the step macro is firing even during a map refresh (it should only fire on honest-to-goodness actions of the player) ... there are a couple of people waiting for me to fix that one. :) Issue #1 is somewhat related, I'll have to dig into it a little further to find the exact cause. Keep an eye on the ACK updates thread, I'm hoping to patch these issues in a week or two, when I get time to dig into the code again.

And, welcome! I'm glad you found your way here!

msa
Posts: 3
Joined: Sat Feb 21, 2009 10:57 am

Post by msa »

Wonderful!

ACK has some pretty weird, and occasionally non-deterministic, behavior. Using items appears to occasionally take 3 turns, for instance.

I get the impression that you are working with a code base in some sort of savage, archaic tongue like QBasic or TurboPascal. In which case, truly, I wish you the best of luck :)

I get new questions from time to time. Should I just post them in this thread or make a new one when its clear I can't fix them. I'm wrestling with mapchk and mapset problems right now, and when I can get a clear description of my problem (assuming its not between keyboard and chair) I will post it wherever you like.

Chris H
Posts: 272
Joined: Sun Dec 02, 2007 4:07 pm
Location: California, USA

Post by Chris H »

Yes, ACK is written in Turbo Pascal -- it's actually a pretty old program itself, mostly done in the early 90s but revived lately just for the sake of fixing "just a couple more bugs" or adding "just a couple more features."

Anyway, feel free to post about what you're trying to do even before you determine exactly what's going on... someone might be able to hazard a guess and/or suggest what might be an easier way of tackling the problem.

As for using items taking three turns -- that sounds like a bug (and the same one we were talking about earlier) but I'm not sure how it manages three -- I'd like to hear about how that happened so I can try to reproduce it.

It's a known bug right now by the way that step macros that use MAPSET are acting funny right now (MAPSET triggers another step macro run), that should get fixed in the next patch. Is that part of what you're fighting with?

msa
Posts: 3
Joined: Sat Feb 21, 2009 10:57 am

Post by msa »

No, my mapset/chk problems have nothing to do with steps this time. I am trying to add random herb patches to one of my wilderness maps. The herb patches are a space that does the following when you step on them:

1. Add a random herb to the players inventory
2. Decrement a counter for the number of herb patches
3. Replace themselves with a patch of grass

When you enter the worldmap region, the game runs a macro that does the following:

1. If the number of herb patches is less than 10
1. Find x,y coordinates that contain a patch of grass
2. Replace it with an herb patch
3. Increment the counter for the number of patches
4. Goto 1

The problem is that frequently less than 10 herb patches are placed. And after each round of harvesting, less herb patches spawn in the area. Here are my experiences:

1. In a 16x16 world map, with the player entering in the middle, no herbss spawn
2. In a 48x32 world map, with the player entering from the upper left, most (but rarely all) of the herbs will spawn and every time you leave and reenter less patches will spawn than were picked
3. In scenario 2, but with herbs only spawning in the bottom left 16x16 quadrant, all of them will spawn, and all will be replaced upon reentry

Here is the macro code for the respawn:

1: IF Y2 = 0 THEN 14 (no more herbs to place)
2:
3: SET F = RND(13) + 2 (X)
4: SET G = RND(13) + 2 (Y)
5: MAPCHK F G E
6: IF E = 43 THEN 10 (found a patch of grass)
7:
8: GOTO 3
9:
10: MAPSET F G 42 (place patch of herbs)
11: SET Y2 = Y2 - 1
12: IF Y2 > 0 THEN 3
13:
14: STOP

Chris H
Posts: 272
Joined: Sun Dec 02, 2007 4:07 pm
Location: California, USA

Post by Chris H »

There's a 3.251 patch now which should fix the first issue you mentioned -- the last issue you described, though, sounds a little more complicated. Can you bundle up whatever test adventure you're using for this, and send it to me so I can try to reproduce the problem?

Post Reply