Skip to content

Instantly share code, notes, and snippets.

@nathan130200
Last active November 4, 2020 19:48
Show Gist options
  • Save nathan130200/83cf06df49a4bf66951a33e9f39d028a to your computer and use it in GitHub Desktop.
Save nathan130200/83cf06df49a4bf66951a33e9f39d028a to your computer and use it in GitHub Desktop.
Workshop dynamic camera system (with editor)
settings
{
lobby
{
Allow Players Who Are In Queue: Yes
Data Center Preference: Brazil
Map Rotation: Paused
Return To Lobby: Never
}
modes
{
Skirmish
{
Respawn Time Scalar: 30%
enabled maps
{
Eichenwalde
}
}
disabled Team Deathmatch
{
Health Pack Respawn Time Scalar: 10%
Respawn Time Scalar: 0%
Spawn Health Packs: Enabled
}
General
{
Hero Limit: Off
}
}
heroes
{
General
{
Pharah
{
Hover Jets Unlimited Fuel: On
}
}
}
}
variables
{
global:
0: Cameras
1: ActivationDistance
2: CurrentCamera
player:
0: Camera
1: CameraResult
2: EnableCamera
}
disabled rule("Initialize global.")
{
event
{
Ongoing - Global;
}
actions
{
Global.Cameras = Array();
Global.ActivationDistance = 5;
}
}
disabled rule("Initialize host hud.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
}
actions
{
Create HUD Text(Event Player, Custom String("Radius: {0}", Global.ActivationDistance), Null, Null, Right, 0, Green, White, White,
Visible To and String, Default Visibility);
Create HUD Text(All Players(All Teams), Custom String("Cameras: {0}", Count Of(Global.Cameras)), Null, Null, Right, 0, Yellow,
White, White, Visible To and String, Default Visibility);
Create Effect(All Players(All Teams), Ring, Purple, Position Of(Event Player), Global.ActivationDistance,
Visible To Position and Radius);
Set Damage Received(Event Player, 0);
Disable Movement Collision With Players(Event Player);
disabled Disable Movement Collision With Environment(Event Player, False);
Disallow Button(Event Player, Primary Fire);
Disallow Button(Event Player, Secondary Fire);
Create HUD Text(All Players(All Teams), Custom String("Press \"{0}\" to toggle custom camera.", Input Binding String(Button(
Melee))), Null, Null, Top, -1, White, White, White, Visible To and String, Default Visibility);
disabled Event Player.EnableCamera = True;
disabled Set Invisible(Event Player, Enemies);
}
}
disabled rule("Create camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Interact) == True;
}
actions
{
If(Is Button Held(Event Player, Crouch));
Global.Cameras = Empty Array;
Else;
Global.Cameras[Count Of(Global.Cameras)] = Array(Eye Position(Event Player), Global.ActivationDistance);
End;
Play Effect(All Players(All Teams), Good Explosion, Orange, Event Player, 3);
Play Effect(All Players(All Teams), Explosion Sound, Orange, Event Player, 35);
}
}
disabled rule("Switch current camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
(Is Button Held(Event Player, Primary Fire) || Is Button Held(Event Player, Secondary Fire)) == True;
}
actions
{
If(Is Button Held(Event Player, Primary Fire));
Global.Cameras += 1;
Else;
Global.Cameras -= 1;
End;
If(Global.CurrentCamera > Count Of(Global.Cameras));
Global.CurrentCamera = 0;
End;
If(Global.CurrentCamera < 0);
Global.CurrentCamera = Count Of(Global.Cameras) - 1;
End;
Wait(0.250, Abort When False);
Loop If Condition Is True;
}
}
disabled rule("(Add) Switch camera activation radius.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Primary Fire) == True;
}
actions
{
Global.ActivationDistance += 0.250;
Wait(0.060, Abort When False);
Loop If Condition Is True;
}
}
disabled rule("(Sub) Switch camera activation radius.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Secondary Fire) == True;
}
actions
{
Global.ActivationDistance -= 0.250;
Wait(0.060, Abort When False);
Loop If Condition Is True;
}
}
disabled rule("Disable bots firing")
{
event
{
Ongoing - Each Player;
Team 1;
All;
}
actions
{
Disallow Button(Event Player, Primary Fire);
Disallow Button(Event Player, Secondary Fire);
Disallow Button(Event Player, Ultimate);
}
}
disabled rule("Destroy last camera")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Jump) == True;
}
actions
{
Modify Global Variable(Cameras, Remove From Array By Index, Count Of(Global.Cameras) - 1);
Play Effect(All Players(All Teams), Good Explosion, Orange, Event Player, 3);
Play Effect(All Players(All Teams), Explosion Sound, Orange, Event Player, 35);
}
}
disabled rule("Stop camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player.CameraResult == Null;
}
actions
{
Wait(1, Abort When False);
Stop Camera(Event Player);
}
}
rule("Find closest camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Alive(Event Player) == True;
}
actions
{
Event Player.CameraResult = First Of(Filtered Array(Global.Cameras, Is In Line of Sight(Event Player, Current Array Element,
Barriers Do Not Block LOS) && Distance Between(Event Player, Current Array Element[0]) <= Current Array Element[1]));
"Verifica se a camera foi encontrada"
If(Event Player.CameraResult != Null);
Event Player.Camera = Event Player.CameraResult;
End;
Wait(0.250, Ignore Condition);
Loop If Condition Is True;
}
}
rule("Start camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player.Camera != Null;
Event Player.EnableCamera == True;
}
actions
{
Start Camera(Event Player, Event Player.Camera[0], Position Of(Event Player), 65);
}
}
rule("Toggle Camera")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
disabled Event Player != Host Player;
Is Button Held(Event Player, Melee) == True;
}
actions
{
Event Player.EnableCamera = !Event Player.EnableCamera;
If(!Event Player.EnableCamera);
Stop Camera(Event Player);
End;
}
}
rule("Map = Eichenwald")
{
event
{
Ongoing - Global;
}
conditions
{
(Current Map == Map(Eichenwalde) || Current Map == Map(Eichenwalde Halloween)) == True;
}
actions
{
Global.Cameras = Array(Array(Vector(-14.209, 6.904, 8.307), 18.500), Array(Vector(-11.876, 8.986, -12.478), 14.750), Array(Vector(
6.627, 10.788, -24.866), 14.750), Array(Vector(-31.013, 4.928, -20.222), 14.750), Array(Vector(-25.038, 10.583, -35.473),
14.750), Array(Vector(14.406, 11.757, -45.739), 14.750), Array(Vector(12.499, 8.567, -34.774), 14.750), Array(Vector(5.746,
13.814, -62.557), 14.750), Array(Vector(19.922, 7.350, -79.930), 14.750), Array(Vector(25.545, 12.556, -62.386), 14.750),
Array(Vector(33.510, 14.884, -50.004), 14.750), Array(Vector(39.920, 11.839, -58.917), 16.250), Array(Vector(54.517, 16.921,
-93.393), 16.250), Array(Vector(82.852, 19.957, -86.097), 16.250), Array(Vector(49.025, 23.578, -96.653), 16.250), Array(
Vector(48.299, 17.623, -107.209), 4.500), Array(Vector(57.355, 20.065, -111.409), 11.500), Array(Vector(57.677, 8.787,
-108.004), 11.500), Array(Vector(57.332, 9.558, -91.630), 8), Array(Vector(60.099, 8.510, -73.113), 8), Array(Vector(72.644,
15.899, -108.699), 12.500), Array(Vector(55.008, 8.044, -101.620), 3.750), Array(Vector(70.867, 12.728, -81.903), 7.250),
Array(Vector(-1.896, 7.350, 2.029), 7.500), Array(Vector(26.604, 9.728, -13.974), 7.500), Array(Vector(5.618, 12.354, -4.456),
7.500), Array(Vector(29.356, 2.372, -10.433), 7.500), Array(Vector(26.647, 5.318, -28.963), 7.500), Array(Vector(27.107, 7.612,
-43.406), 7.500), Array(Vector(27.261, 8.389, -70.680), 7.500), Array(Vector(66.044, 11.982, -86.992), 7.500), Array(Vector(
-22.342, 3.246, -1.105), 2.500), Array(Vector(-27.104, 1.552, -4.353), 2.500), Array(Vector(-18.543, 12.190, -30.307), 6.500),
Array(Vector(56.162, 22.723, -83.040), 6.500), Array(Vector(64.622, 14.553, -77.258), 3.500), Array(Vector(62.842, 11.673,
-69.085), 3.500), Array(Vector(68.981, 6.082, -82.142), 6.750), Array(Vector(74.521, 14.010, -71.120), 6.750), Array(Vector(
56.979, 18.474, -55.622), 6.750), Array(Vector(56.521, 13.073, -67.219), 4.250), Array(Vector(83.735, 18.840, -65.828), 4.250),
Array(Vector(102.383, 18.902, -80.108), 13), Array(Vector(37.915, 7.794, -75.478), 2.750), Array(Vector(33.155, 8.814,
-78.818), 2.750), Array(Vector(24.178, 11.223, -88.078), 2.750), Array(Vector(15.353, 12.362, -88.977), 2.750), Array(Vector(
17.872, 8.047, -91.891), 2.750), Array(Vector(5.861, 6.350, -96.228), 2.750), Array(Vector(-3.051, 4.968, -86.604), 2.750),
Array(Vector(-9.034, 4.604, -76.089), 2.750), Array(Vector(-9.919, 4.350, -64.955), 2.750), Array(Vector(-7.054, 6.502,
-52.660), 8.500), Array(Vector(-1.684, 8.446, -46.023), 3), Array(Vector(1.010, 7.350, -46.249), 3), Array(Vector(5.517,
11.350, -39.468), 3), Array(Vector(67.872, 27.231, -70.481), 19.750), Array(Vector(78.103, 14.073, -57.749), 6.750), Array(
Vector(76.092, 19.148, -48.881), 6.750), Array(Vector(85.702, 18.076, -49.614), 17), Array(Vector(106.979, 16.403, -41.278),
20.500), Array(Vector(121.738, 20.372, -33.057), 20.500), Array(Vector(107.307, 14.639, -21.886), 7.250), Array(Vector(94.283,
19.481, -23.117), 14), Array(Vector(89.108, 19.168, -18.956), 14), Array(Vector(80.770, 19.185, -40.228), 14), Array(Vector(
31.766, 21.346, -84.673), 14), Array(Vector(34.408, 7.856, -55.646), 6.500), Array(Vector(13.523, 8.690, -56.448), 4));
disabled Global.ActivationDistance = 4;
}
}
variables
{
global:
0: Cameras
1: ActivationDistance
2: CurrentCamera
player:
0: Camera
1: CameraResult
2: EnableCamera
}
rule("Initialize global.")
{
event
{
Ongoing - Global;
}
actions
{
Global.Cameras = Array();
Global.ActivationDistance = 5;
}
}
rule("Initialize host hud.")
{
event
{
Player Joined Match;
All;
All;
}
conditions
{
Event Player == Host Player;
}
actions
{
Create HUD Text(Event Player, Custom String("Radius: {0}", Global.ActivationDistance), Null, Null, Right, 0, Green, White, White,
Visible To and String, Default Visibility);
Create HUD Text(Event Player, Custom String("Cameras: {0}", Count Of(Global.Cameras)), Null, Null, Right, 0, Yellow, White, White,
Visible To and String, Default Visibility);
Create Effect(All Players(All Teams), Sparkles, Purple, Position Of(Event Player), Global.ActivationDistance,
Visible To Position and Radius);
Set Damage Received(Event Player, 0);
Disable Movement Collision With Players(Event Player);
disabled Disable Movement Collision With Environment(Event Player, False);
Disallow Button(Event Player, Primary Fire);
Disallow Button(Event Player, Secondary Fire);
Create HUD Text(All Players(All Teams), Custom String("Press \"Interact\" to toggle custom camera."), Null, Null, Top, -1, White,
White, White, Visible To and String, Default Visibility);
Event Player.EnableCamera = True;
}
}
rule("Create camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Interact) == True;
}
actions
{
If(Is Button Held(Event Player, Crouch));
Global.Cameras = Empty Array;
Else;
Global.Cameras[Count Of(Global.Cameras)] = Array(Eye Position(Event Player), Global.ActivationDistance);
End;
Play Effect(All Players(All Teams), Good Explosion, Orange, Event Player, 3);
Play Effect(All Players(All Teams), Explosion Sound, Orange, Event Player, 35);
}
}
disabled rule("Switch current camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
(Is Button Held(Event Player, Primary Fire) || Is Button Held(Event Player, Secondary Fire)) == True;
}
actions
{
If(Is Button Held(Event Player, Primary Fire));
Global.Cameras += 1;
Else;
Global.Cameras -= 1;
End;
If(Global.CurrentCamera > Count Of(Global.Cameras));
Global.CurrentCamera = 0;
End;
If(Global.CurrentCamera < 0);
Global.CurrentCamera = Count Of(Global.Cameras) - 1;
End;
Wait(0.250, Abort When False);
Loop If Condition Is True;
}
}
rule("(Add) Switch camera activation radius.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Primary Fire) == True;
}
actions
{
Global.ActivationDistance += 0.250;
Wait(0.060, Abort When False);
Loop If Condition Is True;
}
}
rule("(Sub) Switch camera activation radius.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player == Host Player;
Is Button Held(Event Player, Secondary Fire) == True;
}
actions
{
Global.ActivationDistance -= 0.250;
Wait(0.060, Abort When False);
Loop If Condition Is True;
}
}
rule("Find closest camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Alive(Event Player) == True;
}
actions
{
Event Player.CameraResult = First Of(Filtered Array(Global.Cameras, Is In Line of Sight(Event Player, Current Array Element,
Barriers Do Not Block LOS) && Distance Between(Event Player, Current Array Element[0]) <= Current Array Element[1]));
"Verifica se a camera foi encontrada"
If(Event Player.CameraResult != Null);
Event Player.Camera = Event Player.CameraResult;
End;
Wait(0.250, Ignore Condition);
Loop If Condition Is True;
}
}
rule("Start camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player.Camera != Null;
Event Player.EnableCamera == True;
}
actions
{
Start Camera(Event Player, Event Player.Camera[0], Position Of(Event Player), 65);
}
}
disabled rule("Stop camera.")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player.CameraResult == Null;
}
actions
{
Wait(1, Abort When False);
Stop Camera(Event Player);
}
}
rule("(Not Host)")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Event Player != Host Player;
Is Button Held(Event Player, Interact) == True;
}
actions
{
Event Player.EnableCamera = !Event Player.EnableCamera;
If(!Event Player.EnableCamera);
Stop Camera(Event Player);
End;
}
}
rule("Rule 11")
{
event
{
Ongoing - Each Player;
Team 2;
All;
}
actions
{
Disallow Button(Event Player, Primary Fire);
Disallow Button(Event Player, Secondary Fire);
Disallow Button(Event Player, Ultimate);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment