mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 11:43:22 +00:00
L4D2Tools: Add auto kill zombies attacking survivor bots
This commit is contained in:
parent
761a21c22e
commit
a13dcaab87
2 changed files with 19 additions and 2 deletions
Binary file not shown.
|
@ -21,7 +21,6 @@ static Handle hTakeOverBot, hGoAwayFromKeyboard;
|
||||||
|
|
||||||
static float OUT_OF_BOUNDS[3] = {0.0, -1000.0, 0.0};
|
static float OUT_OF_BOUNDS[3] = {0.0, -1000.0, 0.0};
|
||||||
|
|
||||||
//TODO: Drop melee on death AND clear on respawn by defib.
|
|
||||||
//TODO: Auto increase abm_minplayers based on highest player count
|
//TODO: Auto increase abm_minplayers based on highest player count
|
||||||
|
|
||||||
public Plugin myinfo = {
|
public Plugin myinfo = {
|
||||||
|
@ -84,6 +83,7 @@ public void OnPluginStart() {
|
||||||
for(int client = 1; client < MaxClients; client++) {
|
for(int client = 1; client < MaxClients; client++) {
|
||||||
if(IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == 2) {
|
if(IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == 2) {
|
||||||
if(IsFakeClient(client)) {
|
if(IsFakeClient(client)) {
|
||||||
|
SDKHook(client, SDKHook_OnTakeDamage, Event_OnTakeDamage);
|
||||||
SDKHook(client, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
SDKHook(client, SDKHook_WeaponDrop, Event_OnWeaponDrop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,6 @@ public Action VGUIMenu(UserMsg msg_id, Handle bf, const int[] players, int playe
|
||||||
BfReadString(bf, buffer, sizeof(buffer));
|
BfReadString(bf, buffer, sizeof(buffer));
|
||||||
return StrEqual(buffer, "info") ? Plugin_Handled : Plugin_Continue;
|
return StrEqual(buffer, "info") ? Plugin_Handled : Plugin_Continue;
|
||||||
}
|
}
|
||||||
//TODO: Might have to actually check for the bot they control, or possibly the bot will call this itself.
|
|
||||||
public void OnClientDisconnect(int client) {
|
public void OnClientDisconnect(int client) {
|
||||||
if(IsClientConnected(client) && IsClientInGame(client) && botDropMeleeWeapon[client] > -1) {
|
if(IsClientConnected(client) && IsClientInGame(client) && botDropMeleeWeapon[client] > -1) {
|
||||||
float pos[3];
|
float pos[3];
|
||||||
|
@ -337,6 +336,24 @@ public Action Event_OnWeaponDrop(int client, int weapon) {
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
public Action Event_OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype) {
|
||||||
|
if(attacker > MaxClients) {
|
||||||
|
char name[16];
|
||||||
|
GetEdictClassname(attacker, name, sizeof(name));
|
||||||
|
if(!StrEqual(name, "infected", true)) {
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool attackerVisible = IsEntityInSightRange(victim, attacker, 130.0, 100.0);
|
||||||
|
if(!attackerVisible) {
|
||||||
|
//Zombie is behind the bot, reduce damage taken and slowly kill zombie (1/10 of default hp per hit)
|
||||||
|
damage = damage / 2.0;
|
||||||
|
SDKHooks_TakeDamage(attacker, victim, victim, 6.0);
|
||||||
|
return Plugin_Changed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
public void Frame_HideEntity(int entity) {
|
public void Frame_HideEntity(int entity) {
|
||||||
TeleportEntity(entity, OUT_OF_BOUNDS, NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(entity, OUT_OF_BOUNDS, NULL_VECTOR, NULL_VECTOR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue