Skip to content

Commit d431d9e

Browse files
committed
Add: BunnyHop Feature
1 parent be4725a commit d431d9e

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

addons/sourcemod/configs/ultra_vip_main.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@
239239
"player_extra_jumps_round" "1" // The first round that player_extra_jumps starts to apply.
240240
"player_extra_jumps_falldamage" "1" // Should you take fall damage after doing an extra jump (1 = Damage enabled | 0 = Damage disabled).
241241
242+
"player_bunnyhop" "0" // Should player have bunnyhop? (1 = enabled | 0 = disabled).
243+
"player_bunnyhop_round" "1" // From which round should player have bunnyhop?
244+
242245
"player_shield" "0" // (This currently is disabled and won't work, feature not possible to implement because of bugs)
243246
"player_shield_round" "1" // The first round that Tactical Shield is given out.
244247

addons/sourcemod/scripting/ultra_vip.sp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ public void OnClientPostAdminCheck(int client)
313313
UpdateClientAdminCache(client);
314314

315315
ExtraJump_OnClientPostAdminCheck(client, g_ClientService[client]);
316+
BunnyHop_OnClientPostAdminCheck(client, g_ClientService[client]);
316317

317318
CallServiceForward(g_Fwd_OnPostAdminCheck, client, g_ClientService[client]);
318319
}
@@ -323,6 +324,7 @@ public void OnClientDisconnect(int client)
323324

324325
Bonus_LeaveMessage(client);
325326
ExtraJump_OnClientDisconect(client);
327+
BunnyHop_OnClientDisconnect(client);
326328
WeaponMenu_ResetPreviousWeapons(client);
327329

328330
g_ClientService[client] = null;
@@ -406,6 +408,7 @@ public Action Command_ReloadServices(int client, int args)
406408
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
407409
{
408410
ExtraJump_OnPlayerRunCmd(client);
411+
BunnyHop_OnPlayerRunCmd(client, buttons);
409412
return Plugin_Continue;
410413
}
411414

addons/sourcemod/scripting/ultra_vip/config.sp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ static bool ProcessSpecialBonuses(KeyValues kv, Service svc, bool fatalError, co
649649
if (CanGetKey(kv, "player_extra_jumps_falldamage"))
650650
svc.BonusExtraJumpsTakeFallDamage = view_as<bool>(kv.GetNum("player_extra_jumps_falldamage", 1));
651651

652+
if (CanGetKey(kv, "player_bunnyhop"))
653+
svc.BonusBunnyHop = view_as<bool>(kv.GetNum("player_bunnyhop", 0));
654+
if (CanGetKey(kv, "player_bunnyhop_round"))
655+
svc.BonusBunnyHopRound = GetConfigRound(kv, "player_bunnyhop_round", 1);
656+
652657
if (CanGetKey(kv, "player_shield"))
653658
svc.BonusPlayerShield = view_as<bool>(kv.GetNum("player_shield", 0));
654659
if (CanGetKey(kv, "player_shield_round"))

addons/sourcemod/scripting/ultra_vip/events.sp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public Action Timer_SpawnBonuses(Handle tmr, DataPack pack)
105105

106106
// This must run for every spawn, even without a service
107107
ExtraJump_OnPlayerSpawn(client, svc);
108+
BunnyHop_OnPlayerSpawn(client, svc);
108109
CallServiceForward(g_Fwd_OnSpawn, client, svc);
109110

110111
if (svc == null)

addons/sourcemod/scripting/ultra_vip/extrajump.sp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static bool s_IsEnabled[MAXPLAYERS + 1] = { EXTRAJUMP_DEFAULT_STATE, ... };
2727
static bool s_IsDoingExtraJump[MAXPLAYERS + 1] = { false, ... };
2828

2929
static bool s_AllowedToMultiJump[MAXPLAYERS + 1];
30+
static bool s_AllowedToBH[MAXPLAYERS + 1];
3031
static int s_MaxMultiJumps[MAXPLAYERS + 1];
3132
static float s_JumpHeight[MAXPLAYERS + 1];
3233

@@ -117,6 +118,15 @@ void ExtraJump_OnClientPostAdminCheck(int client, Service svc)
117118
s_JumpHeight[client] = svc.BonusJumpHeight;
118119
}
119120

121+
void BunnyHop_OnClientPostAdminCheck(int client, Service svc)
122+
{
123+
if (svc == null)
124+
{
125+
s_AllowedToBH[client] = false;
126+
return;
127+
}
128+
}
129+
120130
void ExtraJump_OnPlayerSpawn(int client, Service svc)
121131
{
122132
s_AllowedToMultiJump[client] = false;
@@ -139,6 +149,25 @@ void ExtraJump_OnPlayerSpawn(int client, Service svc)
139149
s_AllowedToMultiJump[client] = true;
140150
}
141151

152+
void BunnyHop_OnPlayerSpawn(int client, Service svc)
153+
{
154+
s_AllowedToBH[client] = false;
155+
156+
if (svc == null)
157+
return;
158+
159+
if (!svc.BonusBunnyHop)
160+
return;
161+
162+
if (!IsPlayerAlive(client))
163+
return;
164+
165+
if (!IsRoundAllowed(svc, svc.BonusBunnyHopRound))
166+
return;
167+
168+
s_AllowedToBH[client] = true;
169+
}
170+
142171
void ExtraJump_OnPlayerDeath(int client)
143172
{
144173
s_AllowedToMultiJump[client] = false;
@@ -153,6 +182,11 @@ void ExtraJump_OnClientDisconect(int client)
153182
s_IsDoingExtraJump[client] = false;
154183
}
155184

185+
void BunnyHop_OnClientDisconnect(int client)
186+
{
187+
s_AllowedToBH[client] = false;
188+
}
189+
156190
static void FakeJump(int client, float jumpHeight = EXTRAJUMP_DEFAULT_HEIGHT)
157191
{
158192
float velocity[3];
@@ -197,3 +231,18 @@ static bool CanJumpAgain(int client, int &jumpCount)
197231
// That makes s_MaxMultiJumps 1-indexed (so use <=)
198232
return jumpCount > 0 && jumpCount <= s_MaxMultiJumps[client];
199233
}
234+
235+
void BunnyHop_OnPlayerRunCmd(int client, int &buttons)
236+
{
237+
if (!s_AllowedToBH[client])
238+
return;
239+
240+
if (IsPlayerAlive(client))
241+
{
242+
if((buttons & IN_JUMP) > 0 && GetEntityMoveType(client) == MOVETYPE_WALK && GetEntProp(client, Prop_Send, "m_nWaterLevel") <= 1)
243+
{
244+
int iOldButtons = GetEntProp(client, Prop_Data, "m_nOldButtons");
245+
SetEntProp(client, Prop_Data, "m_nOldButtons", iOldButtons & ~IN_JUMP);
246+
}
247+
}
248+
}

addons/sourcemod/scripting/ultra_vip/service.sp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,17 @@ methodmap Service < StringMap
270270
public set(int value) { this.SetValue("_bumpmine_round", value); }
271271
}
272272

273+
property bool BonusBunnyHop
274+
{
275+
public get() { return Service_GetCell(this, "_player_bunnyhop"); }
276+
public set(bool value) { this.SetValue("_player_bunnyhop", value); }
277+
}
278+
property int BonusBunnyHopRound
279+
{
280+
public get() { return Service_GetCell(this, "_player_bunnyhop_round"); }
281+
public set(int value) { this.SetValue("_player_bunnyhop_round", value); }
282+
}
283+
273284
property int BonusExtraJumps
274285
{
275286
public get() { return Service_GetCell(this, "_player_extra_jumps"); }

0 commit comments

Comments
 (0)