-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEtmanVehicleAiController.uc
91 lines (70 loc) · 2.32 KB
/
EtmanVehicleAiController.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class EtmanVehicleAiController extends AIController;
const NODES_DISTANCE=1700; // approximate distance between every node and the nearst ones to it
const HIDE_TIME= 90; // in seconds
var array<EtmanPathNode_Traffic> trafficNodes;
var EtmanPathNode_Traffic node;
var EtmanPathNode_Traffic lastVisitedNode;
var EtmanPathNode_TrafficLight trafficNode;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
`Log("########__ Controller for vehicle is Here __########");
}
event Possess(Pawn aPawn , bool bVehicleTransition)
{
Super.Possess(aPawn , bVehicleTransition);
//Pawn.SetMovementPhysics();
`Log("########__ Pawn in Vehicle AI controller -> "@ Pawn @" __########");
}
auto state GettingReady
{
Begin :
Sleep(1);
//`log("#####__ Map Info: "@ MapInfo@" ^^ __#####");
`log("#####__ Now I'm ready to rock and roll ^^ __#####");
GotoState('Wandering');
}
state Wandering
{
Begin:
sleep(0.4);
trafficNodes.Length = 0;
foreach VisibleActors(class'EtmanPathNode_Traffic' , node , NODES_DISTANCE , Pawn.Location )
{
if(!node.Hidden )
{
`Log("########__ Taken Node -> "@ node @" __########");
trafficNodes.AddItem(node);
}
}
foreach VisibleActors(class'EtmanPathNode_TrafficLight' , trafficNode , NODES_DISTANCE , Pawn.Location )
{
if(!node.Hidden )
{
`Log("########__ Taken Node -> "@ trafficNode @" __########");
trafficNodes.AddItem(trafficNode);
}
}
if (TrafficNodes.Length != 0)
{
node = TrafficNodes[Rand(trafficNodes.Length)];
`Log("########__ Moving to -> "@ node @" , Location"@ node.Location@" __########");
MoveTo(node.Location , node);
if(EtmanPathnode_TrafficLight(node) != none)
{
WorldInfo.Game.Broadcast(self, "we have an EtmanTrafficLight here!");
CheckAgain:
Sleep(0.4);
if(EtmanPathnode_TrafficLight(node).currentLight == red ){
WorldInfo.Game.Broadcast(self, "CheckingAgain");
GoTo('CheckAgain');
}
}
node.Hide(HIDE_TIME);
WorldInfo.Game.Broadcast(self, "Finding new path");
}
GoTo('Begin');
}
defaultProperties
{
}