Register for your free account! | Forgot your password?

Go Back   elitepvpers > Other Online Games > Diablo 2 > Diablo 2 Programming
You last visited: Today at 05:12

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Working on Kurast Script for Muddy's D2NT

Discussion on Working on Kurast Script for Muddy's D2NT within the Diablo 2 Programming forum part of the Diablo 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 10
Received Thanks: 4
Working on Kurast Script for Muddy's D2NT

Hi all and esp. Muddy (who I hope will help me clean up)

I have been searching and searching trying to find a working script that will do Lower Kurast, Kurast Bazaar, and Upper Kurast killing everything and opening every chest, looting every body, and basket.

I found several but I think they are all out dated as the code would not run-(only sits in town until game times out)

So I decided to make one from the basic code already in place (I actually used the code from flayer jungle as my guide)

First and foremost I do not guarantee this code will work for you, nor do I take any responsibility of anything going wrong or crashing on your end. This script is a work in progress and like any other script should be used with caution, care, and at your own risk.

Code:
Open: "scripts => NTBot => char_configs => NTConfig_CLASS_CHAR-NAME.ntl"

Find: =>  // Select which containers shall be looted. 0: None; 1: Super Chests, 2: All
	MWConfig_OpenContainerMode = 2;
ensure mode=2
This will make your bot so it opens all chests and loots all bodies and baskets.

Code:
 Find: =>  // ***************** Current schedule ******************

On line after, add => MWConfig_Script.push(["NTKurast.ntj", 0]);
Save and close your Char Config file

Code:
 Open: scripts => NTBot => char_configs => NTConfig.ntl

Find=>  MWConfig_ClearAreaSpectypes.FlayerJungle = 0x01;

On line after, add => MWConfig_ClearAreaSpectypes.Kurast = 0x01;
This adds the area so your char will kill everything in the area

Save and close your ntconfig file

Code:
Open: scripts => NTBot => bots
Find => "NTIcyCellar.ntj"
COPY
PASTE 
rename copy => "NTKurast.ntj"
delete all content of this new file.
This will be your .ntj file

Code:
Open "NTKurast.ntj"
Paste the following into that file

Code:
 
/**
*	This file was modified by Caspert_ghost
*	http://www.elitepvpers.com/forum/private.php?do=newpm&u=4741454
*	from flayerjungle.ntj modified by 
*	Check the programming section for updates and further scripts
*	Last Update: 10/18/2012 
*	
*/

function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");

   NT_LoadConfig();
   NTSI_LoadNIPFiles("NTBot/item_configs");

   MWC_Initialize();

   if(!NTTM_CheckAct(me.act, true))
   {
		NTC_SendMsgToScript("MWBotGame.ntj", NTTM_CheckAct, 18, me.act, true);
		return;
   }

   NTTMGR_TownManager();

   if(!NTTM_TownMove("waypoint"))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTTM_TownMove, 26, "waypoint");
      return;
   }

   if(!NTM_TakeWaypoint(79))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, NTM_TakeWaypoint, 32, 79);
      return;
   }

   NTP_DoPrecast(true);

   NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.Kurast);

   
   if(!NTTM_CheckAct(me.act, true))
   {
		NTC_SendMsgToScript("MWBotGame.ntj", NTTM_CheckAct, 18, me.act, true);
		return;
   }

   NTTMGR_TownManager();

   if(!NTTM_TownMove("waypoint"))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTTM_TownMove, 26, "waypoint");
      return;
   }

   if(!NTM_TakeWaypoint(80))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, NTM_TakeWaypoint, 32, 80);
      return;
   }

   NTP_DoPrecast(true);

   NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.Kurast);
   
   
   if(!NTTM_CheckAct(me.act, true))
   {
		NTC_SendMsgToScript("MWBotGame.ntj", NTTM_CheckAct, 18, me.act, true);
		return;
   }

   NTTMGR_TownManager();

   if(!NTTM_TownMove("waypoint"))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTTM_TownMove, 26, "waypoint");
      return;
   }

   if(!NTM_TakeWaypoint(81))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, NTM_TakeWaypoint, 32, 81);
      return;
   }

   NTP_DoPrecast(true);

   NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.Kurast);
   
	NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
What I need is help cleaning up the code to be neater.
Also I would like to make this similar to the super chest script where I can choose from a list of area to do.
My list would be:
Lower Kurast
Kurast Bazzaar
Upper Kurast

The following scripts are already included but I would like to have them as one script like super chest but opening all chests and killing everything (clearing the area)

Kurast sewers
Kurast Temples

Where now I can have one script for them all and a line in char config like this:

Code:
 MWConfig_Script.push(["NTKurast.ntj", 0]);  MWConfig_Areas = ["Lower Kurast", "Kurast Bazaar", "Upper Kurast",  "Kurast Sewers", "Kurast Temples"];
Just a thought and any assistance would be greatly appreciated.
caspert_ghost is offline  
Old 10/18/2012, 20:54   #2
Administrator
 
Muddy Waters's Avatar
 
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,729
Received Thanks: 12,622
I took the liberty of moving this to another thread as it would go down quite quickly in the release thread which would be unfortunate, hope you don't mind.

Now what you want to do in order to make your code neater is to get rid of the redundancy that your code currently has plenty of. If you break this down a little, the code for doing a single area is obviously this:
Code:
if(!NTTM_CheckAct(me.act, true))
   {
		NTC_SendMsgToScript("MWBotGame.ntj", NTTM_CheckAct, 18, me.act, true);
		return;
   }

   NTTMGR_TownManager();

   if(!NTTM_TownMove("waypoint"))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTTM_TownMove, 26, "waypoint");
      return;
   }

   if(!NTM_TakeWaypoint(79))
   {
      NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, NTM_TakeWaypoint, 32, 79);
      return;
   }

   NTP_DoPrecast(true);

   NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.Kurast);
And what you currently do is repeating this over and over again, even though it is almost the same code (except for the area id that differs). Code repetition should always be avoided. There are basically 3 possible approaches:
  1. Move said code snippet to a function and make the area id of the target an argument that is passed when the function is called:
    Code:
    function DoArea(areaid)
    {
    	// Do stuff...
    }
  2. Store the target area ids in an array and loop through this array by using a for loop:
    Code:
    var _areaIds = [79, 80, 81];
    
    for(var i = 0; i < _areaIds.length; i++)
    {
    	// Do stuff...
    }
  3. Do both, i.e. use a function and then call this function in a for loop:
    Code:
    var _areaIds = [79, 80, 81];
    
    for(var i = 0; i < _areaIds.length; i++)
    	DoArea(_areaIds[i]);

As you can see I kept the examples rather vague so you still have something to figure out for yourself. In case this doesn't work out and you find yourself being stuck, feel free to ask.
Muddy Waters is offline  
Thanks
1 User
Old 10/18/2012, 23:29   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 10
Received Thanks: 4
Question

Muddy Thank you for your input.
Here is what I have

Code:
/**
*	This file was modified by Caspert_ghost
*	http://www.elitepvpers.com/forum/private.php?do=newpm&u=4741454
*	from flayerjungle.ntj modified by 
*	Check the programming section for updates and further scripts
*	Last Update: 10/18/2012 
*	
*/

function NTMain()
{
   Include("libs/common/NTCommon.ntl");
   NTC_IncludeLibs();
   NTC_IncludeConfig("NTBot/char_configs");

   NT_LoadConfig();
   NTSI_LoadNIPFiles("NTBot/item_configs");

   MWC_Initialize();
 
	function DoArea(areaid)
	{
		if(!NTTM_CheckAct(me.act, true))
		{
		NTC_SendMsgToScript("MWBotGame.ntj", NTTM_CheckAct, 18, me.act, true);
		return;
		}
		
		NTTMGR_TownManager();
		
		if(!NTTM_TownMove("waypoint"))
		{
			NTC_SendMsgToScript("MWBotGame.ntj", NTTM_TownMove, 26, "waypoint");
				return;
		}
		if(!NTM_TakeWaypoint(_areaIds[i]))
		{
			NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, NTM_TakeWaypoint, 32, (_areaIds[i]));
			return;
		}
	} 
	
	var _areaIds = [79, 80, 81];
	
	for(var i = 0; i < _areaIds.length; i++)
	{	
		DoArea(_areaIds[i]);
		
		NTP_DoPrecast(true);

		NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.Kurast);
	}	
	NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
It starts at Lower Kurastclears area, goes to town- portals to Kurast bazaar and clears area, returns to town and portals to upper Kurast and clears area then ends, (goes to next script)
I am happy, how does it look to you?

Now to make it in case sections so I can create a workable script like superchests.
caspert_ghost is offline  
Old 10/19/2012, 10:34   #4
Administrator
 
Muddy Waters's Avatar
 
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,729
Received Thanks: 12,622
The problem is, that you defined your function within the main function. While this is still okay, or let's better say doable in JS, it should be avoided (unless it really makes sense), because your function is then defined in a so-called closure scope and only exposed to the function that it is defined in. If you defined another function outside of your main function (i.e. in global scope), that function could not access your nested function, because your nested function is not exposed to global scope and thus not accessible via global scope.

Another problem is the way you access the areid in your function. You are using _areaIds[i], i.e. accessing an element in the array _areaIds at the index i. Now the problem is that both the array and the index are not defined in the context of your function. Those are local variables that have been defined in your main function, but they only exist in the scope of your main function and not in global scope. Here is a simple example to illustrate this:
Code:
function Caller()
{
	var _a = 42;
	Print(_a); // Prints 42
	Callee(_a);
}

function Callee(val)
{
	Print(val); // Prints 42
	Print(_a); // Raises an exception because there is no such variable called _a that Callee could access 
}
It also holds the solution to your problem which is using the argument that is passed to the function as you call it. In my example, the value of _a is assigned to val which is then available in the function. You should do the same in your function. You might also want to move those NTP_DoPrecast and NTA_ClearLevel calls to your function, to make your code even shorter.

I don't see any need for a case structure here like I have used it in superchest script, at least as long as you are doing areas that can be accessed directly via waypoint. The only reason I'm using this in superchest script is that there might be areas that I cannot simply access via waypoint; in that case I had to define a pathing through multiple areas that could be connected by different warps (i.e. portals or stairs).

In your case it should be sufficient to simply define a config variable that can be used to define the target areas. However, if you'd like for users to be able to specify both area ids and area names you'd have to write a function to map the names to the respective ids as you will always need the areaid to move to an area. Depending on on how lazy you are you could write your own function for that or just look it up in my superchest script. The approach is actually rather simple, given that you know a thing or two about the D2NT API.
Muddy Waters is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Release]Kurast Scripte für Muddy D2NT
04/18/2012 - Diablo 2 Programming - 2 Replies
Hi Hier mein Release für UnterKurast, OberKurast und KurastBasar wo keine Monster gekillt werden sondern nur Kisten, Leichen, Waffenständer etc gelootet wird. Die 3 bis 6 Supertruhen in Uk werden in diesem Script ebenfalls geöffnet. Zunächst das in die MWLoot.ntl function MWL_LootAreaChests() { var _pUnit, _chests, _chest;
Muddy's D2NT mit 1.13d D2NT.dll + Neuer D2NT Etal
01/06/2012 - Diablo 2 - 474 Replies
Damit hier mal langsam Ruhe einkehrt lade ich jetzt den Muddy's D"NT mit der D2NT.dll für 1.13d hoch. Die Grundlage ist die Rev3 vom Bot. Hier ist ganz klar zu sagen, dass der Dank für den Bot an Muddy_Waters geht Das hier ist kein Fragethread. Ich habe selber keine Ahnung wie mögliche Bugs, die von der neuen dll kommen gefixt werden können. Wenn ihr Bugs entdeckt und diese fixxen könnt dürft ihr gerne das ganze posten. So kann man schnell für Probleme Lösungen finden. Bei anderen...
[Release] WrathHunter script für Muddy Waters D2NT
06/22/2011 - Diablo 2 Programming - 31 Replies
Update auf v1.2.1 changelog v1.2.1 - Akt 2 Tombs hinzu. - looten von Chests wieder standardmäßig aktiviert (siehe Tipps). v1.2 - Weitere Gebiete hinzugefügt - MWC_Initialize(); Aufruf ersetzt durch NTA_Initialize();
Lower Kurast script für NTbot
04/14/2009 - Diablo 2 - 1 Replies
Ich suche für den NTBot ein Lower Kurast script. Ich habe zwar ein script gefunden jedoch teleportet er sich nur zu der ersten truhe macht ein tp und geht dann zum nächsten boss script. function NTMain() { Include("common/NTCommon.ntl"); NTC_IncludeConfig(); NTC_IncludeLibs(); NT_LoadConfig(); NTSI_LoadNIPFiles();



All times are GMT +1. The time now is 05:12.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.