Page 1 of 1
Script crashing game client
Posted: Mon May 12, 2014 7:55 am
by silinky
Hi!
i made a script for the current event where the turtles attack a bunny and i have to kill them before reaching me (or the bunny). Very similar to andor race minigame.
problem is, that my script starts, waits for the turtles to appear, they appear, it kills some of them, then the game crashes. here is the unfinished script (i need to att quest repeating parts yet.)
any ideas why it crashes the game? does it enter an infinite loop somewhere? could it be that this is not in an instance and too many objects are found in the area, and crashes the memory? it is near varanas gate.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<onLoad>
<![CDATA[
function killTurtles()
repeat
tortoise = player:findNearestNameOrId({120553,120554,120555}) -- tortoises
player:target(tortoise)
RoMScript("UseExtraAction(1)")
yrest(200)
until not player:findNearestNameOrId(120553,120554,120555)
end
print("Waiting for turtles.")
repeat
yrest(100)
until player:findNearestNameOrId(120553)
print("The turtles are coming!")
repeat
killTurtles()
player:update()
yrest(100)
until not player:hasBuff(622174)
error("Success! Going to hand in.")
]]>
</onLoad>
</waypoints>
Re: Script crashing game client
Posted: Mon May 12, 2014 8:13 am
by BlubBlab
The only think which could possible crash the game is that you targeting a mob which not exist any more.
You can also check out mine :
http://www.solarstrike.net/phpBB3/viewt ... =27&t=5169
Re: Script crashing game client
Posted: Mon May 12, 2014 9:26 am
by silinky
second variant, still crashes the game. it doesn't crash it from the start, but after it successfully killed some turtles, so no code errors. it simply crashes the game, and the bot does not show any error.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<onLoad>
<![CDATA[
function killTurtles()
guerilla = player:findNearestNameOrId("Guerilla Tortoise") -- tortoises
if guerilla then
player:target(guerilla)
yrest(50)
RoMScript("UseExtraAction(1)")
yrest(50)
end
snatching = player:findNearestNameOrId("Snatching Tortoise") -- tortoises
if snatching then
player:target(snatching)
yrest(50)
RoMScript("UseExtraAction(1)")
yrest(50)
end
artillery = player:findNearestNameOrId("Heavy Artillery Tortoise") -- tortoises
if artillery then
player:target(artillery)
yrest(50)
RoMScript("UseExtraAction(1)")
yrest(50)
end
end
while (true) do
killTurtles()
end
]]>
</onLoad>
</waypoints>
Re: Script crashing game client
Posted: Mon May 12, 2014 9:34 am
by BlubBlab
hm ..

..

..
I had something similar with my ks script suddenly kept crashing only after they fixed those crashing in the new zone I it ended.
Maybe it is something else but I have then I have no idea what.(you can just try my script if it also crash the client)
Re: Script crashing game client
Posted: Mon May 12, 2014 9:40 am
by silinky
i use your script on andor game, and it works perfectly

but it is too complicated for this event game, here the bot basically has to target 3 kinds of friendly turtles, and and use the extra action 1 on them until they don't spawn anymore.
it should be one of the most simple bots, and it is, dunno why it crashes the game.
when i use a macro to do it, it works perfectly but i must stay at the game the whole time.
Code: Select all
/script TargetNearestFriend();
/script UseExtraAction(1);
and i also have to move the camera all the time because they appear out of FOV too.
i cannot imagine what would crash it, but it does every time.
Re: Script crashing game client
Posted: Mon May 12, 2014 10:15 am
by rock5
With the first code maybe you need a pause between targeting and pressing the extra action button. I see you added them in the second code.
With the second code, if it finds nothing (I don't know if this happens) you have a loop with no pauses.
But still it could be anything.
Re: Script crashing game client
Posted: Mon May 12, 2014 10:27 am
by silinky
do you have any other idea how could i do this with the bot? with another method?
all it has to do is:
- search for one of three friendly mob in an area of a maximum of 200 units
- if one is found to use extra action 1
- if not, wait 1 second and try again
i cannot see what the problem would be, the bot goes on normally, and the game freezes and crashes after it kills some turtles.
Re: Script crashing game client
Posted: Mon May 12, 2014 3:42 pm
by silinky
oh well, i tried more approaches, every one of them crashed the game, dunno what to do anymore. if i add a very long rest before and after skill cast, it doesn't crash every time but the turtles overwhelm me, and i still had crashes randomly.
i guess it is manual for me then.
Re: Script crashing game client
Posted: Mon May 12, 2014 4:30 pm
by ZZZZZ
Maybe its due to targeting and trying to cast on 1 that is fading out? aka 1 that has already been hit by the ExtraAction skill? Try adding an ignore to each findNearestNameOrId() for the last address it targeted with each if statement?
Just guessing here

Re: Script crashing game client
Posted: Tue May 13, 2014 12:05 am
by rock5
Good idea. And findNearestNameOrId has an 'ignore' argument. So all you have to do is set your last target to a global variable eg.
Code: Select all
RoMScript("UseExtraAction(1)")
myLastTarget = tortoise.Address
Then use that variable in the findNextNearestNameOrId command.
Code: Select all
tortoise = player:findNearestNameOrId({120553,120554,120555}, myLastTarget)
Re: Script crashing game client
Posted: Tue May 13, 2014 5:41 am
by silinky
thank you! i will test this also and if it works i will post it here for others to use it.
Re: Script crashing game client
Posted: Mon May 19, 2014 4:33 pm
by ZZZZZ
Tried this function, it seems to work, at least, it doesn't crash but it does get stuck on the addresses. Apparently each position that a turtle appears is the same address, or at least it seems that way. So somehow I need to detect when the old address is gone and remove from the list.
Code: Select all
function killTurtles()
local ignoreTableTort = {}
while true do
yrest(50);
local objectList = CObjectList()
objectList:update()
local objSize = objectList:size()
for i = 0,objSize do
local obj = objectList:getObject(i)
if (obj.Id == 120553 or obj.Id == 120554 or obj.Id == 120555) and not table.contains(ignoreTableTort, obj.Address) then
player:target(obj)
yrest(200)
RoMCode("UseExtraAction(1)")
print("kill")
yrest(500)
table.insert(ignoreTableTort, obj.Address)
end
end
print("New list")
end
end
Re: Script crashing game client
Posted: Mon May 19, 2014 8:15 pm
by ZZZZZ
Ok that's odd, i tried this
Code: Select all
function killTurtlestest()
local ignoreTableTort = {}
while true do
yrest(50);
local objectList = CObjectList()
objectList:update()
local objSize = objectList:size()
for i = 0,objSize do
local obj = objectList:getObject(i)
if (obj.Id == 120553 or obj.Id == 120554 or obj.Id == 120555) and not table.contains(ignoreTableTort, obj.Address) then
player:target(obj)
yrest(100)
RoMCode("UseExtraAction(1)")
print("kill")
yrest(100)
table.insert(ignoreTableTort, obj.Address)
end
end
for k,v in pairs(ignoreTableTort) do
if ignoreTableTort[1] ~= nil then
local check = player:findNearestNameOrId(v)
if not check then
printf(" . ")
table.remove(ignoreTableTort, k)
end
end
end
print("New list")
end
end
It almost finished, going from how long it usually takes to do the event it only had a few turtles to go, then it crashed. Tried increasing the yrests but it'll still do it eventually :/ I give up now lol. Used too many TP runes xD
Re: Script crashing game client
Posted: Mon May 19, 2014 10:08 pm
by rock5
I'm not sure what's happening to the turtles while you are going through the object list but because it takes time for you to go through the list, you might want to check that each object still exists before doing your actions on it. The object class doesn't have an exists function but if you update the object the Id will become 0 if the object doesn't exists anymore, eg.
Code: Select all
for i = 0,objSize do
local obj = objectList:getObject(i)
obj:update()
if obj.Id ~= 0 and (obj.Id == 120553 or obj.Id == 120554 or obj.Id == 120555) and not table.contains(ignoreTableTort, obj.Address) then
....
end
table.insert(ignoreTableTort, obj.Address)
end
I moved the table.insert outside the if statement because I assume you want to add any non turtle objects to the ignore list so you don't keep checking them.
I'm not sure of the necessety to remove addresses from the ignoreTableTort table but the table is a table of addresses. You can not use addresses with findNearestNameOrId. You can only use names and ids. Maybe the easiest solution is to create an object and see if it is valid, eg.
Code: Select all
for k,v in pairs(ignoreTableTort) do
if CObject(v).Id == 0 then
printf(" . ")
table.remove(ignoreTableTort, k)
end
end
Re: Script crashing game client
Posted: Tue May 20, 2014 2:43 am
by ZZZZZ
Basically I was going off the assumption that the game is crashing due to targeting/casting on a turtle that is already hit. So to deal with that I decided to add those that I had hit already to a table, and then check obj ID's and the table against any objects found.
Im not sure why it isnt working, but when I do 'if CObject(v).Id == 0 then' it says its removing it, but for some reason the addresses in that table do not seem to get deleted. Meaning after about 1.5 waves of turtles it simply spams mm with lots of dots and "new list".
Re: Script crashing game client
Posted: Tue May 20, 2014 3:03 am
by rock5
Actually I just realized you don't need obj.Id ~= 0 in the first part because of course if it equals 0 it wont equal 120553/120554/120555.
ZZZZZ wrote:Im not sure why it isnt working, but when I do 'if CObject(v).Id == 0 then' it says its removing it, but for some reason the addresses in that table do not seem to get deleted. Meaning after about 1.5 waves of turtles it simply spams mm with lots of dots and "new list".
I'm not 100% sure what's going on but you will have issues removing items from a table while iterating through it. The only way I know to do this is to go in reverse order. eg.
Code: Select all
for k = #ignoreTableTort,1,-1 do
local v = ignoreTableTort[k]
if CObject(v).Id == 0 then
printf(" . ")
table.remove(ignoreTableTort, k)
end
end
Re: Script crashing game client
Posted: Tue May 20, 2014 3:25 am
by BlubBlab
Used this in the script to make sure:
Code: Select all
function checkclicked(address)
local proc = getProc()
local tmp = memoryReadRepeat("int", proc, address + addresses.pawnAttackable_offset) or 0;
if bitAnd(tmp,0x8) then
return memoryReadRepeat("float", proc, address + addresses.pawnFading_offset) == 0
else
return false
end
end
function pawnevalfunc(address, pawn)
if(checkclicked(address)== true and pawn.Alive and pawn.HP >=1 and pawn.Id ~= 106882)then
return true
else
return false
end
end
That with the pawnAttackable was lisa in the old days.
Re: Script crashing game client
Posted: Fri May 23, 2014 11:05 pm
by ZZZZZ
BlubBlab wrote:Used this in the script to make sure:
Code: Select all
function checkclicked(address)
local proc = getProc()
local tmp = memoryReadRepeat("int", proc, address + addresses.pawnAttackable_offset) or 0;
if bitAnd(tmp,0x8) then
return memoryReadRepeat("float", proc, address + addresses.pawnFading_offset) == 0
else
return false
end
end
function pawnevalfunc(address, pawn)
if(checkclicked(address)== true and pawn.Alive and pawn.HP >=1 and pawn.Id ~= 106882)then
return true
else
return false
end
end
That with the pawnAttackable was lisa in the old days.
Wish I had that earlier xD
Code: Select all
function tortEvalFunc(address, pawn)
if (checkclicked(address) == true and pawn.Id ~= 0) then
return true
else
return false
end
end
function checkclicked(address)
local proc = getProc()
local tmp = memoryReadRepeat("int", proc, address + addresses.pawnAttackable_offset) or 0;
if bitAnd(tmp,0x8) then
return memoryReadRepeat("float", proc, address + addresses.pawnFading_offset) == 0
else
return false
end
end
function killTurtles()
while true do
yrest(50);
local objectList = CObjectList()
objectList:update()
local objSize = objectList:size()
for i = 0,objSize do
local obj = objectList:getObject(i)
obj:update()
if (obj.Id == 120553 or obj.Id == 120554 or obj.Id == 120555) and tortEvalFunc(obj.Address, obj) then
player:target(obj)
yrest(50)
RoMCode("UseExtraAction(1)")
yrest(50)
end
end
end
end
Might make a waypoint to spam it eventually. Assuming event lasts that long lol.
~~ edit: Never mind, its not even worth spamming lol. 2 items per TP rune, 6 TP runes for 15 fire elements. Im just glad it finally worked xD