View Full Version : Help With a Failsafe
Gucci
02-20-2012, 08:03 PM
How could I implement a failsafe that's set up so that if a script leaves a certain area it will return to it?
Thanks in advance for any help and guidance.
PatDuffy
02-20-2012, 08:05 PM
You could set up the area you want the player to be in as an SPS-Box, using 2 points as boundaries, then checking to see if the player is inside the box.
The other way would be using Object DTM's, and checking to see if the player is inside the node for a point.
Gucci
02-20-2012, 08:07 PM
hmmmm how could I make a SPS box, I have done SPS walking but I'm not sure how the box works. If you could point me to a tutorial that would help with the DTM then I might use that as I have never used DTM's
PatDuffy
02-20-2012, 08:12 PM
It's not a DTM so much as an Object DTM :p I know that didn't make sense, but they are made(by a scripter) differently. I know there is a very detailed guide on object DTM's so I would check that out.
For the SPS Box you would get the point for the spots of the top-left and bottom-right areas of the area you want(as a box), then declared it as something likes
Box := intToBox(x1,y1,x2,y2);
Then I'm not sure what you would call exactly, but it's almost definitely in the SPS include.
Gucci
02-20-2012, 08:13 PM
Okay thanks Pat
Gucci
02-20-2012, 08:31 PM
Pat so I set up the Box and everything but I'm getting:
[Error] (135:23): Type mismatch at line 134
Compiling failed.
Failsafe:
procedure FailSafe2 (Reason:String);
var
GoblinArea: TBox;
begin
if not (GoblinArea) then <--- Line 134
BoredHuman;
SPS_WalkToPos(Point(4830, 3700));
end;
This is the Box procedure:
procedure Location;
var
GoblinArea: TBox;
begin
GoblinArea := intToBox(4800, 3662, 4872, 3744);
end;
laakerules
02-20-2012, 09:31 PM
You cant have it in seperate procedures. So you could do something like.
procedure FailSafe2 (Reason:String);
var
GoblinArea: TBox;
begin
GoblinArea := intToBox(4800, 3662, 4872, 3744);
if not (GoblinArea) then <--- Line 134
BoredHuman;
SPS_WalkToPos(Point(4830, 3700));
end;
And next time put in simba tags, but i would recomend doing a distance check from a certain point with sps.
This is one of the dead checkers in my new soulwars script
Function BDead: Variant;
Var
Z:TPoint;
Begin
Z:= SPS_GetMyPos;
if (Distance(Z.X, Z.Y, 489, 5082) < 7) or FindBlackChatMessage('you are dead!') then
Begin
Result := True;
end else if (Not (Distance(P.X, P.Y, 489, 5082) > 5)) or (Not FindBlackChatMessage('you are dead!')) then
Begin
Result := False;
end;
End;
And so for your procedure you could do.
procedure FailSafe2 (Reason:String);
var
Z:TPoint;
begin
Z:= SPS_GetMyPos;
if (Not (Distance(Z.X, Z.Y, 4830, 3700) < 25)) then//Change the 25 to whatever you want your distance checking to be.
Begin
BoredHuman;
SPS_WalkToPos(Point(4830, 3700));
end;
end;
Gucci
02-20-2012, 10:24 PM
Alright thanks
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.