Basic Bot for Gunner

Post Reply
pawelgbw
VIP
Posts: 47
Joined: Fri Feb 10, 2017 8:10 am
Has thanked: 111 times
Been thanked: 14 times

Basic Bot for Gunner

Post by pawelgbw » Wed Jul 12, 2017 9:41 am

Code: Select all

Target = nil
TargetID = nil
SearchEntity = true

-- gunner variables
Weapon1H = nil
Weapon1HCH = nil
FlagWeaponChange = false

-- travel variables
travel_ptr = 1
travel_old = travel_ptr
travel_sig = 1
_time = nil
source = Player:GetPosition()
dest = source
skalar = 1.75		-- To modify

-- FindBestEntity variable
 searchdistance = 16	-- To modify

-- example: ugKatalam spot travel

travel =
{
	536.44213867188, 883.17291259766, 560.10107421875,
	559.58453369141, 917.36724853516, 560.56030273438,
	549.53039550781, 926.91918945313, 560.65936279297,
	543.19085693359, 932.12548828125, 556.64385986328,
	538.57086181641, 937.09899902344, 555.86614990234,
	537.20147705078, 938.31744384766, 555.32531738281,
	522.82427978516, 964.04382324219, 554.875,
	527.51489257813, 964.50482177734, 554.96844482422,
	509.6325378418,  983.08575439453, 555,
	495.11209106445, 946.96942138672, 554.81951904297,
	478.75778198242, 934.90264892578, 554.71545410156,
	475.5625 , 932.40551757813, 552.78259277344,
	465.25872802734, 923.80834960938, 553.35406494141,
	462.33505249023, 901.36541748047, 556.57934570313
}

travel_len = #travel / 3

function ReadTravel(ind)
	id = (ind * 3) - 2
	dest.X = travel [id]
	dest.Y = travel [id + 1]
	dest.Z = travel [id + 2]
end

function OnRun()
	if SearchEntity == true then
		Target = FindBestEntity()
		if Target == nil then
			MovePlayer()
			return
		end
		CheckRealWeapon()
		Weapon1HCH = Weapon1H
		SearchEntity = false
		TargetID = Target: GetID()
		_time = Time()
	end

	Target = EntityList:GetEntity(TargetID)
	if Target ~= nil and Target:IsDead() or Target == nil then
		SearchEntity = true
		TargetID = 0
		return
	end
	
	if Player:GetTargetID() ~= TargetID then
		Player:SetTarget(Target)
	end
	
	Attack_Gunner()
	
	if Time() > _time + 4000 and Target:GetHealth() == 100 then		-- #4000 To modify
		SearchEntity = true
		TargetID = 0
		MovePlayer()
	end
end

function MovePlayer()
	if travel_ptr  < 1 or travel_ptr > travel_len then
		travel_sig = - travel_sig
		travel_ptr = travel_old
	end
	ReadTravel(travel_ptr)

	if MoveTeleport() == true then
		travel_old = travel_ptr
		travel_ptr = travel_ptr + travel_sig
	end
end

function MoveTeleport ()
	source = Player:GetPosition()
	local deltax = dest.X - source.X
	local deltay = dest.Y - source.Y
	local deltaz = dest.Z - source.Z
	local distance = math.sqrt(deltax * deltax + deltay * deltay + deltaz * deltaz)
	if distance <= skalar then
		source = dest
		Player:SetPosition(source)
		return true
	end

	deltax = deltax/distance
	deltay = deltay/distance
	deltaz = deltaz/distance

	source.X = source.X + deltax * skalar
	source.Y = source.Y + deltay * skalar
	source.Z = source.Z + deltaz * skalar
	Player:SetPosition(source)
	return false
end

function FindBestEntity()
	local score = 0
	local bestscore = 0
	local bestentity = nil

	for ID, Entity in DictionaryIterator(EntityList:GetList()) do
		local distance = Player:GetPosition():DistanceToPosition(Entity:GetPosition())
		if distance < searchdistance and not Entity:IsDead() and Entity:IsMonster() and not Entity:IsFriendly() and not Entity:IsGatherable() and Entity:GetTypeID() < 800000 then
			score = 127 - distance
			if Entity:GetTargetID() == Player: GetID() then
				score = score + 128
			end
			if score > bestscore then
				bestscore = score
				bestentity = Entity
			end
		end
	end
	Player:SetTarget(bestentity)
	return bestentity
end

------------------------	Gunner Script    ------------------------ 

function Attack_Gunner()
	--Shock State
	if CheckSkill_ACT_CDR("Seizure Projectile") then
		PlayerInput:Console("/skill Seizure Projectile")
		return
	end

	if CheckSkill_ACT_CDR("Escape") then
		PlayerInput:Console ("/skill Escape")
		return
	end
	if CheckSkill_ACT_CDR("Remove Shock") then
		PlayerInput:Console("/skill Remove Shock")
		return
	end
    -- Evasion / Resistance
    if CheckSkill_ACT_CDR("Aimed Weakpoint Shot") then
    	PlayerInput:Console("/skill Aimed Weakpoint Shot")
    	return
    end
	-- Aether's Hold
	if CheckSkill_ACT_CDR("Torment Cannon Ball") then
		if Weapon1H == true then
			PlayerInput:Console("/skill Torment Cannon Ball")
			return
		end
		Weapon1HCH = true
		return
	end

	CheckRealWeapon()
	if Weapon1H ~= Weapon1HCH then
		if FlagWeaponChange == false then
			PlayerInput:Console ("/changeweaponset")
			FlagWeaponChange = true
			if CheckSkill_ACT_CDR("Projectile of Silence") then
				PlayerInput:Console("/skill Projectile of Silence")
				return
			end
			if CheckSkill_ACT_CDR("Gift of Magic Power") then
				PlayerInput:Console("/skill Gift of Magic Power")
				return
			end
			if CheckSkill_ACT_CDR("Retreal Shot") then
				PlayerInput:Console("/skill Retreal Shot")
				return
			end
		end
		return
	else
		FlagWeaponChange = false
	end
	if Weapon1H == true then
		Weapon1H_Attack()
	else
		Weapon2H_Attack()
	end
end

function Weapon1H_Attack()
	if Player:GetManaCurrent()<404 then
		Weapon1HCH = false
		return
	end

	if CheckSkill_ACT_CDR("Aimed Cannon Shot") then
		PlayerInput:Ability("Aimed Cannon Shot")
		return
	end

	if CheckSkill_ACT_CDR("Snow Projectile") then
		PlayerInput:Console("/skill Snow Projectile")
		return
	end

	if CheckSkill_ACT_CDR("Frost Cannon") then
		PlayerInput:Console("/skill Frost Cannon")
		return
	end

	if CheckSkill_ACT_CDR("Fire Cannon") then
		if Target:GetTargetID() ~= Player:GetID() then
			PlayerInput:Ability ("Fire Cannon")
			return
		else
			PlayerInput:Console("/skill Fire Cannon")
			return
		end
	end
	Weapon1HCH = false
end

function Weapon2H_Attack()
	if CheckSkill_ACT_CDR("Heavy Projectile") then
		PlayerInput:Console ("/skill Heavy Projectile")
		return
	end
	if CheckSkill_ACT_CDR("Repeated Rapid Fire") then
		PlayerInput:Console ("/skill Repeated Rapid Fire")
		return
	end
	if CheckSkill_ACT_CDR("Repeated Volley") then
		PlayerInput:Console ("/skill Repeated Volley")
		return
	end

	if CheckSkill_ACT_CDR("Rapid Soul Fire") then
		PlayerInput:Console("/skill Rapid Soul Fire")
		return
	end
	if CheckSkill_ACT_CDR("Soul Volley") then
		PlayerInput:Console("/skill Soul Volley")
		return
	end
	if CheckSkill_ACT_CDR("Seal Shot") then
		PlayerInput:Console("/skill Seal Shot")
		return
	end

	if CheckSkill_ACT_CDR("Weakpoint Shot") then
		PlayerInput:Console("/skill Weakpoint Shot")
		return
	end
	if CheckSkill_ACT_CDR("Debilitating Volley") then
		PlayerInput:Console("/skill Debilitating Volley")
		return
	end

	if Player:GetMana() < 50 and CheckSkill_ACT_CDR("Soul Shot") then
		PlayerInput:Console("/skill Soul Shot")
		return
	end
	if CheckSkill_ACT_CDR("Pistol Shot") then
		PlayerInput:Console("/skill Pistol Shot")
		return
	end

	if CheckSkill_ACT_CDR("Wild Magic Projectile") then
		PlayerInput:Console("/skill Wild Magic Projectile")
		return
	end

	if CheckSkill_ACT_CDR("Rapid Volley") then
		PlayerInput:Console("/skill Rapid Volley")
		return
	end

	if CheckSkill_ACT_CDR("Restoration Volley") then
		PlayerInput: Console("/skill Restoration Volley")
		return
	end
	if CheckSkill_ACT_CDR("Lifeline Penetration") then
		PlayerInput:Console("/skill Lifeline Penetration")
		return
	end
	if CheckSkill_ACT_CDR("Aimed Wing Shot") then
		PlayerInput:Console("/skill Aimed Wing Shot")
		return
	end
	if CheckSkill_ACT_CDR("Soulsucker Shot") then
		PlayerInput:Console("/skill Soulsucker Shot")
		return
	end
	if CheckSkill_ACT_CDR("Encircling Bomb") then
		PlayerInput:Console("/skill Encircling Bomb")
		return
	end
	if CheckSkill_ACT_CDR("Disrupter Shot") then
		PlayerInput:Console("/skill Disrupter Shot")
		return
	end
	if CheckSkill_ACT_CDR("Sighting Shot") then
		PlayerInput:Console("/skill Sighting Shot")
		return
	end
	if CheckSkill_ACT_CDR("Insert Magic Projectile") then
		PlayerInput:Console("/skill Insert Magic Projectile")
		return
	end
	if CheckSkill_ACT_CDR("Load Magic Projectile") then
		PlayerInput:Console("/skill Load Magic Projectile")
		return
	end
	Weapon1HCH = true
end

function CheckRealWeapon()
	Weapon1H = false
	for Inventory in ListIterator( InventoryList:GetList()) do
		if Inventory:GetType():ToString() == "Weapon2H" and Inventory:GetSlot():ToString() == "3" then
			Weapon1H = true
			break
		end
	end
end

function CheckSkill_ACT_CDR (Name)
	local Ability = AbilityList:GetAbility( Name );
	if Ability ~= nil and Ability:GetActivated()==true and Ability:GetCooldown()==0 then
		return true
	end
	return false
end

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest