Status
Not open for further replies.

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
So basicly I am creating a smokescreen spell ,and I want it to increase your escape chances.
 

In the BattleManager Module I have this (the things colored in red are my additions)
 

#--------------------------------------------------------------------------

# * Create Escape Success Probability

#--------------------------------------------------------------------------

  def self.escapeRatInc

      @escapeRatInc = 1.0

  end

  def self.make_escape_ratio

    @escape_ratio = ( 1.0 * $game_troop.agi / $game_party.agi) *escapeRatInc

  end


Then I want through a common event to change increase escapeRatIncfrom 1.0 to 2.0 
 

I've tried this

@escapeRatInc = 2.0

$end

but I don't now how to send the value to the other 

*Note - I am less than a beginner to Ruby.

Can anyone help me with a solution ?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,504
Reaction score
8,144
First Language
German
Primarily Uses
RMMV
I've moved this thread to Learning RGSS. Please be sure to post your threads in the correct forum next time. Thank you.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,006
Reaction score
2,274
First Language
English
Primarily Uses
RMMV
In this case, @escapeRatInc is an instance variable you're defining in BattleManager, but common events are run within the Interpreter class, which doesn't have a variable with that name because you haven't defined one.

First, you'll need a setter method for it in BattleManager:

def self.escapeRatInc=(rate)

  @escapeRatInc = rate

end

Then in your common event you can do

BattleManager.escapeRatInc = 2.0
 
Last edited by a moderator:

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
Now I have in BattleManager 

 

def self.escapeRatInc = 1.0

      @escapeRatInc = 1.0

  end

def self.make_escape_ratio

    @escape_ratio = ( 1.0 * $game_troop.agi / $game_party.agi) *escapeRatInc

end

 

And in common event
BattleManager.escapeRatInc = 200.0

$end

But when I use the skill ( and the common event is called) I get this Error Message

Script'Game_Interpreter' line1411: NoMethodError occurred.
undefined method 'escapeRatInc=' for BattleManager:Module
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
867
First Language
German
Primarily Uses
Personally, i would handle it this way:

module BattleManager    def self.escapeRatInc      $game_switches[1] ? 2.0 : 1.0   end endThis way the method will return 2.0 as long as switch #1 is ON and 1.0 otherwise and you just to have manage that switch in your skill.

Also, i advise you to take a look at Trihan's Ruby Tutorial (http://forums.rpgmakerweb.com/index.php?/topic/38900-slip-into-ruby-an-introductory-guide-to-rgss-for-beginners/), because you have some mistakes in your code.
 
Last edited by a moderator:

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
I am not sure If I have solved it yet. I need to do something with the 
rand 

because even if I multiply escape_ratio with escapeRatInc ( had it 1000.0 for testing) the escape sometimes fails...) 

Thanks Lavra

Okay 
it works . Problem Solved
Solution
 

#-------------------------------------------------------------------------- # * Create Escape Success Probability #-------------------------------------------------------------------------- def self.make_escape_ratio @escape_ratio = (1.5 - 1.0 * $game_troop.agi / $game_party.agi) end#-------------------------------------------------------------------------- # * Escape Processing #-------------------------------------------------------------------------- def self.process_escape def self.escapeRatInc $game_switches[1] ? 10.0 : 0.0 end $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name)) success = @preemptive ? true : (rand < (@escape_ratio + @escapeRatInc)) Sound.play_escape if success process_abort else @escape_ratio += 0.1 $game_message.add('\.' + Vocab::EscapeFailure) $game_party.clear_actions end wait_for_message return success endAnd I had the skill turn the switch on.
Thanks everyone
 
Last edited by a moderator:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,006
Reaction score
2,274
First Language
English
Primarily Uses
RMMV
Note that when I said

def self.escapeRatInc=(rate)

  @escapeRatInc = rate

end

(rate) wasn't a placeholder for the value, you actually had to type exactly that, the brackets and word rate.
 

Josephkhland

Extremely Hardfork
Veteran
Joined
May 20, 2015
Messages
140
Reaction score
17
First Language
Greek
Primarily Uses
RMVXA
Note that when I said

def self.escapeRatInc=(rate)

  @escapeRatInc = rate

end

(rate) wasn't a placeholder for the value, you actually had to type exactly that, the brackets and word rate.
I actually tried this aswell. But its okay . I solved it now...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,504
Reaction score
8,144
First Language
German
Primarily Uses
RMMV
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.

Latest Threads

Latest Profile Posts

Still early in development but feel like I'm hitting a wall. Either I can't find plugins to do what I need, or they're paywalled :/
Screenshot-2021-05-02-at-15-07-54.png


Tivadar will help you travel to distant places in Eniko: Ghosts Of Grace

Finally done with the school project, here's the raw video of it. o_O :smile:

Forum statistics

Threads
111,176
Messages
1,058,993
Members
144,423
Latest member
rafaelydubay
Top