Gunner.lua

HollyGR
Posts: 21
Joined: Wed Jan 18, 2017 10:30 am
Has thanked: 9 times

Gunner.lua

Post by HollyGR » Wed Jan 18, 2017 11:50 am

Hello, sharing my gunner.lua - I didn't modified it from a long while since is still working perfectly to me without breaks even for all day long.
I use it with autochain enabled and never had any problem so far, vision skill to refill HP included and working aswell - maybe code could be improved somehow but since everything working to me I didn't touched at all :D .

Code: Select all

--[[

	--------------------------------------------------
	Copyright (C) 2011 Blastradius, macrokor, rellis

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
	--------------------------------------------------
	
]]--

--[[
KNOWN STATE ID'S 
- State Name = Stunning Shot II - State ID = 679
- State Name = Stunned - State ID = 8217
- State Name = Entangling Shot III - State ID = 676
- State Name = No Name (Godstone: Deltras's Loyalty) State ID = 8540
- State Name = Shackle Arrow I - State ID = 672
- State Name = Sleep Arrow I - State ID = 695
]]--

function CountMobs( EntityTarget, Distance )

	local i = 0;
	
	-- Iterate through all entities
	for ID, Entity in DictionaryIterator( EntityList:GetList()) do
		-- Check if the entiy is valid.
		if Entity ~= nil then
			-- Retrieve the entity state.
			local EntityState = Entity:GetState();
			-- Check if the entity state is valid.
			if EntityState ~= nil then
				-- Check if this is a living monster that is in range.
				if Entity:IsMonster() and not Entity:IsDead() and Entity:IsHostile() and EntityTarget:GetPosition():DistanceToPosition( Entity:GetPosition()) <= Distance then
					-- Check if this entity is sleeping
					if EntityState:GetState( Helper:CheckName( "Sleep Arro" )) ~= nil then
						return 0;
					-- Increment the number.
					else
						i = i + 1;
					end
				end
			end
		end
	end
	
	return i;
	
end

function SleepMultipleAttacker( EntityTarget, AttackRange )
	-- Check if we have stored a target.
	if self._SleepTarget ~= nil then
		-- Check if the current target is the stored target.
		if self._SleepTarget:GetID() == Player:GetTargetID() then
			-- Check if Sleep Arrow is available.
			if Helper:CheckAvailable( "Sleep Arro" ) then
				-- Shoot the Sleep Arrow.
				Helper:CheckExecute( "Sleep Arro" );
				-- Indicate we cannot continue attacking.
				return false;
			else
				-- Set the target.
				Player:SetTarget( self._SleepTargetRestore );
				-- Indicate we cannot continue attacking.
				return false;
			end
		-- Check if the current target is the original target.
		elseif not Helper:CheckAvailable( "Sleep Arro" ) and self._SleepTargetRestore:GetID() == EntityTarget:GetID() then
			-- Clear the sleep target.
			self._SleepTarget = nil;
			-- Indicate we cannot continue attacking.
			return true;
		else
			-- Set the target.
			Player:SetTarget( self._SleepTarget );
			-- Indicate we cannot continue attacking.
			return false;
		end
	end
	-- Check if Sleep Arrow is available.
	if Helper:CheckAvailable( "Sleep Arro" ) then
		-- Loop through the entities.
		for ID, Entity in DictionaryIterator( EntityList:GetList()) do
			-- Check if this entity is a monster, is not friendly and decided to attack me (and obviously is not my current target).
			if not Entity:IsDead() and Entity:IsMonster() and not Entity:IsFriendly() and Entity:GetTargetID() == Player:GetID() and Entity:GetID() ~= EntityTarget:GetID() then
				-- Check if the entity that is attacking us is within range.
				if Entity:GetPosition():DistanceToPosition( Player:GetPosition()) <= AttackRange then
					-- Store the sleep target.
					self._SleepTarget = Entity;
					-- Store the restore target.
					self._SleepTargetRestore = EntityTarget;
					-- Set the target.
					Player:SetTarget( Entity );
					-- Indicate we cannot continue attacking.
					return false;
				end
			end
		end
	end
	-- Indicate we can continue attacking.
	return true;
end

--- Perform the attack routine on the selected target.
--
-- @param	Entity	Contains the entity we have targeted.
-- @param	double	Contains the distance to the target
-- @param	bool	Indicates whether or not the target is stunned.
-- @return	bool

function Attack( Entity, Range, Stunned, SkipFocusedEvasion )

	local TripeedFruit = InventoryList["Tripeed Fruit"];
	local TripeedSeed = InventoryList["Tripeed Seed"];
	local AttackRange = Player:GetAttackRange();
	
	-- Correct the attack range when using Bestial Fury.
	if Player:GetState():GetState( Helper:CheckName( "Parting Sho" )) then
		AttackRange = AttackRange - 5;
	end

	-- Check if we are allowed to sleep attackers.
	if Settings.Ranger.AllowSleep and not self:SleepMultipleAttacker( Entity, AttackRange ) then
		return false;
	end
	
	
	--------------------------------------------------
	--     I N I T I A L   A T T A C K (S) (I)      --
	--------------------------------------------------
	
	-- Initial Attack 1: Automatic Attack
	if self.AttackStarted ~= Entity:GetID() then
		self.AttackStarted = Entity:GetID();
		Helper:CheckExecute( "Attack/Chat" );
		return false;
	end
	
	--------------------------------------------------
	--        N O R M A L   A T T A C K (S)         --
	--------------------------------------------------
	
	-- Demonstration of using the multicast mechanism on a muse.
--
-- ~ By Blastradius
--

-- Contains the multicast level.
local Level = 0
-- Contains the previous identifier.
local PreviousId = 0

--
-- Perform a begin to end attack routine.
--
function OnRun()
	-- Find the selected target entity.
	local Target = EntityList:GetEntity(Player:GetTargetId())
	-- Check if a selected target is available and is alive.
	if Target ~= nil and not Target:IsDead() then
		-- Retrieve the skill identifier.
		local Id = Player:GetSkillId()
		-- Check if the skill identifier has not been set.
		if Id == 0 then
			-- Initialize the multicast level.
			Level = 0
			-- Initialize the previous identifier.
			PreviousId = 0
			-- Begin with the Incendiary Shell ability.
			Do("Incendiary Shell");
		-- Otherwise check if the previous identifier is invalid.
		elseif PreviousId == 0 then
			-- Initialize the multicast level.
			Level = 1
			-- Set the previous identifier.
			PreviousId = Id
		-- Otherwise check if the identifier has increased.
		elseif Id > PreviousId then
			-- Increment the multicast level.
			Level = Level + 1
			-- Set the previous identifier.
			PreviousId = Id
			-- Check if the desired multicast level has been achieved.
			if Level == 3 then
				-- End with the Incendiary Shell ability.
				Do("Incendiary Shell");
			end
		end
	end
end

--
-- Perform an ability without condition checking.
--
function Do(Name)
	-- Find the ability with the specified name.
	local Ability = AbilityList:GetAbility(Name)
	-- Check if the ability is valid.
	if Ability ~= nil then
		-- Input the command to do the ability.
		PlayerInput:Console("/Skill " .. Ability:GetName())
	end
end

		if Helper:CheckAvailable( "Steal Health" ) then
		Helper:CheckExecute( "Steal Health" );
		return false;
		elseif Helper:CheckAvailable( "Remove Shock" ) then 
		Helper:CheckExecute( "Remove Shock" );
		return false;
		end
    	
    	if Helper:CheckAvailable( "Spend Success" ) and Player:GetDP() >= 2000 then
		    Helper:CheckExecute( "Spend Success" );
		   	return false;
		end
		
		if Helper:CheckAvailable( "Bulletproof" ) then
	    	Helper:CheckExecute( "Bulletproof", Player );
	    	return false;
    	end
		
		if Helper:CheckAvailable( "Bullet Resistance" )  and Player:GetHealth() <= 70 then
		    Helper:CheckExecute( "Bullet Resistance" );
	    	return false;
	    end
		
	
		if Helper:CheckAvailable( "Autoload" ) and Player:GetManaCurrent() < Player:GetManaMaximum() - 3000 then
		Helper:CheckExecute( "Autoload", Entity );
		return false;
		end 
		
	    if Helper:CheckAvailable( "Nature's Favor" ) then
	    	Helper:CheckExecute( "Nature's Favor", Player );
	    	return false;
    	end
    	if Helper:CheckAvailable( "Aion's Favor" ) then
	    	Helper:CheckExecute( "Aion's Favor", Player );
	    	return false;
	    end
		if Helper:CheckAvailable( "Pressurized Chamber" ) then
			Helper:CheckExecute( "Pressurized Chamber", Player );
			return false;
		end
		
		-- Skills starts
		
		if Helper:CheckAvailable( "Hot Shot" ) then                
                Helper:CheckExecute( "Hot Shot" )                
                return false;
        end
		
		if Helper:CheckAvailable( "Green Grenade" ) then                
                Helper:CheckExecute( "Green Grenade" )                
                return false;
        end
		
        if Helper:CheckAvailable( "Direct Shot" ) then                
                Helper:CheckExecute( "Direct Shot" )                
                return false;
        end
		
        if Helper:CheckAvailable( "Hemorrhage Shot" ) then
                Helper:CheckExecute( "Hemorrhage Shot" )
                return false;
        end
		
		-- Chain Attack 1: Crosstrigger
		if Helper:CheckAvailable( "Crosstrigger" ) then
		Helper:CheckExecute( "Crosstrigger" );
		end        
		
		if Helper:CheckAvailable( "Reload" ) then
	    	Helper:CheckExecute( "Reload" );
	    	return false;
    	end	
		
		if Helper:CheckAvailable( "Spinning Fire" ) then
	    	Helper:CheckExecute( "Spinning Fire" );
	    	return false;
    	end	
		
        if Helper:CheckAvailable( "Wing Clip" ) then                
                Helper:CheckExecute( "Wing Clip" )                
                return false;
        end
		
     	if Helper:CheckAvailable( "Pulverizer Cannon" ) then
				Helper:CheckExecute( "Pulverizer Cannon" );
		end 
		
        if Helper:CheckAvailable( "Quieting Gale" ) then
                Helper:CheckExecute( "Quieting Gale" )                
                return false;
        end	
		               
        if Helper:CheckAvailable( "Autoload" ) then
			Helper:CheckExecute( "Autoload" );
			return false;
		end
		
        if Helper:CheckAvailable( "Steady Fire" ) then
            Helper:CheckExecute( "Steady Fire" )
            return false;
        end	
		
		if Helper:CheckAvailable( "Anti-Enemy Fire " ) then
            Helper:CheckExecute( "Anti-Enemy Fire " )
            return false;
        end	
      	    
end

--- Perform healing checks both in and our of combat.
--
-- @param	bool	Indicates whether or not the function is running before force checks.
-- @return	bool

function Heal( BeforeForce )

	-- Nothing was executed, continue with other functions.
	return true;
	
end

--- Perform the safety checks before moving to the next target.
--
-- @return	bool

function Pause()
	
	-- Nothing was executed, continue with other functions.
	return true;
	
end

kendhc
Posts: 5
Joined: Mon Jan 30, 2017 4:52 pm

Re: Gunner.lua

Post by kendhc » Wed Feb 01, 2017 8:45 am

Hi,
i was wondering if you had an improved version, and also how to make the gunner bot stay in one place while farming, so it doesnt aggro primordials etc.

HollyGR
Posts: 21
Joined: Wed Jan 18, 2017 10:30 am
Has thanked: 9 times

Re: Gunner.lua

Post by HollyGR » Wed Feb 01, 2017 10:08 am

kendhc wrote:
Wed Feb 01, 2017 8:45 am
Hi,
i was wondering if you had an improved version, and also how to make the gunner bot stay in one place while farming, so it doesnt aggro primordials etc.
I don't have any improved version since it works simply perfectly for me, can kill mobs for whole day long without any break or death at all.
To put a character into one spot and make it kill the same mob all the time just select the official grinderframework from aionscript without selecting any pathway so it won't move at all and just aggro the mob really next to him, if that will not be enough just go look somewhere into settings.lua of officialgrinderframework about that string and modify it with your personal needs :mrgreen:

Code: Select all

-- Contains the maximum distance of the area in which to search for targets (Requires AllowTargetSearch).
	self.TargetSearchDistance = 15;
If you put the character-bot into a cool spot it will not aggro any other entity ;) .

agonic
VIP
Posts: 159
Joined: Tue Jan 10, 2017 6:39 pm
Has thanked: 34 times
Been thanked: 112 times

Re: Gunner.lua

Post by agonic » Wed Feb 01, 2017 12:52 pm

It contains unnecessary Ranger things. I guess you may clear them. also wrong functions etc. For example, in attack function, there are "OnRun" and "Do(Name)". They should be separated functions and they are unnecessary. Also, You use sleep arrow ?

Code: Select all

function SleepMultipleAttacker( EntityTarget, AttackRange )
Or you use seed ??

Code: Select all

local TripeedFruit = InventoryList["Tripeed Fruit"]; local TripeedSeed = InventoryList["Tripeed Seed"];
And you dont use

Code: Select all

function CountMobs( EntityTarget, Distance )
anywhere. Just delete

HollyGR
Posts: 21
Joined: Wed Jan 18, 2017 10:30 am
Has thanked: 9 times

Re: Gunner.lua

Post by HollyGR » Fri Feb 03, 2017 10:36 am

agonic wrote:
Wed Feb 01, 2017 12:52 pm
It contains unnecessary Ranger things. I guess you may clear them. also wrong functions etc. For example, in attack function, there are "OnRun" and "Do(Name)". They should be separated functions and they are unnecessary. Also, You use sleep arrow ?

Code: Select all

function SleepMultipleAttacker( EntityTarget, AttackRange )
Or you use seed ??

Code: Select all

local TripeedFruit = InventoryList["Tripeed Fruit"]; local TripeedSeed = InventoryList["Tripeed Seed"];
And you dont use

Code: Select all

function CountMobs( EntityTarget, Distance )
anywhere. Just delete
Well, I just shared what I was and still using since is still working perfectly :D - is not made by myself and I didn't modified anything beside adding the vision skill :lol:

User avatar
FarAwaY
Posts: 48
Joined: Sun Jan 29, 2017 9:31 pm
Has thanked: 22 times
Been thanked: 13 times

Re: Gunner.lua

Post by FarAwaY » Fri Feb 10, 2017 2:10 am

What Stigmas i Need to add too my gunner that this script works?

thx
Image

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

Re: Gunner.lua

Post by pawelgbw » Mon Mar 06, 2017 12:43 pm

How to check the current gun on himself,
How can it change?

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Gunner.lua

Post by nucular » Mon Mar 06, 2017 12:50 pm

pawelgbw wrote:
Mon Mar 06, 2017 12:43 pm
How to check the current gun on himself,
How can it change?
Check Templar.lua inside Classes folder and make sure you are using "AionScript Release 28.02.2017".

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

Re: Gunner.lua

Post by pawelgbw » Mon Mar 06, 2017 4:43 pm

/Change Weapon - How to do it in AionScript?

Online
User avatar
nucular
Site Admin
Posts: 260
Joined: Sat Jan 07, 2017 9:08 pm
Has thanked: 27 times
Been thanked: 388 times

Re: Gunner.lua

Post by nucular » Thu Mar 09, 2017 7:17 pm

If you wanna switch use macro command function and then use "/changeweaponset" like this:

PlayerInput:Console("/changeweaponset")

After that check what weapon you have equipped with the function like in Templar.lua.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest