Hp cannot fall below one

Status
Not open for further replies.

Hinorashito

Apprentice
Member
Joined
Feb 14, 2013
Messages
130
Reaction score
14
First Language
english
Primarily Uses
I have a character in my game with a skill called valor which puts a state on him that makes him resist death and so he cant be killed. How would I make it so that while this state is active no matter what happens his hp absolutely cannot fall below 1? when hes at 0 hp he is still standing and can fight but for various reasons the skill will work without issue if I can make it so that when the state is applied his hp cant go below 1 any ideas how I can accomplish such a feat?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Find this script in Game_BattlerBase:

def change_hp(value, enable_death) if !enable_death && @hp + value <= 0 self.hp = 1 else self.hp += value end endReplace it with this:

def change_hp(value, enable_death) if (!enable_death || state?(15)) && @hp + value <= 0 self.hp = 1 else self.hp += value end endbut replace the 15 with whatever id your state is.Then anybody who has that state will have a minimum hp of 1.
 

Hinorashito

Apprentice
Member
Joined
Feb 14, 2013
Messages
130
Reaction score
14
First Language
english
Primarily Uses
ok shaz goddess of the scripts lol let me go check real quick.

Hmm thats odd it did not work? it still goes to zero i put it where you said and changed the 15 to the in my case state 29
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Are you battle testing? Did you save the game first?

Edit ... okay, some of the scripts change hp directly, rather than calling that method.

So, change that back to what it was, and find this instead:

Code:
  def hp=(hp)    @hp = hp    refresh  end
and change it to this:
Code:
  def hp=(hp)    @hp = hp    @hp = 1 if hp <= 0 && (!enable_death || state?(29))    refresh  end
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
see my edited post :)
 

Hinorashito

Apprentice
Member
Joined
Feb 14, 2013
Messages
130
Reaction score
14
First Language
english
Primarily Uses
hmm im still looking is that line of code in the battler base? cause I cant seem to locate it
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yep. Search Game_BattlerBase for def hp=.


You're adding a new line to the method, not looking for an existing line to change.
 
Last edited by a moderator:

Hinorashito

Apprentice
Member
Joined
Feb 14, 2013
Messages
130
Reaction score
14
First Language
english
Primarily Uses
okay here is the error code I get 

line 468 name error occured undefined local variable enable death or something like that.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Ah, silly me. Not my day for scripting, it seems.

Do this instead:

Code:
  def hp=(hp)    @hp = hp    @hp = 1 if hp <= 0 && state?(29)    refresh  end
 

Hinorashito

Apprentice
Member
Joined
Feb 14, 2013
Messages
130
Reaction score
14
First Language
english
Primarily Uses
Yay it works perfect no matter how much of a beating my knight takes he just wont die lol thank you shaz your the best.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
It took us a while, but we finally got there ;)


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.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top