Help - Search - Members - Calendar
Full Version: Status effects inflicted as chance instead of 100%
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Vexus
This is something that I find crappy because by default if you get hit you'll get poisoned unless your fortunate enough on having higher strengths over it.

I prefer it as a chance and so I was going to do it via an event.

Now the problem is how can I know which will be the target? The rest of the event is fairly easy you just need to make a random variable and a conditional to your specific percentage then inflict the status effect if it succeeds.

Anyone know what could I do?

Thanks.
Jens of Zanicuud
If you intend to do it via common event, there's a rather simple way (well, more or less)

1. add this line just below Scene Battle 1,

CODE
class Scene_Battle
attr_reader :active_battler #add this line
def main #etc, etc, etc


2. in the common event, target id is:

CODE
$scene.active_battler.current_action.target_index


Do percentage calculation in Variable X (where X is a number) then:

>Conditional branch: if Variable X == tot (or anything else) then

call script:

CODE
battler = $scene.active_battler
tgt_id = battler.current_action.target_index
if battler.is_a?(Game_Actor)
tgt = $game_troop.smooth_target_enemy(tgt_id)
else
tgt = $game_party.smooth_target_actor(tgt_id)
end
tgt.add_state(ID)


>end branch

Where ID is the state id.

I hope this was clear enough...

Jens
Vexus
The percentage calculation got me a little confused.

So I call the variable x by random number or fixed value? Like if it was it's actual percentage of working?

And by conditional branch if x variable is equal or higher, equal or less? I know how to make it with a random variable but the percentage value is a bit confusing how to make it on conditional branch.

Thanks jens.
Jens of Zanicuud
Let's say you want Poison to hit in the 35% of cases.

Variable[X] = Random number from 0 to 100

>If Variable[X] < 35

call script

>branch end

This is what I meant.
I'm sorry to have been so confusing...

Jens
Vexus
Ok thanks I'll try it out now and don't worry hehe smile.gif

[Edit]

I think it worked (It took the bite to poison target 3 tries at 30% chance).

All I couldn't understand how to implement was:

QUOTE
2. in the common event, target id is:

CODE
$scene.active_battler.current_action.target_index


But the script call you posted at the bottom from what I could understand does it on it's own.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.