-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.cs
More file actions
61 lines (48 loc) · 1.52 KB
/
trigger.cs
File metadata and controls
61 lines (48 loc) · 1.52 KB
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
datablock TriggerData(BotToggleTriggerData)
{
tickPeriodMS = 1000;
};
//i would use these but onremove is overwritten/broken ?
//function BotToggleTriggerData::onRemove(%this, %trigger) { return parent::onRemove(%this, %trigger); }
//function BotToggleTriggerData::onAdd(%this, %trigger) { return parent::onAdd(%this, %trigger); }
function BotToggleTriggerData::onTickTrigger(%this,%trigger,%obj) {}
function BotToggleTriggerData::onEnterTrigger(%this, %trigger, %obj)
{
%client = %obj.client;
if(!isObject(%client) || %client.getClassName() !$= "GameConnection")
return;
%index = %trigger.zoneIndex;
if($BTZ::ZoneObj[%index] != %trigger)
return talk(bad SPC %trigger);
%set = $BTZ::ZoneSet[%index];
%count = %set.getCount();
for(%i = 0; %i < %count; %i++)
{
%obj = %set.getObject(%i);
if(isObject(%obj.hBot))
%obj.hBot.scopeToClient(%client);
}
%trigger.occupants.add(%client);
if($BTZ::Debug)
%client.bottomprint("enter" SPC %index, 3);
}
function BotToggleTriggerData::onLeaveTrigger(%this, %trigger, %obj)
{
%client = %obj.client;
if(!isObject(%client) || %client.getClassName() !$= "GameConnection")
return;
%index = %trigger.zoneIndex;
if($BTZ::ZoneObj[%index] != %trigger)
return talk(bad SPC %trigger);
%set = $BTZ::ZoneSet[%index];
%count = %set.getCount();
for(%i = 0; %i < %count; %i++)
{
%obj = %set.getObject(%i);
if(isObject(%obj.hBot))
%obj.hBot.clearScopeToClient(%client);
}
%trigger.occupants.remove(%client);
if($BTZ::Debug)
%client.bottomprint("leave" SPC %index, 3);
}