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.

[FILLED] Deterioration System

Before I delve into this script, may I warn people that they might find this somewhat morbid and I hope that the system does not strike any raw nerves or upset anyone who may be close to the subject matter.

The basic set up is, the character in question (from here on known as Kayou) is a very weak girl. She is slowly dying from a heart problem, and while her frail frame may be a deceptive shell for an extremely strong martial artist, her powerful fighting techniques take a toll on her body.

What I want is a system that gives Kayou an unremovable status effect which, after a certain amount of time (say 5min realtime?), detracts 1hp from her MAX HP. Medicine can raise her MaxHP again, but over time she will grow steadily weaker. Also, I want a way to make it so that all of Kayou's special techniques also detract from her MaxHP.

Any help with the script would be much appreciated! :D
 
Wait a minute, is this Akasha Seal's ScriptKitty?

anyway, about taking HP, this is pretty rough, work for chara ID 1 only. the '60' is seconds, so change it to fit your need:
Code:
module Graphics  
  class << self
    #never mind this, just an alias
    if @stack_update.nil?
      alias orig_update update
      @stack_update = true
    end    
    def update
      orig_update
      #if 60 seconds has passed
      if Graphics.frame_count % (Graphics.frame_rate * 60) == 0
        $game_actors[1].maxhp -= 1 if $scene.is_a?(Scene_Map)
      end          
    end
  end
end
 
Nope, sorry, not for Akasha Seal! Though I will be getting back to that shortly... This is for a side project of mine, tenatively named Pale. Oh, and don't worry, Kayou's life isn't too fragile, she has some extra forces on her side... But I won't spoil. :D

Thank you very much for the help guys!
 
Yea, don't worry, and about the special skill, what this special skill? May be I could help...

When did you get back here? and may be you should back to AS, everyone is waiting for it to continue, much like everyone is wanting Naruto's filler to end :P :P :P
 
Odd, my previous post didn't seem to go through...

Anyway, as I said in it, I'll get back to AS. But right now I just want to have some fun on a game, not stress over an episode. Kayo (yeah, removed the u, decided not to go with asian names) uses hand-to-hand combat styles, so 'special techniques' are like spells, but physical. Though I may add a few fire techniques in over time, and a steal/mug skill since item gathering becomes extremely important in the game. Besides selling and trading, she needs items to make her medicines. Don't worry, Kayo's not that fragile. :D
 
LegACy said:
Code:
module Graphics  
  class << self
    #never mind this, just an alias
    if @stack_update.nil?
      alias orig_update update
      @stack_update = true
    end    
    def update
      orig_update
      #if 60 seconds has passed
      if Graphics.frame_count % (Graphics.frame_rate * 60) == 0
        $game_actors[1].maxhp -= 1 if $scene.is_a?(Scene_Map)
      end          
    end
  end
end


Odd, that looks some how famaliar to something I gave you a while back... ^_^


Well, let me know if you want me to still do this, or if you have everything figured out. There's a much better way of going about this...
 
I'm still totally up for any suggestions anyone has on ways to handle this, whatever you guys think would be the best, least-laggy, least obtrusive way.

EDIT: My appologies for the doublepost! I really should've just edited my last one. >_<
 
Ok. Here it is:

Code:
class Game_Actor
  Skill_HP_Cost = {}
  Deterioration_State_ID = 1
  Time_To_Deterioration = 5 # In Seconds
  attr_reader :deteriorizing
  attr_accessor :last_deterioration_time
  alias seph_detsys_gmactr_setup setup
  alias seph_detsys_gmactr_states states
  alias seph_detsys_gmactr_scu? skill_can_use?
  alias seph_detsys_gmactr_se skill_effect
  def setup(actor_id)
    seph_detsys_gmactr_setup(actor_id)
    @deteriorizing = false
    @last_deterioration_time = Graphics.frame_count / Graphics.frame_rate
  end
  def states
    states = seph_detsys_gmactr_states
    if @deteriorizing
      states << Deterioration_State_ID
    end
    return states.sort
  end
  def skill_can_use?(skill_id)
    if Skill_HP_Cost.has_key?(skill_id)
      if @hp < Skill_HP_Cost[skill_id]
        return false
      end
    end
    return seph_detsys_gmactr_scu?(skill_id)
  end
  def skill_effect(user, skill)
    seph_detsys_gmactr_se(user, skill)
    if user.is_a?(Game_Actor)
      if user.deteriorizing
        if Skill_HP_Cost.has_key?(skill.id)
          user.hp -= Skill_HP_Cost[skill.id]
        end
      end
    end
  end
  def deteriorizing=(state)
    if state
      @deteriorizing = true
      @last_deterioration_time = Integer(Graphics.frame_count / Graphics.frame_rate)
    else
      @deteriorizing = false
    end
  end
  def update_deterioration
    if @deteriorizing
      current_time = Graphics.frame_count / Graphics.frame_rate
      if @last_deterioration_time + Time_To_Deterioration <= current_time 
        @maxhp_plus -= 1
        @last_deterioration_time = current_time
        @hp = [@hp, maxhp].min
      end
    end
  end
end

module Graphics  
  class << self
    if @stack_update.nil?
      alias orig_update update
      @stack_update = true
    end    
    def update
      orig_update
      unless $game_party.nil?
        $game_party.actors.each {|actor| actor.update_deterioration}
      end
    end
  end
end

Let me know if theres anything you don't understand, or if it doesn't work. Time for some sleep.
 
Yes, below all other scripts and above main.

To set hp cost for skills, just add skill ids and hp cost in the Skill_HP_Cost = {} hash.

Example:
Code:
# skill 3 cost 5hp, skill 5 cost 7 hp
Skill_HP_Cost = {3=>5, 5=>7}

To turn deteriorizing on for an actor, use

$game_party.actors[index].deteriorizing = true (on) or false (off)

The number of in game seconds to reduce hp is Time_To_Deterioration = 5

Finally, make a Deter. state, and set Deterioration_State_ID to the id of your state.

Let me know if theres anything else.
 
Thanks, trying it out now!

EDIT: Okay, I just got "syntax error occoured while running script", no other troubleshooting details provided... I'm guessing it has to do with my actual script call. Which, unfortunately, takes up too lines, and I'm guessing it's not recognizing it as a single line. Anybody got a clue what I can do about that?


EDIT 2, REVENGE OF THE EDIT BUTTON: Okay, someone pointed me to a workaround for it and now it's working beautifully! Thank you so much Seph!
 

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