10 public override bool UseTurbo
20 public override bool CancelWhenDamaged
24 return !
EClass._zone.IsRegion;
30 public override bool CancelWhenMoved
40 public override bool InformCancel
49 public override bool CanManualCancel()
56 public override bool PushChara
60 AIAct parent = this.parent;
61 return parent ==
null || parent.PushChara;
66 public override Point GetDestination()
68 if (this.destCard !=
null)
70 return this.destCard.pos;
76 public AI_Goto(
Point _dest,
int dist,
bool _ignoreConnection =
false,
bool _interaction =
false)
80 this.ignoreConnection = _ignoreConnection;
81 this.interaction = _interaction;
85 public AI_Goto(
Card _card,
int dist,
bool _ignoreConnection =
false,
bool _interaction =
false)
87 this.destCard = _card;
89 this.ignoreConnection = _ignoreConnection;
90 this.interaction = _interaction;
94 public override void OnReset()
100 public AIAct.Status TryGoTo()
103 Point pos = this.owner.pos;
106 if (this.dest.x >
EClass._map.bounds.maxX + 1)
108 this.dest.x = EClass._map.bounds.maxX + 1;
110 else if (this.dest.x <
EClass._map.bounds.x - 1)
112 this.dest.x = EClass._map.bounds.x - 1;
114 if (this.dest.z >
EClass._map.bounds.maxZ + 1)
116 this.dest.z = EClass._map.bounds.maxZ + 1;
118 else if (this.dest.z <
EClass._map.bounds.z - 1)
120 this.dest.z = EClass._map.bounds.z - 1;
125 path.RequestPathImmediate(pos, this.dest, this.destDist, this.ignoreConnection, -1);
131 path.RequestPath(pos, this.dest, this.destDist, this.ignoreConnection, -1);
135 if (path.nodeIndex < 0)
137 return this.Cancel();
140 if (this.owner.IsPC &&
ActionMode.IsAdv && path.nodeIndex > 2)
144 Point shared =
Point.GetShared(pathFinderNode.X, pathFinderNode.Z);
145 if (shared.x ==
this.owner.pos.x && shared.z ==
this.owner.pos.z && path.nodeIndex > 0 && !shared.cell.HasLadder && !
this.owner.Cell.HasLadder)
148 pathFinderNode = path.nodes[path.nodeIndex];
149 shared.Set(pathFinderNode.X, pathFinderNode.Z);
151 if (shared.HasChara && !
this.owner.IsPC)
154 if (this.waitCount < 3 ||
EClass.rnd(5) != 0)
156 return AIAct.Status.Running;
160 Card.MoveResult moveResult = this.owner.TryMove(shared,
true);
161 if (this.owner ==
null)
163 return AIAct.Status.Running;
165 if (moveResult ==
Card.MoveResult.Fail || moveResult ==
Card.MoveResult.Door)
169 return this.Cancel();
171 return base.Restart();
175 if (!this.owner.pos.Equals(shared))
181 if (this.IsDestinationReached())
183 return base.Success(
null);
189 return this.Cancel();
191 return AIAct.Status.Running;
195 public bool IsDestinationReached()
197 if (this.destCard !=
null)
199 int num = this.destCard.pos.Distance(this.owner.pos);
200 return (this.interaction && num == 1 && this.owner.CanInteractTo(
this.owner.pos)) || num <= this.destDist;
202 int num2 = Util.Distance(this.owner.pos.x,
this.owner.pos.z,
this.dest.x,
this.dest.z);
203 return (this.interaction && num2 == 1 && this.owner.CanInteractTo(
this.dest)) || num2 <= this.destDist;
207 public override IEnumerable<
AIAct.Status> Run()
209 if (this.owner.host !=
null)
211 yield
return this.Cancel();
215 if (this.destCard !=
null)
217 this.dest.Set(this.GetDestination());
219 while (this.owner.path.state ==
PathProgress.State.Searching)
221 yield
return AIAct.Status.Running;
224 if (this.IsDestinationReached())
226 yield
return base.Success(
null);
228 EClass.player.enemySpotted =
false;
233 if (
EClass.player.TooHeavyToMove())
235 yield
return this.Cancel();
237 if (
EClass.player.enemySpotted)
239 EClass.player.enemySpotted =
false;
240 Msg.Say(
"enemy_spotted");
241 yield
return this.Cancel();
244 yield
return this.TryGoTo();
245 if (this.destCard !=
null)
247 Point destination = this.GetDestination();
248 int num = this.dest.Distance(destination);
249 if (num > 3 && num < 20)
262 public Card destCard;
271 public int waitCount;
274 public bool ignoreConnection;
277 public bool interaction;