|
You last visited: Today at 01:45
Advertisement
Custom "Skip Area When Monster"
Discussion on Custom "Skip Area When Monster" within the Diablo 2 Programming forum part of the Diablo 2 category.
03/03/2013, 22:36
|
#1
|
elite*gold: 0
Join Date: Sep 2010
Posts: 118
Received Thanks: 23
|
Custom "Skip Area When Monster"
Hello,
Im using Muddys bot. I've got a ice sorc that should clear the river of flame but skip it, if there are Grotesques like the "MWConfig_SkipBaalOnDolls" option for the NTBaal script.
As far as I understand it, Ill need a bool var e.g. "MWConfig_SkipRoFOnGrotesques" and I have to modify the RoF script "MWRiverOfFlame".
Code:
/** MWRiverOfFlame.ntj
* This file was written by
* Check the programming section for updates and further scripts
* Last Update: 16:36 17.08.2011
*/
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(106))
{
if(!NTM_TakeWaypoint(107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, 34, 107);
return;
}
}
else
{
if(!NTM_MoveToStair(me.areaid, 107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_MoveToStair, 42, me.areaid, 107);
return;
}
if(!NTM_TakeStair(107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeStair, 48, 107);
return;
}
}
NTP_DoPrecast(true);
NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.RiverOfFlame);
NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
My guess is that Ill need an if statement around the line "NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.RiverOfFlame);". But Im not sure what I have to write...
The script without modifications will be started with
"MWConfig_Script.push(["MWRiverOfFlame.ntj", 10]); MWConfig_ClearAreaSpectypes.RiverOfFlame = 0x01;".
Ive compared it with the "MWWorldstoneKeep.ntj" script, so my guess is Ill need something like
Code:
if(MWConfig_SkipRoFOnGrotesques && NTC_FindUnit(NTC_UNIT_MONSTER, 300)) // Grotesque ID = 300
{
if(_area)
Print("ÿc1Skipping " + _area.name + " due to Grotesques...");
continue;
}
|
|
|
03/10/2013, 19:21
|
#2
|
Administrator
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,727
Received Thanks: 12,653
|
You don't really need a bool variable at all, you would only need that if you want to be able to make this an option in your char config.
The essential part is actually this:
Code:
NTC_FindUnit(NTC_UNIT_MONSTER, 300) // I'll just assume that 300 is the correct ID, I honestly don't know...
NTC_FindUnit() will return a linked list of Units representing all nearby monsters with the given classid (i.e. 300). If there are no nearby monsters with that ID, the function will return null (or false?), in any case something that will evaluate to false.
So what we basically need is something like this:
Code:
if(NTC_FindUnit(NTC_UNIT_MONSTER, 300))
{
// If this block is executed, NTC_FindUnit() will have returned a linked list of monsters which will evaluate to true, meaning that there actually are monsters with the given classid
}
In the statement block we would stop the current script which basically means to use a return statement, since the entire script is merely a JS function which will be stopped immediately on return.
We want to call that before NTA_ClearLevel() is called, since we do not want to clear the area if there happen to be those nasty cold immune monsters around.
That's why said if statement goes right before the NTA_ClearLevel() call, even before the NTP_DoPrecast() call since we don't really need precast if we are not going to clear the area, resulting in this:
Code:
/** MWRiverOfFlame.ntj
* This file was written by
* Check the programming section for updates and further scripts
* Last Update: 16:36 17.08.2011
*/
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(106))
{
if(!NTM_TakeWaypoint(107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, 34, 107);
return;
}
}
else
{
if(!NTM_MoveToStair(me.areaid, 107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_MoveToStair, 42, me.areaid, 107);
return;
}
if(!NTM_TakeStair(107))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeStair, 48, 107);
return;
}
}
if(NTC_FindUnit(NTC_UNIT_MONSTER, 300))
{
NTC_SendMsgToScript("MWBotGame.ntj", NTC_FindUnit, 55, 300); // Let's print an error message in manager log
return; // Stop this function (a.k.a. bot script) right at this point and return undefined
}
NTP_DoPrecast(true);
NTA_ClearLevel(true, 2, MWConfig_ClearAreaSpectypes.RiverOfFlame);
NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
This is basically how checking for a specific monster type works. Now there are some restrictions, essentially owing to the fact that NTC_FindUnit() can only check for monsters in a limited range (which is about 70 "yards", which is a lot). So if there actually were those Grotesque thingies, but not in a radius of ~70 yards around the waypoint, this little mod could not detect them. In order to make it fully dependable, one would have to edit the NTA_Level() function directly.
That would be a bit more complicated and for most scenarios, not really necessary.
|
|
|
03/10/2013, 23:03
|
#3
|
elite*gold: 0
Join Date: Sep 2010
Posts: 118
Received Thanks: 23
|
Thanks for the answer. I was missing the info how to end a script via "return;".
Quote:
Originally Posted by Muddy Waters
This is basically how checking for a specific monster type works. Now there are some restrictions, essentially owing to the fact that NTC_FindUnit() can only check for monsters in a limited range (which is about 70 "yards", which is a lot). So if there actually were those Grotesque thingies, but not in a radius of ~70 yards around the waypoint, this little mod could not detect them. In order to make it fully dependable, one would have to edit the NTA_Level() function directly.
That would be a bit more complicated and for most scenarios, not really necessary.
|
Where can I find the "NTA_Level()" function?
€: Works fine so far doob
|
|
|
03/11/2013, 13:22
|
#4
|
Administrator
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,727
Received Thanks: 12,653
|
Sorry, that was a typo, what I meant to say was NTA_ClearLevel().
|
|
|
03/11/2013, 14:33
|
#5
|
elite*gold: 0
Join Date: Sep 2010
Posts: 118
Received Thanks: 23
|
Quote:
Originally Posted by Muddy Waters
Sorry, that was a typo, what I meant to say was NTA_ClearLevel(). 
|
And where can I find that function?
|
|
|
03/12/2013, 19:15
|
#6
|
Administrator
elite*gold: 41364
Join Date: Jan 2010
Posts: 22,727
Received Thanks: 12,653
|
Just check the prefix, it always points to the library in which a function is implemented.
In this case the prefix is NTA, hence the function must be implemented in: NTAttack.ntl
|
|
|
All times are GMT +1. The time now is 01:45.
|
|