Skip to content

Commit

Permalink
changed teleport module
Browse files Browse the repository at this point in the history
  • Loading branch information
arturojosejr committed Jun 25, 2017
1 parent bc6adff commit bd1db8d
Show file tree
Hide file tree
Showing 4 changed files with 1,292 additions and 100 deletions.
174 changes: 78 additions & 96 deletions My Scripts/Lvl 1-80 (interlude)/TeleportModule.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
uses
SysUtils, Classes, SettingsModule, ModuleFunctions,
Functions;
SysUtils, Classes;
type
TCity = (DWARVEN = 0, ORC = 1, DARK_ELVEN = 2, ELVEN = 3, TALKING_ISLAND = 4,
HEINE = 5, DION = 6, GIRAN = 7, ADEN = 8, GODDARD = 9, GLUDIO = 10, GLUDIN = 11,
SHTUTTGART = 12, RUNE = 13, OREN = 14, HUNTER = 15, NON_CITY = 16);
TCity2 = record
Enum: TCity;
ID: integer;
Name: String;
gateKeeperID: integer;
supplyManagerID: integer;
newbieBufferID: integer;
pathToBuffer: DimensionArray;
pathToSupply: DimensionArray;
GateKeepersString: String;

const
{
--------------------------------------------------------------------------------
Array with all the locations to which the gatekeeper of a city can teleport
The gatekeepersString share the same index as it's corresponding city
--------------------------------------------------------------------------------
}
SCROLL_OF_SCAPE = 736;
ROXXY = 30006;

CityNames: array[0..16] of string = ('dwarven village','orc village','dark elf village','elf village','kamael village','talking island',
TCities : array[0..16] of TCity = (DWARVEN, ORC, DARK_ELVEN, ELVEN, TALKING_ISLAND,
HEINE, DION, GIRAN, ADEN, GODDARD, GLUDIO, GLUDIN, SHTUTTGART, RUNE, OREN, HUNTER, NON_CITY);

CityNames: array[0..15] of string = ('dwarven village','orc village','dark elf village','elf village','talking island',
'heine','dion','giran','aden','goddard','gludio','gludin','schuttgart','rune','oren','hunter village');

// IDs of the Gatekeepers
GateKeepers: array[0..16] of integer = (30540, 30576, 30134, 30146, 30006,
GateKeepers: array[0..15] of integer = (30540, 30576, 30134, 30146, 30006,
30899, 30059, 30080, 30848, 31275, 30256, 30320, 31964, 31320, 30177, 30233);

TPDelay = 3000; // Time to wait after teleporting, change according to your computer

GateKeepersStrings: array[0..16] of string = (
{
--------------------------------------------------------------------------------
Array with all the locations to which the gatekeeper of a city can teleport
The gatekeepersString share the same index as it's corresponding city
--------------------------------------------------------------------------------
}
GateKeepersStrings: array[0..15] of string = (
'gludio,schuttgart,"dark elf village","talking island","elf village","orc village","mithril mines","abandoned coal mines","eastern mining zone","western mining zone"', //dwarven
'gludio,schuttgart,"dark elf village","dwarven village","talking island","elf village","immortal plateau","immortal plateau south","fozen waterfall"', //orc
'gludio,"dwarven village","talking island","orc village","dark forest","swampland","spider nest","neutral zone"', //darkelven
'gludio,"dwarven village","talking island","orc village","elven forest","elven fortress","neutral zone"', //elven
'gludin,"dark elf village","dwarven village","elf village","orc village","elven ruins","singing waterfall","northen territory","obelisk of victory"', //talking island
'giran,oren,dion,aden,goddard,rune,schuttgart,gludio,"giran harbor","field of silence","field of whispers","alligator island","garden of eva"', //heine
'giran,heine,gludio,goddard,rune,schuttgart,aden,oren,"cruma marshland","cruma tower","fortress of resistance","plains of dion","bee hive","tanor canyon"', //dion
'oren,heine,dion,goddard,rune,schuttgart,gludio,aden,"giran harbor","hardins private academy","dragon valley", "antharas lair", "devils isle","breka stronghold"', //giran
'goddard,oren,giran,heine,schuttgart,dion,gludio,rune,"hunter village","coliseum","forsaken plains","seal of shilen","forest of mirrors","blazing swamp","field of massacre","ancient battleground","silent valley","tower of insolence", //aden
'oren,heine,dion,goddard,rune,schuttgart,gludio,aden,"giran harbor","hardins private academy","dragon valley","antharas lair","devils isle","breka stronghold"', //giran
'goddard,oren,giran,heine,schuttgart,dion,gludio,rune,"hunter village","coliseum","forsaken plains","seal of shilen","forest of mirrors","blazing swamp","field of massacre","ancient battleground","silent valley","tower of insolence"', //aden
'gludio,giran,dion,rune,heine,schuttgart,aden,oren,"varka","ketra","hot springs","wall of argos","monastery of silence"', //goddard
'schuttgart,heine,aden,oren,dion,goddard,giran,rune,gludin,"elf village","dark elf village","dwarven village","orc village","ruins of agony","ruins of despair","ant nest","windawood manor"', //gludio
'gludio,"talking island","elf village","dark elf village","dwarven village","orc village","langk lizardman dwellings","windmill hill","fellmere harvesting grounds","forgotten temple","orc barracks","windy hill",wasteland,"red rock ridge"', //gludin
Expand All @@ -52,20 +46,6 @@ const
'aden,oren,"hardins private academy","enchanted valley south","enchanted valley north","forest of mirrors"' //hunter
);

// DimensionArray = array of array of integer
var
talkingIslandToBuffer: DimensionArray;
heineToBuffer: DimensionArray;
dionToBuffer: DimensionArray;
giranToBuffer: DimensionArray;
adenToBuffer: DimensionArray;
goddardToBuffer: DimensionArray;
gludioToBuffer: DimensionArray;
gludinToBuffer: DimensionArray;
shtuttgartToBuffer: DimensionArray;
runeToBuffer: DimensionArray;
orenToBuffer: DimensionArray;

{
--------------------------------------------------------------------------------
Finds the city in which the character is located
Expand All @@ -87,10 +67,8 @@ begin
if User.InRange (147713,-56202,User.Z,5000,10) then City := GODDARD;
if User.InRange (111434,220426,User.Z,5000,10) then City := HEINE;
if User.InRange (117144, 76824,User.Z,5000,10) then City := HUNTER;
if User.InRange (-118184, 46024, User.Z, 7000, 10) then City := KAMAEL;
if User.InRange (-45080, -113576, User.Z, 5000, 10) then City := ORC;
if User.InRange (81150, 54880, User.Z, 5000, 10) then City := OREN;
if User.InRange (9677, -22176, -3722, 5000, 150) then City := PRIMEVAL_ISLE;
if User.InRange (43838, -48222, User.Z, 5000, 10) or
User.InRange (38283, -48102, User.Z, 5000, 10) then City := RUNE;
if User.InRange (88041, -142502, User. Z,5000, 10) then City := SHTUTTGART;
Expand Down Expand Up @@ -149,9 +127,7 @@ begin
end;

// Go to the Gatekeeper if move = true
if move then
InCity;
end;
if move then MoveInCity;
end;
end;

Expand All @@ -160,7 +136,7 @@ end;
Move from the city respawns to the gatekeeper
--------------------------------------------------------------------------------
}
procedure InCity;
procedure MoveInCity;
var
City: TCity;
Moved : Boolean;
Expand All @@ -169,11 +145,11 @@ var
begin
City := GetCity;

{
------------------------------------------------------------------------------
Aden
------------------------------------------------------------------------------
}
{
------------------------------------------------------------------------------
Aden
------------------------------------------------------------------------------
}
if CITY = ADEN then begin
if User.InRange (149800, 24000, 2100, 600, 200) then begin // Bottom of north-east stairs
Engine.MoveTo (148611, 24319, -2039); // climb stairs
Expand Down Expand Up @@ -619,6 +595,7 @@ begin
end;
if User.InRange(-81073,150110,-3042, 250, 150) then Moved := true;
end;

{
------------------------------------------------------------------------------
Gludio
Expand Down Expand Up @@ -1207,24 +1184,24 @@ begin
Engine.MoveTo(-84184, 244504, -3712);
end;
if User.InRange(-84200, 244488, -3728, 500, 150) then Moved := true;
end;
end;

{
------------------------------------------------------------------------------
If no movement has taken place in the city
------------------------------------------------------------------------------
------------------------------------------------------------------------------
If no movement has taken place in the city
------------------------------------------------------------------------------
}
if not Moved then begin
//GoHome;
Print('Unknown respawn.');
end;
if not Moved then begin
//GoHome;
Print ('Unknown respawn.');
end;
end;

{
--------------------------------------------------------------------------------
Returns the position in the array of the corresponding gatekeeper of the
destination. Returns -1 if it's not found.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Returns the position in the array of the corresponding gatekeeper of the
destination. Returns -1 if it's not found.
--------------------------------------------------------------------------------
}
function getCityToLocationGK (teleportName: String): integer;
var
Expand Down Expand Up @@ -1267,18 +1244,18 @@ begin
if isRightCity (destination) then
begin
Result := true;
end else then // else we get the name of the city in which we are
end else // else we get the name of the city in which we are
begin
currentCity := GetCity;

// If we aren't in a city we go home
if currentCity = NON_CITY then GoHome;

// We take the ordinal value of the destination from the CityNames array and we teleport there
DoTeleport (CityNames[ord(destination)]);
TeleportTo (CityNames[ord(destination)]);

// We repeat the process until we are in our destination
Result := toRightCity (val);
Result := toRightCity (destination);
end;
end;

Expand All @@ -1287,26 +1264,27 @@ end;
Checks if the destination is actually the city to which we want to go.
--------------------------------------------------------------------------------
}
function DoTeleportToLocation (destination: String): boolean;
function TeleportToLocation (destination: String): boolean;
begin
Result := false;
if toRightCity(TCities[getCityToLocationGK(destination)]) then
Result := DoTeleport(destination);
Result := TeleportTo (destination);
end;

{
--------------------------------------------------------------------------------
Teleports to the destination
--------------------------------------------------------------------------------
}
function DoTeleport(destination: String): boolean;
function TeleportTo (destination: String): boolean;
var
City: TCity;
gkId: integer;
cityIndex: integer;
buffer: TL2Live;
gatekeeper: TL2Live;
dialogIndex: integer;
teleportIndex: TStringList;
rightCity: boolean;
begin
City := GetCity;
cityIndex := Ord (City);
Expand All @@ -1316,6 +1294,7 @@ begin
if (City <> NON_CITY) or (Length(destination) <> 0) then
begin
teleportIndex := TStringList.Create;
dialogIndex := 0;

gkId := GateKeepers[cityIndex]; // Get the Gatekeeper ID of our current city

Expand All @@ -1337,46 +1316,49 @@ begin
begin
{
We search the string destination in the possible destinations of our gatekeeper
and assign it to dialogIndex
and assign it to dialogIndex. indexOf returns -1 if it wasn't found.
We add 1 to match the dialog option of the gatekeeper
}
rightCity := true;
dialogIndex := teleportIndex.indexOf (destination) + 1;

// Checks if we are in the right city or teleports us again
if dialogIndex = 0 then
begin
DoTeleportToLocation (destination);
exit; // TODO: I don't like exits in the middle of the code. Change it
end;

if dialogIndex > 0 then
begin
Engine.SetTarget (buffer);
Engine.MoveTo (buffer);
Engine.DlgOpen;
Delay (500);
{
// TODO: Check the gatekeepers that don't have the teleport dialog in the first option
if buffer.id = 30146 then
Engine.DlgSel (1)
else
Engine.DlgSel (ifThen((Pos(buffer.name, 'Ragara') <> 0), 'Teleport', GkDlg));
if dialogIndex = 0 then
begin
dialogIndex := 1;
rightCity := false;
end;
{
Checks if we are in the right city or teleport us to the first city of the dialog options
}
Engine.SetTarget (gatekeeper);
Engine.MoveTo (gatekeeper);
Engine.DlgOpen;
Delay (500);
// TODO: Check the gatekeepers that don't have the teleport dialog in the first option
if gatekeeper.ID = ROXXY then // if we are in talking island
Engine.DlgSel (2)
{
else
Engine.DlgSel (ifThen((Pos(buffer.name, 'Ragara') <> 0), 'Teleport', GkDlg));
case buffer.id of
30256: Engine.DlgSel(2);
30006: Engine.DlgSel(3);
else
}
}
else
Engine.DlgSel(1);
Delay (500);
Engine.DlgSel (dialogIndex);
Delay (TPDelay);
Result := true;
end;
Delay (500);
Engine.DlgSel (dialogIndex);
Delay (TPDelay);
Result := true;

if rightCity = false then
TeleportTo (destination);
end;

teleportIndex.Free;
end;
end;

BEGIN
DoTeleport ('gludio');
//ToRightCity (GLUDIO);
TeleportTo ('dragon valley');
END.
11 changes: 7 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ Adrenaline scripts are written in delphi/pascal syntax so If you want to better
I'm gonna be doing a 1-80 leveler script for Interlude that includes some quests like pet quests, nobless, etc.

TODO list:
- Add array of hunting zones for exping and array of mobs that have useful drops and spoils and specify the path to go to each.
- killAggroMobs doesn't work in Interlude, find another way.
- The killAggroMobs procedure should check for mobs attacking not only you but any party member and kill them.
- There should be an array with of hunting grounds to having to change only the name or to write a number corresponding to the hunting grund
- The teleport function currently teleports to the first location in the gatekeeper dialog if the destination is not reachable from this gatekeeper, and keeps repeating
until the destination is reachable. The number of teleports should be minimized. A way could be to find from which city the destination is reachable, if that city is in
the current gatekeeper dialog then we've finished, else look for a city to go to the previous city and see if it's reachable and so on.
- Add a function in which you specify a hunting zone and it does the necessary teleports and movements to arrive.
There could be an array of hunting grounds to having to write only the name or to write a number corresponding to the hunting grund
and depending of the huntingGround string it would go to a different position.
- The killAgroMobs procedure should suspend the movement thread until finished killing the mobs.
- The killAgroMobs procedure should check for mobs attacking not only you but any party member and kill them.
- The moveInCity procedure currently checks a range of 250 around every respawn of the city. It would be better for it to work in all the city.
Let's say the city has a range of 5000 (the range I think is the radius of a circle), it would need small circles in the different locations of the
city and they should completely fill the city range. It would start by the shops, if you are in the range of a shop you move to the door,
Expand Down
1 change: 1 addition & 0 deletions Scripts/Auto Farm/Back to loc/TeleportModule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ end;


BEGIN
doteleport ('goddard');
END.
Loading

0 comments on commit bd1db8d

Please sign in to comment.