[D2NT Release] Nice Waypoint Give Script

01/12/2011 22:28 tourk1234#1
Tell me if you like the idea of this script.

You can make other script for leeches to take those waypoints automatically.
Its pretty much possible ;-)

* WAYPOINT COMMANDS!
*
* Give Wps 1, Give Wps 2, Give Wps 3, Give Wps 4, Give Wps 5, will give other people the waypoints in an individual act
* Give Wps All = gives every waypoint in the game except halls of pain
* Give Wps Stop - stops script
*/

Config for your character script:
Code:
	NTConfig_Script.push("NTGivewps.ntj");
	NTConfig_ChickenWaypointGiver = true;   // Clear mobs around waypoint
	NTConfig_TimeBetweenWayPoints = 10000;  // Time Between Portals To WayPoints
	NTConfig_AskPlayerForNextWp = true;   // Asks player for next wp instead of time comming from NTConfig_TimeBetweenWayPoints

Script Code:

Code:
/*Readme
 * WAYPOINT COMMANDS!
 * 
 * Give Wps 1, Give Wps 2, Give Wps 3, Give Wps 4, Give Wps 5, will give other people the waypoints in an individual act
 * Give Wps All = gives every waypoint in the game except halls of pain
 * Give Wps Stop - stops script
 */



var Act1WpID = [3, 4, 5, 6, 27, 29, 32, 35];
var Act2WpID = [48, 57, 42, 43, 44, 52, 74, 46];
var Act3WpID = [76, 77, 78, 79, 80, 81, 83, 101];
var Act4WpID = [106, 107];
var Act5WpID = [111, 112, 113, 115, 117, 118, 129];
Stop_Give_Wps = false;

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

	NTC_IncludeConfig("NTBot/char_configs");
	NT_LoadConfig();

	NTSI_LoadNIPFiles("NTBot/item_configs");
	
	NTA_Initialize();
	RegisterEvent(EVENT_GAMEMSG, NT_GameMsgEvents);

	if(!NTTM_CheckAct())
	{
		NTC_SendMsgToScript("default.ntj", "NTTM_CheckAct()");
		return;
	}

	NTTMGR_TownManager();

	if(!NTTM_TownMove("waypoint"))
	{
		NTC_SendMsgToScript("default.ntj", "NTTM_TownMove()");
		return;
	}
	
	while (1)
	{
		Delay(500);
	}

}

function GiveWayPoints(WpID)
{
	NTTMGR_TownManager();
	if(!NTTM_TownMove("waypoint"))
	{
		NTC_SendMsgToScript("default.ntj", "NTTM_TownMove()");
		return;
	}
	for(var j=0; j < WpID.length ;j++)
	{
		if (Stop_Give_Wps) 
		{
			NTM_MakeTP();
			NTM_UsePortal("BluePortal", 1, me.charname); 
			return;
		}
		
		if(!NTM_TakeWaypoint(WpID[j]))
		{
			NTC_SendMsgToScript("default.ntj", "NTM_TakeWaypoint()");
			continue;
		}
		

		if(!NTTMGR_CheckSafe(2))
		{
			NTC_SendMsgToScript("default.ntj",
			"NTTMGR_CheckSafe()");
			return;
		}
		NTM_MoveTo(me.areaid, me.x-4, me.y);
		NTM_MakeTP();
		if (!NTConfig_ChickenWaypointGiver)
		{
			NTP_DoPrecast();
			NTA_ClearPosition(20, true, 2)
		}
		Say("Tp to Wps nr " +(j+1) + " in this Act is up");
		NTM_UsePortal("BluePortal", 1, me.charname);
		if ((WpID.length-1) != j) 
		{
			NTTMGR_TownManager();
			NTTM_TownMove("portalspot");
			if (!NTConfig_AskPlayerForNextWp)
			{
				Say("Waiting " + (parseInt(NTConfig_TimeBetweenWayPoints/1000)) + " seconds");
				Delay(NTConfig_TimeBetweenWayPoints);
			}
			else
			{
				Say("Next Wps? Say >>   y   << in chat to continue");
				NextWps = false;
				while (NextWps == false) {Delay(500);}
			}
			NTM_UsePortal("BluePortal", WpID[j], me.charname);
		}
	}
	//NTM_MakeTP();
	Say("Wps in this ACT done, Good Luck!");
}

//Give Wps 1, Give Wps 2, Give Wps 3, Give Wps 4, Give Wps 5,, = Select these for rushing individual acts
function NT_GameMsgEvents(msg, type){
	if ((type == 0 && msg[msg.indexOf(":")+2] == 'y') && (type == 0 && msg.indexOf("continue") == -1)) {
		NextWps = true;
	}
	if(type == 0 && msg.indexOf("Give Wps Stop") != -1){
		Stop_Give_Wps = true;
		NextWps = true;
		Say("Stopping Script");
	}
	if(type == 0 && msg.indexOf("Give Wps All") != -1){
		Say("Giving Wps in Act 1 Started!");
		GiveWayPoints(Act1WpID);
		Say("Giving Wps in Act 2 Started!");
		GiveWayPoints(Act2WpID);
		Say("Giving Wps in Act 3 Started!");
		GiveWayPoints(Act3WpID);
		Say("Giving Wps in Act 4 Started!");
		GiveWayPoints(Act4WpID);
		Say("Giving Wps in Act 5 Started!");
		GiveWayPoints(Act5WpID);
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}
	}
	if(type == 0 && msg.indexOf("Give Wps 1") != -1){
		Say("Giving Wps in Act 1 Started!");
		GiveWayPoints(Act1WpID);
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}

	}
	if(type == 0 && msg.indexOf("Give Wps 2") != -1){
		Say("Giving Wps in Act 2 Started!");
		GiveWayPoints(Act2WpID);	
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}
	}
	if(type == 0 && msg.indexOf("Give Wps 3") != -1){
		Say("Giving Wps in Act 3 Started!");
		GiveWayPoints(Act3WpID);	
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}
	}
	if(type == 0 && msg.indexOf("Give Wps 4") != -1){
		Say("Giving Wps in Act 4 Started!");
		GiveWayPoints(Act4WpID);	
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}
	}
	if(type == 0 && msg.indexOf("Give Wps 5") != -1){
		Say("Giving Wps in Act 5 Started!");
		GiveWayPoints(Act5WpID);	
		if (Stop_Give_Wps == true)
		{
			Say("Script Stopped");
			Stop_Give_Wps = false;
		}
	}
}
01/12/2011 22:52 lanara#2
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
01/12/2011 23:01 tourk1234#3
Quote:
Originally Posted by lanara View Post
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
Yea, i know them.
Well but you cant control those two by saying commands in chat.
01/12/2011 23:14 Muddy Waters#4
I always appreciate scripts that are not just a copy of an existing script with some tweaks. :)

Here are some suggestions for improvements:
- make sure the commands work case insensitive and add a command trigger or something for more convenient use
- each if statement in NT_GameMsgEvents() includes type == 0; use one if statement type == 0 and place the other if statements within this one for enhanced code readability
- Stop_Give_Wps is not declared properly

The naming does not quite meet the D2NT naming conventions, but is okay for an independent script. :)

Regards
Muddy

@lanara
Die nutzen aber kein Chat Handle und sind somit durch Befehle steuerbar. Somit ist das was eigenes und hat durchaus seine Daseinsberechtigung. :)
01/12/2011 23:37 lanara#5
Shame on me then, didn't really look at it. Just thought "that looks familiar" and found the listed threads on search. [Only registered and activated users can see links. Click Here To Register...]
01/16/2011 20:32 tourk1234#6
Quote:
Originally Posted by Muddy_Waters View Post
I always appreciate scripts that are not just a copy of an existing script with some tweaks. :)

Here are some suggestions for improvements:
- make sure the commands work case insensitive and add a command trigger or something for more convenient use
- each if statement in NT_GameMsgEvents() includes type == 0; use one if statement type == 0 and place the other if statements within this one for enhanced code readability
- Stop_Give_Wps is not declared properly

The naming does not quite meet the D2NT naming conventions, but is okay for an independent script. :)

Regards
Muddy
Thx, I will do some minor fixes too. But, later after exams on my university ;-p.

One more thing, is there any way to make character automatically getting up on Death Screen. I mean pressing ESC button or something. Thats whats makes me angry. D2NT bot has closed source code.

That, would help with auto-passing waypoints script.


Quote:
Stop_Give_Wps is not declared properly
Most funny thing about it is that it works anyway ;-p. Explain it to me.
It doesn't make any sense. Auto declaring on first use? Even if it is without var at the beginning?
01/16/2011 22:01 Muddy Waters#7
Quote:
Originally Posted by tourk1234 View Post
Thx, I will do some minor fixes too. But, later after exams on my university ;-p.

One more thing, is there any way to make character automatically getting up on Death Screen. I mean pressing ESC button or something. Thats whats makes me angry. D2NT bot has closed source code.

That, would help with auto-passing waypoints script.




Most funny thing about it is that it works anyway ;-p. Explain it to me.
It doesn't make any sense. Auto declaring on first use? Even if it is without var at the beginning?
Actually, JavaScript does not really bother too much about slight mistakes.
You can make quite a mess - in comparison to other languages - and it will most likely work anyway.

Not that much of a good idea though, because you can't really tell what your program actually does then. It's up to the runtime interpreting the code.

Regarding character's death:
You could use the function I used for my rush script:
Code:
function MWR_CheckDeath()
{
    if(me.hp <= 0 || me.mode == 17)
    {
        Print("ÿc1Oh noes, I died! :'(");
        for(var i = 0; i < 8; i++)
        {
            if(i % 4 == 0)
                me.Cancel(0);
                
            if(me.hp > 0 || NTC_InTown())
                return true;
                
            NTC_Delay(250);
        }
    }
    
    return false;
}
Regards
Muddy
01/16/2011 22:46 tourk1234#8
Quote:
Originally Posted by Muddy_Waters View Post
Actually, JavaScript does not really bother too much about slight mistakes.
You can make quite a mess - in comparison to other languages - and it will most likely work anyway.

Not that much of a good idea though, because you can't really tell what your program actually does then. It's up to the runtime interpreting the code.

Regarding character's death:
You could use the function I used for my rush script:
Code:
function MWR_CheckDeath()
{
    if(me.hp <= 0 || me.mode == 17)
    {
        Print("ÿc1Oh noes, I died! :'(");
        for(var i = 0; i < 8; i++)
        {
            if(i % 4 == 0)
                me.Cancel(0);
                
            if(me.hp > 0 || NTC_InTown())
                return true;
                
            NTC_Delay(250);
        }
    }
    
    return false;
}
Regards
Muddy
Nice, i will check it out later.

But i think it would be better to look this way

Code:
function MWR_CheckDeath()
{
    if(me.hp <= 0 || me.mode == 17)
    {
        Print("ÿc1Oh noes, I died! :'(");
        for(var i = 0; i < 2; i++)
        {
            me.Cancel(0);  
                
            NTC_Delay(1000);

            if(me.hp > 0 || NTC_InTown())
                return true;
        }
    }
    
    return false;
}
I think its more Cpu friendly. try to dont use % operator its a horror for Cpu.
Hopes it help you.

Does me.Cancel(0); work for D2NT? I found info about this but if remember right it was for D2BS.
01/17/2011 11:29 Muddy Waters#9
Quote:
Originally Posted by tourk1234 View Post
Nice, i will check it out later.

But i think it would be better to look this way

Code:
function MWR_CheckDeath()
{
    if(me.hp <= 0 || me.mode == 17)
    {
        Print("ÿc1Oh noes, I died! :'(");
        for(var i = 0; i < 2; i++)
        {
            me.Cancel(0);  
                
            NTC_Delay(1000);

            if(me.hp > 0 || NTC_InTown())
                return true;
        }
    }
    
    return false;
}
I think its more Cpu friendly. try to dont use % operator its a horror for Cpu.
Hopes it help you.

Does me.Cancel(0); work for D2NT? I found info about this but if remember right it was for D2BS.
You are definately right about the CPU load.

However, this function will behave differently and might result in being quite slow. If you don't want to use the modulus operator, you could just use an if statement instead, but you should avoid huge delays, as they prevent the bot from being both responsive and fast. :)

And me.Cancel(0) definately works. In fact, there are lots of similarities if you compare D2NT to D2BS, because that korean dude who wrote D2NT apparently stole some D2BS code and used it for his own purpose, not revealing his source code and in doing so ignoring D2BS's open source licence. :rolleyes:

Kinds regards
Muddy

P.S.: You might wanna check out the common library, most functions in there use the modulus operator as well. ;)
01/17/2011 12:58 kal_el#10
moved -> programming sektion