local punch_damage = 35 local punch_range = 165 local punched = 0 local temp = 0 local startf = 0 local midf = 0 local endf = 0 function thirdp_melee_init(e) end function thirdp_melee_main(e) if punched == 0 then if g_Scancode == 45 then punched = 1 temp = math.random(1,1) if temp == 1 then startf = 2340 midf = 2370 endf = 2382 else startf = 5511 midf = 5540 endf = 5553 end StopAnimation(e) --CharacterControlUnarmed(e) CharacterControlLimbo(e) SetAnimationFrames(startf,endf) PlayAnimation(e) end elseif punched == 1 then if g_Entity[e]['animating'] == 0 then SetAnimationFrames(startf,endf) PlayAnimation(e) g_Entity[e]['animating'] = 2 end if GetAnimationFrame(e) > midf then for a = 1, 2999 do if a ~= e then if g_Entity[a] ~= nil then if g_Entity[a]['health'] > 0 then if PlayerLooking(a,punch_range,5) == 1 then if AICouldSee(g_Entity[a]['obj'],g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ) == 1 then SetEntityHealth(a,g_Entity[a]['health'] - punch_damage) punched = 2 break end end end end end end end elseif punched == 2 then if GetAnimationFrame(e) >= endf then punched = 0 end end end function thirdp_melee_exit(e) end function PlayerLooking(e,dis,v) if g_Entity[e] ~= nil then if dis == nil then dis = 3000 end if v == nil then v = 0.5 end if GetPlayerDistance(e) <= dis then local destx = g_Entity[e]['x'] - g_PlayerPosX local destz = g_Entity[e]['z'] - g_PlayerPosZ local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle <= 0 then angle = 360 + angle elseif angle > 360 then angle = angle - 360 end while g_PlayerAngY < 0 or g_PlayerAngY > 360 do if g_PlayerAngY <= 0 then g_PlayerAngY = 360 + g_PlayerAngY elseif g_PlayerAngY > 360 then g_PlayerAngY = g_PlayerAngY - 360 end end local L = angle - v local R = angle + v if L <= 0 then L = 360 + L elseif L > 360 then L = L - 360 end if R <= 0 then R = 360 + R elseif R > 360 then R = R - 360 end if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then return 1 elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then return 1 else return 0 end else return 0 end end end