RSSy MYGO.pl Opublikowano Grudzień 24, 2017 o 15:47 RSSy Udostępnij Opublikowano Grudzień 24, 2017 o 15:47 Description: Inspired by AtomicStryker's [L4D2] Karma Charge plugin, jockeys (bots and humans) now can bring karma to their victims when they fall to their painful death. As an added feature, ridden victims can no longer hold on ledges, making them vulnerable to cliffs, edges, etc. ConVars: "karma_ride-l4d2_version" - "1.0" (Version of the plugin) "karma_ride-l4d2_enable" - "1" (Enable/Disable plugin) "karma_ride-l4d2_no_ledge_hang" - "1" (Enable/Disable no ledge hang while being ridden) "karma_ride-l4d2_height_check" - "425.0" (Falling height considered as a karma ride) "karma_ride-l4d2_slowmo_duration" - "5.0" (Duration of slow motion effect during karma rides) "karma_ride-l4d2_slowmo_type" - "1" (Apply slow motion effect to: 0 = The whole server, 1 = Just the rider and the ridden) Commands: None. Bugs: Again, this was thoroughly checked and tested. The results returned NULL. Source: PHP Code: /* * [L4D2] Karma Ride plugin. A SourceMod plugin for Left 4 Dead 2. * =========================================================================== * Copyright (C) 2017-2018 John Mark "cravenge" Moreno. All rights reserved. * =========================================================================== * * The source code in this file is originally made by me, inspired by * AtomicStryker's [L4D2] Karma Charge plugin. * * I strictly prohibit the unauthorized usage, modification, and/or * redistribution of this plugin under a different name but there are * exceptions. * * If you have any suggestions on improving the plugin's functionality, * please do not hesitate to send a private message to my AlliedModders * profile. For feedbacks/improvements, you can either post them in the * thread or notify me through PM. * * ------------------------------- Changelog --------------------------------- * Version 1.0 (December 24, 2017) * * - Initial release. * ? Add check for false detections like the glitches in [L4D2] Karma Charge * plugin by AtomicStryker. */ #pragma semicolon 1 #include <sourcemod> #include <sdktools> ConVar krEnable, krNoLedgeHang, krHeightCheck, krSlowMoDuration, krSlowMoType; int iSlowMoType; bool bEnabled, bNoLedgeHang, bIsRiding[MAXPLAYERS+1]; float fHeightCheck, fSlowMoDuration; Handle hKRTime[MAXPLAYERS+1] = null; public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { char sGameName[12]; GetGameFolderName(sGameName, sizeof(sGameName)); if (StrEqual(sGameName, "left4dead2", false)) { return APLRes_Success; } strcopy(error, err_max, "[KR] Plugin Supports L4D2 Only!"); return APLRes_SilentFailure; } public Plugin myinfo = { name = "[L4D2] Karma Ride", author = "cravenge", description = "Show Players That Jockeys Aren't To Be Underestimated.", version = "1.0", url = "https://forums.alliedmods.net/forumdisplay.php?f=108" }; public void OnPluginStart() { CreateConVar("karma_ride-l4d2_version", "1.0", "Karma Ride Version", FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_DONTRECORD); krEnable = CreateConVar("karma_ride-l4d2_enable", "1", "Enable/Disable Plugin", FCVAR_NOTIFY|FCVAR_SPONLY); krNoLedgeHang = CreateConVar("karma_ride-l4d2_no_ledge_hang", "1", "Enable/Disable No Ledge Hang During Jockey Rides", FCVAR_NOTIFY|FCVAR_SPONLY); krHeightCheck = CreateConVar("karma_ride-l4d2_height_check", "425.0", "Fall Height To Check And Consider As Karma Ride", FCVAR_NOTIFY|FCVAR_SPONLY); krSlowMoDuration = CreateConVar("karma_ride-l4d2_slowmo_duration", "5.0", "Duration Of Slow Motion During Karma Rides", FCVAR_NOTIFY|FCVAR_SPONLY); krSlowMoType = CreateConVar("karma_ride-l4d2_slowmo_type", "1", "Slow Motion Type: 0=Whole Server, 1=Just Jockey And Victim", FCVAR_NOTIFY|FCVAR_SPONLY); iSlowMoType = krSlowMoType.IntValue; bEnabled = krEnable.BoolValue; bNoLedgeHang = krNoLedgeHang.BoolValue; fHeightCheck = krHeightCheck.FloatValue; fSlowMoDuration = krSlowMoDuration.FloatValue; krEnable.AddChangeHook(OnKRCVarsChanged); krNoLedgeHang.AddChangeHook(OnKRCVarsChanged); krHeightCheck.AddChangeHook(OnKRCVarsChanged); krSlowMoDuration.AddChangeHook(OnKRCVarsChanged); krSlowMoType.AddChangeHook(OnKRCVarsChanged); AutoExecConfig(true, "karma_ride-l4d2"); HookEvent("jockey_ride", OnJockeyRide); HookEvent("jockey_ride_end", OnJockeyRideEnd); HookEvent("round_start", OnRoundEvents); HookEvent("round_end", OnRoundEvents); HookEvent("finale_win", OnRoundEvents); HookEvent("mission_lost", OnRoundEvents); HookEvent("map_transition", OnRoundEvents); } public void OnKRCVarsChanged(ConVar cvar, const char[] sOldValue, const char[] sNewValue) { iSlowMoType = krSlowMoType.IntValue; bEnabled = krEnable.BoolValue; bNoLedgeHang = krNoLedgeHang.BoolValue; fHeightCheck = krHeightCheck.FloatValue; fSlowMoDuration = krSlowMoDuration.FloatValue; } public void OnPluginEnd() { krEnable.RemoveChangeHook(OnKRCVarsChanged); krNoLedgeHang.RemoveChangeHook(OnKRCVarsChanged); krHeightCheck.RemoveChangeHook(OnKRCVarsChanged); krSlowMoDuration.RemoveChangeHook(OnKRCVarsChanged); krSlowMoType.RemoveChangeHook(OnKRCVarsChanged); delete krEnable; delete krNoLedgeHang; delete krHeightCheck; delete krSlowMoDuration; delete krSlowMoType; UnhookEvent("jockey_ride", OnJockeyRide); UnhookEvent("jockey_ride_end", OnJockeyRideEnd); UnhookEvent("round_start", OnRoundEvents); UnhookEvent("round_end", OnRoundEvents); UnhookEvent("finale_win", OnRoundEvents); UnhookEvent("mission_lost", OnRoundEvents); UnhookEvent("map_transition", OnRoundEvents); } public void OnJockeyRide(Event event, const char[] name, bool dontBroadcast) { if (!bEnabled) { return; } int rider = GetClientOfUserId(event.GetInt("userid")); if (!IsJockey(rider) || bIsRiding[rider]) { return; } bIsRiding[rider] = true; if (bNoLedgeHang) { int ridden = GetClientOfUserId(event.GetInt("victim")); if (!IsSurvivor(ridden) || !IsPlayerAlive(ridden)) { return; } AcceptEntityInput(ridden, "DisableLedgeHang"); } } public void OnJockeyRideEnd(Event event, const char[] name, bool dontBroadcast) { if (!bEnabled) { return; } int rider = GetClientOfUserId(event.GetInt("userid")); if (!IsJockey(rider) || !bIsRiding[rider]) { return; } bIsRiding[rider] = false; if (bNoLedgeHang) { int ridden = GetClientOfUserId(event.GetInt("victim")); if (!IsSurvivor(ridden) || !IsPlayerAlive(ridden)) { return; } AcceptEntityInput(ridden, "EnableLedgeHang"); } } public void OnRoundEvents(Event event, const char[] name, bool dontBroadcast) { if (!bEnabled) { return; } for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { bIsRiding[i] = false; if (hKRTime[i] != null) { KillTimer(hKRTime[i]); hKRTime[i] = null; } } } } public void OnMapEnd() { if (!bEnabled) { return; } for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { bIsRiding[i] = false; if (hKRTime[i] != null) { KillTimer(hKRTime[i]); hKRTime[i] = null; } } } } public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vec[3], float angles[3], int &weapon) { if (!bEnabled) { return Plugin_Continue; } if (IsJockey(client) && bIsRiding[client]) { if (((buttons & IN_JUMP) && !IsFakeClient(client)) || IsFakeClient(client)) { int iJockeyVictim = GetEntPropEnt(client, Prop_Send, "m_jockeyVictim"); if (IsSurvivor(iJockeyVictim) && IsPlayerAlive(iJockeyVictim) && (GetEntProp(iJockeyVictim, Prop_Send, "m_fFlags") & FL_ONGROUND)) { if (hKRTime[client] == null) { hKRTime[client] = CreateTimer(0.4, QualifyKarmaRide, client, TIMER_REPEAT); } } } } return Plugin_Continue; } public Action QualifyKarmaRide(Handle timer, any client) { if (!IsClientInGame(client) || GetClientTeam(client) != 3 || !IsPlayerAlive(client)) { if (hKRTime[client] != null) { KillTimer(hKRTime[client]); hKRTime[client] = null; } return Plugin_Stop; } if (hKRTime[client] == null) { return Plugin_Stop; } int iJockeyVictim = GetEntPropEnt(client, Prop_Send, "m_jockeyVictim"); if (!IsSurvivor(iJockeyVictim) || !IsPlayerAlive(iJockeyVictim)) { if (hKRTime[client] != null) { KillTimer(hKRTime[client]); hKRTime[client] = null; } return Plugin_Stop; } if (GetEntProp(iJockeyVictim, Prop_Send, "m_fFlags") & FL_ONGROUND) { return Plugin_Continue; } float fRideHeight = MeasureHeightDistance(iJockeyVictim); if (fRideHeight >= fHeightCheck) { EmitSoundToAll("./level/loud/climber.wav", client); switch (iSlowMoType) { case 0: { int iTimeEnt = CreateEntityByName("func_timescale"); DispatchKeyValue(iTimeEnt, "desiredTimescale", "0.2"); DispatchKeyValue(iTimeEnt, "acceleration", "2.0"); DispatchKeyValue(iTimeEnt, "minBlendRate", "1.0"); DispatchKeyValue(iTimeEnt, "blendDeltaMultiplier", "2.0"); DispatchSpawn(iTimeEnt); AcceptEntityInput(iTimeEnt, "Start"); CreateTimer(fSlowMoDuration, RevertTime, iTimeEnt); } case 1: { SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", 0.2); SetEntPropFloat(iJockeyVictim, Prop_Send, "m_flLaggedMovementValue", 0.2); DataPack dpKarmaRide = new DataPack(); dpKarmaRide.WriteCell(GetClientUserId(client)); dpKarmaRide.WriteCell(GetClientUserId(iJockeyVictim)); CreateTimer(fSlowMoDuration, RevertSpeed, dpKarmaRide, TIMER_DATA_HNDL_CLOSE); } } PrintToChatAll("\x05[\x04KR\x05] \x03%N\x01 Karma Ridden \x03%N\x01!", client, iJockeyVictim); if (hKRTime[client] != null) { KillTimer(hKRTime[client]); hKRTime[client] = null; } return Plugin_Stop; } return Plugin_Continue; } public Action RevertTime(Handle timer, any entity) { if (!IsValidEdict(entity)) { return Plugin_Stop; } AcceptEntityInput(entity, "Stop"); AcceptEntityInput(entity, "Kill"); RemoveEdict(entity); return Plugin_Stop; } public Action RevertSpeed(Handle timer, Handle dpKarmaRide) { ResetPack(dpKarmaRide); int rider = GetClientOfUserId(ReadPackCell(dpKarmaRide)); int ridden = GetClientOfUserId(ReadPackCell(dpKarmaRide)); if (IsJockey(rider)) { SetEntPropFloat(rider, Prop_Send, "m_flLaggedMovementValue", 1.0); } if (IsSurvivor(ridden)) { SetEntPropFloat(ridden, Prop_Send, "m_flLaggedMovementValue", 1.0); } return Plugin_Stop; } float MeasureHeightDistance(int client) { float fPos[3], fDirAngle[3]; GetEntPropVector(client, Prop_Send, "m_vecOrigin", fPos); fDirAngle[0] = 90.0; fDirAngle[1] = 0.0; fDirAngle[2] = 0.0; Handle hTrace = TR_TraceRayFilterEx(fPos, fDirAngle, MASK_SHOT, RayType_Infinite, NonEntityFilter); if (!TR_DidHit(hTrace)) { delete hTrace; return 0.0; } float fTraceEnd[3]; TR_GetEndPosition(fTraceEnd, hTrace); delete hTrace; return GetVectorDistance(fPos, fTraceEnd, false); } public bool NonEntityFilter(int entity, int contentsMask, any data) { return (entity && IsValidEntity(entity)); } stock bool IsSurvivor(int client) { return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2); } stock bool IsJockey(int client) { return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 3 && GetEntProp(client, Prop_Send, "m_zombieClass") == 5); } Notes: (This is already found in the source code.) (This is already found in the source code.) (This is already found in the source code.) You may need to download [L4D2] Jockey Jump plugin in case of human jockey karmas. Changelog: 12-24-2017: First release. Attached Files Get Plugin or Get Source (karma_ride-l4d2.sp - 10.5 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się