Multiple triggers?

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

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Multiple triggers?

Post by Garth's Equipment Shop »

I am looking for a way to be able to trigger an object's action by more than one trigger type. I would like an exploding space to be triggered either by passing or by being attacked with a ranged weapon [or just by being attacked in general]. I looked over the macro commands and object actions I could QA but none struck me as helpful in this regard. Any ideas?
Which of you is interested in my fine wares?

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Just ideas

Post by GB »

That's an interesting question. I would have to experiment to look for an answer, but the ideas I'm having? You asked:

in rooms type maps, can an object underneath another respond to passing? If so, maybe you can have the top object respond to being attacked. Attacking it might cause it to run macro, 1. create boom noise, maybe temporarily change icon, and 2. remove the kind of object below that would be triggered by passing.

Or, maybe in a region you could have a test for the player's position in every step. If their x y position is over the mine, then hit them with weapon, fireball. An action on the space or obstacle at x y can then create the boom at that location some other way, but you need to make sure that this causes a condition that makes the macro waiting for the player to step on spot x y then will not harm him.

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Thanks that last idea gives me some more ideas to try. Good thinking. To answer the first one, no, anything that is beneath another object, space or obstacle, cannot be triggered by passing so long as it remains covered. The only time covered objects can be triggered is by the topmost object action activate all. I've been using that factor a lot in devising macros to make this or that suddenly appear where i want it to without having to do too much bothersome mapchk, mapset, mapadd coding [though sometimes those are indispensable tools as well].
Which of you is interested in my fine wares?

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

Post by Chris H »

I'd probably tackle this with a step macro that checked what terrain you're standing on (or your location) to trigger an event, and an attack trigger on the actual space. Although in that case it depends what you're trying to do, as step macros can't cause most actions (QA only works if the macro was triggered by an object action)

And correct: only the top object in a stack is checked for a trigger.

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Thanks Chris. Going to try that now. Oh, and to answer your question, [SPOILER ALERT!]what I am trying to do is to have the PC be able to avoid injury from the explosion of a land mine [provided he knows its there which requires the metal detector] by shooting it from a safe distance and thus clearing a path through a mine field.
Which of you is interested in my fine wares?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Well it almost works. Actually it isn't bad the way it is but it could be better if it worked as I had hoped it would. You see I put the following macro as my step event:

Code: Select all

1 set h=loc[x]
2 set v=loc[y]
3 mapchk h v i
4 if i=2 then 8
5 if i=13 then 8
6 if i=30 then 8
[note there are three different types of terrain in which mines may be buried. I tried using the OR operator | but it didnt work]
7 stop
8 set wmusic=0
9 music=0
10 set icon=134 [a transparent tile... tiles 2, 13, and 30 all change the player icon to a fiery explosion, so this line removes that and allows the replacement crater tile to show through...]
11 sound 81 [explode sound]
12 smsg "you explode like a blood sausage!"
13 mapset h v 103 -crater
14 waitkey
15 set hp=0
16 stop
So when the player steps on any of those spaces he explodes and dies.

Two of those tiles looks just like the surrounding terrain so they are not set to be triggered by attack since the player isn't supposed to know they are there. But one of them is visible to the player as a partially burried mine [revealed by a metal detector which removes the other tiles covering this one so that it can be seen and delt with]. So this one is set to be triggered by attack from a ranged weapon. [wish I could set different effects or macros depending on the weapon used - like damage scaled according to range so that melee weapons would trigger it but cause major dmg to player while the longer the range of the weapon the further away it can be triggered and thus less dmg based on distance].

When the attack triggers this tile I have tried everything. Activate all underneath [and having appropriate explosion sound and graphic tile underneath and a crater tile underneath that.] Run macro with a qa 19 to show the explosion and then another to show the crater. And tried having a stack of tiles starting with a crater on the bottom, a fireball with explode sound on top of that and this activate all triggered by attack tile on top of those, but nothing I tried would enable me to show the explosion and then the crater.

I am able to have the space make an explode sound and show either a permanent fireball tile or a permanent crater tile when attack but not both one after the other. I even tried using a waitkey command in the macro to separate the change over from one tile to the next thinking it was just changing too fast to see but that wasn't it either.
Last edited by Garth's Equipment Shop on Mon Aug 10, 2009 6:46 pm, edited 1 time in total.
Which of you is interested in my fine wares?

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

Garth's Equipment Shop wrote: When the attack triggers this tile I have tried everything. Activate all underneath [and having appropriate explosion sound and graphic tile underneath and a crater tile underneath that.] Run macro with a qa 19 to show the explosion and then another to show the crater. And tried having a stack of tiles starting with a crater on the bottom, a fireball with explode sound on top of that and this activate all triggered by attack tile on top of those, but nothing I tried would enable me to show the explosion and then the crater.
When I was experimenting with different object actions, I couldn't get ACTIVATE ALL to trigger (at all) on an attack for either spaces or obstacles. Is this the same problem you are having, or is it a different issue?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

You are right rld. I just went back and double checked everything and playtested again to make sure it was still doing it and yes the topmost tile has an activate all but is not activating all underneath it. It does eliminate itself when set to do that upon triggered action so when I shoot at it it reveals the explosion tile underneath but that is all, so I have a permanent explosion on the room map long after the mine has exploded and the crater tile under that is never revealed. So for now I just have the crater show instead of the fireball.

I can make this all work perfectly when dealing with what happens when the player passes over the mine since then I can simply have the icon change for that tile changing the player icon to a fireball and then the step macro does the rest changing the player tile to transparent and adding a crater tile.

Uh, actually I only just started doing that last part and it isn't fully tested. Before I wasn't using the transparent tile I was using set loc commands to move the player to an existing nearby crater and changing the player icon to a crater so it wasn't obvious I was doing that, that way since I already had the coordinates for the original mine tile that was stepped on I can just either take the top tile away to reveal the crater underneath or add a crater to the stored coordinates. That method was working flawlessly. I am not sure if this new one will work flawlessly or not but I see no reason why not.

Once again to rehash, the problem is not when I pass over the space but when I shoot it from afar. It doesn't activate every space underneath. I think it is only activating the one directly beneath it.
Which of you is interested in my fine wares?

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Post by GB »

I was just perusing the manual and found something that may be of use to someone trying to do a multiple trigger situation:
Terrain Hit Points

In addition to using action triggers on objects to trigger an action "when attacked", you can also make terrain objects have something like "hit points" where weapons can destroy them.build in the ability to attack inanimate objects. There are a couple rules: First, weapons always do standard damage to terrain; skill is not factored in. Second, an attack is all or none: it will either destroy the terrain or it will have no effect. You set an object with a threshold, called "Structural strength." For example, set a chair to a strength of 7. Any weapon that can do a damage of 7 or more will destroy that chair with a single blow. Any weapon that does less than 7 damage will never have any effect on that chair.

When the terrain is destroyed, it can simply disappear. On room-maps it could be part of a stack, so this might be no problem. On worldmaps it could leave an inconvenient blank spot. Another option, therefore, is to set a "Replaced by" option. When the terrain is destroyed, it is removed from the map and replaced with the terrain or item that you specify. You could have the chair replaced by terrain called "pile of junk," for example. Also, the terrain can run a macro when it is destroyed.
And with your question fresh in my mind I wondered, does this mean you could set a structural strength for the mined terrain just lower than the gun you use to shoot, and then have 1 an action triggered by passing which might be run macro, EXPLODE THIS SPACE, and 2 a macro that runs if the terrain is destroyed with a weapon and the macro that it runs if destroyed is also EXPLODE THIS SPACE?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Once again very good suggestions GB. I tried it and it does work to a degree. To the same degree as the others in fact. I even tried making a macro specifically for just one test space so that I could know in advance the coordinates and manipulate that specific tile using it's exact coordinates. I set a mine object [space] to have no action of its own.

The step macro still tests for its presence everytime the pc enters a new tile and that still works great for the effect of the pc walking on a live landmine, explode sound heard, fire ball appears [pc icon actually] and finally just before the game ends you see the crater take its place.

But now I've made my new mine object have a threshold of 1 so it can be destroyed with one blow from any weapon and it runs macro 15 once destroyed, like a deathmacro. However, no matter what I put in this deathmacro for the mine object it only seems to be able to do one of each kind of event. For example one sound can be played, my explode sound, and one mapadd can be performed, the first one if there are more than one in the macro and the rest are ignored for some odd reason. Here is my deathmacro for the mine.

Code: Select all

1: SET WMUSIC=0 [I DO THIS SO THE EXPLOSION IS MORE STARTLING AND CAN BE HEARD WELL.]
2: SOUND 81
3: MAPADD 6 4 #40-EXPLODE [ITS JUST A DUMMY SPACE TO SHOW A FIREBALL ICON. ORIGINALLY I TRIED USING MAPSET AND THAT DIDN'T WORK, JUST GOT BLANK SPACE]
4: WAITKEY [I ASSUMED I'D NEED THIS FOR THE FIRST MAPADD TO BE SEEN BEFORE USING MAPADD AGAIN TO PUT ANOTHER DUMMY TILE OVER IT]
5: MAPADD 6 4 #103-CRATER
6: STOP
The macro runs when it should, the mine is blown in one shot with my Handgun which does 10 dmg [for now anyway, haven't worked out the whole game balance thing yet] and it plays the explode sound [81] and it shows the first mapadd. The second mapadd is ignored completely!

Also strange is that it does not show the explosion before the waitkey is pressed. First it plays the sound of the gun shooting as expected then immediately plays the expode sound but keeps showing the half buried mine unexploded untill the key is pressed, then shows it, but doesn't show the crater that is added after that.

Even after moving the pc around a whole bunch of times the crater never shows up. So just like before I am stuck resorting to leaving out the explosion graphic and just relying on the player's imagination to imagine a big fireball where this is only the sound of one and then just show the crater that is left over.

It seems that macros are limited to only one mapedit at a time, so basically if I wanted this to work I'd have to cut the macro in two and put the first part as the action of the mine and the second part as the action of the fireball that is added so say when the player passes over the fire it disappears and is replaced by a crater. Doesn't make much sense from a players point of view who would be worried they might lose the game or get hurt walking into a ball of fire.
Last edited by Garth's Equipment Shop on Mon Aug 10, 2009 6:48 pm, edited 1 time in total.
Which of you is interested in my fine wares?

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

Garth's Equipment Shop wrote: The macro runs when it should, the mine is blown in one shot with my Handgun which does 10 dmg [for now anyway, haven't worked out the whole game balance thing yet] and it plays the explode sound [81] and it shows the first mapadd. The second mapadd is ignored completely!

Also strange is that it does not show the explosion before the waitkey is pressed. First it plays the sound of the gun shooting as expected then immediately plays the expode sound but keeps showing the half buried mine unexploded untill the key is pressed, then shows it, but doesn't show the crater that is added after that.

Even after moving the pc around a whole bunch of times the crater never shows up. So just like before I am stuck resorting to leaving out the explosion graphic and just relying on the player's imagination to imagine a big fireball where this is only the sound of one and then just show the crater that is left over.

It seems that macros are limited to only one mapedit at a time, so basically if I wanted this to work I'd have to cut the macro in two and put the first part as the action of the mine and the second part as the action of the fireball that is added so say when the player passes over the fire it disappears and is replaced by a crater. Doesn't make much sense from a players point of view who would be worried they might lose the game or get hurt walking into a ball of fire.
One thing that I have learned through experimentation with the ACK engine is that map edits are not displayed one-by-one as they are made in a macro. Instead, the map is refreshed and all map edits are displayed after the macro completes. So, this basically prevents you from using map edits to perform animations on a single square.
(You can definitely do more than one map edit in a macro and change multiple tiles in different locations.)

However, it is possible to split an action up into two parts by performing one edit in the action macro, and then setting a flag that is recognized by the step macro which completes the edit. You seem to have the 'step on mine' part working ok, so here is my attempt at making the 'mine explodes when shot' bit work correctly.

Mine object: Space, LANDMINE #205
Disappear? IF DESTROYED, run macro 52
Structural strength: 1
Replaced by #206 EXPLOSION

Explosion object: Space, EXPLOSION #206

Empty grass object: Space, GRASS #6

Macro 52:
SET A2 = 1
STOP

So, when you hit the LANDMINE with a weapon, it is destroyed, variable A2 is set to 1, and the tile is replaced with #206 EXPLOSION (which shows a fireball). You might be able to have the 'destroy' macro play a sound at this point too - I haven't tried it.

The tricky bit is replacing the explosion with grass (or a crater, if you prefer). One solution is to have the step macro check to see if the flag (A2) is set indicating a mine was destroyed. If so, it scans the map looking for a #206 EXPLOSION tile. If it finds one, it replaces it with grass. I also animated a separate 'explosion' using an expanding circle (the DRAW command) just to see if it would work.

Code: Select all

Macro 51 (Step Macro):   
        1: IF A2 = 1 THEN 3
        2: STOP 
        3: SET A2 = 0
        4: SET X2 = 1
        5: SET Y2 = 1
        6: MAPCHK X2 Y2 B2
        7: IF B2 = 206 THEN 14    #explosion
        8: SET X2 = X2 + 1
        9&#58; IF X2 < 17 THEN 6
        10&#58; SET X2 = 1
        11&#58; SET Y2 = Y2 + 1
        12&#58; IF Y2 < 12 THEN 6
        13&#58; STOP 
        14&#58; MAPSET X2 Y2 #6-GRASS      #change to grass
        15&#58; SET X2 = X2 * 16            # calc circle location
        16&#58; SET X2 = X2 - 4
        17&#58; SET Y2 = Y2 * 16
        18&#58; SET Y2 = Y2 - 4
        19&#58; DRAW X2 Y2 TO X2 Y2 OF 15 3
        20&#58; PAUSE 1
        21&#58; DRAW X2 Y2 TO X2 Y2 OF 14 5
        22&#58; PAUSE 1
        23&#58; DRAW X2 Y2 TO X2 Y2 OF 15 7
        24&#58; PAUSE 1
        25&#58; DRAW X2 Y2 TO X2 Y2 OF 14 9
        26&#58; PAUSE 1
        27&#58; DRAW X2 Y2 TO X2 Y2 OF 15 11
        28&#58; PAUSE 1
        29&#58; STOP 
This seemed to work ok for me - hopefully it will run ok in your adventure alongside your additional 'check if player stepped on mine' step macro.

GB
Posts: 32
Joined: Tue Jul 01, 2008 2:16 pm
Location: Houston

Post by GB »

Maybe this is a stupid workaround idea, but the first thing that occurrs to me about making a single square animate would be the step macro.

Frankly, I don't have any understanding of the step macro at all. I don't know what its doing, what kind of inputs it can take from where, I don't know where its outputs would go, I don't know what makes it run and what screws it up, I don't know where to find it, what defines it or anything, so I haven't experimented with it at all, and am not likely to until I feel like I have an inkling about it.

But if it can detect that a turn has gone by from the time you did the map edit, then you should be able to use it to change a tile.

I wouldn't necessarily make it do a mapedit. It might be simpler to have it increment a value which changes how a piece of terrain is displayed.

Say your mine macro resets terrain to a fireball, but the fireball is only visible if variable x is less than 2. The fireball macro might also as its last action set x to 0. The step macro increments x by 1 per turn. So you would have a fireball that appeared for 2 turns, then becomes replaced by the crater, because fireball is set to be impassible if x is not less than 2, and when impassible it is replaced by crater.

Fireball could even cause damage when you walk into it, or change your icon, so that if you shot the mine from the adjacent square you would, in effect, have to wait for the debris to fall and the smoke to clear before you could walk into the space.

Of course, this won't help when you set off the mine by stepping on it, but maybe you should just handle that animation with a mosaic instead, since it is a death of player character ending anyway. If the PC dies when he steps on that spot there's no point in having the elaborate mechanisms for continued game play.

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Wow awesome work rld! I'll try that out. I forgot about the code tags! Cool. [going back and adding them in my own posts... ;) ]

@GB: Sounds like good ideas, I'll try those too. Good point there at the end about making an end game event too complex. Only problem with using mosaics for every mine in the game is that I'd have to basically redraw each and every room in which a mine occurs and redraw it again and again for each mine within that room in order to have the animation correspond to specific mine locations. That might actually end up being the best solution, but hopefully rld's solution will do the trick.

Another problem with this method is I was eventually planning on making lethal and non-lethal mines just like those in real life. In reality the basic anti-personel mine is meant not to kill but to seriously wound and maim. Only the more powerful ones are meant to kill or to disable the track of a tank [which incidentally is another part of the game I will need to simulate somehow].

So once I have the game balance of PlayerChar hp/rank, weapon and enemy power/trap dmg, and armor class all worked out I planned on enabling the PC to survive mine blasts either with the proper armor or by just being more powerful/lucky/skilled/or battle-hardened as rank increases. Of course the PC will be seriously injured in any case if not killed.
Last edited by Garth's Equipment Shop on Mon Aug 10, 2009 6:51 pm, edited 2 times in total.
Which of you is interested in my fine wares?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Frankly, I don't have any understanding of the step macro at all. I don't know what its doing, what kind of inputs it can take from where, I don't know where its outputs would go, I don't know what makes it run and what screws it up, I don't know where to find it, what defines it or anything, so I haven't experimented with it at all, and am not likely to until I feel like I have an inkling about it.

But if it can detect that a turn has gone by from the time you did the map edit, then you should be able to use it to change a tile.
There is nothing to step macros really. It is simply a macro that is run every turn which is simply every time the player makes any kind of move on the map. I'm not sure if other non-movement actions count though like a get command or look or using an inventory item. I would guess they count though as they trigger actions and such and those actions cannot occur except in a new turn or at least the effects of them can't anyway.

Yes the step macro could incriment a counter each turn starting with when a certain variable is set and that can be set in the same object action macro that does the map edit. So maybe you are on to something here. The coordinates of the mapedit would have to be stored somewhere though.

Oh and there are two types of step macro. One is global and can be set from the game configuration editor. You first must actually create the macro in the macro editor of course. Then you can choose it as your step macro in the configuration editor. [also within that editor there are several pages of things to change so you'll want to use pgup/pgdwn to see the rest. ]

The other kind of step macro is optional and can be set within the map editor to run a separate step macro specifically for a certain region. From that regional options menu you can choose to use the global macro as the region's step macro [the default setting] or use a different one.
Which of you is interested in my fine wares?

Post Reply