-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKFBotUseTrigger.uc
52 lines (48 loc) · 3.15 KB
/
KFBotUseTrigger.uc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//=============================================================================
// KFBotUseTrigger: To make it possible to order bots.
//=============================================================================
class KFBotUseTrigger extends UseTrigger;
var KFInvBots Controller;
var transient float ReuseTimer,NextMessageTimer;
function PostBeginPlay()
{
Controller = KFInvBots(Owner);
SetTimer(1+FRand()*0.5,true);
}
function Timer()
{
if( Controller.Pawn!=None && Base!=Controller.Pawn )
{
SetLocation(Controller.Pawn.Location);
SetBase(Controller.Pawn);
}
}
function UsedBy(Pawn user)
{
if( ReuseTimer<Level.TimeSeconds && KFPawn(user)!=None && user.Health>0 && user.IsHumanControlled() && CanUse(user) )
{
Controller.OrderBot(user.Controller);
ReuseTimer = Level.TimeSeconds+0.2;
}
}
function Touch( Actor Other )
{
if( NextMessageTimer<Level.TimeSeconds && Controller.Pawn!=None && Controller.Pawn.Health>0 && KFPawn(Other)!=None && KFPawn(Other).Health>0 && KFPawn(Other).IsHumanControlled()
&& CanUse(Pawn(Other)) )
{
Pawn(Other).ClientMessage("Press [Use] to order "$Controller.PlayerReplicationInfo.GetNameCallSign()$" to follow/hold/free.");
NextMessageTimer = Level.TimeSeconds+1.f;
}
}
final function bool CanUse( Pawn Other )
{
local vector HL,HN;
return (Other.Trace(HL,HN,vector(Other.GetViewRotation())*140+Other.Location,Other.Location,true)==Controller.Pawn);
}
defaultproperties
{
bOnlyAffectPawns=True
CollisionRadius=100.000000
CollisionHeight=100.000000
bBlockHitPointTraces=False
}