Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Changing Hit Rate Formula?, To also account for actor level
47948201
post Jan 14 2013, 02:55 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 7
Type: None
RM Skill: Undisclosed




Maybe this is better-suited for the development and support section? I'm not sure. Anyway...

This is hopefully a simple fix, but I'm trying to make actors' hit rates somewhat dependent on their level (so that when re-visiting old areas with inaccurate weapons, you won't have a hard time hitting super weak bats and bees). What I have in Game_Battler under the *Calculate Hit Rate of Skill/Item is
CODE
def item_hit(user,item)
  rate=item.success_rate * 0.01
  rate*= user.hit if item.physical?
  rate+=user.level if user.actor? #THIS IS THE ADDED LINE
  return rate
end
Testing a high-level character against a high-avoid enemy, however, that extra line seems to do nothing. Help?

Thanks!
Go to the top of the page
 
+Quote Post
   
Jens of Zanicuud
post Feb 11 2013, 05:23 AM
Post #2


Dark Jentleman
Group Icon

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120




QUOTE (47948201 @ Jan 14 2013, 11:55 PM) *
Maybe this is better-suited for the development and support section? I'm not sure. Anyway...

This is hopefully a simple fix, but I'm trying to make actors' hit rates somewhat dependent on their level (so that when re-visiting old areas with inaccurate weapons, you won't have a hard time hitting super weak bats and bees). What I have in Game_Battler under the *Calculate Hit Rate of Skill/Item is
CODE
def item_hit(user,item)
  rate=item.success_rate * 0.01
  rate*= user.hit if item.physical?
  rate+=user.level if user.actor? #THIS IS THE ADDED LINE
  return rate
end
Testing a high-level character against a high-avoid enemy, however, that extra line seems to do nothing. Help?

Thanks!


Your code is right, but there's something you haven't considered...
Rate is a variable which ranges from 0 to 1, so if you add your character level, you'll always have a 100% success rate, the minimum being 1.
I suggest to modify the line this way:

CODE
def item_hit(user,item)
  rate=item.success_rate * 0.01
  rate*= user.hit if item.physical?
  rate+=user.level/100.0 if user.actor? #THIS IS THE ADDED LINE
  rate = [rate,1].min
  return rate
end


So, if your character will be level 50 (for instances) default rate would be increased by 0.5.
Remeber that a rate greater than 1 will result in a never-missing attack.
Anyway, rate isn't the one thing which influences hit. If enemies has some sort of evasion, you can't be sure your attack will hit at a 100% rate. To prevent this, try this one:

CODE
#--------------------------------------------------------------------------
  # * Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  def item_apply(user, item)
    @result.clear
    @result.used = item_test(user, item)
    @result.missed = (@result.used && rand >= item_hit(user, item))
    #insert here a modification:
    if user.is_a?(Game_Actor)
    @result.evaded = (!@result.missed && rand < [item_eva(user, item) - user.level/100.0,0].max)
    else
    @result.evaded = (!@result.missed && rand < item_eva(user, item))
    end
    if @result.hit?
      unless item.damage.none?
        @result.critical = (rand < item_cri(user, item))
        make_damage_value(user, item)
        execute_damage(user)
      end
      item.effects.each {|effect| item_effect_apply(user, item, effect) }
      item_user_effect(user, item)
    end
  end


In practice, this will reduce enemies EVA by means of the attacker level.
I hope this can help,

Jens


__________________________
"Thorns are the rose's sweetest essence..."
-Jens of Zanicuud


Games I'm working on:
>

official website: TryAdIne eFfeCt

>

Games I worked on (mainly as a scripter):
>
(Warning: it's a 3rr3's project and it's in Italian!)


Awards

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 11:24 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker