Hello, so my Game Battler 3 is getting quite large from the after-damage effects, so I decided to add them to a method that I can call. Issue I ran into is the user of a skill is "user" in the code and the user of the normal attack is "attacker" in the code. I already have a global variable that checks the ID of the skill used (called $SkillUseID) that equals 0 when using the normal attack.
I could simply just check the SkillUseID to see if it equals 0 and then just copy/pasta everything on both sides (aka make a "attacker" version of each of the conditional branches below.
The code is as follows:
I'm using Skill 97 to test this (which is why it's the only one using @jesus) If you look at [@jesus = user], that gives me the error of undefined local variable being "user."I can still use [user] as normal but @jesus cannot equal to it.
(It came to my attention that it reads self just fine since self is the target in both skills and the normal attack but it does not recognize user or attacker).
Is there a way I can have a variable equate itself to user or attacker or do I just have to make a separate conditional branch for each. So will I have to put SkillUseID == 0 and under that, have the attacker versions, and then under Else, have the user versions or is it possible for @jesus to equate as one of them to make it cleaner and shorter?
EDIT: How do I get this new method to recognize the terms, user and attacker?
I could simply just check the SkillUseID to see if it equals 0 and then just copy/pasta everything on both sides (aka make a "attacker" version of each of the conditional branches below.
The code is as follows:
Ruby:
#-------------------------------------
# After DMG effects
#-------------------------------------
def after_dmg
if $SkillUseID == 0
@jesus = attacker
else
@jesus = user
end
if $SkillUseID == 97 #Earth Fist's SP Damage
self.sp -= Integer(self.damage / 4)
@jesus.hp -= @jesus.hp
end
if $SkillUseID == 114 #Polearm Sweep
user.add_state(6)
end
if $SkillUseID == 128 #Dancing Swords
user.add_state(55)
end
#Life Drain abilities
if $SkillUseID == 41
user.damage -= Integer(self.damage * 0.3)
end
if $SkillUseID == 48
user.damage -= Integer(self.damage)
end
if user.state?(84) #Cannibal Striker
user.damage -= Integer(self.damage * 0.35)
end
if $SkillUseID == 38 #Energize Passive (Life Spell Capstone)
if user.state?(78)
user.remove_state(78)
else
user.add_state(78)
end
end
if $SkillUseID == 112 #Cannibal
if user.state?(84)
user.remove_state(84)
else
user.add_state(84)
end
end
if $SkillUseID == 113 #Vital Hitter
if user.state?(85)
user.remove_state(85)
else
user.add_state(85)
end
end
end
I'm using Skill 97 to test this (which is why it's the only one using @jesus) If you look at [@jesus = user], that gives me the error of undefined local variable being "user."
(It came to my attention that it reads self just fine since self is the target in both skills and the normal attack but it does not recognize user or attacker).
Is there a way I can have a variable equate itself to user or attacker or do I just have to make a separate conditional branch for each. So will I have to put SkillUseID == 0 and under that, have the attacker versions, and then under Else, have the user versions or is it possible for @jesus to equate as one of them to make it cleaner and shorter?
EDIT: How do I get this new method to recognize the terms, user and attacker?