Newer
Older
--- Check if the actor has a light armor
function _M:hasLightArmor()
if not self:getInven("BODY") then return end
local armor = self:getInven("BODY")[1]
if not armor or (armor.subtype ~= "cloth" and armor.subtype ~= "light") then
return nil
end
return armor
end
--- Check if the actor has a heavy armor
function _M:hasHeavyArmor()
if not self:getInven("BODY") then return end
local armor = self:getInven("BODY")[1]
if not armor or (armor.subtype ~= "heavy" and armor.subtype ~= "massive") then
end
--- Check if the actor has a massive armor
function _M:hasMassiveArmor()
if not self:getInven("BODY") then return end
local armor = self:getInven("BODY")[1]
if not armor or armor.subtype ~= "massive" then
return nil
end
--- Check if the actor has a mount
function _M:hasMount()
if not self:getInven("MOUNT") then return end
local mount = self:getInven("MOUNT")[1]
if not mount or mount.type ~= "mount" then
return nil
end
return mount
end
-- Unarmed Combat; this handles grapple checks and building combo points
-- Builds Comob; reduces the cooldown on all unarmed abilities on cooldown by one
function _M:buildCombo()
local duration = 3
local power = 1
-- Combo String bonuses
if self:knowTalent(self.T_COMBO_STRING) then
local t= self:getTalentFromId(self.T_COMBO_STRING)
if rng.percent(t.getChance(self, t)) then
power = 2
end
if self:knowTalent(self.T_RELENTLESS_STRIKES) then
local t= self:getTalentFromId(self.T_RELENTLESS_STRIKES)
self:incStamina(t.getStamina(self, t))
self:setEffect(self.EFF_COMBO, duration, {power=power})
end
function _M:getCombo(combo)
local combo = 0
local p = self:hasEffect(self.EFF_COMBO)
combo = p.cur_power
end
return combo
end
function _M:clearCombo()
if self:hasEffect(self.EFF_COMBO) then
self:removeEffect(self.EFF_COMBO)
end
end
-- Check to see if the target is already being grappled; many talents have extra effects on grappled targets
function _M:isGrappled(source)
local p = self:hasEffect(self.EFF_GRAPPLED)
if p and p.src == source then
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
return true
else
return false
end
end
-- Breaks active grapples; called by a few talents that involve a lot of movement
function _M:breakGrapples()
if self:hasEffect(self.EFF_GRAPPLING) then
-- deactivating GRAPPLING will clear the target's Grappled effect as well
self:removeEffect(self.EFF_GRAPPLING)
end
end
-- grapple size check; compares attackers size and targets size
function _M:grappleSizeCheck(target)
size = target.size_category - self.size_category
if size > 1 then
game.logSeen(target, "%s fails because %s is too big!", self.name:capitalize(), target.name:capitalize())
return true
else
return false
end
end
-- Starts the grapple
function _M:startGrapple(target)
-- pulls boosted grapple effect from the clinch talent if known
if self:knowTalent(self.T_CLINCH) then
local t = self:getTalentFromId(self.T_CLINCH)
power = t.getPower(self, t)
duration = t.getDuration(self, t)
hitbonus = self:getTalentLevel(t)/2
else
power = 5
duration = 4
hitbonus = 0
end
-- Breaks the grapple before reapplying
if self:hasEffect(self.EFF_GRAPPLING) then
-- deactivating GRAPPLING will clear the targets Grappled effect and various holds
self:removeEffect(self.EFF_GRAPPLING, true)
target:setEffect(target.EFF_GRAPPLED, duration, {src=self, power=power}, true)
self:setEffect(self.EFF_GRAPPLING, duration, {src=target}, true)
return true
elseif target:checkHit(self:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 5 - hitbonus) and target:canBe("pin") then
target:setEffect(target.EFF_GRAPPLED, duration, {src=self, power=power})
self:setEffect(self.EFF_GRAPPLING, duration, {src=target}, true)
return true
else
game.logSeen(target, "%s resists the grapple!", target.name:capitalize())
return false
end