随便吧6494949 2023-03-31 05:43:40

金xlua

--[[
金庸群侠传X 攻击逻辑扩展

]]--

local Tools = luanet.import_type('JyGame.Tools')
local Debug = luanet.import_type('UnityEngine.Debug')
local LuaTool = luanet.import_type('JyGame.LuaTool')
local CommonSettings = luanet.import_type('JyGame.CommonSettings')
local RuntimeData = luanet.import_type('JyGame.RuntimeData')

--扩展特殊攻击
function AttackLogic_extendSpecialSkill(result, skill, sourceSprite, targetSprite, bf)
	if (skill.Name == "扳手腕") then
		--施展技能弹的对话
		result:AddCastInfo(sourceSprite, "喝啊!比比谁的力气大!!", 1)
		--造成攻击者100+ 0~50*臂力差 的伤害
		local deltaBili = math.abs(sourceSprite.Role.AttributesFinal["bili"] - targetSprite.Role.AttributesFinal["bili"])
		result.Hp = 100 + Tools.GetRandomInt(0, 50 * deltaBili)
		return result
	end
	
	if (sourceSprite.Role.Key == "少女程灵素" and sourceSprite.Team == targetSprite.Team) then
		if (skill.Name == "白虎金针") then
			targetSprite:AddBuffOnly2("攻击强化",20,3,100)
		elseif (skill.Name == "朱雀火针") then
			targetSprite:AddBuffOnly2("恢复",20,3,100)
		elseif (skill.Name == "青龙木针") then
			targetSprite:AddBuffOnly2("圣战",0,2,100)
		elseif (skill.Name == "玄武水针") then
			targetSprite:AddBuffOnly2("集气",20,3,100)
		elseif (skill.Name == "麒麟土针") then
			targetSprite:AddBuffOnly2("防御强化",20,3,100)
		end
	end
	
	if (skill.Name == "金针渡劫" or skill.Name == "静莲蝶雨") then
		if (targetSprite.Team == sourceSprite.Team) then
			local addhp1 = math.floor(targetSprite.MaxHp * 0.8)
			result.Hp = -addhp1
			result:AddAttackInfo(targetSprite, "+" .. tostring(addhp1), Color.green)
		end
		return result
	end
	
	if (skill.Name == "夺魂" ) then
		if (targetSprite.Team ~= sourceSprite.Team) then
			local isboss = 0
			if (targetSprite.battleRole.IsBoss == true) then
				isboss = 0.2
			end
			math.randomseed(tostring(os.time()):reverse():sub(1, 6))
			if (math.random() <= 0.5 - isboss + math.random() / 10) then
				local sourceSay1 = {"喝啊!","秒杀你!!"}
				result:AddCastInfo(sourceSprite, sourceSay1[math.random(table.getn(sourceSay1))], 1)
				targetSprite.Hp = 0
				bf:Log(sourceSprite.Role.Name .. "对" .. targetSprite.Role.Name .. "施展【夺魂】技能成功!")
			elseif (math.random() <= 0.4 - isboss + math.random() / 10) then 
				local sourceSay2 = {"尼玛!失误了..","一刀两断.."}
				result:AddCastInfo(sourceSprite, sourceSay2[math.random(table.getn(sourceSay2))], 1)
				targetSprite.Hp = math.floor(targetSprite.Role.hp / 2)
				bf:Log(sourceSprite.Role.Name .. "对" .. targetSprite.Role.Name .. "施展【夺魂】技能失误!")
			elseif (true) then
				local sourceSay3 = {"靠!打偏了!","靠!秒杀失败!","运气不好啊!"}
				result:AddCastInfo(sourceSprite, sourceSay3[math.random(table.getn(sourceSay3))], 1)
				bf:Log(sourceSprite.Role.Name .. "对" .. targetSprite.Role.Name .. "施展【夺魂】技能失败!")
			end
		end
		return result
	end
	
	if (skill.Name == "元灵归心术") then
		if (sourceSprite.Team == targetSprite.Team) then
			local addhp1 = targetSprite.MaxHp - targetSprite.Hp
			local addmp1 = math.min(math.floor(targetSprite.MaxMp * 0.1), targetSprite.MaxMp - targetSprite.Mp)
			if (addhp1 > 0) then
				targetSprite.Hp = targetSprite.MaxHp
				result:AddAttackInfo(targetSprite, "+" .. tostring(addhp1), Color.green)
			end
			if (addmp1 > 0 and sourceSprite.Role.Key ~= targetSprite.Role.Key) then
				targetSprite.Mp = targetSprite.Mp + tonumber(addmp1)
				result:AddAttackInfo(targetSprite, "+内力" .. tostring(addmp1), Color.blue)
			end
			result:AddCastInfo(sourceSprite, "元灵归心术!", 1)
			bf:Log(sourceSprite.Role.Name .. "【元灵归心术】发动," .. targetSprite.Role.Name .. "恢复100%生命,恢复10%内力" ) --记录日志
		end
	elseif (skill.Name == "五气朝元") then
		if (sourceSprite.Team == targetSprite.Team) then
			local addhp1 = math.min(math.floor(targetSprite.MaxHp * 0.35), tonumber(targetSprite.MaxHp - targetSprite.Hp))
			if (addhp1 > 0) then
				targetSprite.Hp = tonumber(targetSprite.Hp + addhp1)
			end
			result:AddAttackInfo(targetSprite, "+" .. tostring(addhp1), Color.green)
			bf:Log(sourceSprite.Role.Name .. "【五气朝元】发动," .. targetSprite.Role.Name .. "恢复35%生命" ) --记录日志
		end
	elseif (skill.Name == "还魂咒") then
		if (sourceSprite.Team == targetSprite.Team) then
			result:AddCastInfo(sourceSprite, "还魂咒!", 1)
			if (RuntimeData.Instance:resurrection(0, sourceSprite.Team, 0.5, 0.1) == 0) then
				if (Tools.ProbabilityTest(0.6)) then
					local addhp2 = math.min(math.floor(sourceSprite.MaxHp * 0.1), tonumber(sourceSprite.MaxHp - sourceSprite.Hp))
					if (addhp2 > 0) then
						sourceSprite.Hp = tonumber(sourceSprite.Hp + addhp2)
						result:AddAttackInfo(sourceSprite, "+" .. tostring(addhp2), Color.green)
					end
				end
			end
		end
	end

	--请勿修改
	return result
end

--扩展天赋(包含在AI计算内)
--不要在此函数中直接扣除血量、或者调用sprite的讲话函数,此函数所有的操作应该针对(AttackResult)result变量进行
function AttackLogic_extendTalents(sourceSprite, targetSprite, skill, bf, result)
	----20180920 by softmgr:
	-- skill.attackResult_Hp : 对应 result.Hp , 为本次攻击(被攻击)减少的血量,负数为加血
	-- skill.attackResult_Mp : 对应 result.Mp , 为本次攻击(被攻击)减少的蓝量,负数为加蓝
	
	--天赋:大力士,每次攻击附加臂力的50%的伤害
	if(sourceSprite.Role:HasTalent("大力士")) then
		skill.attackResult_Hp = skill.attackResult_Hp + math.floor(sourceSprite.Role.AttributesFinal["bili"] * 0.5)
		result:AddCastInfo(sourceSprite, LuaTool.MakeStringArray({"受死吧,小不点!","大力士就是我!"}), 1)
	end
	
	if(sourceSprite.Role:HasEquipmentTalent("直捣黄龙") and skill.Type == 3) then
		--2.天赋.直捣黄龙: 施展奇门系武功时,自身与敌人间距每隔一格额外加1.5%敌人最大血量的真实伤害
		local x1 = math.abs(sourceSprite.X - targetSprite.X)
		local y1 = math.abs(sourceSprite.Y - targetSprite.Y)
		local xy1 = math.max(x1, y1)
		if (xy1 > 0) then
			xy1 = xy1 - 1
			if (xy1 > 0) then
				skill.attackResult_Hp = skill.attackResult_Hp + math.floor(targetSprite.MaxHp * xy1 * 0.015)
				if (math.random() <= 0.5) then
					local sourceSay1 = {"怒髪冲冠,凭阑处、潇潇雨歇。","抬望眼,仰天长啸,壮怀激烈。","三十功名尘与土,八千里路云和月。","莫等闲、白了少年头,空悲切!","靖康耻,犹未雪。臣子恨,何时灭!","驾长车,踏破贺兰山缺。","壮志饥餐胡虏肉,笑谈渴饮匈奴血。","待从头、收拾旧山河,朝天阙。"}
					result:AddCastInfo(sourceSprite, sourceSay1[math.random(table.getn(sourceSay1))], 0.9)
				end
				bf:Log(sourceSprite.Role.Name .. "天赋【直捣黄龙】发动!附加真实伤害!")
			end
		end
	end

	if(sourceSprite.Role:HasRoleTalent("凶彘血统") and sourceSprite:HasBuff("屠戮凶彘") == false and sourceSprite.Hp / sourceSprite.MaxHp <= 0.7) then
		bf:Log(sourceSprite.Role.Name .. "天赋【凶彘血统】发动,伤害增加200%!")
		result:AddCastInfo(sourceSprite, "凶彘血统", 0.8)
		skill.attackResult_Hp = skill.attackResult_Hp * 3
	end
	if(targetSprite.Role:HasRoleTalent("凶彘血统") and targetSprite:HasBuff("屠戮凶彘") == false) then
		bf:Log(targetSprite.Role.Name .. "天赋【凶彘血统】发动,减伤20%!")
		result:AddCastInfo(targetSprite, "凶彘血统", 0.8)
		skill.attackResult_Hp = math.floor(skill.attackResult_Hp * 0.8)
	end
	if(sourceSprite.Role:HasRoleTalent("护国将军")) then
		if(targetSprite.Role:HasRoleTalent("凶彘血统")) then
			targetSprite:AddBuffOnly2("屠戮凶彘",0,2,100)
			result:AddCastInfo(sourceSprite, "护国将军", 0.8)
			bf:Log(sourceSprite.Role.Name .. "天赋【护国将军】发动,对" .. targetSprite.Role.Name .. "额外伤害" .. tostring(skill.attackResult_Hp))
			skill.attackResult_Hp = skill.attackResult_Hp * 2
		end
	end
	
	--独臂天赋:独臂相关技能攻击力增加,别的技能攻击力减少
	if(sourceSprite.Role:HasRoleTalent("独臂")) then
		if (string.sub(skill.Name,1,12) == "黯然销魂" or string.sub(skill.Name,1,12) == "玄铁剑法" or skill.Name == "绝学.无招胜有招") then
			--独臂相关技能攻击力增加
			skill.attackResult_Hp = math.floor(skill.attackResult_Hp * 1.5)
			if (math.random() <= 0.5) then
				result:ClearInfo(sourceSprite)
				local sourceSayDubi = {"身残志坚,只手遮天~","少只手,别担忧,不是还有杨过兄"}
				result:AddCastInfo(sourceSprite, sourceSayDubi[math.random(table.getn(sourceSayDubi))], 0.9)
			end
			bf:Log(sourceSprite.Role.Name .. "天赋【独臂】发动,招式【" .. skill.Name .. "】" .. "伤害增加!")
		else
			--别的技能攻击力减少
			skill.attackResult_Hp = math.floor(skill.attackResult_Hp * 0.8)
		end
	end
end


--扩展天赋2(不包含在AI计算内)
--与扩展天赋区别是在此的修改是立即结算
function AttackLogic_extendTalents2(sourceSprite, targetSprite, skill, bf, result)
	----20180112 MOD:
	--修改原版和MOD版的AttackLogic_extendTalents2函数调用方式,去掉skill相关变量,以增强效率
	
	----20171205 MOD:
	--删除AttackLogic_extendTalents0函数,合并到AttackLogic_extendTalents2以增强兼容性

	local isEnemy = false
	if (targetSprite.Team ~= sourceSprite.Team and skill.HitSelf == false) then
		isEnemy = true
	end
	
	--天赋:神.化功大法,20%概率直接将对手内力打空
	if(sourceSprite.Role:HasTalent("神.化功大法") and isEnemy == true) then
		if(Tools.ProbabilityTest(0.2)) then
			targetSprite.Mp = 0
			bf:Log(sourceSprite.Role.Name .. "天赋【神.化功大法】发动!直接打空" .. targetSprite.Role.Name .. "的内力!") --记录日志
			sourceSprite:Say("见识让人闻风丧胆的神.化功大法吧!")
		end
	end
	
	--天赋:诅咒,100%叠加诅咒BUFF(等级5,持续5回合)
	if(sourceSprite.Role:HasTalent("诅咒") and isEnemy == true) then
		targetSprite:Addbuff("诅咒",5,5)
	end


	--以下为softmgr自定义函数:
	local isqlbw = false 
	local isyhjy = false 

	local isSource1 = false
	local isTarget1 = false
	local Source1Name = nil
	local Target1Name = nil
	
	
	
	if (skill.Name == "飞龙探云手") then
		if (isEnemy == true) then
			math.randomseed(tostring(os.time()):reverse():sub(1, 6))
			if(math.random() <= 0.8 + sourceSprite.Role.shenfa / (6000 + sourceSprite.Role.shenfa) ) then
				result:AddAttackInfo(sourceSprite, "劫富济贫", Color.magenta)
				local toudao = 0
				local sourceSayFL1 = {"谢谢老板!银两收下了!","我凭本事偷到的,为什么要还?"}
				local isSayFL1 = Tools.ProbabilityTest(0.6)
				toudao = RuntimeData.Instance:StealMoneyEquipmentLua(sourceSprite, targetSprite)
				if (toudao == 0) then
					if (isSayFL1) then
						local sourceSayFL0 = {"运气真背!","什么也没偷到!"}
						result:AddCastInfo(sourceSprite, sourceSayFL0[math.random(table.getn(sourceSayFL0))], 1)
					end
					bf:Log(sourceSprite.Role.Name .. "运气真背,什么也没偷到!")
				elseif (toudao == 1) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, "偷你武器!", 1)
					end
					result:AddAttackInfo(targetSprite, "-武器", Color.white)
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【武器】!")
				elseif (toudao == 2) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, "偷你防具!", 1)
					end
					result:AddAttackInfo(targetSprite, "-防具", Color.white)
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【防具】!")
				elseif (toudao == 3) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, "偷你饰品!", 1)
					end
					result:AddAttackInfo(targetSprite, "-饰品", Color.white)
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【饰品】!")
				elseif (toudao == 4) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, "偷你经书!", 1)
					end
					result:AddAttackInfo(targetSprite, "-经书", Color.white)
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【经书】!")
				elseif (toudao >= 100) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, sourceSayFL1[math.random(table.getn(sourceSayFL1))], 1)
					end
					result:AddAttackInfo(targetSprite, "-$" .. tostring(toudao), Color.white)
					result:AddAttackInfo(sourceSprite, "+$" .. tostring(toudao), Color.green)
					if(math.random() <= 0.2) then
						local targetSayFL1 = {"草!","不要脸!","银两还给我啊!"}
						result:AddCastInfo(targetSprite, targetSayFL1[math.random(table.getn(targetSayFL1))], 1)
					end
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的银两【" .. tostring(toudao) .. "】!")
				elseif (toudao <= -100) then
					if (isSayFL1) then
						result:AddCastInfo(sourceSprite, sourceSayFL1[math.random(table.getn(sourceSayFL1))], 1)
					end
					result:AddAttackInfo(targetSprite, "-$" .. tostring(toudao * (-1)), Color.white)
					result:AddAttackInfo(sourceSprite, "+$" .. tostring(toudao * (-1)), Color.green)
					if(math.random() <= 0.2) then
						local targetSayFL2 = {"草!","不要脸!","银两还给我啊!"}
						result:AddCastInfo(targetSprite, targetSayFL2[math.random(table.getn(targetSayFL2))], 1)
					end
					bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的银两【" .. tostring(toudao * (-1)) .. "】!")
				end
			else
				result:AddCastInfo(sourceSprite, "毛都没有..", 1)
			end
		end
	elseif (sourceSprite.Role.ModTalents[0] == true and isEnemy == true) then
		math.randomseed(tostring(os.time()):reverse():sub(1, 6))
		local numjxjilv = 0.1 + (sourceSprite.Role.shenfa / 15000) + (math.random() / 100)
		if(math.random() <= numjxjilv) then
			local toudao = 0
			local sourceSayFL1 = {"谢谢老板!银两收下了!","我凭本事偷到的,为什么要还?"}
			local isSayFL1 = Tools.ProbabilityTest(0.6)
			toudao = RuntimeData.Instance:StealMoneyEquipmentLua(sourceSprite, targetSprite)
			if (toudao == 0) then
				bf:Log(sourceSprite.Role.Name .. "什么也没偷到!")
				if (isSayFL1) then
					local sourceSayFL0 = {"运气真背!","什么也没偷到!"}
					result:AddCastInfo(sourceSprite, sourceSayFL0[math.random(table.getn(sourceSayFL0))], 1)
				end
			elseif (toudao == 1) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【武器】!")
				if (isSayFL1) then
					sourceSprite:Say("偷你武器!")
				end
				result:AddAttackInfo(targetSprite, "-武器", Color.white)
			elseif (toudao == 2) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【防具】!")
				if (isSayFL1) then
					sourceSprite:Say("偷你防具!")
				end
				result:AddAttackInfo(targetSprite, "-防具", Color.white)
			elseif (toudao == 3) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【饰品】!")
				if (isSayFL1) then
					sourceSprite:Say("偷你饰品!")
				end
				result:AddAttackInfo(targetSprite, "-饰品", Color.white)
			elseif (toudao == 4) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的【经书】!")
				if (isSayFL1) then
					sourceSprite:Say("偷你经书!")
				end
				result:AddAttackInfo(targetSprite, "-经书", Color.white)
			elseif (toudao >= 100) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的银两【" .. tostring(toudao) .. "】!")
				if (isSayFL1) then
					result:AddCastInfo(sourceSprite, sourceSayFL1[math.random(table.getn(sourceSayFL1))], 1)
				end
				if(math.random() <= 0.2) then
					local targetSayFL1 = {"草!","不要脸!","银两还给我啊!"}
					result:AddCastInfo(targetSprite, targetSayFL1[math.random(table.getn(targetSayFL1))], 1)
				end
				result:AddAttackInfo(targetSprite, "-$" .. tostring(toudao), Color.white)
				result:AddAttackInfo(sourceSprite, "+$" .. tostring(toudao), Color.green)
			elseif (toudao <= -100) then
				bf:Log(sourceSprite.Role.Name .. "成功偷到" .. targetSprite.Role.Name .. "的银两【" .. tostring(toudao * (-1)) .. "】!")
				if (isSayFL1) then
					result:AddCastInfo(sourceSprite, sourceSayFL1[math.random(table.getn(sourceSayFL1))], 1)
				end
				if(math.random() <= 0.2) then
					local targetSayFL2 = {"草!","不要脸!","银两还给我啊!"}
					result:AddCastInfo(targetSprite, targetSayFL2[math.random(table.getn(targetSayFL2))], 1)
				end
				result:AddAttackInfo(targetSprite, "-$" .. tostring(toudao * (-1)), Color.white)
				result:AddAttackInfo(sourceSprite, "+$" .. tostring(toudao * (-1)), Color.green)
			end
		end
	end
	
	--天赋:神.封印,50%概率直接将对手封印
	if (sourceSprite.Role.ModTalents[1] == true and isEnemy == true) then
		local num31 = 0.25 + (sourceSprite.Role.AttributesFinal["fuyuan"] / 24000)
		if(Tools.ProbabilityTest(tonumber(num31))) then
			local isfy = false
			if (targetSprite:AddBuffOnly2("拳掌封印",0,3)) then
				isfy = true
			end
			if (targetSprite:AddBuffOnly2("剑封印",0,3)) then
				isfy = true
			end
			if (targetSprite:AddBuffOnly2("刀封印",0,3)) then
				isfy = true
			end
			if (targetSprite:AddBuffOnly2("奇门封印",0,3)) then
				isfy = true
			end
			if (Tools.ProbabilityTest(0.5) and targetSprite:AddBuffOnly2("仙术封印",0,3)) then
				isfy = true
			end
			if (Tools.ProbabilityTest(0.3) and targetSprite:AddBuffOnly2("特技封印",0,3)) then
				isfy = true
			end
			
			if (isfy == true) then
				bf:Log(sourceSprite.Role.Name .. "天赋【神.封印】发动!已封印" .. targetSprite.Role.Name .. "的所有外功招式!") --记录日志
				if(math.random() <= 0.6) then
					result:AddCastInfo(sourceSprite, "见识让人闻风丧胆的【神.封印】吧!", 1)
				end
			end
		end
	end
	
	if (targetSprite.Role.ModTalents[2] == true and isEnemy == true) then
		local DebuffCleared = false
		local DebuffRebounded = false
		math.randomseed(tostring(os.time()):reverse():sub(1, 6))
		local diaosi = 0.7
		if (targetSprite.Role:HasTalent("屌丝")) then
			diaosi = 0.6
		end
		if(math.random() >= diaosi) then
			if targetSprite:HasBuff("拳掌封印") then
				targetSprite:DeleteBuff("拳掌封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("拳掌封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("剑封印") then
				targetSprite:DeleteBuff("剑封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("剑封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("刀封印") then
				targetSprite:DeleteBuff("刀封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("刀封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("奇门封印") then
				targetSprite:DeleteBuff("奇门封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("奇门封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("仙术封印") then
				targetSprite:DeleteBuff("仙术封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("仙术封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("诸般封印") then
				targetSprite:DeleteBuff("诸般封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("诸般封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if targetSprite:HasBuff("特技封印") then
				targetSprite:DeleteBuff("特技封印")
				DebuffCleared = true
				if (math.random() <= 0.3 and sourceSprite:AddBuffOnly2("特技封印",0,1)) then
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.5) then
				if targetSprite:HasBuff("晕眩") then
					targetSprite:DeleteBuff("晕眩")
					DebuffCleared = true
				end
				if targetSprite:HasBuff("定身") then
					targetSprite:DeleteBuff("定身")
					DebuffCleared = true
				end
			end
			if (math.random() <= 0.3) then
				targetSprite:AddBuffOnly2("圣战",0,1)
			end
			if (DebuffCleared == true) then
				if (DebuffRebounded == true) then
					bf:Log(targetSprite.Role.Name .. "天赋【神.屌丝的逆袭】发动!解除所有封印状态!并反还封印状态!") --记录日志
				else
					bf:Log(targetSprite.Role.Name .. "天赋【神.屌丝的逆袭】发动!解除所有封印状态!") --记录日志
				end
				if (math.random() <= 0.6) then
					result:AddCastInfo(targetSprite, "看我屌丝的逆袭!", 1)
				end
			end
		end
	end
	
	if (skill.Name == "乾坤一掷" and isEnemy == true) then
		local maxattack_money = 9000
		local targethp_money = math.floor(targetSprite.Hp / 10) 
		local total_money = 0
		if (sourceSprite.Team == 1) then
			total_money = RuntimeData.Instance.Money
		else
			total_money = 5000
		end
		local current_money = math.min(maxattack_money, targethp_money, total_money)
		if (current_money > 0) then
			local attack_result1 = current_money * 10 + math.random(sourceSprite.Role.gengu)
			if (sourceSprite.Role.EquippedInternalSkill.Name == "林家心法") then
				attack_result1 = attack_result1 + math.floor(attack_result1 * math.random())
			end
			if (sourceSprite.Team == 1) then
				RuntimeData.Instance.Money = RuntimeData.Instance.Money - tonumber(current_money)
			end
			result.Hp = result.Hp + tonumber(attack_result1)
			result:AddAttackInfo(sourceSprite, "-$" .. tostring(current_money), Color.white)
			bf:Log(sourceSprite.Role.Name .. "施展【乾坤一掷】!消耗银两" .. tostring(current_money) .. "," .. targetSprite.Role.Name .. "被银两伤害" .. tostring(attack_result1))
		end
	elseif (skill.Name == "铜钱镖" and isEnemy == true) then
		local maxattack_money = 900
		local targethp_money = math.floor(targetSprite.Hp / 10)
		local total_money = 0
		if (sourceSprite.Team == 1) then
			total_money = RuntimeData.Instance.Money
		else
			total_money = 1000
		end
		local current_money = math.min(maxattack_money, targethp_money, total_money)
		if (current_money > 0) then
			local attack_result1 = current_money * 10 + math.random(sourceSprite.Role.gengu / 10)
			if (sourceSprite.Role.EquippedInternalSkill.Name == "林家心法") then
				attack_result1 = attack_result1 + math.floor(attack_result1 * math.random())
			end
			if (sourceSprite.Team == 1) then
				RuntimeData.Instance.Money = RuntimeData.Instance.Money - tonumber(current_money)
			end
			result.Hp = result.Hp + tonumber(attack_result1)
			result:AddAttackInfo(sourceSprite, "-$" .. tostring(current_money), Color.white)
			bf:Log(sourceSprite.Role.Name .. "施展【铜钱镖】!消耗银两" .. tostring(current_money) .. "," .. targetSprite.Role.Name .. "被银两伤害" .. tostring(attack_result1))
		end
	end
	
	if (bf:GetTeam1Count() >= 7 or bf:GetTeam2Count() >= 7) then
		if (targetSprite.Team ~= sourceSprite.Team) then
			for _,battleSprite1 in pairs(bf.SpritesTable) do
				if (battleSprite1.Team == sourceSprite.Team) then
					if (isSource1 == false) then
						if (battleSprite1.Role.ModTalents[3] == true) then
							isSource1 = true
							Source1Name = battleSprite1
						end
					end
				else
					if (isTarget1 == false) then
						if (battleSprite1.Role.ModTalents[3] == true) then
							isTarget1 = true
							Target1Name = battleSprite1
						end
					end
				end
			end
		end
		if (isSource1 and bf:GetTeamCount(sourceSprite.Team) > 6) then
			if ((result.Hp > 0 or result.Mp > 0) and Tools.ProbabilityTest(0.9) and targetSprite.Team ~= sourceSprite.Team) then
				local orlHp = result.Hp
				local orlMp = result.Mp
				result.Hp = math.floor(result.Hp * (1.01 + (math.random() / 2) ) )
				result.Mp = math.floor(result.Mp * (1.01 + (math.random() / 2) ) )
				bf:Log(Source1Name.Role.Name .. "阵法【天罡北斗阵】发动,叠加攻击效果。" .. sourceSprite.Role.Name .. "叠加伤害【" .. tostring(result.Hp - orlHp) .. "】,叠加吸取内力【" .. tostring(result.Mp - orlMp) .. "】" ) --记录日志
				result:AddAttackInfo(Source1Name, "天罡北斗阵", Color.red)
			end

		end
		if (isTarget1 and bf:GetTeamCount(targetSprite.Team) > 6) then
			local tgbd1 = false
			if (bf:GetTeamCount(targetSprite.Team) <= 7) then
				tgbd1 = Tools.ProbabilityTest(0.9)
			else
				tgbd1 = Tools.ProbabilityTest(0.7)
			end
			if ((result.Hp > 0 or result.Mp > 0) and tgbd1 and targetSprite.Team ~= sourceSprite.Team) then
				local orlHp = result.Hp
				local orlMp = result.Mp
				result.Hp = math.floor(result.Hp * 0.3)
				result.Mp = math.floor(result.Mp * 0.3)
				if (targetSprite.Hp - result.Hp <= 0) then
					if (Tools.ProbabilityTest(0.9)) then
						result.Hp = tonumber(targetSprite.Hp - 1)
					end
					if (Tools.ProbabilityTest(0.6)) then
						result.Debuff:Clear()
					end
				end
				bf:Log(Target1Name.Role.Name .. "阵法【天罡北斗阵】发动,增加防御力。" .. targetSprite.Role.Name .. "伤害减少【" .. tostring(orlHp - result.Hp) .. "】,被吸内力减少【" .. tostring(orlMp - result.Mp) .. "】" ) --记录日志
				result:AddCastInfo(Source1Name, "天罡北斗阵", 1)
			end

		end
	end


	--【青龙偃月刀】特有的反弹效果: 反弹自身受到伤害的100%-150%	
	if (targetSprite.Role.ModTalents[4] == true and isEnemy == true and (result.Hp > 0 or result.Mp > 0)) then
		math.randomseed(tostring(os.time()):reverse():sub(1, 6))
		local numqlfuyuan = targetSprite.Role.fuyuan / (12000 + targetSprite.Role.fuyuan)
		local numql1 = math.random()
		local numql2 = 0.1 + numqlfuyuan
		local numqlft = math.random(100, 150)
		if (targetSprite.Role:HasTalent("神.武神附体")) then
			numql2 = numql2 * 2
			numqlft = numqlft + math.random(20, 50)
		end
		if(numql1 <= numql2) then
			local targetSayQL1 = {"看招! 【神.青龙摆尾】!","胜利与信念,都交托阁下!","把眼光,从二爷的绿帽子上移开!","血战到底!","全力以赴推倒对面,是战争的基本礼仪!","自己选择的路,再荒谬也要走完!","确定了内心的正道,并绝不动摇!","聪明,就该跟我的大刀保持安全距离!","不要手下留情!","屈辱,比失败更难忍受!"}
			result:AddCastInfo(targetSprite, targetSayQL1[math.random(table.getn(targetSayQL1))], 1)
			result:AddAttackInfo(targetSprite, "神.青龙摆尾", Color.magenta)
			local textql = ""
			local qlshanghai = math.max(result.Hp, result.Mp)
			local numql26 = math.floor(sourceSprite.Hp * (qlshanghai / targetSprite.Hp) * numqlft / 100) + math.random(targetSprite.Role.AttributesFinal["bili"])
			numql26 = math.abs(numql26)
			textql = "-" .. tostring(numql26)
    		if (numql26 ~= 0) then
				result:AddAttackInfo(sourceSprite, textql, Color.white)
				sourceSprite.Hp = math.floor(sourceSprite.Hp - numql26)
				isqlbw = true
				bf:Log(targetSprite.Role.Name .. "【神.青龙摆尾】发动,对" .. sourceSprite.Role.Name .. "反弹伤害" .. tostring(numql26) ) --记录日志
				bf:ShowSkillAnimation(skill, sourceSprite.X, sourceSprite.Y, nil)
			end
		end
	end

	if (targetSprite:HasBuff("不动如山") and result.Hp > 50) then
		result.Hp = 50
		if(math.random() < 0.6) then
			result:AddAttackInfo(targetSprite, "不动如山", Color.magenta)
		end
		bf:Log(targetSprite.Role.Name .. "【不动如山】强制将伤害降为50点!")
	end

    --注意:【移花接玉】要放在AttackLogic_extendTalents2函数的最后
	if (isqlbw) then
		isyhjy = Tools.ProbabilityTest(0.2)
	else
		isyhjy = true
	end
	local yhjyneili = 300
	local num2 = -1
	if (targetSprite.Role.ModTalents[5] == true) then
		math.randomseed(tostring(os.time()):reverse():sub(1, 6))
		num2 = 0.15
		if (targetSprite.Role.ModTalents[6] == true) then
			yhjyneili = 1
			num2 = num2 * 2
		end
	end
	if (num2 > 0.1 and targetSprite.Mp >= yhjyneili and isEnemy == true and isyhjy == true and (result.Hp > 0 or result.Mp > 0)) then
		if(math.random() <= num2) then
			result:ClearInfo(targetSprite)
			local targetSayYH1 = {"移花接玉,神鬼莫敌!","以柔克刚,后发制人!","移花功法,威震天下!"}
			result:AddCastInfo(targetSprite, targetSayYH1[math.random(table.getn(targetSayYH1))], 1)
			result:AddAttackInfo(targetSprite, "移花接玉", Color.magenta)
			local text = ""
			local flag2 = true
			local num26 = math.floor(result.Hp  * 0.25)
			local num27 = math.floor(result.Mp  * 0.25)

			num26 = math.abs(num26)
			text = "-" .. tostring(num26)
    		if (num26 ~= 0) then
				result:AddAttackInfo(sourceSprite, text, Color.white)
				sourceSprite.Hp = math.floor(sourceSprite.Hp - num26)
			end

			num27 = math.abs(num27)
			text = "-内力" .. tostring(num27)
			if (num27 ~= 0) then
				result:AddAttackInfo(sourceSprite, text, Color.blue)
				sourceSprite.Mp = math.floor(sourceSprite.Mp - num27)
			end
			
			if (yhjyneili > 0) then
				targetSprite.Mp = targetSprite.Mp - yhjyneili
				result:AddAttackInfo(targetSprite, "-内力" .. tostring(yhjyneili), Color.blue)
			end
			
			local DebuffRebounded = false
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("中毒") and sourceSprite:AddBuffOnly2("中毒",3,1)) then
					targetSprite:DeleteBuff("中毒")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("内伤") and sourceSprite:AddBuffOnly2("内伤",3,1)) then
					targetSprite:DeleteBuff("内伤")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("致盲") and sourceSprite:AddBuffOnly2("致盲",3,1)) then
					targetSprite:DeleteBuff("致盲")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("缓速") and sourceSprite:AddBuffOnly2("缓速",1,1)) then
					targetSprite:DeleteBuff("缓速")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("晕眩") and sourceSprite:AddBuffOnly2("晕眩",0,1)) then
					targetSprite:DeleteBuff("晕眩")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("攻击弱化") and sourceSprite:AddBuffOnly2("攻击弱化",1,1)) then
					targetSprite:DeleteBuff("攻击弱化")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("伤害加深") and sourceSprite:AddBuffOnly2("伤害加深",3,1)) then
					targetSprite:DeleteBuff("伤害加深")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("重伤") and sourceSprite:AddBuffOnly2("重伤",3,1)) then
					targetSprite:DeleteBuff("重伤")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("定身") and sourceSprite:AddBuffOnly2("定身",1,1)) then
					targetSprite:DeleteBuff("定身")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("封穴") and sourceSprite:AddBuffOnly2("封穴",1,1)) then
					targetSprite:DeleteBuff("封穴")
					DebuffRebounded = true
				end
			end
			if (math.random() <= 0.3) then
				if (targetSprite:HasBuff("麻痹") and sourceSprite:AddBuffOnly2("麻痹",2,1)) then
					targetSprite:DeleteBuff("麻痹")
					DebuffRebounded = true
				end
			end
			
			if (DebuffRebounded) then
				bf:Log(targetSprite.Role.Name .. "天赋【移花接玉】发动,躲避攻击,反弹伤害" .. tostring(num26) .. ",反弹内力" ..  tostring(num27) .. ",反弹负面状态!") --记录日志
			else
				bf:Log(targetSprite.Role.Name .. "天赋【移花接玉】发动,躲避攻击,反弹伤害" .. tostring(num26) .. ",反弹内力" ..  tostring(num27) ) --记录日志
			end
			bf:ShowSkillAnimation(skill, sourceSprite.X, sourceSprite.Y, nil)

			if (flag2 == true) then
				result.Hp = 0
				result.Mp = 0
				result.costBall = 0
				result.Critical = false
				result.Debuff:Clear()
				result.Buff:Clear()
				result:AddAttackInfo(targetSprite, "MISS", Color.white)
			end

		end
	end

	--请勿修改
	return result
end

--扩展天赋3(包含在AI计算内,并参与计算公式)
--与扩展天赋区别是参与了最小攻击、最大攻击、暴击、防御相关的计算公式,但请不要对result.Hp进行赋值
function AttackLogic_extendTalents3(sourceSprite, targetSprite, skill, bf, result, formula)
	
	--天赋:不稳定的野球拳(最小攻击降低50%,最大攻击提高50%)
	if(sourceSprite.Role:HasTalent("不稳定的野球拳") and skill.Name == "野球拳") then
		formula.attackLow = formula.attackLow * 0.5
        if (formula.attackLow < 0) then
            formula.attackLow = 0
        end
        formula.attackUp = formula.attackUp * 1.5
		return
	end
	
	if (skill.Name == "武神") then
		if (formula.criticalHit < 2.0) then
			formula.criticalHit = 2.0
		end
		formula.attackLow = math.abs(formula.attackLow * 1.2)
		formula.attackUp = math.abs(formula.attackUp * 2.0)
		return
	elseif (skill.Name == "剑神") then
		if (formula.criticalHit < 2.0) then
			formula.criticalHit = 2.0
		end
        if (formula.attackLow < 0.1) then
            formula.attackLow = 0.1
        end
		formula.attackUp = math.abs(formula.attackUp * 1.5)
		return
	elseif (skill.Name == "雷神") then
        if (formula.attackLow < formula.attackUp) then
            formula.attackLow = math.abs(formula.attackUp)
        end
		return
	end

end

评论

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.123.4. UTC+08:00, 2024-04-18 00:28
浙ICP备14020137号-1 $访客地图$