@@ -23,6 +23,8 @@ ship_model <- "models/marioragdoll/super mario galaxy/bj ship/bjship.mdl"
2323red_ship <- null
2424blue_ship <- null
2525
26+ ships <- []
27+
2628function OnPrecache ()
2729{
2830 PrecacheModel (ship_model)
@@ -32,32 +34,56 @@ function OnStart()
3234{
3335 Ware_SetGlobalLoadout (TF_CLASS_DEMOMAN, " Stickybomb Jumper" )
3436
37+ local mission = RandomInt (0 ,1 )
3538 foreach (player in Ware_MinigamePlayers)
3639 {
37- local team = player. GetTeam ()
38- if (team == TF_TEAM_RED)
39- Ware_SetPlayerMission (player, 0 )
40- else if (team == TF_TEAM_BLUE)
41- Ware_SetPlayerMission (player, 1 )
40+ Ware_SetPlayerMission (player, mission)
4241 }
43-
44- local swap = RandomBool ()
42+
43+ local x_off = 100
44+
4545 red_ship = Ware_SpawnEntity (" prop_dynamic_override" ,
4646 {
47- origin = Ware_MinigameLocation. center + Vector (2200 , swap ? - 500 : 300 , - 136 ),
47+ origin = Ware_MinigameLocation. center + Vector (2200 + (mission == 0 ? x_off : 0 ), RandomFloat ( - 300 , 300 ) , - 136 ),
4848 model = ship_model
4949 rendercolor = " 255 0 0" ,
5050 })
5151 blue_ship = Ware_SpawnEntity (" prop_dynamic_override" ,
5252 {
53- origin = Ware_MinigameLocation. center + Vector (2200 , swap ? 300 : - 500 , - 136 ),
53+ origin = Ware_MinigameLocation. center + Vector (2200 + (mission == 1 ? x_off : 0 ), RandomFloat ( - 300 , 300 ) , - 136 ),
5454 model = ship_model
5555 rendercolor = " 0 255 255" ,
5656 })
57+
58+ ships <- [red_ship, blue_ship]
59+ foreach (ship in ships)
60+ {
61+ ship. ValidateScriptScope ()
62+ local scope = ship. GetScriptScope ()
63+
64+ scope. speed <- RandomFloat(- 20 , 20 )
65+ if (abs (scope. speed ) < 5 ) scope. speed = RandomBool () ? 10 : - 10
66+ scope. start_y <- ship.GetOrigin(). y
67+ }
68+
5769}
5870
5971function OnUpdate ()
6072{
73+
74+ foreach (ship in ships)
75+ {
76+ local scope = ship. GetScriptScope ()
77+ local origin = ship. GetOrigin ()
78+
79+ if (origin. y > scope. start_y )
80+ scope. speed -= 0.2
81+ else
82+ scope. speed += 0.2
83+
84+ ship. KeyValueFromVector (" origin" , origin + Vector (0 , scope. speed , 0 ))
85+ }
86+
6187 local offset = Vector (0 , 0 , 300 )
6288 local red_point = red_ship. GetOrigin () + offset
6389 local blue_point = blue_ship. GetOrigin () + offset
@@ -75,8 +101,8 @@ function OnUpdate()
75101
76102 local target = player // squirrel needs this to be happy
77103 local origin = player. GetOrigin ()
78- local team = player . GetTeam ( )
79- if (team == TF_TEAM_RED )
104+ local mission = Ware_GetPlayerMission (player )
105+ if (mission == 0 )
80106 {
81107 if (origin. z > red_point. z && VectorDistance2D (origin, red_point) < 150.0 )
82108 {
@@ -95,7 +121,7 @@ function OnUpdate()
95121 Ware_ChatPrint (player, " You pirated the wrong ship!" )
96122 }
97123 }
98- else if (team == TF_TEAM_BLUE )
124+ else if (mission == 1 )
99125 {
100126 if (origin. z > blue_point. z && VectorDistance2D (origin, blue_point) < 150.0 )
101127 {
0 commit comments