Skip to content

Commit 1903d9c

Browse files
add example script system
1 parent 086715f commit 1903d9c

File tree

12 files changed

+374
-32
lines changed

12 files changed

+374
-32
lines changed

ExampleScripts/ExampleScript.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

ExampleScripts/Scripts/InviteInfoScript.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

Examples/ChaosCoinScript.cs

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
namespace SER.Examples;
2+
3+
public class ChaosCoinScript : IExample
4+
{
5+
public string Name => "chaosCoin";
6+
7+
public string Content =>
8+
"""
9+
!-- OnEvent FlippingCoin
10+
11+
# formats of broadcasts, used to not repeat the same things in different broadcasts
12+
$hintInfo = "<color=#ff5555><size=30><b>"
13+
$baseText = "<size=20><b><color=green>the holy coin has been used<br><size=35></color>"
14+
$afterText = "<color=white><size=25><b>"
15+
16+
# "coin locked" is a property of this player, storing whether a coin can be used.
17+
# this is because some effects of the coin take time, and we DO NOT want to
18+
# have the coin be used again WHILE a different effect is still ongoing
19+
if {PlayerDataExists @evPlayer "coin locked"}
20+
if {GetPlayerData @evPlayer "coin locked"}
21+
Hint @evPlayer 5s "{$hintInfo}You can't use the coin for now!<br><size=20>Come back when the current effect has finished."
22+
IsAllowed false
23+
stop
24+
end
25+
end
26+
27+
# 50% chance to lose the coin
28+
if {RandomNum 1 2 int} == 1
29+
Hint @evPlayer 3s "{$hintInfo}Your coin has turned into dust..."
30+
AdvDestroyItem {@evPlayer heldItemRef}
31+
end
32+
33+
# select a random effect of the coin, from 9 available
34+
$effect = RandomNum 9 9 int
35+
36+
# russian rulette with a full gun :trollface:
37+
if $effect == 1
38+
GiveItem @evPlayer GunRevolver
39+
Broadcast @evPlayer 5s "{$baseText}Let's play russian rulette!"
40+
stop
41+
end
42+
43+
# HP change
44+
if $effect == 2
45+
$newHP = RandomNum 1 150 int
46+
SetHealth @evPlayer $newHP
47+
SetMaxHealth @evPlayer $newHP
48+
49+
Broadcast @evPlayer 5s "{$baseText}You now have {$newHP} HP!"
50+
stop
51+
end
52+
53+
# rave
54+
if $effect == 3
55+
*room = {@evPlayer roomRef}
56+
57+
# explode player if he isnt in a room
58+
if not {ValidRef *room}
59+
Explode @evPlayer
60+
stop
61+
end
62+
63+
# we are blocking the use of the coin for the player
64+
# until the rave is over
65+
SetPlayerData @evPlayer "coin locked" true
66+
67+
Broadcast @evPlayer 5s "{$baseText}Time for a rave!"
68+
69+
CloseDoor *room
70+
LockDoor *room AdminCommand
71+
SetLightColor *room #000000
72+
73+
repeat 5
74+
TransitionLightColor *room #ff0000ff .5s
75+
Wait .5s
76+
TransitionLightColor *room #00ff00ff .5s
77+
Wait .5s
78+
TransitionLightColor *room #0000ffff .5s
79+
Wait .5s
80+
end
81+
82+
Wait .1s
83+
UnlockDoor *room
84+
ResetLightColor *room
85+
86+
SetPlayerData @evPlayer "coin locked" false
87+
stop
88+
end
89+
90+
# bomb
91+
if $effect == 4
92+
SetPlayerData @evPlayer "coin locked" true
93+
$initRole = {@evPlayer role}
94+
95+
Countdown @evPlayer 15s "{$baseText}<color=red>You have %seconds% seconds left to live!"
96+
97+
# waiting 15 seconds here
98+
repeat 15
99+
Wait 1s
100+
101+
# every second we are checking if the role of the player changed
102+
# if so, we remove the countdown and unlock the coin
103+
if {@evPlayer role} != $initRole
104+
ClearCountdown @evPlayer
105+
SetPlayerData @evPlayer "coin locked" false
106+
stop
107+
end
108+
end
109+
110+
Explode @evPlayer
111+
SetPlayerData @evPlayer "coin locked" false
112+
stop
113+
end
114+
115+
# bypass
116+
if $effect == 5
117+
$initRole = {@evPlayer role}
118+
SetPlayerData @evPlayer "coin locked" true
119+
120+
Countdown @evPlayer 15s "{$baseText}You can now open any keycard locked thing! (for %seconds% seconds)"
121+
Bypass @evPlayer true
122+
123+
repeat 15
124+
Wait 1s
125+
126+
if {@evPlayer role} != $initRole
127+
ClearCountdown @evPlayer
128+
break
129+
end
130+
end
131+
132+
Bypass @evPlayer false
133+
SetPlayerData @evPlayer "coin locked" false
134+
stop
135+
end
136+
137+
# role downgrade
138+
if $effect == 6
139+
if {@evPlayer role} != "ClassD"
140+
SetRole @evPlayer ClassD None
141+
elif {@evPlayer role} != "Scp0492"
142+
SetRole @evPlayer Scp0492
143+
else
144+
SetRole @evPlayer Spectator
145+
end
146+
147+
Broadcast @evPlayer 5s "{$baseText}Your role got downgraded!"
148+
stop
149+
end
150+
151+
# funny cassie
152+
if $effect == 7
153+
SetPlayerData @evPlayer "coin locked" true
154+
155+
Cassie noJingle "pitch_0.7 warning . pitch_3 XMAS_JINGLEBELLS" ""
156+
Broadcast @evPlayer 5s "{$baseText}Most useful cassie message sent!"
157+
158+
Wait 7s
159+
SetPlayerData @evPlayer "coin locked" false
160+
stop
161+
end
162+
163+
# change size
164+
if $effect == 8
165+
# set player size in every direction to a random number between 10% and 100%
166+
SetSize @evPlayer {RandomNum 0.1 1} {RandomNum 0.1 1} {RandomNum 0.1 1}
167+
168+
Broadcast @evPlayer 5s "{$baseText}Your size has changed a little!"
169+
stop
170+
end
171+
172+
# swap places
173+
if $effect == 9
174+
# cant swap places if there arent at least 2 players
175+
if {AmountOf @alivePlayers} < 2
176+
Explode @evPlayer
177+
stop
178+
end
179+
180+
# gets a random player that is not @evPlayer
181+
@swapPlayer = LimitPlayers {RemovePlayers * @evPlayer} 1
182+
$swapX = {@swapPlayer positionX}
183+
$swapY = {@swapPlayer positionY}
184+
$swapZ = {@swapPlayer positionZ}
185+
186+
# we can teleport @swapPlayer directly to @evPlayer
187+
TPPlayer @swapPlayer @evPlayer
188+
Broadcast @swapPlayer 5s "{$baseText}You have swapped places with {@evPlayer name}"
189+
190+
# because @swapPlayer is in the same place as @evPlayer, we need to use the saved values to teleport
191+
TPPosition @evPlayer $swapX $swapY $swapZ
192+
Broadcast @evPlayer 5s "{$baseText}You have swapped places with {@swapPlayer name}"
193+
stop
194+
end
195+
""";
196+
}

Examples/DoorRestartScript.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace SER.Examples;
2+
3+
public class DoorRestartScript : IExample
4+
{
5+
public string Name => "doorRestart";
6+
7+
public string Content =>
8+
"""
9+
# initial cassie announcement
10+
Cassie jingle "ATTENTIONALLPERSONNEL . DOOR CONTROL CONSOLE MALFUNCTION DETECTED . INITIALIZING REACTIVATION SEQUENCE . ATTEMPTING FULL SYSTEM REACTIVATION IN . 3 . 2 . 1" "Attention all personnel. Door control console malfunction detected.<split>Initializing reactivation sequence. Attempting full system reactivation in..."
11+
12+
# wait for cassie to finish before restarting doors
13+
Wait 1s
14+
WaitUntil ({IsCassieSpeaking} == false)
15+
16+
# restart effects
17+
LightsOut * 15s
18+
CloseDoor *
19+
LockDoor * NoPower
20+
21+
# cassie for spooky effect
22+
repeat 2
23+
Cassie noJingle "pitch_{RandomNum 0.15 0.25} .g{RandomNum 1 6 int}"
24+
end
25+
26+
# duration of the restart
27+
Wait 15s
28+
29+
# revert to unlocked
30+
UnlockDoor *
31+
32+
# cassie information that restart was successful
33+
ClearCassie
34+
Cassie jingle "DOOR CONTROL CONSOLE SUCCESSFULLY ACTIVATED . SYSTEM IS BACK IN OPERATIONAL MODE" "Door control console successfully activated.<split>System is back in operational mode."
35+
""";
36+
}

Examples/IExample.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace SER.Examples;
2+
3+
public interface IExample
4+
{
5+
public string Name { get; }
6+
public string Content { get; }
7+
}

Examples/RaveScript.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace SER.Examples;
2+
3+
public class RaveScript : IExample
4+
{
5+
public string Name => "rave";
6+
7+
public string Content =>
8+
"""
9+
# confirm that @sender variable was created
10+
if {VarExists @sender} == false
11+
Reply "you need to run this script through remote admin!"
12+
stop
13+
end
14+
15+
# the values for the rave
16+
$duration = .5s
17+
*room = {@sender roomRef}
18+
19+
# changing colors for the room
20+
repeat 20
21+
TransitionLightColor *room #ff0000ff $duration
22+
Wait $duration
23+
24+
TransitionLightColor *room #00ff00ff $duration
25+
Wait $duration
26+
27+
TransitionLightColor *room #0000ffff $duration
28+
Wait $duration
29+
end
30+
31+
# reset color to default
32+
Wait 1ms
33+
ResetLightColor *room
34+
""";
35+
}

Examples/ScanScript.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace SER.Examples;
2+
3+
public class ScanScript : IExample
4+
{
5+
public string Name => "scan";
6+
7+
public string Content =>
8+
"""
9+
# scan beginning announcement
10+
Cassie jingle "a facility scan is commencing" "A facility scan is commencing..."
11+
12+
Wait 1s
13+
WaitUntil (not {IsCassieSpeaking})
14+
15+
repeat 3
16+
Wait 10s
17+
18+
# scan sound
19+
Cassie noJingle "pitch_0.3 .G1 .G4" ""
20+
end
21+
22+
# wait until cassie finishes
23+
Wait 10s
24+
25+
# results
26+
$cassie = "scan complete . {AmountOf @scpPlayers} scpsubjects remaining . {AmountOf @classDPlayers} class d personnel remaining . {AmountOf @scientistPlayers} scientist personnel remaining . {AmountOf @foundationForcePlayers} foundation forces remaining . {AmountOf @chaosInsurgencyPlayers} hostileforces remaining . . . . ."
27+
$translation = "<br><size=30><color=red>[{AmountOf @scpPlayers}] SCP subjects</color><br><color=#FF8E00>[{AmountOf @classDPlayers}] Class-D personnel</color><br><color=#FFFF7C>[{AmountOf @scientistPlayers}] Scientist personnel</color><br><color=#70C3FF>[{AmountOf @foundationForcePlayers}] Foundation forces</color><br><color=#15853D>[{AmountOf @chaosInsurgencyPlayers}] Hostile forces</color>"
28+
Cassie jingle $cassie $translation
29+
""";
30+
}

Examples/WelcomeScript.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace SER.Examples;
2+
3+
public class WelcomeScript : IExample
4+
{
5+
public string Name => "welcome";
6+
7+
public string Content =>
8+
"""
9+
# this script is connected to the 'Joined' event, which means that this script will run when a player joins
10+
# this event provides us with the @evPlayer variable with the player who just joined
11+
!-- OnEvent Joined
12+
13+
# this 'Broadcast' method sends a formatted message to the player who just joined
14+
Broadcast @evPlayer 10s "<b><color=#8dfcef><size=35>Welcome {@evPlayer name}!</size></color>\n<color=#ebebb9><size=20>This server is using <u>Scripted Events Reloaded</u>, enjoy your stay!</size></color></b>"
15+
16+
# information for the server owner to visit the scripts folder
17+
Hint @evPlayer 10s "<line-height=1000%><br></line-height><b><size=30>This is the default message.<br>You can modify it - as well as any other example script - by going to the SER folder in plugin configs."
18+
""";
19+
}

Helpers/Log.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public static void Error(string scrName, string msg)
3535
Logger.Raw($"[Script '{scrName}'] {msg}", ConsoleColor.Red);
3636
}
3737

38-
public static void Assert(bool condition, string msg)
39-
{
40-
if (!condition) throw new AndrzejFuckedUpException(msg);
41-
}
42-
4338
public static void D(string msg)
4439
{
4540
#if DEBUG

0 commit comments

Comments
 (0)