--该技能方法参考瑞文和雨衣模组，伤害结算方式与雨衣一致


local Tosocast = Class(function(self, inst)
    self.inst = inst
    --self.canuseskill = false
end)

function Tosocast:areaskill(caster)
    local old = caster.bufferedaction
    if caster:HasTag("huoqiang") then
        self:huoqiang_attack(caster)
	elseif caster:HasTag("baofengxue") then
        self:baofengxue_attack(caster)
    end
    caster.bufferedaction = old
    return true
end
--[[
function Tosocast:checkskillscd(caster)
	local weapon = caster.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
	if weapon and weapon.weapon_skillscd then
	caster.tososkillcd = (100-weapon.weapon_skillscd)/100
	else
	caster.tososkillcd = 1
	end
	return caster.tososkillcd
end

function Tosocast:toso_skilldmg(caster)
	local skilldmg = (10+caster.tosolevel)*caster.tosodmgpercent
	local weapon = caster.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
	if weapon and weapon.components.weapon then
	local weapondmg = weapon.components.weapon.damage
		if weapon.components.weapon.damage > 30 then
			skilldmg = (weapondmg+caster.tosolevel)*caster.tosodmgpercent
		end
	end
	return skilldmg
end
	
function Tosocast:toso_skilldist(caster)
	local skilldist = 3.25
	local weapon = caster.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
	if weapon and weapon.components.weapon then
		if weapon and weapon.components.weapon and weapon.components.weapon.attackrange then
			skilldist = weapon.components.weapon.attackrange+2.25
		end
	end
	return skilldist
end
]]
function Tosocast:tosotarget()
	local pos = Vector3(GetPlayer().Transform:GetWorldPosition())
	local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30)
	for k,v in pairs(ents) do
		if v and v.components.follower and v.components.follower.leader == GetPlayer() and not v:HasTag("myfriend") then
		v:AddTag("myfriend")
		end
		if v.components.combat and v.components.health and not v.components.health:IsDead() and not v:HasTag("tosotarget") and not v:HasTag("toso") and not v:HasTag("myfriend") and not v:HasTag("wall") and not (v.components.inventoryitem and v.components.inventoryitem.owner) then
		v:AddTag("tosotarget")
--		elseif v.components.combat and v.components.health and not v.components.health:IsDead() and not v:HasTag("tosotarget") and not v:HasTag("myfriend") and v:HasTag("monster") and GetPlayer():HasTag("mononly") and not v:HasTag("wall") and not v:HasTag("toso") then
--		v:AddTag("tosotarget")
		end
	end
end
--[[
function Tosocast:get_tosotarget(caster)
	self:tosotarget()
    self.canuseskill = false
	local x1, y1, z1 = caster.Transform:GetWorldPosition()
	local target = GetClosestInstWithTag("tosotarget", caster or GetPlayer(), 15)
	if caster.components.combat.targetfn then
		local target = caster.components.combat.targetfn(caster)
		if not caster.components.combat.target and target ~= nil then
			caster.components.combat:SetTarget(target)
		end
	end
	if target and target~=nil then
		local x2, y2, z2 = target.Transform:GetWorldPosition()
		local dist = math.sqrt((x1 - x2)*(x1 - x2) + (z1 - z2)*(z1 - z2))
		local dist_Instructions = self:toso_skilldist(caster)
		local pos = Point(caster.Transform:GetWorldPosition())
		local range_indicators = TheSim:FindEntities(pos.x,pos.y,pos.z, 10, {"toso_range_indicator"} )
		if dist > self:toso_skilldist(caster) then
			caster.components.combat:SetTarget(target)
			caster:RemoveTag("xinjineng")
			caster:RemoveTag("xinjineng2")
			caster.components.talker:Say(TUNING.TALK19)
			if range_indicators then
				for i,v in ipairs(range_indicators) do if v:IsValid() then v:Remove() end end
				local s  = 0.6
				if dist_Instructions == 0.75 then s =0.75 elseif dist_Instructions >= 5 then s = 1.1+(dist_Instructions-5)*0.074 end
				local range = SpawnPrefab("toso_range_indicator")
				range.entity:SetParent(caster.entity)
				range.Transform:SetPosition(0, 0, 0)
				range.Transform:SetScale(s,s,s)
			else
				local s  = 0.675
				if dist_Instructions == 0.75 then s =0.75 elseif dist_Instructions >= 5 then s = 1.1+(dist_Instructions-5)*0.074 end
				local range = SpawnPrefab("toso_range_indicator")
				range.entity:SetParent(caster.entity)
				range.Transform:SetPosition(0, 0, 0)
				range.Transform:SetScale(s,s,s)
			end
		elseif dist <= self:toso_skilldist(caster) then
			self.canuseskill = true
		end
	end
	if not target or target==nil or (target and target.components.health and target.components.health:IsDead()) then
	caster.components.talker:Say(TUNING.TALKS15)
	caster:RemoveTag("xinjineng")
	caster:RemoveTag("xinjineng2")
	end
	if target and target~=nil and target.components.combat and target.components.health and not target.components.health:IsDead() then
	return target
	end

end

function Tosocast:skill_pt(caster)
	if caster:HasTag("huoqiang") then
		local pt=Vector3(TheInput:GetWorldPosition():Get())
		return pt
	elseif caster:HasTag("baofengxue") then
		local pt=Vector3(TheInput:GetWorldPosition():Get())
		return pt
	elseif caster:HasTag("tososkill8") and not caster:HasTag("tososkill8_target") then
		local pt=Vector3(TheInput:GetWorldPosition():Get())
		return pt
	elseif caster:HasTag("tososkill7") and caster:HasTag("tososkill7_target") then
		self:tosotarget()
		local target = GetClosestInstWithTag("tosotarget", caster or GetPlayer(), 15)
			if not (target and target~=nil and target.components.combat and target.components.health and not target.components.health:IsDead()) then
				local pt=Vector3(TheInput:GetWorldPosition():Get())
				return pt
			elseif target and target~=nil and target.components.combat and target.components.health and not target.components.health:IsDead() and caster:HasTag("xinjineng2") then
				local pt = Vector3(target.Transform:GetWorldPosition())
				return pt
		end
	elseif caster:HasTag("tososkill8") and caster:HasTag("tososkill8_target") then
		self:tosotarget()
		local target = GetClosestInstWithTag("tosotarget", caster or GetPlayer(), 15)
			if not (target and target~=nil and target.components.combat and target.components.health and not target.components.health:IsDead()) then
				local pt=Vector3(TheInput:GetWorldPosition():Get())
				return pt
			elseif target and target~=nil and target.components.combat and target.components.health and not target.components.health:IsDead() and caster:HasTag("xinjineng2") then
				local pt = Vector3(target.Transform:GetWorldPosition())
				return pt
		end

	end
end
]]
--参考瑞文第三段Q，伤害轨迹重写
--踏前斩
function Tosocast:taqianzhan_attack(caster)
        local pt = Vector3(TheInput:GetWorldPosition():Get())
        caster:ForceFacePoint(pt.x, pt.y, pt.z)
        local x2, y2, z2 = caster.Transform:GetWorldPosition()
        local angel = math.atan2(pt.z - z2, pt.x - x2)
        local dist = math.sqrt((pt.x - x2) * (pt.x - x2) + (pt.z - z2) * (pt.z - z2))
        local speed = dist * 2
        caster.AnimState:PlayAnimation("atk")
		local pos1 = Vector3(caster.Transform:GetWorldPosition())
		--加入一个特效	
		local fxhuo = SpawnPrefab("dilie_toso")
		fxhuo.Transform:SetScale(1.4, 1.4, 1.4)
		fxhuo.Transform:SetPosition(caster:GetPosition():Get())	

               local ents = TheSim:FindEntities(pos1.x,pos1.y,pos1.z, 5)
               for k,v in pairs(ents) do
                   if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("toso") and not v:HasTag("myfriend") and not v:HasTag("wall") and not v:HasTag("hive") and not v:HasTag("toso_role") and not v:HasTag("toso_helper") then
                      

                        v.components.health:DoDelta(-10)

                      local pt1 = caster:GetPosition()
                      local pt2 = v:GetPosition()
                      local Repelrate = (1 + math.random() )*1
                      v.Transform:SetPosition((pt2.x-pt1.x)*Repelrate+pt2.x, 0, (pt2.z-pt1.z)*Repelrate+pt2.z)
					  local fx = SpawnPrefab("explode_small")
					  fx.Transform:SetPosition( v.Transform:GetWorldPosition() )
                   end
               end
		
		
		
        caster:DoTaskInTime(0.2, function()
            if math.random() < 0.3 then
                caster.components.talker:Say("什么鬼", nil, true)
            end
            caster.AnimState:PlayAnimation("jump")
            caster.Physics:SetMotorVelOverride(20, 10, 0)
        end)
        caster:DoTaskInTime(0.4, function()
            caster.Physics:ClearMotorVelOverride()
            caster.Physics:SetMotorVelOverride(20, -10, 0)
            caster.AnimState:PlayAnimation("chop_loop")
        end)
        caster:DoTaskInTime(0.6, function()
            caster.SoundEmitter:PlaySound("dontstarve/tentacle/tentacle_attack")
            caster.AnimState:PlayAnimation("atk")
            if caster.components.driver and caster.components.driver.vehicle then
                caster.components.driver.vehicle:Hide()
            end
			
						--caster:DoTaskInTime(.2, function()
							if not caster.sg:HasStateTag("busy") and not caster.sg:HasStateTag("doing") then
								caster.sg:GoToState("idle")
										--local fxbo = SpawnPrefab("groundpoundring_fx")
		                                --fxbo.Transform:SetScale(0.5, 0.5, 0.5)
		                                --fxbo.Transform:SetPosition(caster:GetPosition():Get())
								--caster.SoundEmitter:PlaySound("dontstarve_DLC002/common/boatjump_to_land")
							end
						--end)
			
        end)
		
		
		--这里参考翼语的击飞代码--
        caster:DoTaskInTime(0.5, function()
            local x5, y5, z5 = caster:GetPosition():Get()		
            local ents = TheSim:FindEntities(x5, y5, z5, 5)
			                for k,v in pairs(ents) do
            		if v.components.combat and v.components.health and not v.components.health:IsDead() and not v:HasTag("toso") and not v:HasTag("myfriend") and not (v.components.inventoryitem and v.components.inventoryitem.owner) and not v:HasTag("wall") and not v:HasTag("toso_role") and not v:HasTag("toso_helper") then

                       if v and v.components.health and not (v.components.inventoryitem and v.components.inventoryitem.owner) then
						  v.components.combat:GetAttacked(caster, 5 )
					   end
					   
								if v and v.components.combat then v.components.combat:BlankOutAttacks(1.5) v.components.combat:SetTarget(nil) end
		                        if v.brain then v.brain:Stop() end
		                        if v.components.locomotor then v.components.locomotor:Stop() end
		                        if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.hit and not v.components.health:IsDead() then v.sg:GoToState("hit") end
		                        if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.idle and not v.components.health:IsDead() then v.sg:GoToState("idle") end	
								
								
							    				local x7, y7, z7 = v:GetPosition():Get()
												local ziwen = SpawnPrefab("ziwen")
		                                        ziwen.Transform:SetPosition(x7, y7, z7)
		                                        ziwen.Transform:SetScale(3.5, 3.5, 3.5)
												
				                                local sign=1
				                                v.task1 = v:DoPeriodicTask(0.05,  function()
					                            local x8, y8, z8 = v:GetPosition():Get()
					                            v:AddTag("toso_jifei")
					                            v.Transform:SetPosition(x7, y8+0.35*sign, z7)
				                                end)
				                                v:DoTaskInTime(0.5, function() 
					                            sign=-1
				                                end)
				                                v:DoTaskInTime(1, function()
					                            if v and v.task1 then
					                            v.task1:Cancel()
					                            v.task1 = nil
					                            end
					                            v:RemoveTag("toso_jifei")
					                            v.Transform:SetPosition(x7, y7, z7)
				                                end)

	                        if v and v.components.combat and v.components.health and not v.components.health:IsDead() then
	                        v:DoTaskInTime(1.5, function()
	                        if v.brain then v.brain:Start() end
	                        if v.components.freezable and v.components.freezable:IsFrozen() then v:PushEvent("unfreeze") end
	                        if v then v.components.combat:SetTarget(caster) end
	                        --if v then v.AnimState:SetMultColour(255/255,255/255,255/255,1) end
	                        end)
	                        end
							
            end
            end

        end)
		--这里参考翼语的击飞代码。--	
end

--冰冻三尺
--参照雪莉大招
function Tosocast:bingdongsanchi_attack(caster)
    --if not IsPaused() then
    if caster.components.lingli.currentlingli < 10 then
       caster.components.talker:Say("灵力不足")
    end
	
    if caster.components.lingli.currentlingli >= 10 then
       caster.components.talker:Say("冰冻三尺")
       caster.components.lingli:DoDelta(-10)
       --caster.components.hunger:DoDelta(-10)
       caster.components.playercontroller:Enable(false) 
       local pos = caster:GetPosition()
       caster.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
       
       caster:DoTaskInTime(0.01, function()
            caster.AnimState:PlayAnimation("pickup")
            caster.SoundEmitter:PlaySound("dontstarve/creatures/deerclops/ice_large") 

            for k = 1,math.random(30,40) do
			
            local pt = Vector3(caster.Transform:GetWorldPosition())
            local prefab = "icespike_fx_"..math.random(1,4)
            local fx = SpawnPrefab(prefab)
            fx.Transform:SetPosition(pt.x+(math.random(8)-math.random(8)), 0, pt.z+(math.random(8)-math.random(8)))
            end
          
       end)
       caster:DoTaskInTime(0.02, function()




            local pos = Vector3(caster.Transform:GetWorldPosition())
            local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10)
            for k,v in pairs(ents) do
               
                if v.components.freezable and not v:HasTag("toso") and not v:HasTag("shadowcreature") and not v:HasTag("toso_role") and not v:HasTag("toso_helper") then
                   v.components.health:DoDelta(-5)
                   v.components.freezable:AddColdness(2)
		           v.components.freezable:SpawnShatterFX()
--添加buff
--v:AddTag("ice2")
                end
            end
       
            caster.components.playercontroller:Enable(true)
       end)
    end
	
end


--该技能参考翼语的诸神黄昏代码--	
--煞气
function Tosocast:linglishifang_attack(caster)

    local lingli_percent = caster.components.lingli:GetPercent()
	caster.components.talker.colour = Vector3(0.7, 0.85, 1, 1)
	caster.components.talker.fontsize = 26
	if caster.linghua then caster.linghua:Remove() caster.linghua = nil end
	if not IsPaused() and not caster:HasTag("Linghua") then
		if lingli_percent >= 0.2 then
			caster.components.talker:Say("灵力状态")
			--caster.SoundEmitter:PlaySound("yiyuattack/yiyuattack/jinengr")
			--caster.components.hunger:DoDelta(-20)
			caster.components.lingli:StartLingdc()
			--if caster:HasTag("yiyuhanmer") then
				--caster.components.combat.areahitrange = caster.yiyulevel/15+2.5
				--caster.components.combat.areahitdamagepercent = 1
			--elseif not caster:HasTag("yiyuhanmer") then
				--caster.components.combat.areahitrange = caster.yiyulevel/15+2.5
				--caster.components.combat.areahitdamagepercent = caster.yiyulevel/75+0.1
			--end
			--if caster:HasTag("yiyuwings") then
			--caster.components.locomotor.walkspeed = TUNING.WILSON_RUN_SPEED * 1.7
			--caster.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * 1.7
			--elseif not caster:HasTag("yiyuwings") then
			--caster.components.locomotor.walkspeed = TUNING.WILSON_RUN_SPEED * 1.33
			--caster.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * 1.33
			--end
			caster.components.combat.areahitrange = caster.tosolevel/15+2.5
		    caster.components.combat.areahitdamagepercent = 1
		    caster.components.locomotor.walkspeed = caster.components.locomotor.walkspeed*1.2
		    caster.components.locomotor.runspeed = caster.components.locomotor.runspeed*1.2
			caster.components.hunger.hungerrate = caster.components.hunger.hungerrate * 3
			caster:AddTag("Linghua")
--			caster.AnimState:SetBuild("yuyi")
			local light = caster.entity:AddLight()
			light:SetIntensity(.8)
			light:SetRadius(2+caster.tosolevel/10)
			light:SetFalloff(.4)
			light:Enable(true)
			light:SetColour(180/255,195/255,150/255)
			caster.linghua = SpawnPrefab("lingli_fx")
			--caster.linghua = SpawnPrefab("baguadun")
			caster.linghua.entity:SetParent(caster.entity)
			caster.linghua.Transform:SetPosition(0, -1, 0)
			caster.linghua.AnimState:PushAnimation("lunar_3_loop", true)
			--caster.linghua.AnimState:PushAnimation("idle", true)
		elseif lingli_percent < 0.2 and not caster:HasTag("Linghua") then
			caster.components.talker:Say("灵力不足了")
			caster.components.talker.colour = Vector3(1, 0.85, 0.75, 1)
			if caster.linghua then caster.linghua:Remove() caster.linghua = nil end	   
		end
	elseif caster:HasTag("Linghua") then
		caster:RemoveTag("Linghua")
		caster.components.lingli:StopLingdc()
		caster.Light:Enable(false)
		caster.components.combat.areahitrange = 0
		caster.components.combat.areahitdamagepercent = 0
		caster.components.locomotor.walkspeed = caster.components.locomotor.walkspeed/1.2
		caster.components.locomotor.runspeed = caster.components.locomotor.runspeed/1.2
		caster.components.hunger.hungerrate = TUNING.WILSON_HUNGER_RATE * 1.2
		caster.Light:Enable(false)
		if caster.linghua then caster.linghua:Remove() caster.linghua = nil end	
	end	

end
--这里参考翼语的诸神黄昏代码。--	

--烈火刀法
function Tosocast:liehuodaofa_attack(caster)

    caster:ClearBufferedAction()
    caster.components.playercontroller:Enable(false)
    caster.components.locomotor:Stop()	
    if caster.components.driver and caster.components.driver.vehicle then caster.components.driver.vehicle:Show() end

    local pt = Vector3(caster.Transform:GetWorldPosition())
    caster:DoTaskInTime(0.05, function()

    caster:ForceFacePoint(pt.x,pt.y,pt.z)
    caster.AnimState:PlayAnimation("atk")
	local toso_leiting = SpawnPrefab("liehuodaofa_toso")
	toso_leiting.Transform:SetScale(3, 3, 3)
	toso_leiting.Transform:SetPosition(pt.x, pt.y-0.7, pt.z)
	--toso_leiting.Transform:SetPosition(pt.x, pt.y+4, pt.z)
		self:jianyu_area(pt, caster)
		caster.AnimState:PlayAnimation("chop_loop")
	caster:DoTaskInTime(0.3, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(0.6, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(0.9, function()
		self:jianyu_area(pt, caster)
		caster.AnimState:PlayAnimation("powerup")
	end)
	caster:DoTaskInTime(1.2, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(1.5, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(1.8, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(2.0, function()
		self:jianyu_area(pt, caster)
	end)

        caster.SoundEmitter:PlaySound("dontstarve/wilson/attack_weapon")
        if caster.components.health then
            caster.components.health:SetInvincible(true)
        end
    end)
    caster:DoTaskInTime(0.5, function()
		--caster.SoundEmitter:PlaySound("dontstarve/rain/thunder_close")
        caster.components.locomotor:Stop()
        caster.AnimState:PlayAnimation("idle")

        if caster.components.health then
            caster.components.health:SetInvincible(false)
        end
        caster.components.playercontroller:Enable(true)
        caster:ClearBufferedAction()

    end)	
	
end


--被动死亡返照
function Tosocast:siwangfanzhao_attack(caster)

    caster:ClearBufferedAction()
    caster.components.playercontroller:Enable(false)
    caster.components.locomotor:Stop()	
    if caster.components.driver and caster.components.driver.vehicle then caster.components.driver.vehicle:Show() end

    local pt = Vector3(caster.Transform:GetWorldPosition())
    caster:DoTaskInTime(0.05, function()

    caster:ForceFacePoint(pt.x,pt.y,pt.z)
    caster.AnimState:PlayAnimation("atk")
	local toso_leiting = SpawnPrefab("liekaitexiao")
	toso_leiting.Transform:SetScale(3, 3, 3)
	toso_leiting.Transform:SetPosition(pt.x, pt.y-0.7, pt.z)
	--toso_leiting.Transform:SetPosition(pt.x, pt.y+4, pt.z)
		--self:jianyu_area(pt, caster)
		caster.AnimState:PlayAnimation("eat")
	caster:DoTaskInTime(0.3, function()
		self:jianyu_area(pt, caster)
	end)
	--caster:DoTaskInTime(0.6, function()
		--self:jianyu_area(pt, caster)
	--end)
	caster:DoTaskInTime(0.9, function()
		self:jianyu_area(pt, caster)
	end)
	--caster:DoTaskInTime(1.2, function()
		--self:jianyu_area(pt, caster)
	--end)
	caster:DoTaskInTime(1.5, function()
		self:jianyu_area(pt, caster)
	end)
	--caster:DoTaskInTime(1.8, function()
		--self:jianyu_area(pt, caster)
	--end)
	caster:DoTaskInTime(2.0, function()
		self:jianyu_area(pt, caster)
	end)

        caster.SoundEmitter:PlaySound("dontstarve/wilson/attack_weapon")
        if caster.components.health then
            caster.components.health:SetInvincible(true)
        end
    end)
    caster:DoTaskInTime(0.5, function()
		--caster.SoundEmitter:PlaySound("dontstarve/rain/thunder_close")
        caster.components.locomotor:Stop()
        caster.AnimState:PlayAnimation("idle")

        if caster.components.health then
            caster.components.health:SetInvincible(false)
        end
        caster.components.playercontroller:Enable(true)
        caster:ClearBufferedAction()

    end)	
	
end


function Tosocast:jianyu_attack(caster)

	--caster.components.colourtweener:StartTween({1,1,1,1}, 0)
    caster:ClearBufferedAction()
    caster.components.playercontroller:Enable(false)
    caster.components.locomotor:Stop()	
    if caster.components.driver and caster.components.driver.vehicle then caster.components.driver.vehicle:Show() end

    local pt = Vector3(TheInput:GetWorldPosition():Get())
    caster:DoTaskInTime(0.05, function()

    caster:ForceFacePoint(pt.x,pt.y,pt.z)
    caster.AnimState:PlayAnimation("atk")
	--特效1
	local toso_xuanfeng1 = SpawnPrefab("jianyu")
	--toso_xuanfeng1.Transform:SetScale(1, 1, 1)
	toso_xuanfeng1.Transform:SetScale(3, 3, 3)
	toso_xuanfeng1.Transform:SetPosition(pt.x, pt.y, pt.z)

		self:jianyu_area(pt, caster)
		
	caster:DoTaskInTime(0.33, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(0.66, function()
		self:jianyu_area(pt, caster)
	end)
	caster:DoTaskInTime(0.99, function()
		self:jianyu_area(pt, caster)
	end)
	--caster:DoTaskInTime(2.00, function()
		--self:jianyu_area(pt, caster)
	--end)

        caster.SoundEmitter:PlaySound("dontstarve/wilson/attack_weapon")
        if caster.components.health then
            caster.components.health:SetInvincible(true)
        end
    end)
    caster:DoTaskInTime(0.5, function()
		--caster.SoundEmitter:PlaySound("dontstarve/rain/thunder_close")
        caster.components.locomotor:Stop()
        caster.AnimState:PlayAnimation("idle")

        if caster.components.health then
            caster.components.health:SetInvincible(false)
        end
        caster.components.playercontroller:Enable(true)
        caster:ClearBufferedAction()

    end)	
	
end

function Tosocast:jianyu_area(pt, caster)
	local weapon =  caster.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
	local weapondmg = 20
	if weapon and weapon.components.weapon.damage then
		weapondmg = weapon.components.weapon.damage
	end
	local plus_dmg = 2 + caster.level 
    local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, caster.tosolevel/10+5)
    for k,v in pairs(ents) do
	if v.components.combat and v.components.health and not v.components.health:IsDead() and not v:HasTag("toso") and not v:HasTag("myfriend") and not (v.components.inventoryitem and v.components.inventoryitem.owner) and not v:HasTag("wall") and not v:HasTag("toso_role") and not v:HasTag("toso_helper") then
		if v.components.health and not (v.components.inventoryitem and v.components.inventoryitem.owner) then v.components.combat:GetAttacked(caster, plus_dmg) end
		if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.hit and not v.components.health:IsDead() then v.sg:GoToState("hit") end
		if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.idle and not v.components.health:IsDead() then v.sg:GoToState("idle") end
end
end
end

--预留给以后用的伤害结算
function Tosocast:other_area(pt, caster)
	local weapon =  caster.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
	local weapondmg = 20
	if weapon and weapon.components.weapon.damage then
		weapondmg = weapon.components.weapon.damage
	end
	local plus_dmg = 2 + caster.level
    local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, 5)
    for k,v in pairs(ents) do
	if v.components.combat and v.components.health and not v.components.health:IsDead() and not v:HasTag("toso") and not v:HasTag("myfriend") and not (v.components.inventoryitem and v.components.inventoryitem.owner) and not v:HasTag("wall") and not v:HasTag("toso_role") and not v:HasTag("toso_helper") then
		if v.components.health and not (v.components.inventoryitem and v.components.inventoryitem.owner) then v.components.combat:GetAttacked(caster, plus_dmg) end
		if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.hit and not v.components.health:IsDead() then v.sg:GoToState("hit") end
		if v.sg and v.sg.sg and v.sg.sg.states and v.sg.sg.states.idle and not v.components.health:IsDead() then v.sg:GoToState("idle") end
end
end
end


return Tosocast