How to make a Trolling Treasure Chest

Status
Not open for further replies.

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
I'm trying to make a puzzle in which every time you move, a treasure chest runs away from you. If you can manipulate the chest into the right spot, you can win it's treasure. It's much easier to accidentally push it down a chasm, however. I'm admittedly a script novice using Victor's pixel movement script, which might complicate things. Any ideas about how this might be accomplished?
 

orochii

Abomination of life, or life itself.
Veteran
Joined
Apr 29, 2012
Messages
652
Reaction score
364
First Language
Spanish
As I tend to say... maybe not the best way, but you can make a parallel process event. This event would have the following inside:

<>Variable operation: [varX] set Other->Step number<>Conditional branch: [varX] != [varY]  <>Variable operation [varY] set var[varX]  <>Event custom movement: TrollingChest <>Move away from player (Don't remember exact words for commands, but this is the rough idea).You would probably want to use a non-self switch for this chest too, to ensure that the parallel proccess is disabled too, instead of the chest only.

Hope it helps,

Orochii Zouveleki
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
Regularly you could simply activate custom autonomous movement on the chest-event and have it move away from the player.


That is for regular movement however, I don't know if the move route commands work together with the pixel movement script, you'll have to test that.
 

d_a_renoir

Veteran
Veteran
Joined
Jun 12, 2012
Messages
237
Reaction score
27
First Language
English
Primarily Uses
And don't forget to add an event on the "right spot" to make it stop moving. You might want to test the above suggestions first because I don't know if the pixel movement script affects the other commands or not.
 

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
As I tend to say... maybe not the best way, but you can make a parallel process event. This event would have the following inside:

<>Variable operation: [varX] set Other->Step number<>Conditional branch: [varX] != [varY]  <>Variable operation [varY] set var[varX]  <>Event custom movement: TrollingChest <>Move away from player (Don't remember exact words for commands, but this is the rough idea).You would probably want to use a non-self switch for this chest too, to ensure that the parallel proccess is disabled too, instead of the chest only.

Hope it helps,

Orochii Zouveleki
Thanks, I'll give this a shot on my lunch break today.

The pixel script doesn't affect any other movement besides the player, unless commanded to do so with a comment. Any event can be made to be a pixel mover (move commands will move only in 4px increments, like the player).
 

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
I made some progress, it sort of functions, but it's not quite there.

My code starts off like this.

@>Control Variables: [0006:playerX] = Player's Map X@>Control Variables: [0007:playerY] = Player's Map Y@>Control Variables: [0008:trollX] = [TrollChest]'s Map X@>Control Variables: [0009:trollY] = [TrollChest]'s Map Y@>Control Variables: [0008:trollX] -= Variable [0006:playerX]@>Control Variables: [0009:trollY] -= Variable [0007:playerY]This will store the X and Y for both the player and the troll chest. It then subtracts the player's X and Y from the troll chest's X and Y, leaving the distance between them. Though it stores over trollX and trollY, which is very irritating. Is there any way I can have this store to a different variable? I want to take trollX - playerX, and store into distanceX.

Anyways, the rest of the code:

@>Conditional Branch: Variable [0008:trollX] == 2@>Set Move Route: [TrollChest] (Skip): : $>Move Right@>@>Conditional Branch: Variable [0008:trollX] == 1@>Set Move Route: [TrollChest] (Skip): : $>Move Right@>It just does this basic thing for the 4 cardinal directions. What it intends to say is "If player is ever within 2 tiles of TrollChest, move him away from player."

The problem comes in when the chest gets to a corner. It isn't smart enough to know it's running into a wall, so it gets stuck and is easily approached. Ideally, you only capture it when you reach the end of the puzzle, where I can simply turn the behavior off.

If there is a way to store (trollX - playerX) = distanceX, then I could activate Event Touch events manually placed in corners via switch for the chest to be moved out of the corner. Ideas?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
If there is a way to store (trollX - playerX) = distanceX, then I could activate Event Touch events manually placed in corners via switch for the chest to be moved out of the corner. Ideas?
You need two steps to do that


1) Var distX = trollX


2) var distX -= playerX


(and the same for Y)


Edit: But I still think you should use autonomous movement instead of this complex checking...
 
Last edited by a moderator:

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
The problem with autonomous movement is the chest will still get stuck on edges like in the following picture (I know how to screenshot, but this is running on a computer without net access):

 

DuncanS

Veteran
Veteran
Joined
Sep 18, 2013
Messages
160
Reaction score
96
First Language
English
Primarily Uses
You can check to see if the next tile is passable before the chest tries to move there:

Code:
# Check if the tile one to the left of the chest is passable (@event_id selects the current event)# The 6 is the direction the tile is passable from - 6 is right. Think 2, 4, 6, 8 on the numpad@>Conditional Branch: Script: $game_map.passable?($game_events[@event_id].x - 1, $game_event[@event_id].y, 6)   # move one tile to the left  @>Set Move Route: This event(Wait)   :              : $>Move left : Else  # check another direction the same way or stop if there are no moves left : Branch End
 

orochii

Abomination of life, or life itself.
Veteran
Joined
Apr 29, 2012
Messages
652
Reaction score
364
First Language
Spanish
...Or you can just check the "Skip if cannot move" option. That way the chest will always move away from the player, without these issues. It will run from the player always unless completely cornered.

But anyway,

Orochii Zouveleki

PD.: Is the step count incompatible with the pixel movement script?
 

DuncanS

Veteran
Veteran
Joined
Sep 18, 2013
Messages
160
Reaction score
96
First Language
English
Primarily Uses
If I understood the OP correctly, he's trying to make the chest run away until it's forced into a specific location - autonomous movement makes that difficult to accomplish as the movements are predictable.

Taking that into account, you're right that you can tick the "skip if cannot move" option, the trick is working that into a function that then searches for an alternative direction to move in, since once the skipped Move route is called there is no flag to backtrack through the function without setting up multiple parameters to hold the chest's original and final locations.

That said, maybe I'm overanalyzing it :p . If you have a non-complex way of setting the event up without scripting, I'd be really interested to see how it's implemented!
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
Basically, it is extremely difficult to make a "runaway" script for a random map - the chest will become stuck sooner or later depending on the map.


It would be much easier to make such a script for a specific map, checking the coordinates against specific dead-ends and then use special moveroutes to get the chest out of there.


I suggest you design the map first, keep in mind where the player can go and how the chest will react to that based on default movement.


Then make the chest event, checking coordinates where the player might trick the chest into the wrong position and use fixed moveroutes to prevent that before switching back to the general runaway route.
 

orochii

Abomination of life, or life itself.
Veteran
Joined
Apr 29, 2012
Messages
652
Reaction score
364
First Language
Spanish
I was thinking that the chest could be cornered anywhere, not just on a certain specific spot (which will need some graphical clarification, like sticky floor or something!). But yeah, as you people say, any dead-end will leave the chest completely cornered. It could work just adding a conditional for each of those dead-end locations, and make the chest jump over the player or something.

I also thought of this chest like "you make a step, chest moves", not "chest runs from you anyways". That's why I suggested checking any step count change. But it could not work properly with a pixel movement (something I still don't have clear).

So yeah,

Orochii Zouveleki
 

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
I also thought of this chest like "you make a step, chest moves", not "chest runs from you anyways". That's why I suggested checking any step count change. But it could not work properly with a pixel movement (something I still don't have clear).
This is exactly what I want, but only when you are within 2 tiles of the chest. I have the code working perfectly to make it run away. I have a variable storing the distance X and Y, and calculates where the player is in relation to the chest. When you are 2 tiles away, it takes a step away from you. So THIS is working as I intended. The pixel movement from the player has no affect at all.

Struggling with implementing your code DuncanS... gonna keep experimenting with it.

These corners are a tricky pickle. It looks like the code from DuncanS could work if I could implement it properly.
 
Last edited by a moderator:

RZephyr07

Villager
Member
Joined
Sep 9, 2013
Messages
28
Reaction score
1
First Language
English
Primarily Uses
Got it working almost perfectly. I'll post a demo later. It involved 3 series of checks... a basic check to move the chest away from the player, a second check to see if the chest is against a wall, and a third check to see if the chest is against 2 walls (a corner). The chest behaves exactly how I wanted it and can navigate complex mazes with ease... there's a visual glitch where you can kind of catch up to it if you really work a corner right, but it is still entirely serviceable without involving even more complicated parallel process checks.
 

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
No need to double post, nor post a demo. If you solved it, that's great. Report the topic to be closed next time.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top