Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Architecture : Various scripting questions
Page 1 of 2
2
New Topic New Poll Post Reply
Poster Message
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Various scripting questions (+2)  
Hello forum,

I have just begun trying to build a custom hold. I read the Architectual Handbook but I don't really know how to make the following work:

I want the player character to always attack first even though he does not have a weapon.
I probably need an NPC, we'll name him "Firststrike", make him invisible, place him in the first room of the hold and make his default script begin with Imperative Global.
Then however I'm stuck. I'm pretty sure I cannot assign the strikes first ability to the player character. So maybe I can assign every monster and NPC (for custom monsters) the strikes last ability. But I do not know how to do that. Can someone help me with that?

[Last edited by Aquitanius at 06-02-2016 06:12 PM]
05-29-2016 at 02:15 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4576
Registered: 02-20-2007
IP: Logged
icon Re: Setting behaviour (+1)  
You can give every custom monster the command "Behaviour Attack last", but this will only work with custom monsters and prevents you using default monsters in your hold.

By far the easiest solution is to give the player a custom accessory with "Behaviour Attack first" in its default script.

____________________________
50th Skywatcher
05-29-2016 at 02:41 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
Hi Nuntar. I enjoy your playthrough of Fetch the Pie with Alex Diener and watched your Let's Build. Cool that you're responding and this fast at it.
I managed to script a First Strike accessory and it works fine.
But is there no other simple way? Seems a little limiting since I cannot use other accessories now.
Well, maybe I do not need them.

I'm sure I will need more help in the future, so I may be bothering you all again soon.
Thanks.

EDIT: Is there a database for custom sprites/avatars?

[Last edited by Aquitanius at 05-29-2016 06:07 AM]
05-29-2016 at 06:04 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4576
Registered: 02-20-2007
IP: Logged
icon Re: Setting behaviour (+2)  
Oops, hadn't thought of that. An alternative is to give "Behaviour Attack first" to a custom armor.

Database for custom sprites, scripts etc. It's not very heavily populated; RPG has always been less popular than the main DROD series.

____________________________
50th Skywatcher
05-30-2016 at 04:42 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
Thanks. Should've thought about just making it custom armor.

Could you help me with this code? I cannot get the second part of it to work.
It's supposed to be Armor that gives the player all the listed behaviours and heals the player before striking and damages the enemy before striking. The first one works, the second one not.

Poisonbite:
Click here to view the secret text


EDIT: Got a few more questions:
- Can I change the first loop so I get the heal after the fight?
I would think I'd set a custom var for the health amount and then after the fight set _HP = custom var. But how do I make "after the fight" happen?

- Can I change the color set of the Player?

- How do I make custom accessories act like already given accessories? E.g.: I want a grappling hook but I want a custom picture and call it Jumping Boots or whatever.

- How can I give the Game Effect command a position relative to the player / the NPC? I cannot change a value there I can only chose a set tile by clicking a position.

- How can I take a platform (on water) to an adjacent room?

- Also: Why can the armor above not use the behaviours "Drop trapdoors" and "activate objects"?
At least the behaviours don't work if I add them.

[Last edited by Aquitanius at 05-31-2016 02:46 PM]
05-31-2016 at 01:25 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
komachi
Level: Master Delver
Rank Points: 158
Registered: 07-30-2012
IP: Logged
icon Re: Setting behaviour (+3)  
I'm going to try to answer what I can.
Aquitanius wrote:
Could you help me with this code? I cannot get the second part of it to work.
It's supposed to be Armor that gives the player all the listed behaviours and heals the player before striking and damages the enemy before striking. The first one works, the second one not.

Poisonbite:
Click here to view the secret text

From what I see, can join both conditionals?, because you have two times the "monster engaged".
The problem it's that the script only enter in the first conditional everytime I think.

Can't be in this way, joining both?
Click here to view the secret text


EDIT: Got a few more questions:
Aquitanius wrote:
- Can I change the first loop so I get the heal after the fight?
I would think I'd set a custom var for the health amount and then after the fight set _HP = custom var. But how do I make "after the fight" happen?

Use "Wait for NPC killed" if you have custom monster and "wait for monster stabbed" if you have roach,roach queen, antlion etc...

Aquitanius wrote:
- Can I change the color set of the Player?

You can't change it, even if you use a custom character for it, but I'm not totally sure.

Aquitanius wrote: - How can I give the Game Effect command a position relative to the player / the NPC? I cannot change a value there I can only chose a set tile by clicking a position.

Setting the _MyScriptX = -9999 and _MyScriptY = -9999 and then:
For setting the NPC position use MyScriptX = _MyX and MyScriptY = _MyY in the NPC script.
For setting the player's position use MyScriptX = _X and MyScriptY = _Y inside the script.
The script should have
Click here to view the secret text

05-31-2016 at 05:16 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1527
Registered: 06-13-2015
IP: Logged
icon Re: Setting behaviour (+2)  
To clarify, what _MyScriptX/Y does is override any command's instructions on what tile to check or act upon, replacing the entered X/Y value with the variable's value in any command after one that sets one of those two. You can use it to dynamically set an X and Y value for things like what you're looking to do. However, it overrides all commands that ask for a location, and possibly other commands as well, so you should always set _MyScriptX/Y back to -9999 as soon as you're done using it to tell a command what to do because that's the "don't override" value. Probably about seven times out of ten if something breaks in a script including Myscript overrides it's because it doesn't set back to "don't override" soon enough.

Also handy, if you don't know it: You can use the "Assign", "Add," "Subtract", etc. functions to alter one variable relative to another by putting that other variable's name (i.e., _X or _MyX) instead of a number in the little number box.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 05-31-2016 06:55 PM]
05-31-2016 at 06:52 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Setting behaviour (0)  
There are a lot of questions in your post, so I will deal with them one at a time.

First of all, here is a fix of your script that makes it heal and damage at the start of the fight, copy it into your clipboard then press Ctrl + Shift + B in the script editor in-game to paste it directly:

  Behavior 14
Label Loop
  Wait for event Monster engaged
  Set var "_HP" + _EnemyREP * 8
  Set var "tempVar" = _REP * 25
  If ... 
        Wait until var "tempVar" > _EnemyHP - 1
     Set var "_EnemyHP" = 1
  Else 
     Set var "_EnemyHP" - _REP * 25
  If End 
  Wait 0
  Go to Loop


Here's what I've changed:

* Wyrm and goblin weaknesses only work on weapons and monsters, so I removed them.

* The code after "Goto Loop" could never actually execute because the code could never reach it, so I removed it.

* You did not need a "Wait 0" at the end of each if statement. What this did was make the game wait a turn after executing the heal, and then check the NEXT turn if you engaged a monster on that turn in order to deal damage to the next monster. So I also combined them both into the same if statement, then just got rid of the if statement entirely because that's the only thing the loop checked for, so it can just wait for the event instead of run the whole loop each turn.

* When dealing damage at the start of a fight, if the monster's HP drops to or below 0 before the fight starts, it aborts the fight. This is because unfightable NPCs have an HP of zero. Therefore what you have to do is check if the damage would reduce the monster's HP to or beyond 0, and then set its HP to 1 rather than deal the damage.

Something to note, by changing monster HP it doesn't count as dealing damage, so no damage numbers show up. The only way to deal damage to a monster and also have the damage amount fly out of its head is to build an explosion on top of it with the _Explosion variable set to the correct amount (in which case you do not need to bother with the check to see if its HP would drop to zero, as the explosion handles killing the monster correctly).

[Last edited by kieranmillar at 05-31-2016 09:17 PM]
05-31-2016 at 08:29 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Setting behaviour (0)  
Aquitanius wrote:
EDIT: Got a few more questions:
- Can I change the first loop so I get the heal after the fight?
I would think I'd set a custom var for the health amount and then after the fight set _HP = custom var. But how do I make "after the fight" happen?
Alright this one's a bit trickier but the same concept:

  Behavior 14
  Set var "tempVar2" = 0
Label Loop
  Wait for event Monster engaged
  Set var "tempVar2" = _EnemyREP * 8
  Set var "tempVar" = _REP * 25
  If ... 
        Wait until var "tempVar" > _EnemyHP - 1
     Set var "_EnemyHP" = 1
  Else 
     Set var "_EnemyHP" - _REP * 25
  If End 
  Wait for event Monster stabbed
  Set var "_HP" + tempVar2
  Set var "tempVar2" = 0
  Go to Loop


This code adds a bit more to the loop, a check for "Wait for Event Monster Stabbed" which is an event that executes after the monster dies. Here a variable "tempVar2" sets to what the healing amount should be at the start of the fight (when we have access to the _EnemyREP variable), then adds that amount of health once the enemy dies. You can change tempVar2 to whatever you want and set it whenever if you want to change the healing amount to something else. It doesn't have to be set at the start of the fight.

Here's the catch: Wait for Event Monster Stabbed executes the turn AFTER the fight, so you won't see the health gain immediately. The good news is that this will work correctly when you fight two monsters in a row, you will just have the HP gain appear to happen at the start of the fight on the next turn.

You may note I removed the "Wait 0" from the script. Due to the way RPG scripting works it's not possible to have "Wait for event monster stabbed" to run straight right after "Wait for event monster engaged" so the script will always wait a turn at this point, therefore we no longer need to worry about pausing the script for a turn. This only seems to be the case for these two events, in pretty much all other cases using Wait 0 is a good idea.

One issue this script and the previous one have: They do not work properly if you and a mimic both stab a monster on the same turn, so you'll have to avoid the possibility of that happening, but that's easy to work around.

If you want the HP to restore on the SAME turn as the fight and still after the fight, then this is fixable but with a drawback. You must either:
a) put this code in a weapon and not armour. This allows you to use the "Each attack" command to check if the enemy HP is zero after you deal the killing blow and give you the health right then, or
b) put this code inside the code of a custom monster, and duplicate it for EVERY SINGLE MONSTER in your game, all of which much be custom. In this case, the monster can use the "Each defend" command to detect when its HP turns to zero once it gets hit and give you the HP then (it will execute just before it dies).

If you want to know how to implement either of these let me know.
05-31-2016 at 09:02 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Setting behaviour (0)  
Aquitanius wrote: - Can I change the color set of the Player?
No. you'll need to provide custom images if you want to do this.

Aquitanius wrote: - How do I make custom accessories act like already given accessories? E.g.: I want a grappling hook but I want a custom picture and call it Jumping Boots or whatever.
There is no way to inherit the existing behaviours, and therefore will have to code a replacement from scratch. I strongly do not advise this (and in some cases like invisibilty potion, speed potion and flippers, it's impossible to code a replacement).

Aquitanius wrote: - How can I take a platform (on water) to an adjacent room?
You can't. You'll have to swap rooms at a room boundary where another different platform exists in the next room.

Aquitanius wrote: - Also: Why can the armor above not use the behaviours "Drop trapdoors" and "activate objects"?
At least the behaviours don't work if I add them.
These behaviours are to be given to NPCs to drop trapdoors, or push mirrors and activate tokens if they step on them. Only makes sense for an NPC that can move, of course.
05-31-2016 at 09:10 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Setting behaviour (0)  
Aquitanius wrote:
- How can I give the Game Effect command a position relative to the player / the NPC? I cannot change a value there I can only chose a set tile by clicking a position.
This has been helpfully explained by Xindaris above, so here's an example script of it in action. This generates a Steam effect on the square directly North of the player each turn. Put it in some character in the room.

Label Loop
  Set var "_MyScriptX" = _X
  Set var "_MyScriptY" = _Y - 1
  Game effect Center,Steam,0,0,On
  Set var "_MyScriptX" = -9999
  Set var "_MyScriptY" = -9999
  Wait 0
  Go to Loop


05-31-2016 at 09:16 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
Oh boy! Thank you all for your help!

I will try out all the things and come back to you with more questions. ;)

The _MyScriptX/Y variables are very interesting. That makes everything way more doable. Thank you all for explaining them to me.

Also thanks for going through my bad heal/damaging loop and explaining the changes. That helps very much.
I wondered about the damage never showing up when I had semi working code, that reduced the hp of enemies but then let me not attack them anymore. I know now why that is.

As you all can see, I haven't really understood the wait 0 command and when to use it. I pretty much spam it everywhere when something doesn't work right or I keep stuck e.g. in a cut scene.
Any tips on that?


Also I was sure I had seen someone take a platform to another room, but there was probably a second platform.



Can I still give the player the behaviours "drop trapdoors, activate orbs" without giving them a sword.
A power token at the beginning of every room seems a bit annoying.
Is there an empty weapon that I can give those scripts, but does not act as a sword?


[Last edited by Aquitanius at 06-01-2016 06:55 AM]
06-01-2016 at 06:53 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Setting behaviour (0)  
There is no power token equivalent in RPG. To have the player drop trapdoors and hit orbs he has to be wielding a sword. Also all weapons are swords, if there is anything in the weapon slot it will be treated as a sword, nothing you can do to change that I'm afraid.

If your cutscenes keep getting stuck in a loop when youre expecting them to end, try using the cutscene command again but with a value of zero. This tells the game to end the cutscene.
06-01-2016 at 07:43 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
Aww. That's too bad. Then I just have to work without trapdoors and with switches instead of orbs.

Thanks.
06-01-2016 at 08:33 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4576
Registered: 02-20-2007
IP: Logged
icon Re: Setting behaviour (+1)  
Aquitanius wrote: As you all can see, I haven't really understood the wait 0 command and when to use it. I pretty much spam it everywhere when something doesn't work right or I keep stuck e.g. in a cut scene.
Any tips on that?
Wait 0 halts a script from executing any further the current turn. The right place to use it is when you have a loop with no other execution-halting commands, so that the engine would attempt to execute the same code twice in one turn. (When this happens, it aborts the script as if it hit an End command, which can really mess up your room design if you weren't expecting that.)

So, for instance, you would use Wait 0 in this structure:

Label loop
If...
[some condition]
[action]
If End
If...
[some other condition]
[action]
If End
(but what if neither condition is true? Need to halt until the next turn to check again!)
Wait 0
Go to loop

____________________________
50th Skywatcher
06-01-2016 at 12:13 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
Thank you!

But sometimes even the simplest things don't work for me and I cannot figure out what's going wrong.

In this room there's 3 custom NPCs.
1) None, invis
Set var _ItemMult=300
Imperative restart script on entrance


This NPC does not seem to break the others. But I included it nonetheless.

2) Red Guard, visible
Cut scene 2000
Speech Red Guard, 1300, "..."
Speech Self, 1000, "..."
Wait o turn(s)
Turn into monster
Cut scene 0


There is also another Red Guard in the room.
There is either no cutscene at all or no speech and the cutscene goes on forever.
If I move around or delete cut scene 0 /wait 0 there is no cutscene at all.

3) None, invis,
Label "Loop"
Wait for player to touch me
Speech Self, (1800) "..."
Wait 0 turn(s)
Go to "Loop"


If this NPC is in the room, the cutscene in 2) breaks. But if it is not in the room, 2) works.

[Last edited by Aquitanius at 06-01-2016 04:05 PM]
06-01-2016 at 04:05 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1527
Registered: 06-13-2015
IP: Logged
icon Re: Setting behaviour (+1)  
My immediate guess is that at least part of the problem stems from your:

Turn into monster
Cutscene 0

Because as far as I know "Turn into Monster" makes the character now a monster matching its original appearance and halts all script the same way "Imperative Die" does. Possibly just swapping the order of those two commands will help.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 06-01-2016 04:18 PM]
06-01-2016 at 04:18 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Chaco
Level: Smitemaster
Rank Points: 3623
Registered: 10-06-2005
IP: Logged
icon Re: Setting behaviour (+1)  
The behavior you're seeing is due to a combiation of two factors. The first is that after an NPC "turns into monster", it no longer counts as an NPC, just a monster, and its script automatically stops running. The second is that cutscenes will automatically end if there are no NPC scripts running in the room anymore, but they will not automatically end if there still is a script running, and will instead wait for a Cut Scene 0 command.

Character 1's script stops on the zeroth turn as soon as it's done running its "set var" command.

Character 2's script stops as soon as it hits the Turn Into Monster command. This is where the problem lies - the Cut Scene 0 should be placed before the Turn Into Monster, not after it.

Character 3's script never stops.

--

Finally, for the speech itself, you don't necessarily need a cutscene if you just want to add some speech commands, since short bits of dialogue don't necessarily have to be synched to room turns. If you do want a cutscene, you'll have to change your "Wait 0 turns" to wait some integer number of turns (a multiple of the unit "2000", the number of milliseconds per turn) in order to place the speech commands and the "turn into monster" on separate turns. Since the duration of your two speech commands adds up to 2300, "Wait 2 turns" should be fine. You could also wait 23 turns in a Cut Scene 100, 12 turns in a Cut Scene 200, etc.

____________________________
Quick links to my stuff (in case you forgot where it was):
Click here to view the secret text


[Last edited by Chaco at 06-01-2016 04:24 PM]
06-01-2016 at 04:22 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
That was correct. Apparently I flatout lied when I wrote moving cutscene 0 does not work. I have probably not used every possibility. Sorry.

I also changed the speech to not be in a cutscene.

Thank you both very much.
06-01-2016 at 04:33 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (+1)  
And another question:
Can I equip an accessory through a script? E.g.: An NPC talks and then gives me the accessory directly?
I can already do that with custom equipment via the swap Accessory command. But I cannot choose the normal accessories (flippers, grappling hook,...).

EDIT: Sorry, should've edited my previous post.

[Last edited by Aquitanius at 06-01-2016 05:16 PM]
06-01-2016 at 05:16 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
komachi
Level: Master Delver
Rank Points: 158
Registered: 07-30-2012
IP: Logged
icon Re: Setting behaviour (+1)  
Aquitanius wrote:
And another question:
Can I equip an accessory through a script? E.g.: An NPC talks and then gives me the accessory directly?
I can already do that with custom equipment via the swap Accessory command. But I cannot choose the normal accessories (flippers, grappling hook,...).

EDIT: Sorry, should've edited my previous post.

Yes, use:
set var _Accesory=1, _Accesory=2...
It gives the items by order. 1 it's the hook, 2 it's the flippers and so.
You can also gives custom equipment if you want using the custom ID of the character, like 20012.

[Last edited by komachi at 06-01-2016 05:33 PM]
06-01-2016 at 05:32 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Setting behaviour (0)  
Ah, thanks.

And another question. Sorry. ^^

I have this NPC 4 times in the room, each on a hot tile:
None, invis:
Label "Loop"
Wait for event Player burned
If...
Wait until var _X = _MyX
If...
Wait until var _Y = _MyY
Build floor at (where corresponding hot tile is)
Disappear
If End
Wait 0 turn(s)
If End
Wait 0 turn(s)
Go to "Loop"


These work as intended. They "shut" the hot tile after walking on them and getting burned.

The following is what acts really strange:

Aumtlich, visible
Behaviour Beam attack
Label "ALoop0"
If...
Wait for event player burned
Go to "ALoop1"
If End
Wait 0 turn(s)
Go to "ALoop0"

Label "ALoop1"
Wait 1 turn(s)
If...
Wait for event player burned
Go to "ALoop2"
If End
Wait 0 turn(s)
Go to "ALoop1"

Label "ALoop2"
Wait 1 turn(s)
If...
Wait for event player burned
Go to "ALoop3"
If End
Wait 0 turn(s)
Go to "ALoop2"

Label "ALoop3"
Wait 1 turn(s)
If...
Wait for event player burned
Disappear
If End
Wait 0 turn(s)
Go to "ALoop3"


This should work like the following:
Each time the player gets burned, the NPC goes to the next loop.
When it is in Loop3 and you get burned, it disappears.

That works for normal hot tiles. Walk on 4 of them and the NPC disappears and the beam with it.

But it works differently for the hot tiles the first NPC is on.
I have four of those, each the same with the exception of the position they are in and that their loops are labeled "NLoop", "WLoop", "ELoop" and "SLoop" for their positions (North, West, East, South).

If I walk on the four hot tiles in almost any order the Aumtlich will NOT disappear.

But when I walk in the order "North, South, West, East" or in the order "East, West, South, North" the Aumtlich does disappear. Why is this??

I actually find this pretty useful as I can make a riddle out of this. But why does it work this way?

EDIT: I added another loop to the hot tile NPCs:
They switch to Loop2 after they build floor over the hot tile. The second loop checks if a pressure plate is pressed and then builds the hot tile again and switches back to the first loop.

That works in rebuilding the hot tiles but that makes the Aumtlichs behave even stranger. The same combinations don't work when the pressure plate is pressed in between. In some cases it still does, in most it doesn't. Also running over the same (rebuilt) hot tile doesn't kill the Aumtlich either.
That also messes with a reset loop I wanted to built into the aumtlich, where it checks in every loop, if the pressure plate was pressed and resets the "hot tile walked" counter to 0.

EDIT2: Also when I enter another room in test mode and come back, the order seems to become random.


=========================
=========================

EDIT3: Another topic: I seem to be doing equipment wrong. I used custom equipment in scripts only.

The following Character is supposed to be an armor:
Spiderbite
Behaviour Attack first
Wait for player to touch me
Disappear
Set var _X = _MyX
Set var _Y = _MyY
Equipment Swap Armor Spiderbite


That works when I place the character somewhere. Also works on other armors (like the healing one from above).
Also works when I give it to the player in the following script:

LevelUps
Imperative Make script global
Label "1"
If...
Wait until var _REP > 4
[...]
Equipment Swap Armor Spiderbite
Go to "2"
Else
Wait 0 turn(s)
[...]



But I cannot give the armor via the F4 menu to the player. The ID gives me an accessory with the same name but it has no accessory picture (the chest) and does not work properly. (E.g the healing effect from earlier is not applied.)
What's the problem here? Is there a command to make a character be an equipment that I have not found?

EDIT4: [Was another problem, fixed it myself.]

EDIT5: Solved the ground part. Just had to swap the loop to the bottom whoops. Still doesn't work with giving it via custom ID in the F4 screen.

EDIT6: Now I have yet another problem with the equipment. It ceases working after I leave a room. That didn't happen before.
Why does everything break all the time. It's really frustrating. Pretty annoying to work with...
[Fixed this, but I don't know how.]

EDIT7: [retracted]


[Last edited by Aquitanius at 06-03-2016 03:05 AM]
06-01-2016 at 07:12 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Various scripting questions (0)  
Sorry it's taken a while to get back to this topic. I'll try and help you out.

For the hot tile script... I don't understand what exactly your script is trying to do. Why are there so many separate loops that you constantly jump between? Without more context of what the room looks like and what you're trying to achieve I don't know how to help you here, because I don't understand what behaviour you want.

If all you want is for the script to wait until you've been burned in the room 4 times then you don't even need a loop. Something like this would work:

Behaviour Beam attack
Wait for event player burned
Wait 0 turn(s)
Wait for event player burned
Wait 0 turn(s)
Wait for event player burned
Wait 0 turn(s)
Wait for event player burned
Dissapear


Here the code just waits for the event to trigger 4 times. It has Wait 0 in between each command only because if it was 4 wait for events in a row then they would all trigger on the same turn.

To help clarify Wait For commands, they will make the script stop where it is until the thing it is waiting for happens. But if you put an if command in front of them, then it checks only if the thing happened on that very turn, and then carries on regardless. Loops with if statements are useful when you want something to check multiple things each turn, but if the script is only sitting waiting for one thing to happen, you don't need to worry about constructing a loop and can just use the regular Wait for Event.
06-03-2016 at 10:30 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Various scripting questions (0)  
For the errors you're having with your equipment I'm afraid you're going to have to upload your hold for testing, because nothing in the code snippets you've posted seems wrong. I can't see what the issue is from what you've posted, sorry!
06-03-2016 at 10:37 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Various scripting questions (0)  
Sorry it's taken a while to get back to this topic. I'll try and help you out.

I'm just glad I'm being helped at all. I'm spamming my questions a bit. >.>

I actually didn't even think about just using "wait for" 4 times. That's stupidly easy and does the job...

However, I still want to try something else with it:
I have 4 hot tiles in the room on position 1,2,3 and 4 each which disappears after stepping on it and reappears after pressing a switch.
The code for that is 2 loops.
One checks for burned and the X and Y position. If everything is true it builds a floor on the hot tile and goes to the second loop. Else it restarts the first loop.
The second loop just checks if a switch was pressed and returns to the first loop if it was.
I have that working.

Now the harder part of the setup I want is this:

I want a custom NPC, a not fightable Aumtlich with beam, to disappear only after stepping on the four hot tiles in a given order. (E.g.: Disappear only if stepped on 1,2,4,3 in that order.)
For that I should build 4 loops since I have to check more that one thing each time.
First: check if the player stepped on the switch
If so, restart in the first loop.
Second: check if the player was burned
If so: Third: check if the player was at X and Y of the hot tile I want.
If this gives true I should go to the next loop, else I go to the first loop.
The next three loops should work the same but the last doesn't send to a next loop but makes the aumtlich disappear.

The NPC should look like this, if I'm not mistaken:
Aumtlich, visible
Behaviour Beam attack
Label "Loop1"
Wait for event pressure plate activated
Wait 0 turn(s)
Go to "Loop1"
If...
 Wait for event player burned
 If...
  Wait until var _X = [X_position of hot tile 1] 
  If...
   Wait until var _X = [X_position of hot tile 1] 
   Wait 0 turn(s)
   Go to "Loop2"
  If End 
   Wait 0 turn(s)
   Go to "Loop1" 
  If End
  Wait 0 turn(s)
  Go to "Loop1"
 If End
Wait 0 turns
Go to "Loop1"



For the other problem: I misinterpreted the F4 menu and had a mistake in another script. I think I fixed it.


===================


EDIT: I have a few more questions:

1) How does the "Wait for defeat" command work? I tried making an NPC that does something when it dies but just using wait for defeat does not work. Dead NPCs disappear and their script with them, so that makes sense. But what is this command for if not to circumvent that?


2) How does the "each attack/defend" command work. I have to chose a label to go to for each attack/defend. But that Label is only done twice:
The first time I enter the room even without attacking. And then a second time on the first attack/defend. Then never again. What am I supposed to do here?
EDIT: Still have the problem that the action is also taken the first time I'm moving in the room. But I can get it to trigger on each attach/defend when I add Imperative Run on combat engagement.


3) Is there a way to build briar roots, briars or make them grow only after a while?
If that doesn't work, I can still use the Build remove item command to remove a wall that blocks an existing briar. Would still be nice.

4) How can I make briars grow on events? Creating and instantly killing an NPC seems to not be an option. That makes them hang around a turn and looks ugly.
Activate item unfortunately does not work on briar roots. That would be great.

[Last edited by Aquitanius at 06-04-2016 06:02 PM]
06-03-2016 at 11:18 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Various scripting questions (+1)  
The hot tile order question:

Assuming the hot tiles are at (1,1), (2,2) etc, and the rest switch is at (10,10), I'd do something like this, placed either in a separate character or in your Aumtlich script:

  Set var "burnOrder" = 0
Label Loop
  If ... 
        Wait for entity Player 10,10,10,10
     Set var "burnOrder" = 0
  If End 
  If ... 
        Wait for entity Player 1,1,1,1
     If ... 
           Wait until var "burnOrder" = 0
        Set var "burnOrder" + 1
     Else 
        Set var "burnOrder" = 0
     If End 
  If End 
  If ... 
        Wait for entity Player 2,2,2,2
     If ... 
           Wait until var "burnOrder" = 1
        Set var "burnOrder" + 1
     Else 
        Set var "burnOrder" = 0
     If End 
  If End 
  If ... 
        Wait for entity Player 3,3,3,3
     If ... 
           Wait until var "burnOrder" = 3
        Set var "burnOrder" + 1
     Else 
        Set var "burnOrder" = 0
     If End 
  If End 
  If ... 
        Wait for entity Player 4,4,4,4
     If ... 
           Wait until var "burnOrder" = 2
        Set var "burnOrder" + 1
     Else 
        Set var "burnOrder" = 0
     If End 
  If End 
  Wait 0
  Go to Loop


This will end with the burnOrder variable being 4 when the correct sequence is found, so you can then just check each turn if burnOrder has a value of 4 and then make your aumtlich disappear or whatever you want to do. The script is mostly a simple if statement repeated multiple times with key numbers changed.

[Last edited by kieranmillar at 06-05-2016 10:16 PM]
06-05-2016 at 10:16 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Various scripting questions (+1)  
Aquitanius wrote: 1) How does the "Wait for defeat" command work? I tried making an NPC that does something when it dies but just using wait for defeat does not work. Dead NPCs disappear and their script with them, so that makes sense. But what is this command for if not to circumvent that?

It waits until the monster loses a fight. Unfortunately, it usually never has a chance to trigger because the monster is dead, so you have to give it the Unkillable Imperative so it doesn't die at the end of the fight, then kill it manually. You'll still get REP and GR for winning the fight even though the monster does not die. Example:

  Imperative 1
  Set var "_MyHP" = 100
  Wait for defeat 
  Speech "Death, my one true weakness!",Normal,Self,0,.
  Imperative 4


(Those imperatives are Unkillable and Die, the game doesn't copy/paste imperatives to text in a readable way unfortunately).

Annoyingly Imperative Die doesn't take effect until the following turn, so you might want to simulate the monster dying like this instead:

  Imperative 1
  Set var "_MyHP" = 100
  Wait for defeat 
  Speech "Death, my one true weakness!",Normal,Self,0,.
  Disappear 
  Set var "_MyScriptX" = _MyX
  Set var "_MyScriptY" = _MyY
  Game effect Center,Blood splatter,0,0,On
  Set var "_MyScriptX" = -9999
  Set var "_MyScriptY" = -9999



Aquitanius wrote:
2) How does the "each attack/defend" command work. I have to chose a label to go to for each attack/defend. But that Label is only done twice:
The first time I enter the room even without attacking. And then a second time on the first attack/defend. Then never again. What am I supposed to do here?
EDIT: Still have the problem that the action is also taken the first time I'm moving in the room. But I can get it to trigger on each attach/defend when I add Imperative Run on combat engagement.
Each Attack/Defend can be put on a monster or on equipment (attack only works on swords, defend only on shields) to make code execute when the character or you attacks or takes a hit in a fight. The code works by IMMEDIATELY ABORTING any code that equipment or monster is running and tells the script to instead run where the label is that the Each attack or Each defend command points to. Note that because the part of the script that is executing gets changed, if you want it to go back to where it was before you'll need to tell the code to do so with labels and gotos. So for example, if you have an unkillable monster that sits at a "wait for defeat" command but you also give it an Each defend label, then as soon as it gets hit it stops waiting for defeat and runs the code it's asked to run when it defends, so you'll have to send it back to your "wait for defeat" line.

Probably makes more sense to illustrate it with an example. Here's me building on the previous example monster:

  Each defend Took a Hit
  Imperative 1
  Set var "_MyHP" = 100
  Set var "_MyATK" = 20
Label Wait for death
  Wait for defeat 
  Flush Speech Off
  Speech "Death, my one true weakness!",Normal,Self,0,.
  Disappear 
  Set var "_MyScriptX" = _MyX
  Set var "_MyScriptY" = _MyY
  Game effect Center,Blood splatter,0,0,On
  Set var "_MyScriptX" = -9999
  Set var "_MyScriptY" = -9999
  Go to Skip to End
Label Took a Hit
  Speech "Ouch!",Normal,Self,0,.
  Go to Wait for death
Label Skip to End


Note that we're dealing with regular labels here, the code doesn't "section off" the code it's asked to jump to when the monster takes a hit, so if we don't want this code to run again once the monster dies, we have to skip past it with a label, hence the "Skip to End" label. This is why your Each defend code is running the first time you move in the room, the code is just running it like normal because it's just code that follows a label, you have to skip past it so it doesn't run when you don't want it to.
06-05-2016 at 10:41 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Various scripting questions (0)  
Aquitanius wrote:
3) Is there a way to build briar roots, briars or make them grow only after a while?
If that doesn't work, I can still use the Build remove item command to remove a wall that blocks an existing briar. Would still be nice.

Good catch that it's missing from the build menu. Good news, according to this stickied topic you can still build it by trying to build something else with _MyScriptF set to 39, 40 or 41, which overwrites what the build command is trying to build (don't forget to set it back to -9999 when you're done!)

I've not tested this myself, so hopefully it works OK.

Aquitanius wrote: 4) How can I make briars grow on events? Creating and instantly killing an NPC seems to not be an option. That makes them hang around a turn and looks ugly.
Activate item unfortunately does not work on briar roots. That would be great.

Unfortunately there is no code command to trigger briar to grow.
06-05-2016 at 10:46 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Various scripting questions (+1)  
Thank you very much!
The burn order solution is great. I still don't know why my original build behaves like it does. But I will be replacing it with yours and not think about it too much. >.>

Also thank you for explaining the commands and labels so well. Really helps.

Unfortunately the briar roots the build 39 command places do not work. They are just obstacles that do not grow. That's probably the reason why they aren't in the build menu in the first place.
They don't even kill you when they are placed on the player.
That's a little sad. ^^


EDIT: I made this fleeing monster script and it actually works fine. In combat it steps away from the player each attack if it is able. It's pretty neat. Just wanted to show that I can actually do something myself. ;)
But I'm too lazy to write up the code. You copy your code directly from the game, right? I can insert it with ctrl+shift+b. But how do you copy it to your windows clipboard? I tried ctrl+shift+c and ctrl+c. Both don't do it. Couldn't find it by searching in this forum either.

Aaaand... I still have another question: How do the behaviour movement commands work? They don't seem to do anything on their own. If I want to emulate moving towards the player I could use my code and change it around a little and not put it into each defend. But that seems a little too complicated when there are movement commands already in the editor. Thanks. :D

EDIT2: kieran, I have two questions about your burnOrder script.

1) It doesn't work if I set it up in a different NPC and let the Aumtlich just check if the burnorder is 4. It does work if it is in the Aumtlich script itself. Why?

2) Also if I want to Aumtlich that behave this way, they need two seperate burnOrder variables. I guess it's just because the first Aumtlich sets the burnOrder correctly to 1, but then the second one checks the wrong condition, because the burnOrder is now 1 and resets it to 0. That should be the explanation, right?


[Last edited by Aquitanius at 06-07-2016 09:59 PM]
06-06-2016 at 02:52 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Aquitanius
Level: Goblin
Rank Points: 27
Registered: 05-27-2016
IP: Logged
icon Re: Various scripting questions (+1)  
Uhm. Also I used the script given in the Architectural Handbook for the inventory. One to one. And it doesn't work. The cmd button doesn't ungrey and I cannot click it. What am I doing wrong here?
For reference, this is the code:
Click here to view the secret text

06-08-2016 at 12:37 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Page 1 of 2
2
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Architecture : Various scripting questions
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.