Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - KK20

3041
Curious as to why it can't be used via events. Animations require the instance of an RPG::Sprite--exactly what events/characters use. Without using an event, you're forced to create a temporary instance of an RPG::Sprite to play one animation, while somehow updating it through the Scene_Map, and then keeping track of its own variables to compare with the player's (and other battlers if so desired) and... *rambles on*

I'm pretty sure intuitive use of game variables can make this possible with events.
3042
Whipped this up really quick (like 2 minutes quick).
Spoiler: ShowHide
class Game_Battler
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to 1
      self.damage = 1
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate power
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    # If miss occurs
    else
      # Set damage to 1
      self.damage = 1
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
end
Wasn't sure if you wanted to keep the status ailments and such, so I pretty much just left it all in there.
3043
RMXP Script Database / Re: [XP] Stat Distribution System
September 27, 2012, 07:58:56 pm
Quote from: Launian on September 27, 2012, 06:24:17 pm
Sadly, this doesn't change the behaivor of the stat distribution window, wich means that, if you allocate 1 DP to your HP, it'll show 501 instead of 510 until you click on Accept Changes. I can't find out how to make it so the window reflects the fact that it adds 10 HP instead of 1, but leaving alone the Stats (STR, DEX, etc.).

That would be this line:
self.contents.draw_text(116, y, 64, 32,
        (@current[i] + @spent[i] / BlizzCFG::ExchangeRates[i]).to_s, 2)
Simple use of case i can make it possible.
3044
RMXP Script Database / Re: [XP] Diary
September 27, 2012, 07:56:53 pm
Quote from: Launian on September 27, 2012, 03:39:42 pm
Hello. I'm just wondering: is there any way I can put line jumps on the script? I've been fooling around with it, and I can't figure it out.

Clicky
3045
Troubleshooting / Help / Re: Few questions on Blizz ABS
September 25, 2012, 02:48:07 pm
As I have said before, I do not even know how to reproduce the problem. No matter what I do, my summons work fine for me. If you provide a demo of your project, I can take a look at it. But until you specifically show us what you did to your project, we can't do anything for you.
3046
I appreciate it.  ;)

I'll see if using clear rects will cause any problems, mainly lag. I doubt it, but I don't know.
3047
RMXP Script Database / Re: [XP] Achievements Script
September 22, 2012, 02:44:43 pm
"Changed width to height"? Why in the world would you want to do that? Unless you worded that wrong and you did this:
self.contents = Bitmap.new(width - 32, row_max * height)
3048
Script Troubleshooting / Re: A small problem with Z value
September 22, 2012, 02:38:58 pm
Haven't bothered to test the script, but I'll make a few quick guesses just from looking at the script.

First off: Is it an issue to set ALWAYS_ON_TOP to false?

If so, then put it to false and do this. Find this line
@icon_sprite = ALWAYS_ON_TOP ? Sprite.new(topview) : Sprite.new(viewport)
And right below it put this:
@icon_sprite.z = 9999

I think that should work...my mind has been filled with code for the past 3 days. It's getting hard to focus on 5 projects at once.
3049
RMXP Script Database / Re: [XP] Achievements Script
September 22, 2012, 02:30:41 pm
I believe this line is the problem:
self.contents = Bitmap.new(width - 32, row_max * Awards::Icon_Size[1])
I noticed that in your picture, the sprites on the 3rd line are slightly cut off, so instantly I knew it had to be a bitmap size problem. You want to change that Awards::Icon_Size to something else. Originally it was height, so I don't know what you were trying to accomplish in changing that.
3050
Okay this is what I have so far. It's not done yet, but at least you can understand the idea I have.
Spoiler: ShowHide
class Game_Map
  # Returns true if the tile is considered to have a graphic displayed under
  # the character's sprite.
  def bottom_graphic_tile?(x, y)
    if @map_id != 0
      for i in [2, 1, 0]
        tile_id = data[x, y, i]
        if tile_id == nil
          return false
        elsif @terrain_tags[tile_id] == 7
          return true
        end
      end
    end
    return false
  end
 
  def tile_id(x, y, h = nil)
    if @map_id != 0
      return tile_id[x,y,h] unless h.nil?
      for i in [2, 1, 0]
        tile_id = data[x, y, i]
        next if tile_id == nil or tile_id == 0
        return data[x,y,i]
      end
    end
    return nil
  end
 
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
#  This sprite is used to display the character.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Character < RPG::Sprite
 
  alias reinit_this_again_for_tiles initialize
  def initialize(viewport, character = nil)
    @over_special_tile = false
    @grass_sprite = Sprite.new(viewport)
    @grass_sprite.bitmap = Bitmap.new(32, 5)
    reinit_this_again_for_tiles(viewport, character)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_grass_graphic_after update
  def update
    # Call alias update method
    update_grass_graphic_after
    # If tile that the character is over is a 'special' tile
    cx, cy = character.real_x/128, character.real_y/128
    # Check if moving over a layer tile
    if $game_map.bottom_graphic_tile?(cx, cy) or
    $game_map.bottom_graphic_tile?(cx+1, cy) or
    $game_map.bottom_graphic_tile?(cx, cy+1)
      # Initialize overlaying graphic
      @grass_sprite.bitmap.clear
      #@grass_sprite.bitmap.dispose unless @grass_sprite.bitmap.nil?
      #@grass_sprite.bitmap = nil
      # Set bitmap to width of 32 and height of 5
      #@grass_sprite.bitmap = Bitmap.new(32, 5) #if @grass_sprite.bitmap.nil?
      # Get tileset graphic
      tileset_bitmap = RPG::Cache.tileset($game_map.tileset_name)
     
      # Get tile IDs (current, to the right, to the south)
      tile_id1 = $game_map.tile_id(cx, cy)
      tile_id2 = $game_map.tile_id(cx+1, cy)
      tile_id3 = $game_map.tile_id(cx, cy+1)
      #p [tile_id1,tile_id2,tile_id3] if Input.trigger?(Input::SHIFT)
      # Condition checking variables
      current_grassy = (tile_id1 >= 384 and $game_map.bottom_graphic_tile?(cx, cy))
      right_grassy = (tile_id2 >= 384 and $game_map.bottom_graphic_tile?(cx+1, cy))
      bottom_grassy = (tile_id3 >= 384 and $game_map.bottom_graphic_tile?(cx, cy+1))
      tile_id1 -= 384
      tile_id2 -= 384
      tile_id3 -= 384
      #If current tile is grassy, and not moving
      if current_grassy and !@character.moving?
        sox, soy = (tile_id1 % 8) * 32, (tile_id1 / 8) * 32 + 26
        rect = Rect.new(sox, soy, 32, 5)
        @grass_sprite.bitmap.blt(0, 0, tileset_bitmap, rect)
       
      elsif !current_grassy and !@character.moving?
       
      #If on grass and moving down to grass: Draw all the rectangles from x,y to x,y+1.
      elsif current_grassy and bottom_grassy and @character.real_y / 128 < @character.y
        height_remaining = 5
        y1 = (@character.real_y % 128) / 4
        p y1 if Input.trigger?(Input::SHIFT)
        unless y1 >= 5
          sox, soy = (tile_id1 % 8) * 32, (tile_id1 / 8) * 32 + 26 + y1
          h = 5-y1
          rect = Rect.new(sox,soy,32,h)
          @grass_sprite.bitmap.blt(0, 0, tileset_bitmap, rect)
          height_remaining -= h
        end
        if height_remaining > 0
          sox, soy = (tile_id3 % 8) * 32, (tile_id3 / 8) * 32 + [y1 - 5, 0].max
          rect = Rect.new(sox,soy,32,height_remaining)
          @grass_sprite.bitmap.blt(0, 5-height_remaining, tileset_bitmap, rect)
        end
       
      #If on grass and moving down off grass: Do not bother to draw rectangles at all
      elsif current_grassy and !bottom_grassy and @character.real_y / 128 < @character.y
       
      #If on grass and moving up to grass: Same as first condition
      elsif bottom_grassy and current_grassy and @character.real_y / 128 >= @character.y
        height_remaining = 5
        y1 = (@character.real_y % 128) / 4
        unless y1 == 0 #<- Is that even possible? I don't think so
          sox, soy = (tile_id3 % 8) * 32, (tile_id3 / 8) * 32 + [y1 - 5, 0].max
          h = [y1, 5].min
          height_remaining -= h
          rect = Rect.new(sox,soy,32,h)
          @grass_sprite.bitmap.blt(0, [height_remaining, 0].max, tileset_bitmap, rect)
        end
        if height_remaining > 0
          sox, soy = (tile_id1 % 8) * 32, (tile_id1 / 8) * 32 + (31 - y1)
          rect = Rect.new(sox,soy,32,height_remaining)
          @grass_sprite.bitmap.blt(0, 0, tileset_bitmap, rect)
        end
     
      #If on grass and moving up to nothing: Draw rectangles all the way to the last possible spot
      elsif bottom_grassy and !current_grassy and @character.real_y / 128 >= @character.y
        y1 = (@character.real_y % 128) / 4
        p y1 if Input.trigger?(Input::SHIFT)
        unless y1 == 0 #<- Is that even possible? I don't think so
          sox, soy = (tile_id3 % 8) * 32, (tile_id3 / 8) * 32 + [y1 - 5, 0].max
          h = [y1, 5].min
          rect = Rect.new(sox,soy,32,h)
          @grass_sprite.bitmap.blt(0, 0, tileset_bitmap, rect)
        end
       
       
      #If not on grass and moving down onto grass: Reverse process of above
      elsif !current_grassy and bottom_grassy and @character.real_y / 128 < @character.y
        y1 = (@character.real_y % 128) / 4
        unless y1 == 0 #<- Is that even possible? I don't think so
          sox, soy = (tile_id3 % 8) * 32, (tile_id3 / 8) * 32 + [y1 - 5, 0].max
          h = [y1, 5].min
          rect = Rect.new(sox,soy,32,h)
          @grass_sprite.bitmap.blt(0, 0, tileset_bitmap, rect)
        end
       
      #If not on grass and moving up onto grass: Do not bother to draw rectangles
      elsif !bottom_grassy and current_grassy
       
      end
    end
    @grass_sprite.x = @character.screen_x - 16
    @grass_sprite.y = @character.screen_y - 5
    @grass_sprite.z = @character.screen_z + 32
  end
 
end

Put this just above Main. Go into your tileset database and give tiles with grass a terrain tag of 7. Note that this does NOT work with autotiles. Now walk up and down (I haven't done left or right yet).

Probably spent a good 8 hours thinking and writing this today... :down:
3051
The script provided by diagostimo was only needed to be placed below BABS but above Main.
Your first idea is "possible", but it would probably lag like hell. And probably still wouldn't work properly (clipped off the character's feet when partly standing on grass).

Now I'm thinking that a graphic from the tilemap based on the tile_id can be drawn over the character, but taking only small sections at a time. It will be rectangular like bush_tiles. It's probably possible to delete pixels to make it look more angular and grass-like, but I'm not sure how much lag that may cause. I'll explore it more a bit.

And while the case still stands, we're assuming that all characters this script will apply to are of width 32.
3052
RMXP Script Database / Re: [XP] Skill Equipment System
September 21, 2012, 06:24:43 pm
Yes, I just only want to figure out the bug. I don't really need to play the game other than maybe to test battle. If it's something you don't feel comfortable sharing with everyone, send me the link/file via email.
3053
RMXP Script Database / Re: [XP] Skill Equipment System
September 20, 2012, 10:52:44 pm
I should have probably said this. Can you upload a demo?
3054
Pretty close there. There's a little hiccup when the character moves off the grass (you will see the entire char_set graphic for a split second). Tile ID sounds good enough since there is a script that allows multiple terrain IDs.

Granted this only works with characters of width 32 and of all the same height. Not to mention the graphic of the grass has to be stretched to the left and right edges (no pretty rounded out grass, just square...unless you devote tiles in the tileset that act as the border to the grass). It's still bugging me as to how this can be perfected, but I'm starting to just give up with it.
3055
RMXP Script Database / Re: [XP] Skill Equipment System
September 20, 2012, 12:04:03 pm
Well, two things you can do at this point:
1.) If you have any other custom scripts in your game, try removing all of them. Test play your game and see if the error still persists. If it does, then something in your database is out of place. If the error goes away, which I don't think is possible since you claim there are no other scripts that use those two methods, one of your scripts is making a compatibility problem.
2.) Make a new project.
3056
^^ Originally thought of doing that but it won't work. First off, how do you manage to not make the grassy patch "cut off" the character's head? Also, it wouldn't look good when the character walks up or down.

Yeah, I've been trying to do that diagostimo. I'm trying to rewrite the mine/wood cutting script of yours to fit this.
3057
RMXP Script Database / Re: [XP] Blizz-ABS
September 19, 2012, 10:55:53 pm
Looked at the code, and it's all there. You won't see the explosion unless the appropriate target is nearby the trap's range.

This isn't the first time someone has requested playing an explosion animation, regardless of hitting a target or not, and I am slowly starting to believe this should be built into the code.
3058
RMXP Script Database / Re: [XP] Blizz-ABS
September 19, 2012, 10:05:59 pm
Timed traps. As for throwing, that would probably need to be coded manually.
3059
Yeah, that probably would be best.
3060
That's not quite what he's looking for. If you could change the transparency of the bush tiles to zero, you pretty much have this solved.

...holy hell I can't believe I didn't think of that before  :facepalm:
Granted, it still wouldn't be perfect, but it would be pretty darn close. Problem now is how to edit the Sprite class...

EDIT
Oh wait...that wouldn't work to make it look like the example picture above. Yeah, still have no idea yet.