Skip to content

Commit

Permalink
#108 - needs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Jan 21, 2024
1 parent 3667e05 commit c430dbd
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/data/microtf2/Minigames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions src/scripting/MinigameSystem.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
131 changes: 131 additions & 0 deletions src/scripting/Minigames/Shove.sp
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);
}
}
19 changes: 19 additions & 0 deletions src/translations/translations.tsutproj
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c430dbd

Please sign in to comment.