Help with some script

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Help with some script

#1 Post by vo2male » Sat Nov 03, 2012 9:51 pm

Hi everyone. i will be using this code for example,

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>

   <!-- #  1 --><waypoint x="-21533" z="-22929" y="597" type="TRAVEL">
   player:target_NPC("Diandon");
   CompleteQuestByName("Extinguish More Flames");
   yrest(500);
   player:target_NPC("Diandon");
   AcceptQuestByName("Extinguish More Flames");
   yrest(500);
   __WPL:setDirection(WPT_FORWARD);
   </waypoint>
   <!-- #  2 --><waypoint x="-21680" z="-23204" y="594" type="TRAVEL">
   queststate = getQuestStatus("Extinguish More Flames");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Strange Flame Seedling");yrest(1000); (<--flame A)
      queststate = getQuestStatus("Extinguish More Flames");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>
   <!-- #  3 --><waypoint x="-21739" z="-23072" y="597" type="TRAVEL">
   yrest(500);player:target_Object("Strange Flame Seedling");yrest(1000); (<--flame B)
   __WPL:setDirection(WPT_BACKWARD);
   </waypoint>
</waypoints>
I wanted to add another flame spot on that area.. presently there are only 2 flame areas on that code ,Flame A and B.
How can i add another Flame C, Flame D, etc etc on the code.. My goal really is to know how

Code: Select all

  __WPL:setDirection(WPT_BACKWARD);
  __WPL:setDirection(WPT_FORWARD);
can be used effectively for other waypoints.

Let's say there is 10 target objects i wanted to target/harvest.. (object A to J) and i wanted to add quest status check on Object C, F, G..

Do i have to add this code on waypoint C, F, G?

Code: Select all

 <!-- #  2 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object C");yrest(1000); 
      queststate = getQuestStatus("QUest title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>
Thanks in advance

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

Re: Help with some script

#2 Post by rock5 » Sun Nov 04, 2012 12:27 am

It's a very complex question as it depends on the layout for that quest. I see that you go to the Flame A waypoint, then the Flame B waypoint, then the Flame A waypoint, then back to the start waypoint. I take it then they are in a line? So I take it you are asking how to add other paths, eg. another path that goes to Flame C and D.

Creating multiple paths using forward and backwards is tricky. I would stick with forward motion and just continue the waypoint back. Here is a basic framework I would use for the above example. It's very simplified. Let me know if you need any part explained.

Code: Select all

<onload> flamecounter = 0 </onload>
<waypoint tag="Start">
    complete and accept quest if necessary
    flamecounter = flamecounter + 1
    if flamcounter == 1 then
        goto "path1"
    elseif flamecounter == 2 then 
        goto "path2"
    else 
        flamecounter = 0
        goto "Start" 
    end
</waypoint>

<waypoint tag="path1"> 
    harvest
    if questcomplete then goto "Start" end
</waypoint>
<waypoint> harvest </waypoint>
<waypoint></waypoint>
<waypoint> goto "Start" </waypoint>

<waypoint tag="path2"> 
    harvest
    if questcomplete then goto "Start" end
</waypoint>
<waypoint> harvest </waypoint>
<waypoint></waypoint>
<waypoint> goto "Start" </waypoint>
  • 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

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#3 Post by vo2male » Sun Nov 04, 2012 4:18 am

rock5 wrote:It's a very complex question as it depends on the layout for that quest. I see that you go to the Flame A waypoint, then the Flame B waypoint, then the Flame A waypoint, then back to the start waypoint. I take it then they are in a line? So I take it you are asking how to add other paths, eg. another path that goes to Flame C and D.

Creating multiple paths using forward and backwards is tricky. I would stick with forward motion and just continue the waypoint back. Here is a basic framework I would use for the above example. It's very simplified. Let me know if you need any part explained.

Code: Select all

<onload> flamecounter = 0 </onload>
<waypoint tag="Start">
    complete and accept quest if necessary
    flamecounter = flamecounter + 1
    if flamcounter == 1 then
        goto "path1"
    elseif flamecounter == 2 then 
        goto "path2"
    else 
        flamecounter = 0
        goto "Start" 
    end
</waypoint>

<waypoint tag="path1"> 
    harvest
    if questcomplete then goto "Start" end
</waypoint>
<waypoint> harvest </waypoint>
<waypoint></waypoint>
<waypoint> goto "Start" </waypoint>

<waypoint tag="path2"> 
    harvest
    if questcomplete then goto "Start" end
</waypoint>
<waypoint> harvest </waypoint>
<waypoint></waypoint>
<waypoint> goto "Start" </waypoint>

Thanks Rock! I get the idea, but it is still complicated for me ^_^.
What if like this. my bot just go from A to J and vice versa and just add a waypoint Tag to each waypoint ( each object ) to check if quest is completed. If the quest is complete it will trigger to go to the waypoint (tag) that would hand in the quest..Otherwise it will just go through A to J, J to A.

Btw rock. that code above was just an example or a referrence because that is the only script i see which is closest to what i want to happen on my waypoint.

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

Re: Help with some script

#4 Post by rock5 » Sun Nov 04, 2012 4:54 am

vo2male wrote:What if like this. my bot just go from A to J and vice versa and just add a waypoint Tag to each waypoint ( each object ) to check if quest is completed. If the quest is complete it will trigger to go to the waypoint (tag) that would hand in the quest..Otherwise it will just go through A to J, J to A.
In that case it's easy. Just duplicate the code in waypoint 2. Or if you can go directly to the start waypoint then go directly to it using a tag.
  • 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

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#5 Post by vo2male » Sun Nov 04, 2012 5:13 am

rock5 wrote:
vo2male wrote:What if like this. my bot just go from A to J and vice versa and just add a waypoint Tag to each waypoint ( each object ) to check if quest is completed. If the quest is complete it will trigger to go to the waypoint (tag) that would hand in the quest..Otherwise it will just go through A to J, J to A.
In that case it's easy. Just duplicate the code in waypoint 2. Or if you can go directly to the start waypoint then go directly to it using a tag.
So like this,

Code: Select all

<!-- #  1 --><waypoint x="-21533" z="-22929" y="597" >
   player:target_NPC("QuestNPC");
   CompleteQuestByName("Quest Title");
   yrest(500);
   player:target_NPC("QuestNPC");
   AcceptQuestByName("Quest Title");
   yrest(500);
   __WPL:setDirection(WPT_FORWARD);
   </waypoint>


<!-- #  1 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object A");yrest(1000);
      queststate = getQuestStatus("Quest Title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>

]<!-- #  2 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object B");yrest(1000); 
      queststate = getQuestStatus("Quest Title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>

]<!-- #  3 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object C");yrest(1000); 
      queststate = getQuestStatus("Quest Title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>

]<!-- #  4 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object D");yrest(1000);
      queststate = getQuestStatus("Quest Title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>


]<!-- #  5 --><waypoint x="-xxxx" z="-xxxx" y="xxx" type="TRAVEL">
   queststate = getQuestStatus("Quest Title");
    if queststate == "incomplete" then      
      yrest(500);player:target_Object("Object E");yrest(1000); 
      queststate = getQuestStatus("Quest Title");
      if queststate == "incomplete" then
         __WPL:setDirection(WPT_FORWARD);
      else
         __WPL:setDirection(WPT_BACKWARD);
      end
   else
      __WPL:setDirection(WPT_BACKWARD);
   end
   </waypoint>

How can i incorporate waypoint tags on each of them?

Do i have to make my first waypoint (hand in waypoint) like this

Code: Select all

<!-- #  1 --><waypoint x="-21533" z="-22929" y="597" tag="Turn in" >
   player:target_NPC("QuestNPC");
   CompleteQuestByName("Quest Title");
   yrest(500);
   player:target_NPC("QuestNPC");
   AcceptQuestByName("Quest Title");
   yrest(500);
   __WPL:setDirection(WPT_FORWARD);
   </waypoint>

and add this to each of the waypoint

else

Code: Select all

<waypoint> goto "Turn in" </waypoint>

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

Re: Help with some script

#6 Post by rock5 » Sun Nov 04, 2012 6:02 am

vo2male wrote:How can i incorporate waypoint tags on each of them?
Basically instead of changing the direction backwards when the quest status is complete, you go to the waypoint instead. So instead of

Code: Select all

         __WPL:setDirection(WPT_BACKWARD);
you use

Code: Select all

         __WPL:setWaypointIndex(__WPL:findWaypointTag("Turn in"))
The "Turn in" code looks like it would work but you don't need to retarget the npc and you don't normally need pauses. The QuestByName functions are good at handling those. So this should work.

Code: Select all

<!-- #  1 --><waypoint x="-21533" z="-22929" y="597" tag="Turn in" >
   player:target_NPC("QuestNPC");
   CompleteQuestByName("Quest Title");
   AcceptQuestByName("Quest Title");
   __WPL:setDirection(WPT_FORWARD);
   </waypoint>
  • 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

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#7 Post by vo2male » Sun Nov 04, 2012 4:57 pm

Hi again rock. this is what i've come up

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onload>
        startGMDetect();
	player:mount();
</onload>
	<!-- #  1 --><waypoint x="-33102" z="27300" y="-131">
	player:target_NPC("QuestNPC");
        CompleteQuestByName("Quest Title");
        AcceptQuestByName("Quest Title");
        __WPL:setDirection(WPT_FORWARD);
 </waypoint>
	<!-- #  2 --><waypoint x="-33165" z="27532" y="-131">
</waypoint>
	<!-- #  3 --><waypoint x="-33216" z="27913" y="-131" tag="Turn in">
	queststate = getQuestStatus("Quest Title");
	if queststate == "incomplete" then		
		yrest(10);player:target_NPC("QuestNPC");yrest(20);
		queststate = getQuestStatus("Quest Title");
		if queststate == "incomplete" then
		__WPL:setDirection(WPT_FORWARD);
		else
			__WPL:setDirection(WPT_BACKWARD);
		end
	else
		__WPL:setDirection(WPT_BACKWARD);
	end
</waypoint>
	<!-- #  4 --><waypoint x="-32927" z="27977" y="-164">	</waypoint>
	<!-- #  5 --><waypoint x="-32943" z="28005" y="-164">	
	queststate = getQuestStatus("Quest Title");
	if queststate == "incomplete" then		
		yrest(10);player:target_NPC("QuestNPC");yrest(20);
		if queststate == "incomplete" then
		__WPL:setDirection(WPT_FORWARD);
		else
			__WPL:setDirection(WPT_BACKWARD);
		end
	else
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Turn in"))
	end
</waypoint>
	<!-- #  6 --><waypoint x="-32558" z="28086" y="-165">
	queststate = getQuestStatus("Quest Title");
	if queststate == "incomplete" then		
		yrest(10);player:target_NPC("QuestNPC");yrest(20);
		if queststate == "incomplete" then
		__WPL:setDirection(WPT_BACKWARD);
	else
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Turn in"))
end
	end
</waypoint>
</waypoints>
Ok here are my observations..
the bot is functioning well. no errors just some things i didn't expect to happen.

-Bot accepts quest from Quest giver. (waypoint 1)
-Goes from Waypoint 1 to 3 with no problem.. ( waypoint 2 is just a detour for the bot to be not stucked)
-Does the quest at waypoint 3.. does the check if quest completed or not.
-Goes to Waypoint 5 and do the quest.. ( Waypoint 4=detour). Checks if quest completed or not.

Problem comes in
from waypoint 5 it goes to waypoint 6.
from waypoint 6 to waypoint 5 and back to waypoint 6.. so in short.. the bot started a loop in waypoint 5 to 6 and vice versa..
Another thing is when the quest is completed it seems not to recognize the tag i put in.
So at waypoint 6 if the quests is completed it goes directly to waypoint 1.. Not on waypoint 2 where i make the Tag.


What i want to happen is this:
Waypoints 3, 5, 6 are the waypoints where my bot does the quest.
if quest is not completed at waypoint 3, it goes to 5 and 6. if quest is still not completed on waypoint 6 it should go back to waypoint 5 and waypoint 3 and so on.. (3 --> 5 --> 6 | 6 --> 5 --> 3 loop ) until quest is completed. If quest is complete the tag "Turn in" would be triggered and the bot goes from waypoint 5 or 6 to waypoint 3 and finally to waypoint 1.

i put tag on waypoint 3 cause it also has the

Code: Select all

else
			__WPL:setDirection(WPT_BACKWARD);
		end
	else
		__WPL:setDirection(WPT_BACKWARD);
	end

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

Re: Help with some script

#8 Post by rock5 » Mon Nov 05, 2012 12:11 am

For starters you need to replace all WPT_BACKWARD lines with the

Code: Select all

__WPL:setWaypointIndex(__WPL:findWaypointTag("Turn in"))
line.

I need to know what your intending. I'm still not 100% clear. When the quest is complete you want to make it go directly to wp 3 and from there to go "Backward" to wp 1. Right? If it reaches wp 6 and hasn't completed the quest you want it to go to wp 3 so it can go "Forward". Right? Or do you want it to go "Backwards" and make it's way back to wp 3?
  • 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

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#9 Post by vo2male » Mon Nov 05, 2012 3:07 am

rock5 wrote: When the quest is complete you want to make it go directly to wp 3 and from there to go "Backward" to wp 1. Right? -Right! - When the 3/3 goal or task is complete.
If it reaches wp 6 and hasn't completed the quest you want it to "Backwards" and make it's way back to wp 3? - Exactly! if this is possible


Ok rock.im gonna try that out.. I am doing a waypoint on a quest in tergoten

Code: Select all

runesdatabase.com/quest/424542/deliver-to-the-residents
The quest is a 3/3 goal. There are lots of NPCs there. the problem with this quest is that there is only a 50% chance that you could complete the task from each NPC. and if you target any NPC you would have to wait 14secs before you can target/pass him the quest. so i decided between this 14 secs to go to other NPCs.. and all of them are also like that (target them, 50% chance to complete the goal.wait for 14 secs again before you can target them). So all in all i wanted to make a loop within 3 NPCs.
NPCs are WP3, WP5, WP6. if i completed the goal which is 3 out of 3 from any of these NPCs i would like to trigger my bot to go to WP3 and from there to WP1 to turn in/accept the quest..

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Help with some script

#10 Post by Jandrana » Mon Nov 05, 2012 8:00 am

Perhaps you can use the concept, I'm using in my butterfly script.

To make the script looking less botish, I let the the script randomly decide to go one of several paths inside the garden. As soon as the last butterfly is killed (either by my char, or somebody else) or the end of this "subpath" is reached I start to go back (set direction backward) to the entry of the garden. If the quest is not complete, randomly choose another path otherwise go back to the Quest NPC. You could do something similar for your quest. Instead of choosing a random path, you could also track which NPCs you already talked to and choose a different one.

Code: Select all


   -- Check if quest is finished. If quest is finished, set direction backward.
   -- If quest is finished and we reached the waypoint "beginRoute", goto waypoint
   -- "completeRoute".

	function checkfinish(beginRoute, endRoute, completeRoute)
	   local queststate = getQuestStatus(questName);
      local beginIndex = __WPL:findWaypointTag(beginRoute);
      local endIndex = __WPL:findWaypointTag(endRoute);
      printf ("checkfinish "..queststate);
   	if queststate == "complete" then
         __WPL:setForcedWaypointType(WPT_TRAVEL);
         __WPL:setDirection( WPT_BACKWARD );
			if player.Mounted == false then
		      player:mount();
		   end
         if __WPL.CurrentWaypoint == beginIndex then
            __WPL:setWaypointIndex(__WPL:findWaypointTag(completeRoute));
         end
      else
         __WPL:setForcedWaypointType(WPT_NORMAL);
         if __WPL.CurrentWaypoint == endIndex then
            __WPL:setDirection( WPT_BACKWARD );        
         else
	         if __WPL.CurrentWaypoint == beginIndex then
               __WPL:setDirection( WPT_FORWARD );        
               wpName = __WPL:findWaypointTag(completeRoute);
               printf ("going to " ..wpName);
               __WPL:setWaypointIndex(wpName);
            end
         end
      end
	end
   
   -- check what do 
   -- if quest is not complete, randomly choose a route with the core name "route1".
   -- A random number 1-4 is being appended - corresponding tags must be defined.
   -- if quest is complete, go to the "complete" route
   
   function checkGoQuest( route1, complete )
	   local queststate = getQuestStatus(questName);
      local route, routeName;
      printf("checkGoQuest - questState " ..queststate);
	   if queststate == "complete" then
         __WPL:setForcedWaypointType(WPT_TRAVEL);
			if player.Mounted == false then
		      player:mount();
		   end
         __WPL:setDirection( WPT_BACKWARD );
         __WPL:setWaypointIndex(__WPL:findWaypointTag(complete));
      else
         __WPL:setForcedWaypointType(WPT_NORMAL);
         route = tostring(math.random(1,4));
         routeName = route1 .. route;
         printf("going to"..routeName);
         __WPL:setDirection( WPT_FORWARD );        
         __WPL:setWaypointIndex(__WPL:findWaypointTag(routeName));
      end
	end



	<!-- # 32 --><waypoint x="7521" z="2715" y="168" tag="goQuest">	</waypoint>
	<!-- # 33 --><waypoint tag="Start">	checkGoQuest("R", "goQuest"); </waypoint>

   <!-- #  1 --><waypoint tag="R1"> checkfinish("R1", "R1E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  5 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  6 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  7 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  8 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  9 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- # 10 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R1E"> checkfinish("R1", "R1E", "Start")	</waypoint>

	<!-- #  1 --><waypoint tag="R2"> checkfinish("R2", "R2E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R2E">	checkfinish("R2", "R2E", "Start")</waypoint>

   	<!-- #  1 --><waypoint tag="R3"> checkfinish("R3", "R3E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R3E">	checkfinish("R3", "R3E", "Start")</waypoint>
....

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#11 Post by vo2male » Mon Nov 05, 2012 12:39 pm

Jandrana wrote:Perhaps you can use the concept, I'm using in my butterfly script.

To make the script looking less botish, I let the the script randomly decide to go one of several paths inside the garden. As soon as the last butterfly is killed (either by my char, or somebody else) or the end of this "subpath" is reached I start to go back (set direction backward) to the entry of the garden. If the quest is not complete, randomly choose another path otherwise go back to the Quest NPC. You could do something similar for your quest. Instead of choosing a random path, you could also track which NPCs you already talked to and choose a different one.

Code: Select all


   -- Check if quest is finished. If quest is finished, set direction backward.
   -- If quest is finished and we reached the waypoint "beginRoute", goto waypoint
   -- "completeRoute".

	function checkfinish(beginRoute, endRoute, completeRoute)
	   local queststate = getQuestStatus(questName);
      local beginIndex = __WPL:findWaypointTag(beginRoute);
      local endIndex = __WPL:findWaypointTag(endRoute);
      printf ("checkfinish "..queststate);
   	if queststate == "complete" then
         __WPL:setForcedWaypointType(WPT_TRAVEL);
         __WPL:setDirection( WPT_BACKWARD );
			if player.Mounted == false then
		      player:mount();
		   end
         if __WPL.CurrentWaypoint == beginIndex then
            __WPL:setWaypointIndex(__WPL:findWaypointTag(completeRoute));
         end
      else
         __WPL:setForcedWaypointType(WPT_NORMAL);
         if __WPL.CurrentWaypoint == endIndex then
            __WPL:setDirection( WPT_BACKWARD );        
         else
	         if __WPL.CurrentWaypoint == beginIndex then
               __WPL:setDirection( WPT_FORWARD );        
               wpName = __WPL:findWaypointTag(completeRoute);
               printf ("going to " ..wpName);
               __WPL:setWaypointIndex(wpName);
            end
         end
      end
	end
   
   -- check what do 
   -- if quest is not complete, randomly choose a route with the core name "route1".
   -- A random number 1-4 is being appended - corresponding tags must be defined.
   -- if quest is complete, go to the "complete" route
   
   function checkGoQuest( route1, complete )
	   local queststate = getQuestStatus(questName);
      local route, routeName;
      printf("checkGoQuest - questState " ..queststate);
	   if queststate == "complete" then
         __WPL:setForcedWaypointType(WPT_TRAVEL);
			if player.Mounted == false then
		      player:mount();
		   end
         __WPL:setDirection( WPT_BACKWARD );
         __WPL:setWaypointIndex(__WPL:findWaypointTag(complete));
      else
         __WPL:setForcedWaypointType(WPT_NORMAL);
         route = tostring(math.random(1,4));
         routeName = route1 .. route;
         printf("going to"..routeName);
         __WPL:setDirection( WPT_FORWARD );        
         __WPL:setWaypointIndex(__WPL:findWaypointTag(routeName));
      end
	end



	<!-- # 32 --><waypoint x="7521" z="2715" y="168" tag="goQuest">	</waypoint>
	<!-- # 33 --><waypoint tag="Start">	checkGoQuest("R", "goQuest"); </waypoint>

   <!-- #  1 --><waypoint tag="R1"> checkfinish("R1", "R1E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  5 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  6 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  7 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  8 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- #  9 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- # 10 --><waypoint >	checkfinish("R1", "R1E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R1E"> checkfinish("R1", "R1E", "Start")	</waypoint>

	<!-- #  1 --><waypoint tag="R2"> checkfinish("R2", "R2E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R2", "R2E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R2E">	checkfinish("R2", "R2E", "Start")</waypoint>

   	<!-- #  1 --><waypoint tag="R3"> checkfinish("R3", "R3E", "Start")	</waypoint>
	<!-- #  2 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- #  3 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- #  4 --><waypoint >	checkfinish("R3", "R3E", "Start") </waypoint>
	<!-- # 11 --><waypoint tag="R3E">	checkfinish("R3", "R3E", "Start")</waypoint>
....

thanks for the suggestion Jandrana.. but i find it hard to follow.im sorry im not really that good in coding. i just look at some waypoints that i used and familiar with and refer to them.
long scripts makes me confuse >_<

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Help with some script

#12 Post by Jandrana » Tue Nov 06, 2012 4:29 am

I tried to comment things, but perhaps it needs a bit more explanation.

I will comment the usage of the label and functions to make it clearer, what this script does:

"goQuest":
This label is used to go back to quest NPC - WP direction must be set to backward

"Start":
this label marks the start point where a subpath is chosen.

checkGoQuest("R", "goQuest");
This function checks if the quest is complete - if the quest is complete it sets
direction backward and lets script continue at label "goQuest".

If the quest is not complete it takes the label string "R" and appends a number
(in my case the number is random - but you can simply increment it or use a
different logic to choose a label). This way you get a label "R1" ... "R4".
Script continues at this label.

checkfinish("R1", "R1E", "Start");
This function is called at each waypoint of a subpath and does the following:
The labels "R1" and "R1E" define the start and the end of a subpath.
("R2" - "R2E", "R3" - "R3E", ... are additional subpaths - add more if required)
At each waypoint it checks, if the end of the subpath is reached.
If the end of the subpath is reached, it sets WP direction to backward,
so it will go back to the start of subpath. If the start of the subpath is reached
it will continue at the waypoint with label "Start". It also has some logic
to go back to start of subpath if quest is completed - this is specific to the
quest - in my case it requires killing stuff, but for your quest things are different.

The script at waypoint labeled "Start" checks if the quest is complete.
If the quest is not complete it walks another subpath otherwise it will go back to quest NPC.

I was thinking that your quest is similar:

- Quest NPC -> walk to a WP called "Start"
- at "Start" check if quest is complete
if quest is complete go back to quest NPC
if quest is not complete walk a subpath to one of your NPCs and
then walk back to "Start"

vo2male
Posts: 122
Joined: Mon Aug 27, 2012 6:41 am

Re: Help with some script

#13 Post by vo2male » Tue Nov 06, 2012 10:06 pm

Jandrana wrote:I tried to comment things, but perhaps it needs a bit more explanation.

I will comment the usage of the label and functions to make it clearer, what this script does:

"goQuest":
This label is used to go back to quest NPC - WP direction must be set to backward

"Start":
this label marks the start point where a subpath is chosen.

checkGoQuest("R", "goQuest");
This function checks if the quest is complete - if the quest is complete it sets
direction backward and lets script continue at label "goQuest".

If the quest is not complete it takes the label string "R" and appends a number
(in my case the number is random - but you can simply increment it or use a
different logic to choose a label). This way you get a label "R1" ... "R4".
Script continues at this label.

checkfinish("R1", "R1E", "Start");
This function is called at each waypoint of a subpath and does the following:
The labels "R1" and "R1E" define the start and the end of a subpath.
("R2" - "R2E", "R3" - "R3E", ... are additional subpaths - add more if required)
At each waypoint it checks, if the end of the subpath is reached.
If the end of the subpath is reached, it sets WP direction to backward,
so it will go back to the start of subpath. If the start of the subpath is reached
it will continue at the waypoint with label "Start". It also has some logic
to go back to start of subpath if quest is completed - this is specific to the
quest - in my case it requires killing stuff, but for your quest things are different.

The script at waypoint labeled "Start" checks if the quest is complete.
If the quest is not complete it walks another subpath otherwise it will go back to quest NPC.

I was thinking that your quest is similar:

- Quest NPC -> walk to a WP called "Start"
- at "Start" check if quest is complete
if quest is complete go back to quest NPC
if quest is not complete walk a subpath to one of your NPCs and
then walk back to "Start"
Thanks Jandrana! I will see how can i make use of your script. Unfortunately, things came up and i became busy. So ill give you a feed back after some time.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests