Would like help with DSA

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.
Post Reply
Isildur

Would like help with DSA

Post by Isildur »

Hello, I'm just trying to create a DSA wich would allow to create new object. the purpose is to make a kind of potion-fountains, I did a swap actuator wich exchange a empty flask for a vi potion (quite easy..) but It has a limited number of use. So I would like to use a DSA with an ADD and a timer (for not allowing too quick use), but I fell totally confused by the syntax, can anyone help me ? thank you.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Your fountain must be a pushbutton, activated by empty flask, targetting your DSA.

you need to create a potion of vi in some hidden place, and note its ID: when editing the tile where you put the potion, you see a number before its name, like something like [4edc], for example: which would be 20188 in decimal.

Your DSA, when activated, must do two things:
&DEL the item in cursor hand (location = -1)
&ADD the potion (20188 in this case) in cursor hand (location = -1).

to know the ID for the &DEL command, you must do a:
&CHPOSS with charnum -1 (object in hand), index 0

That's all, I think. If it's not enough I'll try to be more specific tomorrow.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

note its ID: when editing the tile where you put the potion
I prefer to determine the ID at runtime by Fetching the object at that location.
Either way works as well but by doing it my way you can write a more general
DSA that will take the location as a parameter and put ANY object at that location
in the player's hand. The other parameter could be the delay.

Isildur: If you want to go at this yourself, great! If you would rather
an expert (?) do it and put the result as the first entry in our library then
let me know.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Weird, I must admit that I wanted to do this exact thing with a DSA at one point

Your advice seems to be circumventing the original mechanics, yes? So by actvating a DSA the cursor hand changes from an enmpty flask to the vi potion? And ignores the item release function of a normal wall object?

In that case, can you also do this with a floor trigger? Walking infront of a certain altar or decoration, a staff in the hand could be turned into a sword, for example? (Yes, i just realised this would probably go wrong if you don't have a staff in the hand...but the priciple would work, correct?)
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

Determining the ID at runtime is more generic, yes, but one more step into complexity. If Isildur wants to write the DSA by himself he should start by the simplest, I think. Then add complixity.

Beo: In fact it would be possible to use a swapobject to make the exchange and a pressbutton to activate the DSA, but the DSA would need to make a copy anyway of the potion (by &ADDing it). Besides, using a pushbutton gives more flexibility.

To simplify the DSA, you could tell the the pushbutton to "eat" the empty flask when activated, tus ridding yourself from the &DEL part, but I don't know in which order things would happen: will the DSA get activated before the potion is eaten, in which case you couldn't &ADD an item to an occupied hand...

As for a floor trigger activated by "party possessing empty flask", you would need to ensure first that the objet in cursor (&CHPOSS with charnum -1 and index 0) is of &TYPE 85120 (85120 is an empty flask of power 0. )
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 keyhole 'eats' the key as part of pressing the button.
The message to the DSA may get queued either before or after the
key is eaten. But the message will not get processed until the program
is finished processing the pushbutton.

Does that make sense?

Another way to say it:
The pushbutton code gets executed to completion before any further
messages are process.....including the message that activates the DSA.
Even if the delay is zero.

I should add that Filters are not activated by messages but
are part of the code itself. This is not relavant to the current
discussion but might prevent misunderstandings later.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

In this case, a pushbutton, activated by empty flask, with remove object from hand, targetting a DSA which &ADDs object 20188 to location -1 is enough.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

In this case, a pushbutton, activated by empty flask, with remove object from hand, targetting a DSA which &ADDs object 20188 to location -1 is enough.
I understand what you said. Sort of a sad comment on something or other.
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

It was promising, but, by the end, definitely not wicked enough.
Isildur

Post by Isildur »

thank you all, for your quick answer, by the way I'm not as expert as you in DSA. In fact, I'm starting to understand the mechanics you propose me, but the syntax let me confused. I mean, to make it simple, what is the ADD syntax to get a vi potions at a specific position ? next what's the syntax to DEL an empty flask at another position ? (tell me if I'm wrong but I think that ADD create an item, it does not move an existing item )
User avatar
Zyx
DSA Master
Posts: 2592
Joined: Mon Jun 05, 2000 1:53 pm
Location: in the mind
Contact:

Post by Zyx »

&ADD create a copy of an existing item.

With the Help button of DSA's dialog you get the following info:
&ADD (posMsk <location> obj ...)
Wich means &ADD will use 3 parameters (left part of the ...) and return no value (right part of the ...)
Parameters are stocked in a stack, so you need to load them before executing &ADD:

For the position mask: in this case, 0 (I guess), since its in your hand. (position mask is about the facing inside a tile)
L0

For the location: in this case, -1, which means cursor hand. You cannot load negative value, so you have to load the absolute value first, then make it negative:
L1 &NEG

For the object: the object ID you got at design time with CSBuild (or with a DSA function at runtime as suggested by Paul). In our example, we suppose it's 20188:
L20188

So here's the line:
L0 L1 &NEG L20188 &ADD

I guess I should try it... I may have forgotten something...
Post Reply

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