Skeletons who rise up after defeat every game hour.

redmedved2

Veteran
Veteran
Joined
Nov 2, 2020
Messages
79
Reaction score
19
First Language
Belarusian
Primarily Uses
RMMV
I want to create opponents, let's say they are skeletons that crumble into bones after defeat, but every hour of the game time these bones are reassembled into a skeleton again. And to permanently kill them it is necessary to destroy the tombstone on the location, which causes their resurrection.
Moreover, I want to do this without creating a separate switch for each skeleton and generally use as few common events and switches as possible.

What I've done so far:
In trying to figure out how not to create a separate switch for each skeleton, I accidentally invented the buffering technique for myself. It actually works so that when one skeleton dies, it fills one unoccupied memory cell (a switch, which is a total of 5). That is, if you kill one skeleton, the system looks at which buffer cells (switches) are free and switches one unoccupied.
In my general time flow event, I built in an event that every time minutes >=60 resets minutes to 0, adds one hour, and turns off all resurrection switches, so skeletons are resurrected.

And everything actually works, but then the question arises: why am I writing this here?
Because of that:
1631528982813.png

1)The first page is a basic event page where the battle happens and one switch activates.
2)The second page is a resurrection page created just for animated transition between dead and alive states, it just plays resurrection animation when resurrection switches are off and then goes back to the first page again.
3-7)And all of the rest pages are 5 buffer cells. If Switch 1 is active, 3 page will be active where bones just lies on the ground. If the first 3 switches are occupied, 4 switch will turn on and the 6 page will be active, which do the same, shows lying bones.
8)And also I forgot to add the 8 page which will be active when the tombstone will be destroyed(and there I have to create another switch like "location 1 tombstone" = off).

So I just wanted to know how would you do it and is there any way to reduce the number of pages, maybe I'm missing something.
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
1,010
Reaction score
635
First Language
Polish
Primarily Uses
RMMV
I have the feeling that you are making things difficult. Create skeleton event where the last page have blank page with switch for tombstone#1=ON as condition. If you destroy tombstone nr 1, then make switch tombstone#1 = ON, it make skeletons dissappear. On the pages before, create one page with actual enemy to battle (if killed, then selfswitch A=ON), then on second page with condition selfswitch=A, create a parallel page with "dead sekelton"(lol) graphic, and in page events, create time/respawn commands (simplest way is to use "wait" command). This way you can create skeletons with 3 tabs, it's easy, clean and simple I think.

Edit: But yes, "wait" works only on same map, so the solutions under are fine I think.
 
Last edited:

redmedved2

Veteran
Veteran
Joined
Nov 2, 2020
Messages
79
Reaction score
19
First Language
Belarusian
Primarily Uses
RMMV
I have the feeling that you are making things difficult. Create skeleton event where the last page have blank page with switch for tombstone#1=ON as condition. If you destroy tombstone nr 1, then make switch tombstone#1 = ON, it make skeletons dissappear. On the pages before, create one page with actual enemy to battle (if killed, then selfswitch A=ON), then on second page with condition selfswitch=A, create a parallel page with "dead sekelton"(lol) graphic, and in page events, create time/respawn commands (simplest way is to use "wait" command). This way you can create skeletons with 3 tabs, it's easy, clean and simple I think.
Lol, that's really so simple...I just didn't think that I can use wait command and...thanks. it works well.

But anyway, I will keep my buffer technique. I bet it definitely come in handy in the future.
For something really
difficult.
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
970
Reaction score
432
First Language
english
Primarily Uses
RMMV
(if killed, then selfswitch A=ON), then on second page with condition selfswitch=A, create a parallel page with "dead sekelton"(lol) graphic, and in page events, create time/respawn commands (simplest way is to use "wait" command). This way you can create skeletons with 3 tabs, it's easy, clean and simple I think.
issue with this is the parallel page will only run while still on that map.

3 page event, page 1 for active skeleton, no page condition, on win set a variable to 3600.
page 2 for pile of bones, page condition variable >= 1.
page 3 for tombstone switch page condition when the skeleton is perma-dead.

then you have a common event for the 1 hour respawns running parallel
(this way the respawn time will count down while your on any map)
wait 60 frames (1 second)
control variable -1 (3600 seconds = 1 hour)

you'll need 1 variable for each skeleton to track their respawns separately.
1 switch for each tombstone.
only 1 common event total that controls all the variables.
(if you have a common evented time system already you can work this into that same event)

if something like sleeping at an inn or camp site is supposed to skip the respawn time ahead you just have those events change the variables. when variable hits 0 the skeleton respawns.
if 1 hour game time is only like 20 minutes real time you just use a different number for the variable,
ie: 60sec * 20min = 1200
 
Last edited:

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
271
Reaction score
374
First Language
French, German
Primarily Uses
RMMZ
The wait command only works as long as the player remains on the same map, though. As soon as the player leaves the map and returns, the respawn timer will restart from scratch.

One way to solve this, is to create a variable named "Respawn Clock", and create a Parallel Process Common Event that uses a wait command for 60 frames, and increases the Respawn Clock by 1.

When the skeleton gets defeated, you create a variable and set its value to the current Respawn Clock + how many seconds it should remain down.

In your "skeleton dead" event page, you'd check if the Respawn Clock is now greater or equal the value of your skeleton variable, and set the Self Switch to OFF to revive the skeleton.

Since you didn't want to create a new switch for each skeleton, I imagine you don't want to do that for variables either. There's a little trick we can use: we'll use the Self Switch to make our very own "Self Variable".

Simply execute following script:
JavaScript:
var key = [this._mapId, this._eventId, SELFSWITCH_ID];
$gameSelfSwitches._data[key] = $gameVariables.value(VARIABLE_ID) + 60;

SELFSWITCH_ID is the ID of the Self Switch. This is a letter from "A" to "D".
VARIABLE_ID is the ID of the "Respawn Clock" variable. This is a number, for example 1.

This code saves the value of the Respawn Clock + 60, so the skeleton will remain down for a minute. You can change 60 to any number you want.

The above script will automatically turn the Self Switch ON. Due to how JavaScript handles data, any Switch with a value that isn't 0 will be ON. Also, once you set the Self Switch to OFF, the timer value you saved into it will be deleted.

To retrieve the value of your "Self Variable", simply execute this script:
JavaScript:
$gameSelfSwitches._data[[this._mapId, this._eventId, SELFSWITCH_ID]];

You can also do this directly inside a Conditional Branch:
JavaScript:
$gameVariables.value(VARIABLE_ID) >= $gameSelfSwitches._data[[this._mapId, this._eventId, SELFSWITCH_ID]];
 

redmedved2

Veteran
Veteran
Joined
Nov 2, 2020
Messages
79
Reaction score
19
First Language
Belarusian
Primarily Uses
RMMV
The wait command only works as long as the player remains on the same map, though. As soon as the player leaves the map and returns, the respawn timer will restart from scratch.

One way to solve this, is to create a variable named "Respawn Clock", and create a Parallel Process Common Event that uses a wait command for 60 frames, and increases the Respawn Clock by 1.

When the skeleton gets defeated, you create a variable and set its value to the current Respawn Clock + how many seconds it should remain down.

In your "skeleton dead" event page, you'd check if the Respawn Clock is now greater or equal the value of your skeleton variable, and set the Self Switch to OFF to revive the skeleton.

Since you didn't want to create a new switch for each skeleton, I imagine you don't want to do that for variables either. There's a little trick we can use: we'll use the Self Switch to make our very own "Self Variable".

Simply execute following script:
JavaScript:
var key = [this._mapId, this._eventId, SELFSWITCH_ID];
$gameSelfSwitches._data[key] = $gameVariables.value(VARIABLE_ID) + 60;

SELFSWITCH_ID is the ID of the Self Switch. This is a letter from "A" to "D".
VARIABLE_ID is the ID of the "Respawn Clock" variable. This is a number, for example 1.

This code saves the value of the Respawn Clock + 60, so the skeleton will remain down for a minute. You can change 60 to any number you want.

The above script will automatically turn the Self Switch ON. Due to how JavaScript handles data, any Switch with a value that isn't 0 will be ON. Also, once you set the Self Switch to OFF, the timer value you saved into it will be deleted.

To retrieve the value of your "Self Variable", simply execute this script:
JavaScript:
$gameSelfSwitches._data[[this._mapId, this._eventId, SELFSWITCH_ID]];

You can also do this directly inside a Conditional Branch:
JavaScript:
$gameVariables.value(VARIABLE_ID) >= $gameSelfSwitches._data[[this._mapId, this._eventId, SELFSWITCH_ID]];
I'm sorry to admit this, but I really can't figure it out here, despite how detailed you've described everything. I created a simple event to test if the script works, where the first page is the script, and the second is activated by a self switch. I run the time flow with a respawn clock+1 each second, I activate the event, but after 2 seconds nothing happens, the switch doesn't toggle.
1631558041247.png
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
271
Reaction score
374
First Language
French, German
Primarily Uses
RMMZ
I see that you used
JavaScript:
var key = [this._mapId, this._eventId, A];
but it should actually be:
JavaScript:
var key = [this._mapId, this._eventId, "A"];
The A for SELFSWITCH_ID must be wrapped in single quotes (') or double quotes ("), for example: "A" or 'A', but not just A.

I'm sorry I didn't explain properly.
 

redmedved2

Veteran
Veteran
Joined
Nov 2, 2020
Messages
79
Reaction score
19
First Language
Belarusian
Primarily Uses
RMMV
I see that you used
JavaScript:
var key = [this._mapId, this._eventId, A];
but it should actually be:
JavaScript:
var key = [this._mapId, this._eventId, "A"];
The A for SELFSWITCH_ID must be wrapped in single quotes (') or double quotes ("), for example: "A" or 'A', but not just A.

I'm sorry I didn't explain properly.
I honestly do not know what the problem is, because I almost never used scripts, but I do not understand how to set up this whole system.

In the time system, I set up that every 60 frames the system adds+1 to Respawn clock variable.

I changed that script, added quotes and get it to work. But the problem is that this event turns on the selfswitch not after one respawn clock+60, but just after the duration of one respawn clock(60 frames). I changed the duration of the game minute from 60 frames to 200 for example to make sure that this script always turns on the switch in exactly one respawn clock duration. And even this was okay because I could just create another clock and set the duration of the respawn clock to like 3600(one real minute).

But when I try to use that script not on a test event, but on an enemy event I just don't know how to use it properly. What I've done so far:
1631732083652.png
Basic event page. When the enemy touches you, the battle played, then selfswitch "B" turns on and selfswitch "A" goes on the timer. (at least it should)
1631732097193.png
The second page is blank when the enemy is down. Is should be active only while selfswitch A is not active yet(the time hasn't pass).
1631732114774.png
When switch A activates, the animation playing and all the switches turn off, so the event get back to the first page.

But in fact, when I defeat the enemy, the event goes straight to page three. That is, the script activates switch A immediately, without even waiting for 60 frames.
I'm sorry because I have no idea how these scripts work. It's really weird that in almost identical events the script works differently. Like there:
1631732765883.png
it waits 60 frames and then turns on the switch to activate the second page.
And there:
1631732083652.png
it doesn't wait 60 frames and after battle turns on the switch immediately. Maybe because I change the page to 2? But then I don't know how to change enemy sprite to "defeated" without changing the page.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
271
Reaction score
374
First Language
French, German
Primarily Uses
RMMZ
But in fact, when I defeat the enemy, the event goes straight to page three. That is, the script activates switch A immediately, without even waiting for 60 frames.

That is correct. Writing a value to a Self Switch will turn it ON. That's why you don't need Self Switch B for this case. I'm sorry I didn't explain that properly.


Here's an example of how this should work:
This is a very simple example, where the skeleton dies as soon as you "talk" to it.

Common Event
Trigger: Parallel
Screenshot 2021-09-15 232014.png

My Respawn Clock has ID 1, but in your case it should be 82, I think.

The clock updates every 60 frames (1 second).


Skeleton Event (Page 1: Skeleton alive)
Screenshot 2021-09-15 232156.png

$gameVariables.value(1) should be $gameVariables.value(82) in your case.

This will turn Self Switch A ON.

The + 5 means that this enemy respawns after 5 seconds, because the clock is set to 1 second, and we wait for 5 updates. You can change this to whatever value you want, such as + 60 for 60 seconds of respawn time.

Note: It's possible that the enemy respawns 1 second earlier when the script is executed shortly before the clock updates. If this is not good enough, we can reduce the Respawn Clock Wait to for example 6 frames, but then we need to change the + 5 to + 50 (50 * 6 frames = 300 frames = 5 seconds). With a 6 frames clock, the skeleton might respawn 0.1 seconds earlier instead. Most people shouldn't notice the difference.

Although I don't think an error of +- 1 seconds is significant, but that depends on you.


Skeleton Event (Page 2: Skeleton dead)
Conditions: Self Switch A
Trigger: Parallel
Screenshot 2021-09-15 232820.png

Again, $gameVariables.value(1) should be $gameVariables.value(82) in your case.

The Trigger must be Parallel, so the event can check if enough time has passed (5 seconds). Then the skeleton will respawn by turning Self Switch A OFF.



I hope this helped.
 
Last edited:

redmedved2

Veteran
Veteran
Joined
Nov 2, 2020
Messages
79
Reaction score
19
First Language
Belarusian
Primarily Uses
RMMV
That is correct. Writing a value to a Self Switch will turn it ON. That's why you don't need Self Switch B for this case. I'm sorry I didn't explain that properly.


Here's an example of how this should work:
This is a very simple example, where the skeleton dies as soon as you "talk" to it.

Common Event
Trigger: Parallel
View attachment 201362

My Respawn Clock has ID 1, but in your case it should be 82, I think.

The clock updates every 60 frames (1 second).


Skeleton Event (Page 1: Skeleton alive)
View attachment 201363

$gameVariables.value(1) should be $gameVariables.value(82) in your case.

This will turn Self Switch A ON.

The + 5 means that this enemy respawns after 5 seconds, because the clock is set to 1 second, and we wait for 5 updates. You can change this to whatever value you want, such as + 60 for 60 seconds of respawn time.

Note: It's possible that the enemy respawns 1 second earlier when the script is executed shortly before the clock updates. If this is not good enough, we can reduce the Respawn Clock Wait to for example 6 frames, but then we need to change the + 5 to + 50 (50 * 6 frames = 300 frames = 5 seconds). With a 6 frames clock, the skeleton might respawn 0.1 seconds earlier instead. Most people shouldn't notice the difference.

Although I don't think an error of +- 1 seconds is significant, but that depends on you.


Skeleton Event (Page 2: Skeleton dead)
Conditions: Self Switch A
Trigger: Parallel
View attachment 201364

Again, $gameVariables.value(1) should be $gameVariables.value(82) in your case.

The Trigger must be Parallel, so the event can check if enough time has passed (5 seconds). Then the skeleton will respawn by turning Self Switch A OFF.



I hope this helped.
Thank you very very much. Thanks to your efforts I finally figured it out and it works just perfect. The whole system I was going to break down into 8 pages and lots of switches, you did in a couple lines of code and 1 variable. You are simply the best.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
271
Reaction score
374
First Language
French, German
Primarily Uses
RMMZ
I'm glad I could help.
 

Latest Threads

Latest Profile Posts

One uncomfortable truth that has withstood the test of time, is how most people will stand by while they see a crime happening, unless it's illegal to stand by. We probably wouldn't have stories about "special heroes" or games about heroes if the "everyday common folk" were largely capable of being heroes. Heroes face dangers that most people are not willing to.
I'm having toooo much fun designing the new MP (Mental Psyche) system. I've only worked it out for enemies so far, but it's fun to stun them, then go after their MP and delete them instead to farm for better item drops.
anyone know of a place I can promote my game? sorta like game awards but for indie devs, like a place where I can drop a trailer and like stir up some hype
Doing RPG Maker News for 17th October 2021

That moment when you came up with a very good game title, but when you searched it, it has already been used... T.T

Forum statistics

Threads
115,881
Messages
1,093,685
Members
151,124
Latest member
jonahcisco
Top