Script crashing game client

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Script crashing game client

#1 Post by silinky » Mon May 12, 2014 7:55 am

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>

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Script crashing game client

#2 Post by BlubBlab » Mon May 12, 2014 8:13 am

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
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: Script crashing game client

#3 Post by silinky » Mon May 12, 2014 9:26 am

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>

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Script crashing game client

#4 Post by BlubBlab » Mon May 12, 2014 9:34 am

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)
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: Script crashing game client

#5 Post by silinky » Mon May 12, 2014 9:40 am

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.

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Script crashing game client

#6 Post by rock5 » Mon May 12, 2014 10:15 am

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.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: Script crashing game client

#7 Post by silinky » Mon May 12, 2014 10:27 am

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.

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: Script crashing game client

#8 Post by silinky » Mon May 12, 2014 3:42 pm

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.

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Script crashing game client

#9 Post by ZZZZZ » Mon May 12, 2014 4:30 pm

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 :)

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Script crashing game client

#10 Post by rock5 » Tue May 13, 2014 12:05 am

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)
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: Script crashing game client

#11 Post by silinky » Tue May 13, 2014 5:41 am

thank you! i will test this also and if it works i will post it here for others to use it.

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Script crashing game client

#12 Post by ZZZZZ » Mon May 19, 2014 4:33 pm

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

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Script crashing game client

#13 Post by ZZZZZ » Mon May 19, 2014 8:15 pm

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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Script crashing game client

#14 Post by rock5 » Mon May 19, 2014 10:08 pm

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
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Script crashing game client

#15 Post by ZZZZZ » Tue May 20, 2014 2:43 am

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".

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Script crashing game client

#16 Post by rock5 » Tue May 20, 2014 3:03 am

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
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Script crashing game client

#17 Post by BlubBlab » Tue May 20, 2014 3:25 am

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.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Script crashing game client

#18 Post by ZZZZZ » Fri May 23, 2014 11:05 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests