- Joined
- Dec 30, 2014
- Messages
- 13
- Reaction score
- 1
- First Language
- English
- Primarily Uses
I have effectively no experience scripting with ruby, save for the reading of a few tutorials about it.
I'm comfortable enough modifying the existing default game scripts.
Here's the existing game battler script area I want to modify.
def item_effect_gain_tp(user, item, effect) value = effect.value1.to_i @result.tp_damage -= value @result.success = true if value != 0 self.tp += valueendI added this line : @result.evaded = true
in an attempt to increase TP gain on a successful evade. In my first attempt at doing so, with a test in combat, it had no effect. So I'm guessing that isn't how I go about it, however I think I do need to add in some line in this section since I want the TP gain for an evade to be a minimum amount of 1, and up to some percentage of the amount of damage the attack would have inflicted had it hit. This gain is meant to represent a relevance to the chosen attack option of the enemy. For example, a standard attack during testing seems to do about 14-17 damage, so the TP gain should be at least 1, and rarely 2. While a strong attack during testing does 40-50 damage, so the TP gain should be at least 1, possibly as much as 5, however the tp gain should be quite minuscule compared to the gain presented on an actual hit.
The area I think I need to modify to enact a TP gain for an evade is in this section.
def item_apply(user, item)
@result.clear
@result.used = item_test(user, item)
@result.missed = (@result.used && rand >= item_hit(user, item))
@result.evaded = (!@result.missed && rand < item_eva(user, item))
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
because of the if branch, item.effects.each{ } only fires on a hit, so how do I modify 'if@result.hit?' to be an or that includes @result.evaded?
or should I just put
if@result.evaded
item.effects.each {|effect| item_effect_apply(user, item, effect) }
item_user_effect(user, item)
end
I know with programming there are often a lot of ways to accomplish the same thing, and some are more effective than others, and some are just downright ignorant. I'm hoping I can implement this leaning more toward elegant rather than ignorant.
After a lot of experimentation, I've added this to the end of item_apply:
else if @result.evaded
self.tp += 1 + rand(4)
end
Although this does generate the effect I want, It's not the way I want to go about it.
I'm comfortable enough modifying the existing default game scripts.
Here's the existing game battler script area I want to modify.
def item_effect_gain_tp(user, item, effect) value = effect.value1.to_i @result.tp_damage -= value @result.success = true if value != 0 self.tp += valueendI added this line : @result.evaded = true
in an attempt to increase TP gain on a successful evade. In my first attempt at doing so, with a test in combat, it had no effect. So I'm guessing that isn't how I go about it, however I think I do need to add in some line in this section since I want the TP gain for an evade to be a minimum amount of 1, and up to some percentage of the amount of damage the attack would have inflicted had it hit. This gain is meant to represent a relevance to the chosen attack option of the enemy. For example, a standard attack during testing seems to do about 14-17 damage, so the TP gain should be at least 1, and rarely 2. While a strong attack during testing does 40-50 damage, so the TP gain should be at least 1, possibly as much as 5, however the tp gain should be quite minuscule compared to the gain presented on an actual hit.
The area I think I need to modify to enact a TP gain for an evade is in this section.
def item_apply(user, item)
@result.clear
@result.used = item_test(user, item)
@result.missed = (@result.used && rand >= item_hit(user, item))
@result.evaded = (!@result.missed && rand < item_eva(user, item))
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
because of the if branch, item.effects.each{ } only fires on a hit, so how do I modify 'if@result.hit?' to be an or that includes @result.evaded?
or should I just put
if@result.evaded
item.effects.each {|effect| item_effect_apply(user, item, effect) }
item_user_effect(user, item)
end
I know with programming there are often a lot of ways to accomplish the same thing, and some are more effective than others, and some are just downright ignorant. I'm hoping I can implement this leaning more toward elegant rather than ignorant.
After a lot of experimentation, I've added this to the end of item_apply:
else if @result.evaded
self.tp += 1 + rand(4)
end
Although this does generate the effect I want, It's not the way I want to go about it.
Last edited by a moderator:

