-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* MicroTF2 - Minigame 32 | ||
* | ||
* Shove them off! | ||
*/ | ||
|
||
int g_iMinigame32PlayerIndex; | ||
|
||
public void Minigame32_EntryPoint() | ||
{ | ||
AddToForward(g_pfOnMinigameSelectedPre, INVALID_HANDLE, Minigame32_OnMinigameSelectedPre); | ||
AddToForward(g_pfOnMinigameSelected, INVALID_HANDLE, Minigame32_OnMinigameSelected); | ||
AddToForward(g_pfOnPlayerDeath, INVALID_HANDLE, Minigame32_OnPlayerDeath); | ||
AddToForward(g_pfOnMinigameFinish, INVALID_HANDLE, Minigame32_OnMinigameFinish); | ||
} | ||
|
||
public void Minigame32_OnMinigameSelectedPre() | ||
{ | ||
if (g_iActiveMinigameId == 32) | ||
{ | ||
g_eDamageBlockMode = EDamageBlockMode_OtherPlayersOnly; | ||
g_bIsBlockingKillCommands = false; | ||
g_iMinigame32PlayerIndex = 0; | ||
} | ||
} | ||
|
||
public void Minigame32_OnMinigameSelected(int client) | ||
{ | ||
if (g_iActiveMinigameId != 32) | ||
{ | ||
return; | ||
} | ||
|
||
if (!g_bIsMinigameActive) | ||
{ | ||
return; | ||
} | ||
|
||
Player player = new Player(client); | ||
|
||
if (player.IsValid) | ||
{ | ||
player.SetGodMode(false); | ||
player.SetHealth(1000); | ||
player.SetCollisionsEnabled(false); | ||
|
||
player.Class = TFClass_Scout; | ||
player.RemoveAllWeapons(); | ||
|
||
player.Status = PlayerStatus_Winner; | ||
|
||
g_iMinigame32PlayerIndex++; | ||
|
||
player.GiveWeapon(220); | ||
player.SetWeaponPrimaryAmmoCount(4); | ||
player.SetWeaponClipAmmoCount(32); | ||
|
||
float vel[3] = { 0.0, 0.0, 0.0 }; | ||
int posa = 360 / g_iActiveParticipantCount * (g_iMinigame32PlayerIndex-1); | ||
float pos[3]; | ||
float ang[3]; | ||
|
||
pos[0] = -7567.6 + (Cosine(DegToRad(float(posa)))*300.0); | ||
pos[1] = 3183.0 - (Sine(DegToRad(float(posa)))*300.0); | ||
pos[2] = -282.0; | ||
|
||
ang[0] = 0.0; | ||
ang[1] = float(180-posa); | ||
ang[2] = 0.0; | ||
|
||
TeleportEntity(client, pos, ang, vel); | ||
SDKHook(client, SDKHook_PreThink, Minigame32_RemoveLeftClick); | ||
} | ||
} | ||
|
||
public void Minigame32_OnPlayerDeath(int client, int attacker) | ||
{ | ||
if (g_iActiveMinigameId != 32) | ||
{ | ||
return; | ||
} | ||
|
||
if (!g_bIsMinigameActive) | ||
{ | ||
return; | ||
} | ||
|
||
Player player = new Player(client); | ||
|
||
if (player.IsValid && player.IsParticipating) | ||
{ | ||
player.Status = PlayerStatus_Failed; | ||
|
||
Player attackerPlayer = new Player(attacker); | ||
|
||
if (attackerPlayer.IsValid) | ||
{ | ||
attackerPlayer.Status = PlayerStatus_Winner; | ||
} | ||
} | ||
} | ||
|
||
public void Minigame32_OnMinigameFinish() | ||
{ | ||
if (g_bIsMinigameActive && g_iActiveMinigameId == 32) | ||
{ | ||
for (int i = 1; i <= MaxClients; i++) | ||
{ | ||
Player player = new Player(i); | ||
|
||
if (player.IsValid && player.IsParticipating) | ||
{ | ||
player.Status = (player.IsAlive ? PlayerStatus_Winner : PlayerStatus_Failed); | ||
|
||
SDKUnhook(i, SDKHook_PreThink, Minigame32_RemoveLeftClick); | ||
player.Respawn(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void Minigame32_RemoveLeftClick(int client) | ||
{ | ||
int buttons = GetClientButtons(client); | ||
|
||
if ((buttons & IN_ATTACK)) | ||
{ | ||
buttons &= ~IN_ATTACK; | ||
SetEntProp(client, Prop_Data, "m_nButtons", buttons); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters