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 ?
I've moved this thread to Learning RGSS. Please be sure to post your threads in the correct forum next time. Thank you.
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
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
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
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.
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.