|
| 1 | +(* |
| 2 | +# Transporter |
| 3 | +Responsible for transporting you from one place to another. |
| 4 | +This is not meant to be used directly but through {ref}`TRSWalker` WebWalking. |
| 5 | +*) |
| 6 | + |
| 7 | +{$DEFINE WL_TRANSPORTER_INCLUDED} |
| 8 | +{$INCLUDE_ONCE WaspLib/osrs.simba} |
| 9 | + |
| 10 | +{.$DEFINE WL_TRANSPORTER_DEBUG} |
| 11 | + |
| 12 | +type |
| 13 | +(* |
| 14 | +## TTransporter type |
| 15 | +Main record responsible for transporting the player from one place to another. |
| 16 | +*) |
| 17 | + TTransporter = record |
| 18 | + Position: TWalkerPositionFunction; |
| 19 | + end; |
| 20 | + |
| 21 | +function TTransporter.CheckTeleportGrandExchange(): Boolean; |
| 22 | +begin |
| 23 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 24 | + WriteLn GetDebugLn('Transporter', 'Checking teleport to Grand Exchange spell.'); |
| 25 | + {$ENDIF} |
| 26 | + if Stats.GetLevel(ERSSkill.MAGIC) < 25 then Exit; |
| 27 | + if Achievements.Diaries.GetLevel(ERSAchievementDiary.VARROCK) < 2 then Exit; |
| 28 | + Result := Magic.ContainsSpell(ERSSpell.VARROCK_TELEPORT); |
| 29 | +end; |
| 30 | + |
| 31 | +function TTransporter.DoTeleportGrandExchange(): Boolean; |
| 32 | +begin |
| 33 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 34 | + WriteLn GetDebugLn('Transporter', 'Casting teleport to Grand Exchange.'); |
| 35 | + {$ENDIF} |
| 36 | + if Magic.CastSpell(ERSSpell.VARROCK_TELEPORT, 'Grand Exchange') then |
| 37 | + Result := SleepUntil(Self.Position().InRange([8565, 36522], 60), 300, 5000); |
| 38 | +end; |
| 39 | + |
| 40 | + |
| 41 | +function TTransporter.CheckTeleportVarrock(): Boolean; |
| 42 | +begin |
| 43 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 44 | + WriteLn GetDebugLn('Transporter', 'Checking teleport to Varrock spell.'); |
| 45 | + {$ENDIF} |
| 46 | + if Stats.GetLevel(ERSSkill.MAGIC) < 25 then Exit; |
| 47 | + Result := Magic.Open() and Magic.ContainsSpell(ERSSpell.VARROCK_TELEPORT); |
| 48 | +end; |
| 49 | + |
| 50 | +function TTransporter.DoTeleportVarrock(): Boolean; |
| 51 | +begin |
| 52 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 53 | + WriteLn GetDebugLn('Transporter', 'Casting teleport to Varrock.'); |
| 54 | + {$ENDIF} |
| 55 | + if Magic.CastSpell(ERSSpell.VARROCK_TELEPORT, 'Cast') then |
| 56 | + Result := SleepUntil(Self.Position().InRange([8752, 36716], 60), 300, 5000); |
| 57 | +end; |
| 58 | + |
| 59 | + |
| 60 | +function TTransporter.CheckTeleportLumbridge(): Boolean; |
| 61 | +begin |
| 62 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 63 | + WriteLn GetDebugLn('Transporter', 'Checking teleport to Lumbridge spell.'); |
| 64 | + {$ENDIF} |
| 65 | + if Stats.GetLevel(ERSSkill.MAGIC) < 31 then Exit; |
| 66 | + Result := Magic.Open() and Magic.ContainsSpell(ERSSpell.LUMBRIDGE_TELEPORT); |
| 67 | +end; |
| 68 | + |
| 69 | +function TTransporter.DoTeleportLumbridge(): Boolean; |
| 70 | +begin |
| 71 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 72 | + WriteLn GetDebugLn('Transporter', 'Casting teleport to Lumbridge.'); |
| 73 | + {$ENDIF} |
| 74 | + if Magic.CastSpell(ERSSpell.LUMBRIDGE_TELEPORT, 'Cast') then |
| 75 | + Result := SleepUntil(Self.Position().InRange([8752, 36716], 60), 300, 5000); |
| 76 | +end; |
| 77 | + |
| 78 | + |
| 79 | +function TTransporter.CheckTeleportFalador(): Boolean; |
| 80 | +begin |
| 81 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 82 | + WriteLn GetDebugLn('Transporter', 'Checking teleport to Falador spell.'); |
| 83 | + {$ENDIF} |
| 84 | + if Stats.GetLevel(ERSSkill.MAGIC) < 31 then Exit; |
| 85 | + Result := Magic.Open() and Magic.ContainsSpell(ERSSpell.FALADOR_TELEPORT); |
| 86 | +end; |
| 87 | + |
| 88 | +function TTransporter.DoTeleportFalador(): Boolean; |
| 89 | +begin |
| 90 | + {$IFDEF WL_TRANSPORTER_DEBUG} |
| 91 | + WriteLn GetDebugLn('Transporter', 'Casting teleport to Falador.'); |
| 92 | + {$ENDIF} |
| 93 | + if Magic.CastSpell(ERSSpell.FALADOR_TELEPORT, 'Cast') then |
| 94 | + Result := SleepUntil(Self.Position().InRange([8752, 36716], 60), 300, 5000); |
| 95 | +end; |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +procedure TTransporter.AddTeleports(graph: PWebGraph; chunk: TPoint); |
| 100 | +begin |
| 101 | + case chunk of |
| 102 | + [46,52]: |
| 103 | + begin |
| 104 | + graph^.AddTeleport([7764, 36906], @Self.CheckTeleportFalador, @Self.DoTeleportFalador); |
| 105 | + end; |
| 106 | + |
| 107 | + [49,54]: |
| 108 | + begin |
| 109 | + graph^.AddTeleport([8565, 36522], @Self.CheckTeleportGrandExchange, @Self.DoTeleportGrandExchange); |
| 110 | + end; |
| 111 | + |
| 112 | + [50,50]: |
| 113 | + begin |
| 114 | + graph^.AddTeleport([8792, 37554], @Self.CheckTeleportLumbridge, @Self.DoTeleportLumbridge); |
| 115 | + end; |
| 116 | + |
| 117 | + [50,53]: |
| 118 | + begin |
| 119 | + graph^.AddTeleport([8752, 36716], @Self.CheckTeleportVarrock, @Self.DoTeleportVarrock); |
| 120 | + end; |
| 121 | + end; |
| 122 | +end; |
| 123 | + |
| 124 | +procedure TTransporter.Setup(position: TWalkerPositionFunction; mapLoader: PRSMapLoader); |
| 125 | +var |
| 126 | + chunk: TPoint; |
| 127 | + region: TRSMapRegion; |
| 128 | +begin |
| 129 | + Self.Position := @position; |
| 130 | + |
| 131 | + for region in mapLoader^.Regions do |
| 132 | + for chunk in region.Chunks do |
| 133 | + begin |
| 134 | + Self.AddTeleports(@mapLoader^.Graph, chunk); |
| 135 | + //Self.AddShortcuts(graph, chunk); |
| 136 | + //Self.AddWhatever(graph, chunk); |
| 137 | + end; |
| 138 | +end; |
| 139 | + |
| 140 | +{$H-} |
| 141 | +var |
| 142 | +(* |
| 143 | +## Transporter variable |
| 144 | +Global {ref}`TTransporter` variable. |
| 145 | +*) |
| 146 | + Transporter: TTransporter; |
| 147 | +{$H+} |
0 commit comments