Page 1 of 1

HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 4:47 pm
by puto_velho
Hello there first of all let me just say THANK YOU Lisa and Rock5 for the work and explanations done, not to me directly but to all that read the forum.

Now to the business... I'm trying to make a script to make a script for a Dwarf quest (with no good results atm) called "Here Comes the Rain!" that its to "repair" a gate.

After accept the quest, the npc Valent Blackscar start saying out of 2 tools 1 to use...
[Say] [Valent Blackscar]: Now! Grab your hammer!
click hammer and then click gate

[Say] [Valent Blackscar]: Now! Grab your pliers!
click pliers and then click gate

[Say] [Valent Blackscar]: Now! Grab your hammer!
click hammer and then click gate
...and so on until quest is done...

I realise that its possible to have this work with EventMonitor & EventMonitorCheck
this is my last try.. i know it might be all f.. messed up but i really tried :S

Code: Select all

<onload>
	function black()
		local time, moretocome, msg = EventMonitorCheck("blacksay","1")
		if msg ~= nil then
			if string.find(msg, "Now! Grab your hammer!") then 
				stuff to do
			elseif if string.find(msg, "Now! Grab your pliers!") then
				other stuff to do
			end
		end
	end
</onload>

<!-- #  1 --><waypoint x="-11" z="374" y="1561">
	EventMonitorStart("blacksay","CHAT_MSG_SAY",",,,Valent Blackscar");
</waypoint>
<!-- #  2 --><waypoint x="-371" z="321" y="1638">
	player:target_NPC("Valent Blackscar"); AcceptQuestByName("Here Comes the Rain!"); yrest(5000);

	while (getQuestStatus("Here Comes the Rain!") == "incomplete") do
		black()
	end

	player:target_NPC("Valent Blackscar"); CompleteQuestByName("Here Comes the Rain!"); yrest(2000);

	EventMonitorStop("blacksay");

	loadPaths("next_stuff");
</waypoint>
the Valent is in the top of a stair, i made waypoint 1 away from them starting the event monitor and the waypoint 2 its near him to do the quest with a rest of 5 for the time he takes giving orders.

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 7:19 pm
by lisa
I actually have done this quest manually and something I noticed was the tool only appeared on the ground when it was needed to be used.

Maybe just do a check for the tool and then click it, then click the 3 little orb thingies you need to "repair"

If you really want to use the event monitoring though check out Rock's Invader script he posted in the userfunction/WP section. More specifically the one that does the repair thing, it monitors for similar things.

can also try this

Code: Select all

local time, moreToCome, name, msg = EventMonitorCheck("blacksay", "4,1")

instead of

local time, moretocome, msg = EventMonitorCheck("blacksay","1")
Points to note,
Your msg arg is the 3rd arg, which is actually the name argument.
you only check for "1" in the monitor, can't remember the meaning of those numbers off hand but yeah try "4,1"

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 7:50 pm
by puto_velho
thanx for the repply, i tryed his CoO-invaders for the elite skills with no luck...

i'm stuck with the eventMonitor&check. i really cant get it to work...

there 2 have a small(tiny) diference... the quest, the npc "speak" in SYSTEM chat and in the quest Val speak in SAY chat.

each tool appear when he "say so"...

use the hammer... the hammer appear... click on it and repair
use the pliers... the apliers appears... click on it and repair

and so on... 3 times for each tool and quest done...

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 7:53 pm
by lisa
I have a habbit of editing my posts, problem is probably you have msg as 3rd argument.

arg is prob not best word, variable/value is probably better, either way same story =)

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 8:01 pm
by puto_velho
hehe np.

for what i managed to understand the Arg.4 is the "sender" and the Arg.1 is the "message"

as i start the monitor filtering the 4th Arg. to Valent...

Code: Select all

EventMonitorStart("blacksay","CHAT_MSG_SAY",",,,Valent Blackscar");
...i thought it wasn't needed to "re-use it" in EventMonitorCheck because the "messages", in my point of view, are all from Valent, filtered in the eventmonitorstart()

and no... didnt worked also :|

PS.: found the link from rock5 about the "filter"

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 8:18 pm
by lisa
I went to go check out this quest by all 8 of my accounts are full of chars, deleted half a dozen but have to wait 24hours before I can make some dwarves to play around with this.

I personally would go with checking for the items and just click it then click the orbs, you can click all 3 orbs in a single round, so should be able to do the quest quickly enough.


If you want to you can do a print of nearby objects and then work on a script to work with the item Id's.

You can make up a userfunction and run bot using the commandline WP
rom/bot path:commandline

Code: Select all

function objname()
	local objectList = CObjectList();
	objectList:update();
	local objSize = objectList:size()
	filename = getExecutionPath() .. "/logs/npc.txt";
	file, err = io.open(filename, "a+");
	if( not file ) then
		error(err, 0);
	end
	player:update()
		for i = 0,objSize do 
			obj = objectList:getObject(i);
			player:update()
			file:write("<NPC name=\""..obj.Name.."\" 	id="..obj.Id.." x=\""..obj.X.."\"  z=\""..obj.Z.."\"  y=\""..obj.Y.."\" zoneid=\""..getZoneId().."\"	/>\n")
		end
	file:close();
end
When you call that function it will save the data to a log file called npc.txt in the log folder.
Alternatively you can just run
rom/getid
and then point the mouse at the objects, I like to use my function though =)

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 8:51 pm
by puto_velho
mmm... :geek:

never thought on that...

something like..... ??

Code: Select all

	<!-- #  1 --><waypoint x="-368" z="327" y="1637">
		player:target_NPC("Valent Blackscar"); AcceptQuestByName("Here Comes the Rain");

		while (getQuestStatus("Here Comes the Rain") == "incomplete") do
			-- if pliers exist
			if player:findNearestNameOrId(120242) then
				player:target_Object(120242); yrest(1000);
				player:target_Object(120388); yrest(1000);
				player:target_Object(120388); yrest(1000);
				player:target_Object(120388); yrest(1000);
			end			
			-- if hammer exist
			if player:findNearestNameOrId(120241) then
				player:target_Object(120241); yrest(1000);
				player:target_Object(120243); yrest(1000);
				player:target_Object(120243); yrest(1000);
				player:target_Object(120243); yrest(1000);
			end
		end

		loadPaths("break");
	</waypoint>
PS1.: code updated... working now.. using player:findNearestNameOrId() to check if hammer or pliers are near... if so.. use it 3 times :) thank you so much lisa
PS2.: didnt knew the --comment inside waypoints :) re-updated and now in 1 WP. thanx again. btw..

this is part of a self leveling dwarf... auto gear choose by class and getting help from guildies for TPs :)

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Fri Jun 22, 2012 9:02 pm
by lisa
something like that

Code: Select all

<!-- if pliers exist -->
that will probably error out MM as it is within a waypoint tag so the code is concidered a function.

So you could either leave the comment out or just use

Code: Select all

-- if pliers exist

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Sat Jun 23, 2012 5:52 am
by puto_velho
the quest is by with other means than with EventMonitorCheck but i would like to know why it wasn't with the original script...

NPC "Valent Blackscar" say 2 things..
a) get the hammer -> [Say] [Valent Blackscar]: Now! Grab your hammer!
b) get the pliers -> [Say] [Valent Blackscar]: Now! Grab your pliers!

point of situation...
what i know...
1)start the monitor
first end the monitor to remove probable recorded events and we start a new empty event record

Code: Select all

<!--- # 1 --><waypoint x="xxx" z="zzz" y="yyy" tag="cometherain">
   EventMonitorEnd("blacksay");
   EventMonitorStart("blacksay","CHAT_MSG_SAY",",,,Valent Blackscar");
</waypoint>
2)check the monitor for event
i used thought that using a function would be fine for this but didn't worked and i can't seem to know why it that.
probable cause: some code error and i dont know enough to fix it

Code: Select all

<onload>
   function black()
      local time, moretocome, msg = EventMonitorCheck("blacksay","1")
      if msg ~= nil then
         if string.find(msg, "Now! Grab your hammer!") then 
            click hammer then click thing (no problem here)
         elseif if string.find(msg, "Now! Grab your pliers!") then
            click plier then click thing (no problem here)
         end
      end
   end
</onload>

<!--- # 1 --><waypoint x="xxx" z="zzz" y="yyy">
   EventMonitorEnd("blacksay");
   EventMonitorStart("blacksay","CHAT_MSG_SAY",",,,Valent Blackscar");
</waypoint>

<!--- # 2 --><waypoint x="xxx" z="zzz" y="yyy">
   -- working
   player:target_NPC("Valent Blackscar"); AcceptQuestByName("Here Comes the Rain");
</waypoint>

<!--- # 3 --><waypoint x="xxx" z="zzz" y="yyy">
   while (getQuestStatus("Here Comes the Rain!") == "incomplete") do
      black()
   end
</waypoint>

<!--- # 4 --><waypoint x="xxx" z="zzz" y="yyy">
   -- no problems here
   player:target_NPC("Valent Blackscar"); sendMacro("CompleteQuest()");
</waypoint>

Re: HELP @ EventMonitor & EventMonitorCheck needed

Posted: Sat Jun 23, 2012 6:43 am
by lisa
My deleted alts should be off their timer tomorrow at some stage, I'll make some dwarves and do some testing.
It might be possible that even though the NPC text comes up on screen as "say" it may not be in the actual say channel. Since everyone would see the same text from the NPC about the text and that would just be silly.

So yeah I'll load up a few chars and see what I can see.