aboutsummaryrefslogtreecommitdiff
path: root/bobthebob.testing/scripts/vscripts/_bobtestingfunctions_mp.gnut
blob: b782243a4d63afefbfdb3ee1c96f553c4570fb40 (plain)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
untyped
globalize_all_functions

void function SvTestingMPInit()
{
	Bleedout_Init()
	AddCallback_EntitiesDidLoad( CreateSpawns )
}

void function CreateSpawns()
{
	//thread CreateSpawns_Threaded()
}

void function CreateSpawns_Threaded()
{
	WaitEndFrame() // wait for spawns to get cleared, game ctds if we don't do this
	entity validSpawn = GetEntArrayByClass_Expensive( "info_spawnpoint_human" )[ 0 ]

	for ( int i = 0; i < 50; i++ )
	{
		entity newSpawn = CreateEntity( "info_spawnpoint_human" )
		newSpawn.SetOrigin( validSpawn.GetOrigin() )
		DispatchSpawn( newSpawn )
	}
}

void function TestSpawnpoints( bool titan = false )
{
	entity player = GetPlayerArray()[0]
	array<entity> spawnpoints
	if ( !titan )
		spawnpoints = SpawnPoints_GetPilotStart( player.GetTeam() )
	else
		spawnpoints = SpawnPoints_GetTitanStart( player.GetTeam() )
	
	SpawnPoints_InitRatings( player, player.GetTeam() )
	
	foreach ( entity spawnpoint in spawnpoints )
		spawnpoint.CalculateRating( titan ? TD_TITAN : TD_PILOT, player.GetTeam(), RandomFloat( 7.0 ) - 3.5, RandomFloat( 7.0 ) - 3.5 )
		
	if ( !titan )
	{
		SpawnPoints_SortPilotStart()
		spawnpoints = SpawnPoints_GetPilotStart( player.GetTeam() )
	}
	else
	{
		SpawnPoints_SortTitanStart()
		spawnpoints = SpawnPoints_GetTitanStart( player.GetTeam() )
	}
		
	entity chosenPoint
	foreach ( entity spawnpoint in spawnpoints )
		if ( IsSpawnpointValid( spawnpoint, player.GetTeam() ) )
		{
			chosenPoint = spawnpoint
			break
		}
	
	player.SetOrigin( chosenPoint.GetOrigin() )
	player.SetAngles( chosenPoint.GetAngles() )
	
	//SpawnPoints_DiscardRatings() // somehow the game seems to call this automatically so unneeded
}

bool function IsSpawnpointValid( entity spawnpoint, int team )
{
	if ( GameModeRemove( spawnpoint ) )
		return false

	// ultra temp
	print( spawnpoint.GetTeam() )
	if ( spawnpoint.GetTeam() == 0 )
		return false
	
	if ( spawnpoint.GetTeam() > 0 && spawnpoint.GetTeam() != team )
		return false

	
		
	return true
}

void function TestScoreEvent( entity player, int id )
{
	ScoreEvent event = ScoreEvent_FromId( id )
	
	Remote_CallFunction_NonReplay( player, "ServerCallback_ScoreEvent", id, event.pointValue, event.displayType, player.GetEncodedEHandle(), event.earnMeterOwnValue, event.earnMeterEarnValue )
}

void function TestDrop( entity player )
{
	thread CreateTitanForPlayerAndHotdrop( player, GetTitanReplacementPoint( player, false ) )
}

void function WarpThroughSpawnpoints( string modeOverride = "" ) 
{
	if ( !modeOverride.len() )
		modeOverride = GAMETYPE

	entity player = GetPlayerArray()[0]

	array<entity> spawnpoints = GetEntArrayByClass_Expensive( "info_hardpoint" ) //SpawnPoints_GetPilot()
	foreach ( entity spawnpoint in spawnpoints )
	{
		//string gamemodeKey = "gamemode_" + modeOverride
		//if ( spawnpoint.HasKey( gamemodeKey ) && ( spawnpoint.kv[ gamemodeKey ] == "0" || spawnpoint.kv[ gamemodeKey ] == "" ) )
		//	continue
		//	
		//if ( !spawnpoint.HasKey( gamemodeKey ) )
		//	continue
		
		if ( spawnpoint.HasKey( "hardpointGroup" ) )
			print( spawnpoint.kv.hardpointGroup )
			
		player.SetOrigin( spawnpoint.GetOrigin() )
		player.SetAngles( spawnpoint.GetAngles() ) 
		
		wait 0.5
	}
}

void function AttemptSpawnBuddyTitan()
{
	PrecacheModel( $"models/titans/buddy/titan_buddy.mdl" )
	PrecacheModel( $"models/weapons/arms/buddypov.mdl" )
	
	entity player = GetPlayerArray()[0]
	entity titan = CreateNPCTitan( "titan_buddy", player.GetTeam(), player.GetOrigin(), <0, 0, 0> )
	SetSpawnOption_AISettings( titan, "npc_titan_buddy" )
	SetSpawnOption_Weapon( titan, "mp_titanweapon_xo16_vanguard", [ ] )
	
	DispatchSpawn( titan )
	
	player.SetPetTitan( titan )
	titan.SetOwner( player )
	titan.SetUsable()
}


void function SetPlayerCameraToHead()
{
	entity viewControl = CreateEntity( "point_viewcontrol" )
	viewControl.kv.spawnflags = 56
	DispatchSpawn( viewControl )
	
	viewControl.SetParent( GetPlayerArray()[0], "headshot" )
	viewControl.SetOrigin( < 4, 0, 1 > )
	viewControl.SetAngles( < 0, 0, 0 > )
	GetPlayerArray()[0].SetViewEntity( viewControl, true )
}

void function CreateTestControlPanel()
{
	entity player = GetPlayerArray()[0]
	
	entity panel = CreateEntity( "prop_control_panel" )
	panel.SetValueForModelKey( $"models/communication/terminal_usable_imc_01.mdl" )
	panel.SetOrigin( player.GetOrigin() )
	panel.SetAngles( player.GetAngles() )
	panel.kv.solid = SOLID_VPHYSICS
	SetTargetName( panel, "cpanel" )
	DispatchSpawn( panel )
	
	panel.SetModel( $"models/communication/terminal_usable_imc_01.mdl" )
	panel.s.onPlayerFinishesUsing_func = TestOnPanelHacked
	
}

function TestOnPanelHacked( panel, player, success )
{
	expect entity( panel )
	expect entity( player )
	expect bool( success )
	
	if ( !success )
		return
	
	print( panel + " was hacked by " + player )
	PanelFlipsToPlayerTeamAndUsableByEnemies( panel, player )
}

void function TestFastball()
{
	PrecacheModel( $"models/titans/buddy/titan_buddy.mdl" )
	RegisterSignal( "fastball_start_throw" )
	RegisterSignal( "fastball_release" )
	PrecacheParticleSystem( $"P_BT_eye_SM" )
	
	entity player = GetPlayerArray()[0]
	
	entity prop = CreatePropDynamic( $"models/titans/buddy/titan_buddy.mdl", player.GetOrigin(), player.GetAngles() )
	thread PlayAnim( prop, "bt_beacon_fastball_throw_end" )
	
	player.ContextAction_SetFastball()
	FirstPersonSequenceStruct throwSequence
	throwSequence.attachment = "REF"
	throwSequence.useAnimatedRefAttachment = true
	throwSequence.hideProxy = true
	throwSequence.firstPersonAnim = "ptpov_beacon_fastball_throw_end"
	//throwSequence.thirdPersonAnim = "pt_beacon_fastball_throw_end"
	throwSequence.firstPersonBlendOutTime = 0.0
	
	thread FirstPersonSequence( throwSequence, player, prop )
	player.HolsterWeapon()
	
	EmitSoundOnEntityOnlyToPlayer( player, player, "Music_Beacon_14_BTThrowThruFirstCrane" )
	
	prop.WaitSignal( "fastball_start_throw" )
	float duration = EmitSoundOnEntity( prop, "diag_sp_spoke1_BE117_04_01_mcor_bt" ) // trust me
	vector eyeAngles = player.EyeAngles()
	
	// particle effect 
	StartParticleEffectOnEntity( prop, GetParticleSystemIndex( $"P_BT_eye_SM" ), FX_PATTACH_POINT_FOLLOW, prop.LookupAttachment( "EYEGLOW" ) )
	wait duration
	
	prop.WaitSignal( "fastball_release" )
	player.ContextAction_ClearFastball()
	player.ClearParent()
	ClearPlayerAnimViewEntity( player )
	player.SetVelocity( AnglesToForward( eyeAngles ) * 1250 )
	player.DeployWeapon()
	
	wait 0.5
	prop.Destroy()
}

void function TestPlanetExplosion() // won't look good until we can load textures from rpak for these models
{
	PrecacheModel( $"models/vistas/planet_ex_static.mdl" )
	PrecacheModel( $"models/vistas/planet_explosion_animated.mdl" )
	
	entity cam = GetEnt( "skybox_cam_level" )
	cam.SetOrigin( < 7000, 7000, 7000 > ) // arbitrary point
	CreatePropDynamic( $"models/vistas/planet_ex_static.mdl", cam.GetOrigin(), cam.GetAngles() )
	entity explosion = CreatePropDynamic( $"models/vistas/planet_explosion_animated.mdl", cam.GetOrigin(), cam.GetAngles() )
	thread PlayAnim( explosion, "planet_ex_ending" )
}