Re: GW2 bot goals & ideas
Posted: Thu Oct 18, 2012 1:29 am
It's not really very functional right now.
That's not the problem, I still want to test the script,Administrator wrote:It's not really very functional right now.
I am curious how you can use something that is stated as not functional.rfehr wrote:That's not the problem, I still want to test the script,
can you advice me, how to use the Script.
Lisa wrote:
I am curious how you can use something that is stated as not functional.
It is like having 4 flat tires on your car and saying you will drive it to the shops.
Code: Select all
include("classes/statemanager.lua")
local subdir = getDirectory(getExecutionPath() .. "/classes/states/")
for i,v in pairs(subdir) do
include("classes/states/"..v) -- <<<< We need to avoid any disturbing subfolders like the ones created by svn clients
end
include("romcode.lua")
local version = "lisa V 8"
...
Code: Select all
include("classes/statemanager.lua")
local subdir = getDirectory(getExecutionPath() .. "/classes/states/")
for i,v in pairs(subdir) do
if v ~= ".svn" then
include("classes/states/"..v)
end
end
include("romcode.lua")
local version = "lisa V 8"
...
Code: Select all
https://gw2-bot.googlecode.com/svn/
Code: Select all
local subdir = getDirectory(getExecutionPath() .. "/functions/")
for i,v in pairs(subdir) do
if string.find(v,".lua") then
include("functions/"..v)
end
end
Well I installed tortoise more than 2 years ago when I started using ROMbot and never updated it, so... yes probably its an old version. Also I had your V8 script in a "gw2" folder wich I tried to update, but seems that main.lua and any other file that I had previously in that folder wasn't updated, thats why I got that error, I wasn't using the latest main.lua as I thought. Anyway sorry for the mistake, I was just trying to help, not to make you work more than you use toThe only way I can think of you getting so many .svn is if you are using a really old version of tortoise.
Well... maybe not really very functional but functional enough to show a smileAdministrator wrote:It's not really very functional right now.
Code: Select all
radius.lua
--[[
Child of State class.
]]
-- kill/loot in radius zone
-- will loot monsters in combat if activated in profile
-- Using this state you may die but... usage: gw2/main radius:XXXX (minimum radius of 'maxdistance' will be set)
include("../state.lua");
RadiusState = class(State);
function RadiusState:constructor(originX, originZ, radius)
self.name = "Radius";
self.tabtime = getTime();
self.originX = originX;
self.originZ = originZ;
if radius and tonumber(radius) >= profile['maxdistance'] then
self.radius = tonumber(radius);
else
self.radius = profile['maxdistance'];
end
end
function RadiusState:update()
logger:log('debug-states',"Coming to RadiusState:update()");
statusupdate() -- update Interaction
targetupdate() -- to get target cleared
if distance(player.X, player.Z, self.originX, self.originZ) > self.radius then
logger:log('info',"Too far from origin, we return origin at: %s %s", self.originX, self.originZ)
self:returnToOrigin();
end
if player.TargetMob ~= 0 then
statusupdate()
coordsupdate()
if distance(player.X, player.Z, target.TargetX, target.TargetZ) < profile['maxdistance'] and
distance(target.TargetX, target.TargetZ,self.originX, self.originZ) < self.radius then
if distance(player.X, player.Z, target.TargetX, target.TargetZ) < profile['fightdistance'] then
local newCombat = CombatState()
logger:log('info',"Target is at skill range, we push combat state");
newCombat.getNewTarget = false -- don't get new targets in combat state, just defend
stateman:pushState(newCombat);
else
logger:log('info',"get new target in radius, we push Firstattack state");
stateman:pushState(FirstattackState());
end
else
logger:log('info',"Target is too far away, we clear target");
keyboardPress(key.VK_ESCAPE); --clear target
self:returnToOrigin();
end
else --no target
player:getNextTarget(); --get new target
if player.TargetMob == 0 then --still no target
--logger:log('info',"no more targets near, we return origin at: %s %s", self.originX, self.originZ)
self:returnToOrigin();
end
end
end
function RadiusState:returnToOrigin()
statusupdate()
coordsupdate()
self.tabtime = getTime();
if distance(player.X, player.Z, self.originX, self.originZ) > profile['fightdistance'] then --if we are far from origin we return origin
player:stopMoving();
player:stopTurning();
local walking = true;
while (walking) do
logger:log('info',"Moving to origin");
coordsupdate() --Not sure if neccesary
if distance(player.X, player.Z, self.originX, self.originZ) > profile['fightdistance'] then
player:moveTo_step(self.originX, self.originZ, math.random()*20);
yrest(500);
else
walking = false;
end
if ( deltaTime(getTime(), self.tabtime ) > 10000 ) then -- just 10 secs to move to origin
walking = false;
end
end
else --if we are near origin we just turn around
logger:log('info',"Looking around");
player:moveTo_step(self.originX+(math.random()*100), self.originZ+(math.random()*100), math.random()*100); --random movement
yrest (1000);
end
player:stopMoving();
player:stopTurning();
end
function RadiusState:handleEvent(event)
end
table.insert(events,{name = "Radius", func = RadiusState})
Code: Select all
lootincombat.lua
--[[
Child of State class.
]]
include("../state.lua");
LootInCombatState = class(State);
function LootInCombatState:constructor(corpseX , corpseZ)
self.name = "LootInCombat";
self.corpseX = corpseX;
self.corpseZ = corpseZ;
self.foundcorpse = false;
self.movetime = getTime();
end
function LootInCombatState:update()
logger:log('debug-states',"Coming to LootInCombatState:update()");
coordsupdate()
if distance(player.X, player.Z, self.corpseX, self.corpseZ) > 100 then
while not self.foundcorpse do
logger:log('info',"Moving towards fallen foe");
coordsupdate() --Not sure if neccesary
if distance(player.X, player.Z, self.corpseX, self.corpseZ) > 100 then
player:moveTo_step(self.corpseX, self.corpseZ, math.random()*20);
yrest(500);
else
self.foundcorpse = true;
end
if ( deltaTime(getTime(), self.movetime ) > 5000 ) then -- just 5 secs to find corpse
self.foundcorpse = true;
end
end
player:stopTurning();
player:stopMoving();
end
statusupdate()
if player.Interaction == true and player.Ftext ~= language:message('InteractGreeting') and player.Ftext ~= language:message('InteractTalk') then
while (player.Interaction and player.Ftext ~= language:message('InteractGreeting') and player.Ftext ~= language:message('InteractTalk')) do -- try loot till no interaction, just in case you kill more than a mob at same place
keyboardPress(keySettings['interact']);
logger:log('info',"Looting corpse at: %s %s", self.corpseX, self.corpseZ);
yrest(500);
statusupdate()
end
else
logger:log('info',"No drop");
end
logger:log('info',"finished looting, popping")
stateman:popState("loot finished");
end
table.insert(events,{name = "LootInCombat", func = LootInCombatState})
Code: Select all
['lootInCombat'] = true, --I included it just below 'loot' flag
Code: Select all
combat.lua
....
....
self.wasFighting = false; -- remember if we have used skill
self.corpseX = 0; -- Not sure if neccesary to include corpse coords
self.corpseZ = 0; -- here at constructor, but its a way
end
....
....
....
....
targetupdate();
statusupdate();
if target.TargetX ~= 0 and target.TargetZ ~= 0 then
self.corpseX = target.TargetX; -- everytime we do targetupdate() we refresh
self.corpseZ = target.TargetZ; -- the coords of the future mob corpse
end
....
....
....
....
self.wasFighting = false
-- if profile['loot'] == true and deltaTime(getTime(), self.startFightTime) > 1000 then -- ??? why wait ?
if profile['loot'] == true then
if profile['lootInCombat'] == true then -- Only for brave ones...
stateman:pushState(LootInCombatState(self.corpseX , self.corpseZ));
stateman:run(); -- had to do this... sorry
else
stateman:pushEvent("Loot", "finished combat");
end
end
stateman:popState("combat ended");
return
end
....
....
....
....
-- no more targets, leave combat state
if player.TargetMob == 0 then -- still no target
if profile['lootInCombat'] == true then -- force loot before leaving state
stateman:pushState(LootInCombatState(self.corpseX , self.corpseZ));
stateman:run();
end
stateman:popState("end of combat state, no more targets");
return
end
....
....
Code: Select all
else -- don't have a target
Code: Select all
main.lua
....
....
stateman = StateManager();
for i = 2,#args do
local foundpos = string.find(args[i], ":", 1, true);
if foundpos then
local var = string.sub(args[i], 1, foundpos-1);
local val = string.sub(args[i], foundpos+1);
if( var == "path" ) then
wpName = val;
end
if( var == "multipath" ) then
multipathName = val;
end
if( var == "radius" ) then -- so usage should be gw2/main radius:10000
local radius = val;
coordsupdate()
local originX = player.X;
--local originY = player.Y;
local originZ = player.Z;
defaultState = RadiusState(originX, originZ, radius);
logger:log('info',"Origin set at: %s %s Radius: %s", originX, originZ, radius)
end
if( var == "state" ) then
for k,v in pairs(events) do
if string.lower(v.name) == string.lower(val) then
defaultState = v.func();
end
end
end
....
....
Code: Select all
firstattack.lua
....
....
if player.TargetMob ~= 0 then
if profile['maxdistance'] > distance(player.X, player.Z, target.TargetX, target.TargetZ) then
if player:moveTo_step(target.TargetX, target.TargetZ, profile['fightdistance']) then
self.starttime = os.time()
keyboardPress(key.VK_1)
yrest(1000)
stateman:popState("first attack done") --added this line but can't really explain why
end
else
stateman:popState("Target to far away") keyboardPress(key.VK_ESCAPE)
end
else
stateman:popState("first attack popped") return -- returned from combat or loot
end
--if os.difftime(os.time(),self.starttime) > 5 then stateman:popState("first attack no damage") keyboardPress(key.VK_ESCAPE) end -- I comented this line for no special reason
end
....
....
It makes me smile that I didn't have to spend an hour explaining how everything worksChikitor wrote:Well... maybe not really very functional but functional enough to show a smile
Code: Select all
SETTINGS['useKeypress'] = true
Code: Select all
--=== range of the skills (for scepter/dagger elementalist) ===--
['skill1range'] = 900,
['skill2range'] = 900,
['skill3range'] = 240,
['skill4range'] = 240,
['skill5range'] = 300,
['skill7range'] = 1500, -- Arcane Blast
['skill8range'] = 360, -- Arcane Wave
['skill9range'] = 360, -- Arcane shield
Code: Select all
if profile['skillXuse'] == true and os.difftime(os.time(),self.skillXused) > profile['skillXcd'] + SETTINGS['lagallowance'] and profile['skillXrange'] >= dist then
...