From c430dbdb4c8a730c3f35eb5356a69ec23b9372da Mon Sep 17 00:00:00 2001 From: Stevu Date: Sun, 21 Jan 2024 19:21:50 +0000 Subject: [PATCH] #108 - needs testing --- src/data/microtf2/Minigames.txt | 9 ++ src/scripting/MinigameSystem.sp | 1 + src/scripting/Minigames/Shove.sp | 131 +++++++++++++++++++++++++ src/translations/translations.tsutproj | 19 ++++ 4 files changed, 160 insertions(+) create mode 100644 src/scripting/Minigames/Shove.sp diff --git a/src/data/microtf2/Minigames.txt b/src/data/microtf2/Minigames.txt index b1b8a5d..9a4be92 100644 --- a/src/data/microtf2/Minigames.txt +++ b/src/data/microtf2/Minigames.txt @@ -271,4 +271,13 @@ "BlockedSpecialRounds" "3,12,15" "BackgroundMusic_Length" "3.9" } + "32" + { + "enabled" "1" + "BackgroundMusic" "gemidyne/warioware/{version}/minigames/bgm/airblast.mp3" + "EntryPoint" "Minigame32_EntryPoint" + "BlockedSpecialRounds" "12" + "RequiresMultiplePlayers" "1" + "BackgroundMusic_Length" "3.874125" + } } diff --git a/src/scripting/MinigameSystem.sp b/src/scripting/MinigameSystem.sp index 4bf96f3..c51aa44 100644 --- a/src/scripting/MinigameSystem.sp +++ b/src/scripting/MinigameSystem.sp @@ -67,6 +67,7 @@ static ArrayList g_hPlayedBossgamePool; #include "Minigames/DontTouch.sp" #include "Minigames/HealAMedic.sp" #include "Minigames/LandSafely.sp" +#include "Minigames/Shove.sp" // Bossgames #include "Bossgames/AcidPitEscape.sp" diff --git a/src/scripting/Minigames/Shove.sp b/src/scripting/Minigames/Shove.sp new file mode 100644 index 0000000..0e80f1c --- /dev/null +++ b/src/scripting/Minigames/Shove.sp @@ -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); + } +} \ No newline at end of file diff --git a/src/translations/translations.tsutproj b/src/translations/translations.tsutproj index 352f2fe..fc56ca8 100644 --- a/src/translations/translations.tsutproj +++ b/src/translations/translations.tsutproj @@ -2557,6 +2557,25 @@ }, "ignoreEmptyValue": false }, + { + "key": "Minigame32_Caption", + "category": "Microgames", + "description": null, + "text": "SHOVE THEM OFF!", + "formatArguments": [], + "translations": { + "pt": null, + "fr": null, + "it": null, + "pt_p": null, + "ru": null, + "es": null, + "jp": null, + "pl": null, + "de": null + }, + "ignoreEmptyValue": false + }, { "key": "Bossgame7_Caption_TypeTheWords", "category": "Bossgames",