spell that reduces encounter rate

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

spell that reduces encounter rate

Post by Willy Elektrix »

I'm working on an update for Dreg Sector that addresses some of the community's complaints, but I need some help.

I want to make a spell that disables random encounters for certain number of steps. I've found the "suspend random enemies" command, but I'm not quite sure how to create a loop that counts a certain number of steps before activating "resume random enemies".
User avatar
RMSephy
Metal Slime
Posts: 356
Joined: Mon Dec 21, 2009 5:56 pm

Post by RMSephy »

Under the general map settings, you can set an "each step" script that activates each time the player takes a step. And then you can count down a global variable for each step.
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

I've come into another problem. How do I make a spell that can only be triggered outside of combat? Is this even possible?

Likewise, I don't think I can make a spell that triggers a script. I would prefer to have this effect be a spell rather than an item if at all possible.
Last edited by Willy Elektrix on Tue Mar 19, 2013 1:11 am, edited 1 time in total.
User avatar
msw188
Metal Slime
Posts: 783
Joined: Tue Oct 16, 2007 1:43 am
Location: Los Angeles, CA

Post by msw188 »

Custom menu is the only thing I can think of. Eliminate the normal spell menu, and have a custom spell menu driven by plotscripting. I've wanted this sort of functionality for awhile as well, although I haven't really had the time to do much of anything OHR related this past year.
I am Srime
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Spells can't directly trigger scripts, and you can't set a spell to only be usable out of batle.

But I can think of really convoluted ways to achieve both: for the first, set aside one of the stats and have the spell increase that stat (this means the hero target picker comes up though). Have a script run after using the spells menu and check that stat. For the other, have the spell cost an item and use an instead of battle script to remove that item for the duration of each battle.

I'm not expecting you to follow this crazy plan. A much much better idea is to implement this in the engine. (I am not promising anything)
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

I guess I'm doing this as an item rather than a spell. Here is the script I came up with.

The script "step" is run each time the hero moves. The script "radar" is done when the hero activates the item. Unfortunately, the script "radar" freezes when it runs, because it's stuck inside of its do loop infinitely. When I wrote the script, I assumed the hero could still be moved while the loop operated. How do I make this work?

plotscript, radar, begin
suspend random enemies
stepcount := 0
while (stepcount <= 29) do (
)
show text box (382)
wait for text box
resume random enemies
end

plotscript, step, begin
increment (stepcount,1)
end
User avatar
msw188
Metal Slime
Posts: 783
Joined: Tue Oct 16, 2007 1:43 am
Location: Los Angeles, CA

Post by msw188 »

I'd decrement instead, and put the work in the stepping script. Here's quick pseudo code before bed:

[pseudocode]

Code: Select all

plotscript,radar,begin
suspendrandomenemies
stepcount&#58;=29
end

plotscript,step,begin
if&#40;stepcount==0&#41;,then
 &#40;exitscript&#41; #don't risk interfering with other scripts that might suspend enemies
if&#40;stepcount==1&#41;,then
 begin
  text
  resumerandomenemies
 end
decrement&#40;stepcount&#41;
end
UNTESTED! WRITTEN IN <10min!! But this general approach should work out, I'm pretty certain.
I am Srime
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

Thanks MSW188. That worked great!
User avatar
msw188
Metal Slime
Posts: 783
Joined: Tue Oct 16, 2007 1:43 am
Location: Los Angeles, CA

Post by msw188 »

Glad I could help you out!
I am Srime
Post Reply