Permalink
Browse files

*Added R_WaitToStopMoving and relocated R_WaitToMove to Timing.simba.

  *Increased wait time in R_WaitToAnimate and R_WaitToStopAnimating to reduce CPU usage.
  *Added R_GetNPCCount to NPCs.simba.

Signed-off-by: Justin Waite <jdeanwaite@gmail.com>
  • Loading branch information...
jdeanwaite committed Sep 5, 2011
1 parent 0eaa7d2 commit 5fbe8aa2abd2d146e2a6e3c22cd1dd10214530fc
Showing with 89 additions and 39 deletions.
  1. +20 −0 lib/animable/characters/NPCs.simba
  2. +0 −31 lib/mapwalk/MapWalk.simba
  3. +69 −8 lib/misc/Timing.simba
@@ -39,6 +39,26 @@ begin
Result[i] := NPCs[i2];
end;
+(*
+R_GetNPCCount
+~~~~~~~~~~~~~
+
+.. code-block:: pascal
+
+ function R_GetNPCCount: Integer;
+
+Returns the number of NPC's in the area.
+
+.. note::
+
+ by Drags111
+
+*)
+function R_GetNPCCount: Integer;
+begin
+ Result := SmartGetFieldInt(0, hook_static_NPCCount);
+end;
+
(*
R_GetNPCActionArray
~~~~~~~~~~~~~~~~~~~
View
@@ -431,37 +431,6 @@ begin
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i));
end;
-(*
-R_WaitToMove
-~~~~~~~~~~~~
-
-.. code-block:: pascal
-
- function R_WaitToMove(Timeout: integer): Boolean;
-
-Waits for the local player to move with a timeout. Returns true if moved,
-false if timed out.
-
-.. note::
-
- by lordsaturn
-
-*)
-function R_WaitToMove(Timeout: integer): Boolean;
-var
- a, Speed: integer;
-begin
- a := GetSystemTime;
- Speed := R_GetMotion;
- while Speed < 1 do
- begin
- Speed := R_GetMotion;
- if GetSystemTime - a > Timeout then Exit;
- Wait(100);
- end;
- Result := True;
-end;
-
(*
R_Flag
~~~~~~
View
@@ -213,6 +213,36 @@ begin
Result := False;
end;
+(*
+R_WaitToAnimate
+~~~~~~~~~~~~~~~
+
+.. code-block:: pascal
+
+ function R_WaitToAnimate: Boolean;
+
+Waits until your player is animating.
+
+.. note::
+
+ by Drags111
+
+*)
+function R_WaitToAnimate(MaxWait: Integer): Boolean;
+var
+ T: Integer;
+begin
+ Result := False;
+ MarkTime(T);
+ while(not R_Animating)do
+ begin
+ if(TimeFromMark(T) >= MaxWait)then
+ Break;
+ Wait(100+Random(100));
+ end;
+ Result := (TimeFromMark(T) < MaxWait);
+end;
+
(*
R_WaitToStopAnimating
~~~~~~~~~~~~~~~~~~~~~
@@ -238,37 +268,68 @@ begin
begin
if(TimeFromMark(T) >= MaxWait)then
Break;
- Wait(20+Random(10));
+ Wait(200+Random(100));
end;
Result := (TimeFromMark(T) < MaxWait);
end;
(*
-R_WaitToAnimate
-~~~~~~~~~~~~~~~
+R_WaitToMove
+~~~~~~~~~~~~
.. code-block:: pascal
- function R_WaitToAnimate: Boolean;
+ function R_WaitToMove(Timeout: integer): Boolean;
-Waits until your player is animating.
+Waits for the local player to move with a timeout. Returns true if moved,
+false if timed out.
+
+.. note::
+
+ by lordsaturn
+
+*)
+function R_WaitToMove(Timeout: integer): Boolean;
+var
+ a, Speed: integer;
+begin
+ a := GetSystemTime;
+ Speed := R_GetMotion;
+ while Speed < 1 do
+ begin
+ Speed := R_GetMotion;
+ if GetSystemTime - a > Timeout then Exit;
+ Wait(100+Random(100));
+ end;
+ Result := True;
+end;
+
+(*
+R_WaitToStopMoving
+~~~~~~~~~~~~~~~~~~
+
+.. code-block:: pascal
+
+ function R_WaitToStopMoving(MaxWait: Integer): Boolean;
+
+Waits until your player is not moving anymore.
.. note::
by Drags111
*)
-function R_WaitToAnimate(MaxWait: Integer): Boolean;
+function R_WaitToStopMoving(MaxWait: Integer): Boolean;
var
T: Integer;
begin
Result := False;
MarkTime(T);
- while(not R_Animating)do
+ while(R_Moving)do
begin
if(TimeFromMark(T) >= MaxWait)then
Break;
- Wait(20+Random(10));
+ Wait(200+Random(100));
end;
Result := (TimeFromMark(T) < MaxWait);
end;

0 comments on commit 5fbe8aa

Please sign in to comment.