From c04488de312785098f2a95ed79e9bb722fc84932 Mon Sep 17 00:00:00 2001 From: Jackz Date: Fri, 14 May 2021 09:18:44 -0500 Subject: [PATCH] epi: Documentation update --- scripting/l4d2_extraplayeritems.sp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripting/l4d2_extraplayeritems.sp b/scripting/l4d2_extraplayeritems.sp index 4966a95..896ae12 100644 --- a/scripting/l4d2_extraplayeritems.sp +++ b/scripting/l4d2_extraplayeritems.sp @@ -1,3 +1,15 @@ +/* + Logic Flow: + + Once a player reaches the saferoom, it will give at a minimum a kit for each extra player over 4. + There is a small chance of bonus kit, and will give bonus depending on average team health + + Kits are provided when a player attempts to pickup a new kit, + or when they load back in after map transition (and don't already have one) + + Once a new map starts, all item spawners are checked and randomly their spawn count will be increased by 1. +*/ + #pragma semicolon 1 #pragma newdecls required @@ -13,7 +25,6 @@ #include //TODO: On 3rd/4th kit pickup in area, add more //TODO: Add extra pills too, on pickup -//TODO: Set ammo pack ammo to max primary #define L4D2_WEPUPGFLAG_NONE (0 << 0) #define L4D2_WEPUPGFLAG_INCENDIARY (1 << 0) @@ -39,6 +50,7 @@ static bool isCheckpointReached, isLateLoaded, firstGiven, isFailureRound; static ArrayList ammoPacks; static int g_iAmmoTable; + /* on first start: Everyone has a kit, new comers also get a kit. then when you reach the saferoom, extraKitsAmount is set to the amount of players minus 4. Ex: 5 players -> 1 extra kit @@ -266,6 +278,7 @@ public void OnMapEnd() { ammoPacks.Clear(); } public void EntityOutput_OnStartTouchSaferoom(const char[] output, int caller, int client, float time) { + //TODO: Possibly check client (as entity) if it is a kit, to check that the kit being picked up is in saferoom? if(!isCheckpointReached && client > 0 && client <= MaxClients && IsValidClient(client) && GetClientTeam(client) == 2) { isCheckpointReached = true; int extraPlayers = GetSurvivorsCount() - 4; @@ -294,16 +307,17 @@ public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) if(!isFailureRound) isFailureRound = true; } public Action Event_MapTransition(Event event, const char[] name, bool dontBroadcast) { + #if defined DEBUG + PrintToServer("Map transition | %d Extra Kits", extraKitsAmount); + #endif isCheckpointReached = false; isLateLoaded = false; - //If any kits were consumed before map transition, decrease from reset-amount (for if a round fails) - #if defined DEBUG - PrintToServer("Map transition | Extra Kits Left %d | Starting Amount %d", extraKitsAmount, extraKitsStarted); - #endif extraKitsStarted = extraKitsAmount; abmExtraCount = GetRealSurvivorsCount(); playerstoWaitFor = GetSurvivorsCount(); } + +//TODO: Possibly hacky logic of on third different ent id picked up, in short timespan, detect as set of 4 (pills, kits) & give extra public Action Event_Pickup(int client, int weapon) { char name[32]; GetEntityClassname(weapon, name, sizeof(name)); @@ -401,6 +415,8 @@ public Action Timer_AddExtraCounts(Handle hd) { && StrContains(classname, "zombie", true) == -1 && StrContains(classname, "scavenge", true) == -1 ) { + int newEnt = CreateEntityByName(classname); + DispatchSpawn(newEnt); int count = GetEntProp(i, Prop_Data, "m_itemCount"); //Add extra kits (equal to player count) to any 4 set of kits. if(count == 4 && StrEqual(classname, "weapon_first_aid_kit_spawn", true)) {