Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : Scripting questions
New Topic New Poll Post Reply
Poster Message
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Scripting questions (+1)  
I'm trying to get into some scripting for my hold, and running right into trouble with some things that seem in my head like they should be easy.

Can I make a roach where killing it is optional? All the monsters in this room and required to complete the room, except the roaches. In all other aspects it behaves like a normal roach.

Can I make a character that drops trap doors as it walks over them? Seems like there's at least one character types that does it (Beethro) but can I make a guard character or stalwart or citizen drop trapdoors?

Also, I vaguely recall there are some secret debug options to see or tinker with variables, but I can't find any documentation on this.
07-04-2020 at 11:17 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1856
Registered: 07-11-2014
IP: Logged
icon Re: Scripting questions (+2)  
quote:
Remlin wrote: Can I make a roach where killing it is optional? All the monsters in this room and required to complete the room, except the roaches. In all other aspects it behaves like a normal roach.

Scripted characters are unrequired by default. Make sure you're not using the command Turn into monster as that will just replace your character with a regular required roach. And of course, make sure you don't have "Imperative Required target" set.

quote:
Remlin wrote:
Can I make a character that drops trap doors as it walks over them? Seems like there's at least one character types that does it (Beethro) but can I make a guard character or stalwart or citizen drop trapdoors?


There's a hard way to do this, and an easy but sad way to do this. The hard way is for a scripted character to use MyScript variables to call Destroy trapdoor at its previous turn's location if it changed grid squares this turn. You'll need to use local variables on that character.

The easy way is to sit and wait in the hope that hyperme's drop trapdoor behaviour gets officially implemented into the game, but you could be waiting forever: https://www.youtube.com/watch?v=Jc7ZlfLbhUQ

quote:
Remlin wrote:
Also, I vaguely recall there are some secret debug options to see or tinker with variables, but I can't find any documentation on this.

While playtesting in the editor, press Ctrl+F7 and when a variable changes its value a message will appear at the top of the screen showing the variable and its new value.

[Last edited by kieranmillar at 07-04-2020 11:31 PM]
07-04-2020 at 11:30 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
mauvebutterfly
Level: Smitemaster
Rank Points: 507
Registered: 05-03-2015
IP: Logged
icon Re: Scripting questions (+1)  
The first two are doable, but the only way to do them is a bit convoluted.

For the roach you could make a custom enemy that looks and acts like the roach but doesn't have Imperative: Required Target. That should (mostly) do it. It would still have the standard custom enemy issues where it isn't affected by invisibility or brains, but that might be fine for your hold.

As for dropping trapdoors, the easiest way to do that would be to have a construct character walk over them. If you want to have a guard NPC drop the trapdoors you have a few options: you could manually remove the trapdoors after they are walked over (this probably won't look great though) or you could make a custom construct character that has a custom sprite that makes it look like a guard. Unfortunately, the "Set Appearance" command will remove the trapdoor dropping property of the construct once it looks like a guard, so that wouldn't work.

____________________________
106th Skywatcher
07-04-2020 at 11:33 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Re: Scripting questions (+2)  
Thanks guys, great info, but please talk me through this a bit more. I've made a character of type Roach, and given it a processing sequence of 1000 and imperatives for Normal Beelining and Deadly, and then Move To Player. Is that all there is to it? Then because I don't want the roach reappearing in a conquered room, I started the character invisible and put "if, wait for event room conquered, end" but that doesn't seem to work. Am I detected room conquer state wrong?

For the trapdoors, I didn't know about MyScript variables. Seems powerful and dangerous! I think I almost got it working, but my problem is that the character's turn ends immediately after moving, so it can't then execute a "destroy trapdoor" command. It ends up destroying the trapdoor on the start of its next turn instead. I guess I could use a second character to do the check, but how would the second character know the current location of the first character?

Are the in-game help files available out of game? There's a lot of useful info in them, but not being able to ctrl-f makes it really hard to find.
07-05-2020 at 12:41 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
RoboBob3000
Level: Smitemaster
Avatar
Rank Points: 1953
Registered: 10-23-2003
IP: Logged
icon Re: Scripting questions (+2)  
I tried the roach thing some time ago in order to add custom behaviors to basic roach behavior. You're welcome to reuse the code (or give it a read over to understandhow I implemented it): http://forum.caravelgames.com/viewtopic.php?TopicID=38640&page=0#387104

Scared Roach is what you want as your starting point. You'll want to remove the chunks underneath labels that refer to the "flashlight". Anything pertaining to the "flee" state could be removed safely, but isn't necessary. You'll also want to check the imperative settings at the start of the script.

Away from my desktop today, so I can't produce a truly generalized version at the moment.

____________________________
http://beepsandbloops.wordpress.com/
07-05-2020 at 12:46 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1856
Registered: 07-11-2014
IP: Logged
icon Re: Scripting questions (+1)  
quote:
Remlin wrote:
Thanks guys, great info, but please talk me through this a bit more. I've made a character of type Roach, and given it a processing sequence of 1000 and imperatives for Normal Beelining and Deadly, and then Move To Player. Is that all there is to it? Then because I don't want the roach reappearing in a conquered room, I started the character invisible and put "if, wait for event room conquered, end" but that doesn't seem to work. Am I detected room conquer state wrong?

End command permanently KOs the character including if you reenter the room. Its mainly to ensure characters dealing with cutscenes never come back. Instead, after disappearing your character, have a label at the last line of the script and jump to it. Reaching the end of the script stops execution without permanently destroying it.

quote:
Remlin wrote:
For the trapdoors, I didn't know about MyScript variables. Seems powerful and dangerous! I think I almost got it working, but my problem is that the character's turn ends immediately after moving, so it can't then execute a "destroy trapdoor" command. It ends up destroying the trapdoor on the start of its next turn instead. I guess I could use a second character to do the check, but how would the second character know the current location of the first character?

Ah. Yes, good point, the move to commands immediatly pause execution. That makes it trickier, you have to handle movement yourself. Check for a free move (I think there's a command that handles this?) and then the character changes its MyX and MyY variables, this doesnt pause execution so you can then do the trapdoor dropping.

quote:
Remlin wrote:
Are the in-game help files available out of game? There's a lot of useful info in them, but not being able to ctrl-f makes it really hard to find.

Yes, they're html files in one of the folders. If its not in the instal location, try the Caravel folder of Program Files or Users Appdata or wherever thst folder is hidden, not at my PC right now so can't check the exact location.

[Last edited by kieranmillar at 07-05-2020 01:05 AM]
07-05-2020 at 01:03 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dragon Fogel
Level: Smitemaster
Rank Points: 1400
Registered: 06-21-2014
IP: Logged
icon Re: Scripting questions (+3)  
Some of the terminology in scripting is a little unclear.

"Wait for event room conquered" means "wait for a turn on which the room gets conquered". So if there are no conquer tokens, it triggers on the turn when the last monster in the room dies. (Maybe one turn after due to how the processing sequence works? Not sure, I haven't really used it myself.) If you want to check if the room is clear at the start, you want "wait for clean room".

You should also be careful using the End command, as it means the character will never reappear. So you want to be completely sure that there's no situation where you'll be using them again. For instance, if there's a seeding beacon in the room and one of your custom roaches calls the End command, if you hit the beacon the roaches will not be in the room when you return.

If you need to avoid this, use Disappear instead. This does have a minor issue in that a monster that uses Disappear and is on a pressure plate will act as if it was holding down the plate at the start of the room, then act as if it stepped off. (Similarly, a monster that uses Appear will activate plates under it as soon as it becomes visible.)
07-05-2020 at 01:06 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
mauvebutterfly
Level: Smitemaster
Rank Points: 507
Registered: 05-03-2015
IP: Logged
icon Re: Scripting questions (+1)  
If you have a custom monster that shouldn't appear in a room that has already been cleared I would put something like this at the beginning of the script:

if
>wait for room cleared
>end
else
>put the rest of your script here

Note that this will prevent the monster from ever respawning even if a seeding beacon is used.

Using disappear instead of end might make this work with seeding beacons, but I've never tested that myself.

____________________________
106th Skywatcher
07-05-2020 at 01:33 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
disoriented
Level: Smitemaster
Rank Points: 1739
Registered: 08-07-2007
IP: Logged
icon Re: Scripting questions (0)  
Yeah, one thing that confused me is that “wait” type commands act differently when they’re standalone as opposed to when they appear as a condition in an If statement.

____________________________
34th Skywatcher
07-05-2020 at 01:49 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Re: Scripting questions (+3)  
Thanks everyone, I've got the non-required roach working well the way I want. The illusion isn't perfect, because the fake-roach looks in the direction he actually moves instead of the direction he wanted to move, like a real roach would. I see how I can fix that by writing the movement algorithm myself and updating the MyWhatever variables instead of just using "move to player", but that seems like more trouble than it's worth.

The trapdoor dropping character is currently seeming like more trouble than it's worth and I didn't have anything particularly wonderful planned for it anyway, so I'm just going to let that go.

[Last edited by Remlin at 07-05-2020 02:13 AM]
07-05-2020 at 02:13 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 902
Registered: 06-13-2015
IP: Logged
icon Re: Scripting questions (+1)  
Maybe it's too late for this, but here is the primer I wrote on myscripts, if you're interested. The real difficulty with using myscript to drop trapdoors comes if the player gets access to a stunning/pushing weapon, as it needs to be imperative not stunnable or something and detect when it's been pushed around by keeping track of its previous location and gaah. But if it only ever moves under its own power, dropping a trapdoor should be fairly easy? Also, I strongly recommend using myscripts in conjunction with "get natural target" for a custom roach if you want it to respond properly at all to things like decoys, invisibility/stealth, stalwarts/soldiers, etc.

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 07-05-2020 03:14 AM]
07-05-2020 at 03:09 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Re: Scripting questions (0)  
I guess my hope is still to avoid a pile of logic that looks something like:
If target is nw and I can move nw, move nw
Else if target is nw and I can move n, move n
Else...

Thanks to the help here I can at least see how to do the trapdoor dropping and a more realistic roach if I do go that route, and thank you for pointing me at Get Natural Target, seems like a much better input to the "if target is nw" check than using player coordinates.
07-05-2020 at 05:40 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1856
Registered: 07-11-2014
IP: Logged
icon Re: Scripting questions (+3)  
In my hold Beethro Budkin's Big Burrito Butt Blast, I have a scripted Roach that looks like a regular Roach. It does use the built-in movement command because it doesn't need to do any post-movement processing, but it does do a much better job of turning to face the player than your typical scripted monster. Here's the code if you're interested, it's not as bad as it might seem. (The Imperatives are Normal Beelining, Required target and Deadly) (also ignore the In_Flight variable check, that's for the rest of the hold's scripted things)

  If ... 
        Wait for clean room 
     Disappear 
     Go to Skip to End
  If End 
  Appear 
  Imperative 27
  Imperative 3
  Imperative 7
  Set var "faceX" = 0
  Set var "faceY" = 0
  Wait 0
Label Loop
  If ... 
        Wait until var "In_Flight" = 0
     If ... 
           Wait until var "_X" = _MyX
        Set var "faceX" = 0
     Else If 
           Wait until var "_X" > _MyX
        Set var "faceX" = 1
     Else If 
           Wait until var "_X" < _MyX
        Set var "faceX" = -1
     If End 
     If ... 
           Wait until var "_Y" = _MyY
        Set var "faceY" = 0
     Else If 
           Wait until var "_Y" > _MyY
        Set var "faceY" = 1
     Else If 
           Wait until var "_Y" < _MyY
        Set var "faceY" = -1
     If End 
     Set var "_MyO" = (faceX + 1) + (3 * (faceY + 1))
     Move to Player 1,1
     Go to Loop
  If End 
  Wait 0
  Go to Loop

There is no Wait 0 in the loop because the Move to command is the pausing command.

This hold doesn't have any of the components that scripted characters don't play nicely with, which simplifies things a lot.

[Last edited by kieranmillar at 07-05-2020 06:38 PM]
07-05-2020 at 06:29 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Re: Scripting questions (+2)  
I went with something very similar to what kieranmillar suggested, great insight that you could keep the move very simple and just tinker with the direction the roach is facing to make it look much more realistic.

But I've got a fresh batch of questions! First, how are you guys copy/pasting code onto the forums? When I ctrl-c from within the game, nothing gets put on my clipboard.

I'm looking for a way to have an obstacle in my hold, that will later be removed after some condition is met. I could do it with invulnerable characters sitting there blocking (maybe a wubba?), but I'd like something that looks more natural, like an Obstacle entity, or maybe a pile of golem remains. I can't find a scripting way to spawn in or remove anything like that though. Any suggestions?

How do you deal with rooms with no real monsters, only characters that are flagged as required targets? These rooms seem to start off in a cleared state, I guess because there's nothing to kill in the instant the room loads before the scripts with Imperative Required Target have run.
07-23-2020 at 02:35 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 902
Registered: 06-13-2015
IP: Logged
icon Re: Scripting questions (+3)  
Question 1: ctrl+B and ctrl+shift+B are alternate copy and paste commands respectively which copy to and paste from your actual clipboard so that you can copy code from one character to another, or out to a file or forum post, or in from a file or forum post. On this forum the "code" tag will format code the way you see it formatted in posts above.

Question 2: If you just want rock golem rubble, you can generate entity rock golem and attack tile stab each tile you want one to be in, then just put that in an if statement to not spawn them when you want them to not be there. This will make a noise whenever the player enters the room of all the golems dying, though. Or you can use custom character graphics to make your invulnerable wubba character look like something more obstacle-ish. Or you can just have a wall there, but build floor when you want it to be accessible.
To do custom character graphics, click "characters" in the scripting menu of an NPC, then type in a new character name and click 'create character'. From there, select your new character and click "custom tiles" over on the right to import the graphics you want. There are more details somewhere in DROD's help files, I think?

Question 3: The general method is to put a "real" monster such as a roach somewhere in the room, or a conquer token, and if you want the player to not see the roach you can just put a scripted character which attack tile kills the location of the roach and does nothing else. (The attack tile kill command silently removes whatever entity it targets, without any of the usual "death" animations or results. For example, attack tile kill on a construct/golem will remove it without leaving a corpse.)

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 07-23-2020 03:20 PM]
07-23-2020 at 03: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: 1856
Registered: 07-11-2014
IP: Logged
icon Re: Scripting questions (+3)  
quote:
Xindaris wrote:
Question 3: The general method is to put a "real" monster such as a roach somewhere in the room, or a conquer token, and if you want the player to not see the roach you can just put a scripted character which attack tile kills the location of the roach and does nothing else. (The attack tile kill command silently removes whatever entity it targets, without any of the usual "death" animations or results. For example, attack tile kill on a construct/golem will remove it without leaving a corpse.)

I reccomend a spider instead of a roach as your dummy enemy, because it's invisible if you are viewing an uncleared room from somewhere else (by clicking on the map).
07-23-2020 at 06:26 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Remlin
Level: Master Delver
Rank Points: 178
Registered: 04-28-2005
IP: Logged
icon Re: Scripting questions (+1)  
Thanks for the tips! I'd actually already been using an insta-killed roach for the room clear problem (now converted to a spider), but I figured I'd ask and learn the proper way to do it. Oh well :?

Tell me more about custom character graphics please. Is there a way to use an already-existing drod asset? I like the idea here, but it's not going to work if I need to be an artist.

I had a moment of hope when I noticed that Obstacle is one of the options given for the Wait For Item command, even though it's not listed in this reference. To me that implies there might be a _MyScriptF input for Obstacle I could use in a build command. Would anyone know?
07-23-2020 at 10:59 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
disoriented
Level: Smitemaster
Rank Points: 1739
Registered: 08-07-2007
IP: Logged
icon Re: Scripting questions (0)  
RE: Character graphics

If you want to re-use Caravel assets, it's best to ask Mike Rimer for permission.

If it's simple art you need, one of us on the forum would probably be happy to make it for you.

____________________________
34th Skywatcher

[Last edited by disoriented at 07-23-2020 11:21 PM]
07-23-2020 at 11:21 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
kieranmillar
Level: Smitemaster
Rank Points: 1856
Registered: 07-11-2014
IP: Logged
icon Re: Scripting questions (+1)  
quote:
Remlin wrote:
I had a moment of hope when I noticed that Obstacle is one of the options given for the Wait For Item command, even though it's not listed in this reference. To me that implies there might be a _MyScriptF input for Obstacle I could use in a build command. Would anyone know?

Obstacles cannot be built or removed.
07-23-2020 at 11:41 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 902
Registered: 06-13-2015
IP: Logged

File: Invisible.PNG (135 bytes)
Downloaded 1 times.
License: Public Domain
icon Re: Scripting questions (+3)  
I strongly suggest reading DROD's internal help on exactly how to format custom character tiles, but even if you (say) want a custom character that looks like a regular obstacle, you will still need to import custom tiles. It is absolutely true that when your hold is through, before pushing it to the HA's and "proper" publication, you will need to get permission for any official graphics used, but here I'm going to describe the actual, practical steps to "grabbing" such graphics in the first place. It is my understanding and experience that doing this for an in-progress hold is perfectly fine, and I've never had my own use of official graphics for a hold rejected.

To this post, I've attached the "invisible" color. In custom tiles for characters, this particular shade of gray is registered as "transparent" because character graphics don't use transparency. Also, the image attached is exactly the size of a single tile as the character graphics expect it -- 22x22 pixels. To "grab" an image of (say) a particular type of obstacle, make a room full of image floor using this image, put the obstacle on the image floor, and use something like windows's snipping tool (not DROD's internal screenshot--that seems to mess with the image a bit) to grab an image. Then crop it down to the proper 22x22 size the same way it is in-game, and import that for your custom character's graphics.

To do the tiny bit of image editing necessary, you'll want to use an image editor that works on a pixel-by-pixel basis. So: Not windows's awful new paint program. I use old-school mspaint as it was before windows 7, which I'm pretty sure is still available for free download in places.

____________________________
109th Skywatcher

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


[Last edited by Xindaris at 07-24-2020 05:51 AM]
07-24-2020 at 05:44 AM
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: 3330
Registered: 10-06-2005
IP: Logged
icon Re: Scripting questions (+3)  
quote:
disoriented wrote:
If you want to re-use Caravel assets, it's best to ask Mike Rimer for permission.


Mike Rimer has stated this in the private Hold Administrators forum, although I can't seem to find any public post with the same thing yet:
quote:
mrimer wrote:
Going forward, to grease the wheels of bureaucracy, I'm okay with *not* requiring individuals to request permission for reasonable use of copied or modified Caravel graphics being included in their own published holds.


So, he trusts the senior forum members to keep an eye on this sort of thing - but if you want to borrow the roach graphics, or make a pink roach, or anything straightforward like that, go right on ahead.

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


[Last edited by Chaco at 07-24-2020 01:09 PM]
07-24-2020 at 01:08 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
mauvebutterfly
Level: Smitemaster
Rank Points: 507
Registered: 05-03-2015
IP: Logged
icon Re: Scripting questions (+1)  
Yeah, the obvious limitation there is that you do NOT have permission to use DROD assets for anything outside of DROD.

Using DROD assets in your DROD hold will probably be judged as reasonable by the HAs though.

____________________________
106th Skywatcher
07-24-2020 at 05:02 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : 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.