Looking for puzzle scripts

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Looking for puzzle scripts

Post by guo »

Salutations.

I am looking for any and all scripts that can be used for puzzles, no matter how simple. Demos/games with the scripts included would be much appreciated. Anyone have a good starting point?

Regards.
vvight.wordpress.com
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Ok, what about block puzzles? Surfasaurus did it very well. Is there a way to replicate that but on a map with push blocks? I wouldn't know where to begin. Regards.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

While there are plenty of puzzle games, I really can't think of many cases of people posting scripts for a puzzle for other people to use or build on, with the exception of some of the scripts on the ancient Moglery website.

You could also look through puzzle games in the hope of finding something.
Here: games tagged "puzzle" on SS, and a bigger list of games matching a search for "puzzle" (I could add a way to see whether there are scripts...)
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

I wouldnt mind discussing some puzzle formats. what's your poison?
block pushing puzzles are fairly easy if you use zones and NPCs.
You can use NPC movement and avoid zones for example.
Turn pushability on, or if you want them to have some specific behaviour beyond this, use a script.

You can walk an NPC with
"Walk NPC (who, direction, distance)"
http://hamsterrepublic.com/ohrrpgce/doc ... ut-walknpc


make sure to set NPC walk speed to something other than 0.

If you want to check its in the right spot, you can use an NPC and check if it's the NPC at the spot with

"NPC at spot (npc x(NPC), npc y (NPC), number)"
http://hamsterrepublic.com/ohrrpgce/doc ... -npcatspot

but NPCs normally obstruct each other, so you might need

"set NPC obstructs (NPC, off)"
http://hamsterrepublic.com/ohrrpgce/doc ... cobstructs


you can check what Zone is at a spot with

"Zone at spot (npc x (NPC), npc y(NPC), 0)"
http://hamsterrepublic.com/ohrrpgce/doc ... zoneatspot
Last edited by SwordPlay on Fri Jan 12, 2018 1:41 am, edited 2 times in total.
"Imagination. Life is your creation."
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks!

So say I want a puzzle where you must put (perhaps) 6 blocks in the right position, would it be best to run an "each step" or "each tick" script that checks "npc at spot"?

I guess instead of using each step/tick, there could be an "on touch" script that checks the direction the player is pushing from, move the block, and then make the check to see if it's in the right place.. Perhaps rendering the NPC unmovable once it's in the right place (and with an audio cue to alert the player).

As I'm not a code-minded person, what would be the best way to do this without a convoluted series of nested "if" statements?

Image

I always appreciate help. Quid pro quo - if there is anything I can contribute back to those who help, simply ask!
Last edited by guo on Fri Jan 12, 2018 9:28 am, edited 1 time in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

If each NPC has a single position in which it must be placed, then a list of if statements is a perfectly reasonable way to accomplish that. I wouldn't call that convoluted. It could look like

Code: Select all

if (npc x(4) == 5 && npc y(4) == 7 &&
    npc x(5) == 6 && npc y(5) == 6 &&
    npc x(6) == 6 && npc y(6) == 9) then (
Or you have heaps of these blocks, or multiple positions each could go (or multiple indistinguishable NPCs), you could use zones: require that NPC ID X is pushed into zone X. That's easy too, something like:

Code: Select all

variable (id, npc, solved)
solved := true
for (id, 4, 6) do (  # npc id and zone id
  for (copy, 0, npc copy count(id) -- 1) do (
    npc := npc reference (id, copy)
    if (read zone(id, npc x(npc), npc y(npc)) == false) then (solved := false)
  )
)
if (solved) then (...)
Don't use an each-step script, because it's triggered when the hero moves, not when an NPC moves. An each tick (autorun) script is fine.

Oh! And this reminds me of James' Capt'n Squiddy's Bootleg Push-Push (Huh, I didn't realise that there are OHR games James has released which aren't on CP, SS, or the wiki)
His Paladin Traducer and Plip Tamer (public domain) amongst other puzzle games might also be relevant. It seems that James and Mogri have made a lot more puzzle games than anyone else.
Last edited by TMC on Sun Jan 14, 2018 8:57 am, edited 6 times in total.
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

Here is a statue pushing puzzle in a more simple way.

Code: Select all

plotscript,statuen,begin
if (NPC X (0) == 7) 
then (if (NPC Y (0) == 4)
then (if (NPC X (1) == 9)
then (if (NPC Y (1) == 6)
then (if (NPC X (2) == 8)
then (if (NPC Y (2) == 5)
then (if (NPC X (3) == 9)
then (if (NPC Y (3) == 4)
then (if (NPC X (4) == 7)
then (if (NPC Y (4) == 6)
then (set tag (61,on)))))))))))
show text box(378)
end
The script checks, if all the statues are at their right position. This is not triggered automatically, so the player must ask a small figure in the bottom corner of the map, if everything is at the right place. I once played an OHR game, that slowed my old machine down, because it had an "each step script", so I want to stat the script manually to save computing power.

The statues are the NPCs 0 to 4, which the script checks. The positions in my example are (7,4), (9,6), (8,5), (9,4) and (7,6), which can be also seen on the picture here. You can also see, that talking to the statues will give you some hints, where the right place is.
The mentioned text box in the end of the script tells the player, if the puzzle is solved. But therefor the tag (nr. 61 in the example) must be switched on, which will only happen if all the positions are correct.

Golden Sun used a lot of these statue puzzles, but they were too simple.
Attachments
Statue puzzle
Statue puzzle
puzzle.GIF (13.17 KiB) Viewed 7925 times
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

TMC wrote:Oh! And this reminds me of James' Capt'n Squiddy's Bootleg Push-Push (Huh, I didn't realise that there are OHR games James has released which aren't on CP, SS, or the wiki)
Well, dang! I forgot to upload that one! I can remedy that!

Image

The plotscripts are here: https://pastebin.com/raw/mEnPVxGG
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Bird wrote:I once played an OHR game, that slowed my old machine down, because it had an "each step script", so I want to stat the script manually to save computing power.
For such a simple script, that's not a concern. And besides, the script interpreter today is far faster than it was in the DOS days.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Oh my! The quality of replies is fantastic. Thankyou all. I didn't realise we could use if/and statements like that - should make my scripting a little easier from here on in. Also, Cap'n Squiddy is one I'll have to try. I'm a sucker for Sokoban type games.
vvight.wordpress.com
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Here's a simple puzzle idea that I don't really see in OHR games I've played. You should make a puzzle where the hero must get from the bottom of the room to the top of the room. The problem is that there is an NPC (or multiple NPCs) on the other side of the room that mirror your movement. Therefore if you walk straight north the NPC will walk straight south and collide with you blocking your path. If you go west, the NPC will also go west... you get the idea. In order to outwit the mirror NPC you must make it collide with a wall, land on some spikes, fall in a pit or any other mechanic you can think of.

I swear I saw this mechanic used in a Zelda game I played but am having trouble searching for a video to show what I mean.

In order to make this I think you just need to check if the hero is walking in your autorun script. If they are walking then you check what direction they are moving and you mirror it with your NPC(s). If you want to keep the puzzle simple you can just use walls to block NPCs. You'll want the move speed of the NPC to be greater than or equal to the hero. I'm not 100% if this will work properly but if it doesn't then you might need to use the Hero Will Move script ( https://rpg.hamsterrepublic.com/ohrrpgc ... _will_move ) to trigger NPC movement so every move happens simultaneously.

Alternatively you could have this puzzle behave in a turn-based fashion by using an each-step script. Each step you take the script will suspend hero and store the hero's last movement direction. The script will then move the NPC in the mirrored direction one tile. Then the hero movement will resume. I think this is much easier to script, it just depends what you want your puzzles to look like. If you go this route it may be cool to have your mirror NPC be a wall of fire. If you step on this NPC then you are either damaged or burned to death (this will also prevent situations in which the hero becomes trapped with no direction to move as the player can always opt to kill themselves to reset the puzzle).

On another note, I've always been a huge fan of ice-sliding puzzles like you find in Pokemon, Undertale and Zelda. Here's a great yet simple example of an ice-sliding puzzle: https://www.youtube.com/watch?v=yNsuHwVrfOo

I know you're probably avoiding getting too script-heavy but if you wanted to then why not combine the ice-sliding mechanics with the mirror NPC mechanics in order to create increasingly hard puzzles. You could start the puzzles off without ice and begin introducing it once the player has figured out how to overcome the mirror NPC puzzles. Sliding your hero while mirror NPCs only move one tile can allow you to offset your hero on the grid to overcome the puzzle. Or sliding your NPCs in to certain formations can allow you to use them as a wall to prevent you from sliding in to a pit or something like that.

EDIT: I managed to find an example of the Zelda mirror NPC puzzle I mentioned. The behaviour of this puzzle actually works different than how I described and relies on you eliminating the enemies to proceed to the next room. I guess I developed sort of a false memory on how this worked as I haven't played it in so long. Here's a video: https://youtu.be/CcmsCckZyVo?t=11m41s

Whether your puzzle's goal is to navigate a room or eliminate the enemies I think it will be good either way. I kind of think it would be refreshing to see a navigational puzzle as I described earlier. I really enjoy how the Zelda enemies either mirror your direction or mimic your direction based on their colour which is simple to code but adds another layer of complexity to the puzzle.
Last edited by sheamkennedy on Sun Jan 14, 2018 9:15 am, edited 7 times in total.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks Sheam. I really like this idea, and in fact it will work wonders with something else I have planned (involving a particular antagonist).
vvight.wordpress.com
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

guo wrote:Thanks Sheam. I really like this idea, and in fact it will work wonders with something else I have planned (involving a particular antagonist).
Awesome! I look forward to seeing something like this in action.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Hi TMC.

[s]
An each tick (autorun) script is fine.
What's the best way to run an "each tick" script? I already have a map autorun script in effect. I'm thinking make a "while" loop that runs if a tag is off, and checks that the npc(s) is/are in the right position, upon which it sets a tag on (thus stopping the while loop from running). I'd make this as a "script" rather than a "plotscript" and call it from the map's autorun.[/s]

Nailed it.

Regards

edit: I'd also love a new script command "drag npc" or some such, that works exactly the same as "walk npc" but without changing the npcs direction or using any kind of animation. Atm, to save on NPCs, I have 4 different sprites set to the 4 directions of a walkabout set for static objects - eg, up is a rock, right is a vase, down is a crate, left is a barrel. "Walk NPC" means I have to write a separate script for each instance of a pushable object when using a "pull" script on the NPC in question.
(I suppose the easiest option for now would be to have different walkabout sets for each object.)
Last edited by guo on Wed Jan 31, 2018 12:30 am, edited 5 times in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Actually, if you're cramming 4 different sprites into one spriteset, you don't care whether it animates as you move it or not, you just want to walk an npc while preserving its direction. That seems to be something people want to do quite commonly, so probably there should be a more obvious way to do it, or a separate command. It's quite easy to do though: just use "set npc direction" after the "walk npc" command, and it'll override the direction:

Code: Select all

# Replacement for "walk npc"
script, push npc, npc, direction, dist=1, begin
  variable(olddir)
  olddir := npc direction(npc)
  walk npc(npc, direction, dist)
  set npc direction(npc, olddir)
end
Last edited by TMC on Fri Feb 02, 2018 2:32 pm, edited 1 time in total.
Post Reply