Overriding repair skill for pilot - AUTOMATIC1111/IntoTheBreachLua GitHub Wiki
The repair skill is called Skill_Repair, and you can override its functions just like any other function:
function Skill_Repair:GetSkillEffect(p1,p2)
# your own implementation!
end
You can store old implementation in a local variable. The code below overrides repair skill, but does nothing but call the original implementation:
oldGetSkillEffect = Skill_Repair.GetSkillEffect
function Skill_Repair:GetSkillEffect(p1,p2)
return oldGetSkillEffect(self,p1,p2)
end
You can check which pilot is activating the skill using Board:GetPawn(p1):GetPersonality(), and if it's yours, call your own implementation of the repair skill, otherwise, call original implementation:
Custom_Skill_Repair=Skill_Repair:new {}
function Custom_Skill_Repair:GetSkillEffect(p1,p2)
local ret = SkillEffect()
# do something
return ret
end
oldGetSkillEffect = Skill_Repair.GetSkillEffect
function Skill_Repair:GetSkillEffect(p1,p2)
if Board:GetPawn(p1):GetPersonality() == "Pilot-Personality-Here" then
return Custom_Skill_Repair:GetSkillEffect(p1,p2)
end
return oldGetSkillEffect(self,p1,p2)
end
Here's an example, making Ralph's (personality "Original") repair skill do AOE damage instead:
Self_Destruct_Skill_Repair=Skill_Repair:new {}
function Self_Destruct_Skill_Repair:GetSkillEffect(p1,p2)
local ret = SkillEffect()
for i = DIR_START,DIR_END do
local curr = p1 + DIR_VECTORS[i]
local damage = SpaceDamage(curr, 1)
damage.sAnimation = "explopush1_"..i
ret:AddDamage(damage)
end
local damage = SpaceDamage(p1, 1)
damage.sAnimation = "ExploArt3"
damage.sSound = "/props/airstrike_explosion"
ret:AddDamage(damage)
return ret
end
oldGetSkillEffect = Skill_Repair.GetSkillEffect
function Skill_Repair:GetSkillEffect(p1,p2)
if Board:GetPawn(p1):GetPersonality() == "Original" then
return Self_Destruct_Skill_Repair:GetSkillEffect(p1,p2)
end
return oldGetSkillEffect(self,p1,p2)
end