-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexplode_detonator_device.verse
91 lines (69 loc) · 2.81 KB
/
explode_detonator_device.verse
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
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/Diagnostics }
using {/UnrealEngine.com/Temporary/SpatialMath}
# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.
# A Verse-authored creative device that can be placed in a level
explode_detonator_device := class(creative_device):
@editable
Car : vehicle_spawner_nitro_drifter_sedan_device = vehicle_spawner_nitro_drifter_sedan_device{}
@editable
Bomb :explosive_device = explosive_device{}
@editable
BeaconProp : creative_prop = creative_prop{}
@editable
TimerSwitch : switch_device = switch_device{}
@editable
PowerUp : collectible_object_device = collectible_object_device{}
@editable
EliminationSound : audio_player_device = audio_player_device{}
var CurrentPosition : vector3 = vector3{}
var isAlive : logic = true
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Car.AgentEntersVehicleEvent.Subscribe(OnUpdateListener)
PowerUp.CollectedEvent.Subscribe(OnGetPowerUp)
#Car.AgentExitsVehicleEvent.Subscribe(OnDeathListener)
OnGetPowerUp(Agent : agent):void=
Print("Power Up!")
OnDeathListener(Agent : agent):void=
Print("Morido")
set isAlive = false
if(FortChar := Agent.GetFortCharacter[]){
Print("{CurrentPosition}")
if(BeaconProp.TeleportTo[CurrentPosition, rotation{}]){}
spawn:
ExplodeBomb(Agent)
}
EliminatePLayer(Result:elimination_result): void=
#Print("eliminate player")
#Print("Morido2")
set isAlive = false
EliminatedCharacter := Result.EliminatedCharacter
if(EliminatedAgent := EliminatedCharacter.GetAgent[]){
#Print("{CurrentPosition}")
if(BeaconProp.TeleportTo[CurrentPosition, rotation{}]){}
spawn:
ExplodeBomb(EliminatedAgent)
}
OnUpdateListener(Agent : agent): void=
if(FortChar : fort_character = Agent.GetFortCharacter[]){
spawn:
UpdatePosition(FortChar)
}
UpdatePosition(FortChar : fort_character)<suspends>:void=
loop:
if(isAlive = false){
break
}else{
FortChar.EliminatedEvent().Subscribe(EliminatePLayer)
Sleep(0.2)
set CurrentPosition = FortChar.GetTransform().Translation
#Print("new pos: {CurrentPosition}")
}
ExplodeBomb(Agent : agent)<suspends>:void=
#Sleep(10.0)
EliminationSound.Play()
Bomb.Explode(Agent)