The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Tutorials and Eventing => Topic started by: hexgame on May 13, 2011, 01:51:19 AM

Title: Event wait timers to continue while off map?
Post by: hexgame on May 13, 2011, 01:51:19 AM
Now in the correct section.

So, I have resource nodes in my game, which have wait timers to respawn after you harvest them. When I leave the map, the event page with the respawn timer resets. Is there a way to avoid this? I'd like for them to continue while on a different map.

I'm not sure if this can be done just from eventing, but I'm sure a script would be a lot easier to maintain (if its possible that is) for each resource node.
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 13, 2011, 04:31:29 AM
Well, you could do it with variables. All you need to do is start the timer like this once the resource is harvested:

@>Conditional Branch: Variable [XXXX: Timer] > 120
      @>Do all the stuff to harvest the resource...
      @>Control Variables: [XXXX: Timer] = 0
      @>Control Switches: [YYYY: Hidden Timer] = ON
      @>
  :  Branch End
     
Now make a parallel process common event triggered by the YYYY: Hidden Timer switch:

@>Wait: 60 frame(s)
@>Control Variables: [0XYZ: Timer] += 1
@>

The 120 in the first event is just the amount of time in seconds you wanted it to wait. So that would be two minutes. If you wanted it to be 7 minutes and 24 seconds, then it would be 444, and so on.

Depending on how many resources you have, it could get pretty bulky and tedious, but it shouldn't be too laggy.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 13, 2011, 05:17:08 AM
Am I doing this correct? Because I can't seem to be able to mine them now.


(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi1189.photobucket.com%2Falbums%2Fz423%2FxPerky%2Fminingrespawn.png&hash=5a2d834cd007a1a3ca3e805c11d0f04366177d01)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi1189.photobucket.com%2Falbums%2Fz423%2FxPerky%2Fminingrespawn2.png&hash=8b881132191552e96dbe2c971818c7a176de015e)
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 13, 2011, 05:32:45 AM
Well, the first time you need to manually set the variable to > 60. So, when the game starts or whatever you can set the variable to 61. Either that or you could use a self-switch at the top of the event like this:

@>Conditional Branch: Self-Switch A is OFF
      @>Control Variable: [0005: Mining Respawn] = 61
      @>Control Self-Switch A = ON
      @>
  :  Branch End

That would be right above it on the same page, and it would just make it so that the very first time you automatically get it.

The other problem with your event is that your variable and switch operations are outside of the conditional branch. That means the timer will be reset everytime the player checks for ore, even if it was before the time would have run out. That part should be inside the Timer conditional branch, right below the Mining Conditional Branch and above the Else.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 13, 2011, 05:56:42 AM
Perhaps its me being so sleep deprived, but I still can't get this to work. If I set the timer conditional branch on top, I can't gather the ore. If I set the pickaxe conditional branch, I can't get the timer to start. I tried many different variations, mixing around the events, but those didn't work either.

I think I may need someone to show me a working picture of the event similar to mine. If that isn't too much to ask.
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 13, 2011, 03:23:02 PM
I've attached a demo. I set the time to only be 30 seconds so you can test it easier. You can buy a pickaxe from the blue haired vendor.

The timer is in the first common event.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 13, 2011, 06:59:34 PM
Thanks for all your help MA, you're probably one of the most helpful members in all the rpg maker communities. I have one more question though. I toyed around with the demo a bit before I went to work, and it seems to work nicely. I've added a self switch to the event so once harvested, it removes the graphic until it respawns. I can see now why my approach wasn't working, and I've learned a lot, thank you!
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 13, 2011, 07:10:39 PM
I'm always glad to help :) Well, usually anyway. There's no question in that post though, so I will assume that you were going to ask how to make it so the graphic would disappear but figured it out on your own and forgot to take that sentence out of the post.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 13, 2011, 07:16:37 PM
I'm always glad to help :) Well, usually anyway. There's no question in that post though, so I will assume that you were going to ask how to make it so the graphic would disappear but figured it out on your own and forgot to take that sentence out of the post.

Oh whoops, yeah you got it. xD
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 14, 2011, 12:40:34 AM
Sorry for the double post, but I'm on the verge of ripping my hair out. So, I got home from work, all excited that the resources would now respawn. I did a simple copy and paste with new renamed variables and switches. Loaded up my game, and the ore didn't respawn. Loaded up yours, and it did.

Rechecked all variables, conditional branches and switches compared to yours, exactly similar, yet different results. I'm quite confused.


(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi1189.photobucket.com%2Falbums%2Fz423%2FxPerky%2Fminingprob1.png&hash=a7202d5c9b429c7789a2bd65b10175976261af42)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi1189.photobucket.com%2Falbums%2Fz423%2FxPerky%2Fminingprob2.png&hash=8a89e8b26774746474e8a1f2bc55b9b70b37e82e)

Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 14, 2011, 12:49:14 AM
They do look the same to me. Did you remember to copy the common event as well?
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 14, 2011, 12:55:28 AM
They do look the same to me. Did you remember to copy the common event as well?

Yup, I have it. Changed the variable in it and everything.
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 14, 2011, 12:57:49 AM
Changed the trigger switch too?

I'm confused about your second page too, really. Almost all of it is unnecessary, aside from the variable check and turning Self-Switch B off. You should also put in a few wait frames since it won't need to check all the time. But as far as I can tell, the extra stuff you have would only cause a real problem if the player didn't have a pickaxe - it wouldn't cause the problem you are speaking of.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 14, 2011, 01:01:53 AM
Changed the trigger switch too?

Wow I'm an idiot...! Had it set under the wrong switch, >.< Sorry for wasting your time lol.
Title: Re: Event wait timers to continue while off map?
Post by: modern algebra on May 14, 2011, 01:03:07 AM
No worries. I also edited my last post with some comments about your second page.
Title: Re: Event wait timers to continue while off map?
Post by: hexgame on May 14, 2011, 01:07:20 AM
No worries. I also edited my last post with some comments about your second page.

Yeah, I know. I'm still toying around with them. Thanks for your help once again. :)