[Release]Kurast Scripte für Muddy D2NT

04/18/2012 15:40 papachef#1
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
Code:
function MWL_LootAreaChests()
{
	var _pUnit, _chests, _chest;
	
	_chests = new Array();
	_pUnit = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT); // Get an array that holds all object units in our current area

	if(!_pUnit)
		return;
	
	var _debugArray = new Array();
	for(var i = 0; i < _pUnit.length; i++)
	{
		if(!MWL_IsLootableChest(_pUnit[i].id) && _MWL_SuperChestClassids.indexOf(_pUnit[i].id) == -1) // Skip non lootable object units
			continue;
		
		if(typeof _debugArray[_pUnit[i].id] != "number")
			_debugArray[_pUnit[i].id] = 1;
		else
			_debugArray[_pUnit[i].id]++;
			
		// Add an object that holds all data that we will need for locating it
		_chests.push({
						x: _pUnit[i].roomx*5 + _pUnit[i].x,
						y: _pUnit[i].roomy*5 + _pUnit[i].y,
						classid: _pUnit[i].id
					});
	}
	
	for(var i = 0; i < _debugArray.length; i++)
	{
		if(_debugArray[i])
			Print("Classid " + i + ": " + _debugArray[i]);
	}
	
	// Define a sort function that will sort the given objects by distance to controlled unit in descending order:
	_chests.sorter = function(a, b)
	{
		if(GetDistance(me.x, me.y, a.x, a.y) < GetDistance(me.x, me.y, b.x, b.y))
			return 1; // Place b before a
    
		return -1; // Place a before b
	};
	
	while(_chests.length > 0)
	{
		_chests.sort(_chests.sorter); // Sort chests by distance - closest one will be moved to last index
		_chest = _chests.pop(); // Remove the last element and return it
		
		if(!NTM_MoveTo(me.areaid, _chest.x + 1, _chest.y + 1, 3))
			continue;

		if(NTC_OpenChest(MWL_FindContainerUnit(_chest)))
			NTSI_PickItems();
	}
}
Anmerkung: Die Kistenansage von Muddy hab ich drin gelassen weil ich sie ganz cool finde, nötig ist sie nicht.

Ebenfalls in der MWLoot.ntl weiter unten bei
Code:
function MWL_IsLootableChest(classid)
Code:
case 169:
hinzufügen.

Die ID 169 steht für "Hollow Log" (Baumstumpf). Da die recht häufig sind also unbedingt einfügen.

Nun hier das UK Script:
Erstellt eine neue Datei die bspw uk.ntj heißt. und kopiert den Code hinein.
Die Datei "uk.ntj" muss im Order "Bots" sein.
Code:
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, 32, 79);
		return;
	}

   NTP_DoPrecast(true);

   Delay(500);
   
   _unit = GetPresetUnits(me.areaid, NTC_UNIT_OBJECT);

   if(_unit)
   {
      for(n = 0 ; n < _unit.length ; n++)
      {
         if(_unit[n].id == 580)
         {
            NTM_MoveTo(me.areaid, _unit[n].roomx*5+_unit[n].x, _unit[n].roomy*5+_unit[n].y);
           
            _chest = NTC_FindUnit(NTC_UNIT_OBJECT, GetLocaleString(3260), 1);
            if(_chest)
               {
                  do
                  {
                     if(NTC_OpenChest(_chest))
                     NTSI_PickItems();
                  }while(_chest.GetNext());
               }
         }
         else if(_unit[n].id == 104 || _unit[n].id == 105 || _unit[n].id == 106 || _unit[n].id == 107)
         {
            NTM_MoveTo(me.areaid, _unit[n].roomx*5+_unit[n].x, _unit[n].roomy*5+_unit[n].y);
           
            _chest = NTC_FindUnit(NTC_UNIT_OBJECT, GetLocaleString(3247));
            if(_chest)
               {
                  do
                  {
                     if(NTC_OpenChest(_chest))
                     NTSI_PickItems();
                  }while(_chest.GetNext());
               }   
               
            _chest = NTC_FindUnit(NTC_UNIT_OBJECT, GetLocaleString(3248));
            if(_chest)
               {
                  do
                  {
                     if(NTC_OpenChest(_chest))
                     NTSI_PickItems();
                  }while(_chest.GetNext());
               }         
         }
         
      }
   }

MWL_LootAreaChests(); 
   
   NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END");
}
Der Bot telt nun zuerst zu den Supertruhen und Waffenständern und öffnet danach (fast) alle Truhen in ganz UK.

Wer nur die Supertruhen öffnen will muss im Script
Code:
MWL_LootAreaChests();
einfach nur weglassen

Um in OberKurast auch nur alle Chests zu looten folgendes Script in den Botsordner kopieren und nennt es bspw "ok.ntj" :
Code:
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(81))
	{
		NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, 32, 81);
		return;
	}

	NTP_DoPrecast(true);

	MWL_LootAreaChests(); // Call MWL_LootAreaChests
	
	NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END")
}
Für KurastBasar ebenfalls in dem Ordner Bots eine Datei erstellen bspw "kb.ntj" und folgenden Code hinein kopieren:
Code:
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(80))
	{
		NTC_SendMsgToScript("MWBotGame.ntj", NTM_TakeWaypoint, 32, 80);
		return;
	}

	NTP_DoPrecast(true);

	MWL_LootAreaChests(); // Call MWL_LootAreaChests
	
	NTC_SendMsgToScript("MWBotGame.ntj", "SCRIPT_END")
}
Nun in die jeweilige Charconfig gehen und eure Scripte dort einfügen.
So zum Beispiel:
Code:
MWConfig_Script.push(["MWuk.ntj", 10]); 
MWConfig_Script.push(["MWkb.ntj", 10]); 
MWConfig_Script.push(["MWok.ntj", 10]);
Thanks geht natürlich an Muddy und an Blizzhackers.

Kind regards
04/18/2012 20:28 Muddy Waters#2
Irgendwie ist die Umsetzung für UK reichlich schlampig im Vergleich zu der für die anderen ebenen. Das könnte man durchaus noch optimieren. :o
04/18/2012 22:44 papachef#3
Ja ich bin dabei aber auch hier muss ich erstmal wirklich warm werden.
Erstmal läuft es so und wer es will kann es so nutzen.
Ich werde sicher in Zukunft mal eine bessere Version editieren die schöner aufgebaut ist aber ich bekomme zum jetzigen Zeitpunkt die Supertruhen nicht unter MWL_IsLootableChest eingebunden.
Ich werd das schon hinbekommen aber good Thinks needs time to learn.