Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Trying to make a weird heal type item in RMXP

xctive

Member

Ok so what I am trying to do is make an item that when you have it in your inventory and you get knocked out it doesn't go gameover and you heal and the item gets removed. Ive tryed to do this alot of different ways but can't seem to get it to work it allways goes gameover :sad: . Does anyone have any ideas on how i could get this to work.
 
I'm not sure if you want this in battle or on the map.
I know on the map you can change the party's status to Death without going to the GameOver screen. So when you add the item to the inventory just inflect death on everybody. You'll have to use a another event that waits for you to heal to remove the item.

Edit:
You can use a common event with a conditional branch that looks like this
@>Conditional Branch:[Hero] is [Death] inflicted
@>
:else
@>Remove items: [your item],-1
@>
:end branch
 

xctive

Member

So you get the item which is a little stone that can be used only once. But you can get more for a really high price. What it does is in battle if you have it in your inventory and then you die it will bring you back to life. Well thats what i want it to do. does that make sence?
 
Not sure if this works 100% of the time.
-First you need a switch, call it "Fairy Bottle" or something.
-Turn it on when you receive the item.
Go to your troop page and make an Event page with the condition fairy bottle switch is on.
When the players are dead. Heal whoever, however. Remove the item. In the case you have more then one use a conditional branch to turn off the switch when you're out.
-You'll have to copy this event page to every troop so it works everytime.
 
I'm at work now, so don't have rmxp with me to look at the scripts, but something along these lines should work:
Go into the scene_battle script.
Goto the judge method.
In that method you'll need to add something along the lines of,
"if $game_party.items.include?(id of the item)
$game_party.recover_all
battle_end(T)"
end"

T is the way the battle ends, you'll need to look there to determine what exactly T should be.

I know this isn't exactly comprhensive, if you need additional help, or I have time when I get home, I'll provide the details:)
 
Go into the script editor.
Goto Scene_Battle1 and goto the judge method.
Directly beneath the line

Code:
if $game_party.all_dead? or $game_party.actors.size == 0

Paste

Code:
if $game_party.item_number(K) > 0

    $game_party.lose_item(K,1)

    $game_party.actors.each() {|x| x.recover_all}

    $game_system.bgm_play($game_temp.map_bgm)

    battle_end(2)

   return true

end

Just replace the K's with the id of the item you are using:)
 
Phoenix' code needs to be right above "# Set game over flag", and T should be 2 (0:win 1:lose 2:escape)
and you need a 'return true' or you may get an extra battle event.

Code:
  #--------------------------------------------------------------------------

  # * Determine Battle Win/Loss Results

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

  def judge

    # If all dead determinant is true, or number of members in party is 0

    if $game_party.all_dead? or $game_party.actors.size == 0

      # If possible to lose

      if $game_temp.battle_can_lose

        # Return to BGM before battle starts

        $game_system.bgm_play($game_temp.map_bgm)

        # Battle ends

        battle_end(2)

        # Return true

        return true

      end

      ###  Add this part. Replace item_id with the number of your item in the database

      if $game_party.items.include?(item_id)

        $game_party.recover_all

        $game_party.gain_item(item_id, -1)

        battle_end(2)

        return true

      end

      ### End of custom code

      # Set game over flag

      $game_temp.gameover = true

      # Return true

      return true

    end

    # Return false if even 1 enemy exists

    for enemy in $game_troop.enemies

      if enemy.exist?

        return false

      end

    end

    # Start after battle phase (win)

    start_phase5

    # Return true

    return true

  end

Oops, we forgot to remove the item... fixed. Change "item_id" in 2 places.

Be Well
 
I'm confused...my code does have a 2 in it, no T, and there is a return true...I tested it twice as is, it worked perfect.

*Edit
Also odd:
Game_Party doesn't have a recover_all method.
Why use $game_party.items.include?(item_id) since items isn't attr_reader by default;
Also, last I checked, using inlucde? on a hash in Ruby checks if it has a key with that value,
So if he has 0 of the item, the inlcude? will still return a true, not false as it should
(You only get a false if the party never yet encountered the item.)

**Edit
Sorry if the above seems snippy,
I just noticed the apostrophe next to the "Phoenix" as in "Phoenix's code",
but without the 's, it looked like you were direclty addressing me by name...
From that perspective, your message seemed kind of mean;
The ending seemed very sarcastic the way I was reading it:)
 
We were typing at the same time, and I'm a slow typer (I reread a lot). I was referring to your previous post. :scruff:
I also didn't check the 'recover_all' method. Or test it for that matter... :)
I just copied your code from the previous post, and showed him where to put it. (assuming "...when I get home" meant much later.)

Use Phoenixia's code, not mine!!!! :grin:

Now I'm scratching my head on the order. You have the heal code before the "Continue even when loser" code.
"Continue even when loser" typically gets used for simulated battles where the party doesn't really die. (fist fight, training, test of strength). Would you want the party to 'auto-heal' and waste the magic item? Will you even use this type of battle?

Something to ponder...

Be Well
 
Phoenixia":3px1rush said:
**Edit
Sorry if the above seems snippy,
I just noticed the apostrophe next to the "Phoenix" as in "Phoenix's code",
but without the 's, it looked like you were direclty addressing me by name...
From that perspective, your message seemed kind of mean;
The ending seemed very sarcastic the way I was reading it:)

No worries, love. It's all in fun. (I'm a big giant teddy bear. Very rarely mean.) :wink:

My "Oops" was tongue in cheek. I was narrating the fact that I suddenly realized we also needed to remove the item.

Be Well

[edit] It also just occurred to me that if we are using event based battles, we could just use the "Continue even if loser" setting, and handle it all with events. But I like this solution better, less work, and it works for random encounters too.
 
No, you're right about the order; I never use it, so guess I over looked it.
I feel like an idiot now though, I thougt you were refering to my second post, not the first...
I was wondering what you were talking about...
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top