Jump to content

Recommended Posts

Hey, guys. Fairly new here, so forgive me for any ambiguity on my part.

 

What I'm looking for is a way to improve a weapon's bonuses once certain conditions are met; in this case, every time an enemy is slain with the weapon in question. The several topics I've leafed through all suggested similar solutions, such as making several copies of the weapon with improved stats, but that's something I'd like to avoid doing, if possible. I'll list a few specifics for clarity.

 

> For every ten enemies killed with the weapon, improve the ATK parameter bonus of the weapon by one.

> This should apply to any and all copies of the weapon currently being used (there's only one in the game being that it's legendary, but more than one actor is able to equip it).

> While I don't particularly mind if there's no cap on how much you can gain, I'd appreciate it if I could optionally implement one.

 

I plan to do about 21 of these - one for each weapon type I currently have. They're primarily 'cursed' weaponry that start out even weaker than their respective defaults, but slowly become the best possible after..*cough* hours of grinding *cough*.

 

I apologize if there's a script like this already, but I appreciate it if you didn't tl:dr to this point.

Thanks! :)

Share this post


Link to post
Share on other sites

$game_actors[x].equips[y].params[2] += z

 

This will make actor x's equipment in slot y raise it's attack (the params[2] part) by z permanently.

You'll probably need a script or some other checks to find out exactly which actor has the proper equip, but as for the basic syntax, there it is.

And just remember: This WILL raise the stats of ALL weapons that match that equip's ID, so make sure the equip is one-of-a-kind or you'll have issues with it later.

 

(BTW, you can also increase the price of the equip with a similar call:

 

$game_actors[x].equips[y].price =+ z

)

Share this post


Link to post
Share on other sites

No prob.

And welcome to the forums, btw. :-)

 

Well, in my project, I did a lot of editing to the original scrips to allow checks whenever a skill with a physical flag was used.

I could look into those edits again to put something together, but a formal scripter might do it a bit faster that I could.

Edited by Maliki

Share this post


Link to post
Share on other sites

You could add a check in the method that handles enemy death (def die) if I'm not mistaken. It would have to check the actor ID and equipment in the weapon slot ID and then raise a variable if conditions are met.

 

At that point, you could add damage to the weapon attack formula by referencing that variable (assuming you're using a script that gives individual weapons their own damage formula).

 

That would be the long way of doing it, anyway.

 

If I weren't at work right now I'd be able to write that up. If Glasses doesn't fill that request for you by the time I get back I'll give it a try.

Share this post


Link to post
Share on other sites

Here you go.

 

 

module LevelingWeapon
  WEAPONS = {
    # ID => {
    #   :kills_needed => X,
    #   :atk_gained => Y,
    #   :limit => Z
    #},
    
    30 => {
      :kills_needed => 10,
      :atk_gained   => 1,
      :limit        => 100
    },
  }
end

class Game_Party < Game_Unit
  alias :mrts_levwp_gp_initialize :initialize
  def initialize
    mrts_levwp_gp_initialize
    @mrts_weapons_leveled = {}
  end
  
  def score_lw_kill(id)
    if @mrts_weapons_leveled[id]
      @mrts_weapons_leveled[id] += 1 unless limit_lw_reached?(id) 
    else
      @mrts_weapons_leveled[id] = 1
    end
  end
  
  def limit_lw_reached?(id)
    return false unless @mrts_weapons_leveled[id]
    return false if @mrts_weapons_leveled[id] < LevelingWeapon::WEAPONS[id][:limit]
    return true
  end
  
  def atk_lw_gained(id)
    return 0 unless @mrts_weapons_leveled[id]
    return (@mrts_weapons_leveled[id].to_f / LevelingWeapon::WEAPONS[id][:kills_needed] * LevelingWeapon::WEAPONS[id][:atk_gained]).floor
  end
end

class Game_Enemy < Game_Battler
  alias :mrts_levwp_ge_execute_damage :execute_damage
  def execute_damage(user)
    if user.is_a?(Game_Battler) && hp - @result.hp_damage <= 0 && @result.item.is_a?(RPG::Skill) && @result.item.id == user.attack_skill_id
      user.weapons.each { |w|
        @result.item.is_a?(RPG::Weapon) && LevelingWeapon::WEAPONS[@result.item.id]
        $game_party.score_lw_kill(w.id) if LevelingWeapon::WEAPONS[w.id]
      }
      mrts_levwp_ge_execute_damage(user)
    else
      mrts_levwp_ge_execute_damage(user)
    end
  end
end

class Game_ActionResult
  alias :mrts_levwp_gar_make_damage :make_damage
  
  attr_accessor :item

  def make_damage(value, item)
    mrts_levwp_gar_make_damage(value, item)
    @item = item
  end
end

class Game_Actor < Game_Battler
  alias :mrts_levwp_gar_param_plus :param_plus
  def param_plus(param_id)
    return mrts_levwp_gar_param_plus(param_id) if (param_id != 2)
    return mrts_levwp_gar_param_plus(param_id) + lw_atk_plus
  end
  
  def lw_atk_plus
    weapons.compact.inject(0) {|r, weapon| r += $game_party.atk_lw_gained(weapon.id) }
  end
end 

 

 

Share this post


Link to post
Share on other sites

@Backwardskey,

How do you define 'dying to the weapon'? Normal Attack command or any skill that character uses? Or normal Attack + specific skills that character uses?
Since currently it's configured to only count kills from a normal Attack.

Share this post


Link to post
Share on other sites

Ah, I gotcha.

 

I think I meant that as the character killing an enemy with basically anything - aside from a detrimental item or status effect - with the weapon equipped.

If it's outside your expertise to configure it like that, however, that's perfectly fine.

Edited by Backwardskey

Share this post


Link to post
Share on other sites

@Backwardskey,

Just remove

&& @result.item.id == user.attack_skill_id

then.

Share this post


Link to post
Share on other sites

If I may, I think checking for the physical flag might work.

 

@result.item.physical?

 

As long as all weapon skills are set to physical.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted