Skip to content

Commit

Permalink
#256 - needs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Jan 21, 2024
1 parent c430dbd commit 9245259
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/data/microtf2/Minigames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,13 @@
"RequiresMultiplePlayers" "1"
"BackgroundMusic_Length" "3.874125"
}
"33"
{
"enabled" "1"
"BackgroundMusic" "gemidyne/warioware/{version}/minigames/bgm/airblast.mp3"
"EntryPoint" "Minigame33_EntryPoint"
"BlockedSpecialRounds" "12"
"RequiresMultiplePlayers" "1"
"BackgroundMusic_Length" "3.874125"
}
}
3 changes: 2 additions & 1 deletion src/scripting/Events.sp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ public void TF2_OnConditionAdded(int client, TFCond condition)
TFCond_RuneHaste,
TFCond_CritCola,
TFCond_HalloweenCritCandy,
TFCond_Parachute:
TFCond_Parachute,
TFCond_HalloweenKart:
{
removeCondition = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/scripting/MinigameSystem.sp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static ArrayList g_hPlayedBossgamePool;
#include "Minigames/HealAMedic.sp"
#include "Minigames/LandSafely.sp"
#include "Minigames/Shove.sp"
#include "Minigames/KartBump.sp"

// Bossgames
#include "Bossgames/AcidPitEscape.sp"
Expand Down
134 changes: 134 additions & 0 deletions src/scripting/Minigames/KartBump.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/**
* MicroTF2 - Minigame 33
*
* Shove them off!
*/

int g_iMinigame33PlayerIndex;

public void Minigame33_EntryPoint()
{
AddToForward(g_pfOnMinigameSelectedPre, INVALID_HANDLE, Minigame33_OnMinigameSelectedPre);
AddToForward(g_pfOnMinigameSelected, INVALID_HANDLE, Minigame33_OnMinigameSelected);
AddToForward(g_pfOnPlayerDeath, INVALID_HANDLE, Minigame33_OnPlayerDeath);
AddToForward(g_pfOnMinigameFinish, INVALID_HANDLE, Minigame33_OnMinigameFinish);
}

public void Minigame33_OnMinigameSelectedPre()
{
if (g_iActiveMinigameId == 33)
{
g_eDamageBlockMode = EDamageBlockMode_OtherPlayersOnly;
g_bIsBlockingKillCommands = false;
g_iMinigame33PlayerIndex = 0;
}
}

public void Minigame33_OnMinigameSelected(int client)
{
if (g_iActiveMinigameId != 33)
{
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_iMinigame33PlayerIndex++;

player.GiveWeapon(220);
player.SetWeaponPrimaryAmmoCount(4);
player.SetWeaponClipAmmoCount(32);

float vel[3] = { 0.0, 0.0, 0.0 };
int posa = 360 / g_iActiveParticipantCount * (g_iMinigame33PlayerIndex-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);
player.AddCondition(TFCond_HalloweenKart);

SDKHook(client, SDKHook_PreThink, Minigame33_RemoveLeftClick);
}
}

public void Minigame33_OnPlayerDeath(int client, int attacker)
{
if (g_iActiveMinigameId != 33)
{
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 Minigame33_OnMinigameFinish()
{
if (g_bIsMinigameActive && g_iActiveMinigameId == 33)
{
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, Minigame33_RemoveLeftClick);
player.RemoveCondition(TFCond_HalloweenKart);
player.Respawn();
}
}
}
}

public void Minigame33_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 @@ -2576,6 +2576,25 @@
},
"ignoreEmptyValue": false
},
{
"key": "Minigame33_Caption",
"category": "Microgames",
"description": null,
"text": "BUMP 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 9245259

Please sign in to comment.