Jump to content
Sign in to follow this  
Ferry66

Binding the MP % of an actor to a state?

Recommended Posts

Is it possible to bind the remaining percentage of MP (or TP for that matter) to a state?

 

For example: a mage uses all of its MP and automatically gets the ''Exhausted'' state which will immobilize him, or a warrior uses gets to 50% of its TP and gets a state that lowers its damage.

Share this post


Link to post
Share on other sites

Hmm, have you tried running a conditional via common events? (I get the feeling common events might only run on the map screen though. Unsure)

 

If the above doesn't work you'll probably have to delve into the script editor. Just put the same conditional:

if $game_actors[x]. mp == x

$game_actors[x].state?[x] (actually think this one is for checking not applying but you'll find the right one via google)

end  

 

but stick it in turn end processing found Game_Battle or something.

 

 

(Sorry, can't be more accurate, in work so don't have the editor in front of me)

  • Like 1

Share this post


Link to post
Share on other sites

Hmm, have you tried running a conditional via common events? (I get the feeling common events might only run on the map screen though. Unsure)

 

If the above doesn't work you'll probably have to delve into the script editor. Just put the same conditional:

if $game_actors[x]. mp == x

$game_actors[x].state?[x] (actually think this one is for checking not applying but you'll find the right one via google)

end  

 

but stick it in turn end processing found Game_Battle or something.

 

 

(Sorry, can't be more accurate, in work so don't have the editor in front of me)

Please do elaborate.

I am in need of both a script that adds a state on a % of mp/tp and one that removes said state when over this %.

Tried using several scripts like $game_party.battle_members.each {|a| a.add_state(x)} but they don't do the trick.

Share this post


Link to post
Share on other sites

Hmm, that script call looks more or less how I remember it. I've got an old project where I did something along these lines so I'll edit this later with the right script call.

As for removing it it would be much the same. In pseudocode it would look like:

 

If hp <= 50%

add state

else

remove state

end

 

To give you an idea of how this would work (assuming the snippet is placed in turn end processing):

Turn1: Actor starts with full hp. Takes 70% damage. State applied on turn end.

Turn2: Actor has 30% hp. Actor heals by 30%. State removed on turn end.

Turn3 Actor has 60% hp..... and so on. 

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Yup that script call is correct. so yours should look something like:

 

if $game_actors[1].hp <= $game_actors[1].mhp / 2
$game_party.battle_members.each {|a| a.add_state(1)}

else

$game_party.battle_members.each {|a| a.remove_state(1)}
end

 

And you'll want to place it around line 300 of BattleManager (assuming you haven't made any changes there already)

 

Now, since your game probably has more than one party member your condition (the bit directly after 'if') will need to be a bit different. You might be able to hardcode it by simply copying that for each member (ie. ...actors[2], ...actors[3]) but I think each would interfere with each other. Something worth testing but I think someone better at this stuff is going to have to step in at this point.

  • Like 1

Share this post


Link to post
Share on other sites

May I suggest another syntax, the way I read your code Tarq: if actor 1 has less then half hp add state to ALL battle members.

 

$game_party.battle_members.each { |actor|

  if [1, 3, 5].include?(actor.id) && actor.hp <= actor.mhp / 2

    actor.add_state(1)

  else

    actor.remove_state(1)

  end

 

  if [2, 3, 4].include?(actor.id) && actor.mp == 0

    actor.add_state(2)

  else

    actor.remove_state(2)

  end

}

 

This way you can simply add actor id to the corresponding array. I haven't tested it but I think only some minor modification may be needed.

  • Like 1

Share this post


Link to post
Share on other sites

I thought as much Cookie (I've never had to mess around with multiple party members before)

 

Let us know how you get on Ferry. If there's no problems we can close this.

Share this post


Link to post
Share on other sites

May I suggest another syntax, the way I read your code Tarq: if actor 1 has less then half hp add state to ALL battle members.

 

$game_party.battle_members.each { |actor|

  if [1, 3, 5].include?(actor.id) && actor.hp <= actor.mhp / 2

    actor.add_state(1)

  else

    actor.remove_state(1)

  end

 

  if [2, 3, 4].include?(actor.id) && actor.mp == 0

    actor.add_state(2)

  else

    actor.remove_state(2)

  end

}

 

This way you can simply add actor id to the corresponding array. I haven't tested it but I think only some minor modification may be needed.

Been trying using this:

 
def 
  $game_party.battle_members.each { |actor|
 
  if [1,2, 3, 4].include?(actor.id 1) && actor.mp <= actor.mmp / 2
    actor.add_state(31)
  else
    actor.remove_state(31)

  end 

 

But it doesn't apply the state. What do? :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted