SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <sourcemod> | |
| 2 | #include <sdktools> | |
| 3 | ||
| 4 | #define MAXLIST 11 | |
| 5 | ||
| 6 | - | Handle sdkCallVomitOnPlayer, sdkCallBileJarPlayer, sdkCallBileJarInfected; |
| 6 | + | |
| 7 | #pragma semicolon 1 | |
| 8 | ||
| 9 | static bool ignoreNextDamageDealt[MAXPLAYERS+1] = false; | |
| 10 | - | Handle ConfigFile = LoadGameConfigFile("added_vomit");
|
| 10 | + | |
| 11 | static const char gModelsItemsList[MAXLIST][] = | |
| 12 | - | StartPrepSDKCall(SDKCall_Player); |
| 12 | + | |
| 13 | - | PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "CTerrorPlayer_OnVomitedUpon"); |
| 13 | + | "models/weapons/melee/v_katana.mdl", //0 |
| 14 | - | PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer); |
| 14 | + | "models/weapons/melee/v_fireaxe.mdl", //1 |
| 15 | - | PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain); |
| 15 | + | "models/weapons/melee/v_machete.mdl", //2 |
| 16 | - | sdkCallVomitOnPlayer = EndPrepSDKCall(); |
| 16 | + | "models/weapons/melee/v_crowbar.mdl", //3 |
| 17 | "models/v_models/v_knife_t.mdl", //4 | |
| 18 | - | StartPrepSDKCall(SDKCall_Player); |
| 18 | + | "models/weapons/melee/v_frying_pan.mdl", //5 |
| 19 | - | PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "CTerrorPlayer_OnHitByVomitJar"); |
| 19 | + | "models/weapons/melee/v_bat.mdl", //6 |
| 20 | - | PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); |
| 20 | + | "models/weapons/melee/v_cricket_bat.mdl", //7 |
| 21 | - | sdkCallBileJarPlayer = EndPrepSDKCall(); |
| 21 | + | "models/weapons/melee/v_tonfa.mdl", //8 |
| 22 | "models/weapons/melee/v_electric_guitar.mdl", //9 | |
| 23 | - | StartPrepSDKCall(SDKCall_Entity); |
| 23 | + | "models/weapons/melee/v_golfclub.mdl" //10 |
| 24 | - | PrepSDKCall_SetFromConf(ConfigFile, SDKConf_Signature, "Infected_OnHitByVomitJar"); |
| 24 | + | }; |
| 25 | - | PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); |
| 25 | + | |
| 26 | - | sdkCallBileJarInfected = EndPrepSDKCall(); |
| 26 | + | static const char gGeneralMelee[MAXLIST - 6][] = |
| 27 | {
| |
| 28 | - | HookEvent("player_death", EventHook);
|
| 28 | + | "katana", |
| 29 | "fireaxe", | |
| 30 | "machete", | |
| 31 | - | public Action EventHook(Event event, const char[] name, bool dontBroadcast) |
| 31 | + | "crowbar", |
| 32 | "knife" | |
| 33 | - | int client = GetClientOfUserId(event.GetInt("userid"));
|
| 33 | + | }; |
| 34 | - | if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetEntProp(client, Prop_Send, "m_zombieClass") == 2) |
| 34 | + | |
| 35 | static const float gMeleeModifier[MAXLIST - 5] = | |
| 36 | - | SetVomit(client); |
| 36 | + | |
| 37 | 1.0, | |
| 38 | 1.0, | |
| 39 | 0.99, | |
| 40 | - | public void OnEntityDestroyed(int entity) |
| 40 | + | 0.9, |
| 41 | 0.7, | |
| 42 | - | if (IsValidEntity(entity)) |
| 42 | + | 0.6 |
| 43 | }; | |
| 44 | - | char sTypeEx[56]; |
| 44 | + | |
| 45 | - | GetEntityClassname(entity, sTypeEx, sizeof sTypeEx); |
| 45 | + | |
| 46 | - | if (strcmp(sTypeEx, "vomitjar_projectile") == 0) |
| 46 | + | |
| 47 | HookEvent("infected_hurt", iInfectedHurt);
| |
| 48 | - | SetVomit(entity); |
| 48 | + | |
| 49 | ||
| 50 | public Action iInfectedHurt(Event event, const char[] name, bool dontBroadcast) | |
| 51 | {
| |
| 52 | char weaponname[56]; | |
| 53 | - | stock void SetVomit(int client) |
| 53 | + | |
| 54 | int attacker = GetClientOfUserId(event.GetInt("attacker"));
| |
| 55 | int entity = event.GetInt("entityid");
| |
| 56 | - | float fDistance; |
| 56 | + | |
| 57 | - | char entType[64]; |
| 57 | + | if (!attacker || !IsValidEntity(entity) || ignoreNextDamageDealt[attacker]) return; |
| 58 | - | float vPos[3], vTargetPos[3]; |
| 58 | + | |
| 59 | - | GetEntPropVector(client, Prop_Send, "m_vecOrigin", vPos); |
| 59 | + | int dmg_health = GetEventInt(event,"amount"); |
| 60 | - | vPos[2] += 60; |
| 60 | + | int eventhealth = GetEntProp(entity, Prop_Data, "m_iHealth"); |
| 61 | - | |
| 61 | + | int damagedelta; |
| 62 | - | for (int i = 1; i <= 2048; i++) |
| 62 | + | |
| 63 | int iCurrentWeapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon"); | |
| 64 | - | if (!IsValidEntity(i) || i == client) continue; |
| 64 | + | |
| 65 | - | if (i <= MaxClients && IsClientInGame(i) && IsPlayerAlive(i)) |
| 65 | + | if(!IsValidEntity(iCurrentWeapon)) return; |
| 66 | ||
| 67 | - | GetClientAbsOrigin(i, vTargetPos); |
| 67 | + | GetEntityClassname(iCurrentWeapon, weaponname, sizeof(weaponname)); |
| 68 | - | fDistance = GetVectorDistance(vPos, vTargetPos); |
| 68 | + | if (strcmp(weaponname, "weapon_melee") == 0) |
| 69 | - | if(fDistance < 150 && IsVisibleTo(vTargetPos, vPos)) |
| 69 | + | GetEntPropString(iCurrentWeapon, Prop_Data, "m_strMapSetScriptName", weaponname, sizeof weaponname); |
| 70 | else return; | |
| 71 | - | switch( GetClientTeam(i) ) |
| 71 | + | |
| 72 | - | {
|
| 72 | + | |
| 73 | - | case 2: SDKCall(sdkCallBileJarPlayer, i, client, true); |
| 73 | + | if(weaponname[0] == 0) |
| 74 | - | case 3: SDKCall(sdkCallVomitOnPlayer, i, client, true); |
| 74 | + | |
| 75 | - | } |
| 75 | + | char ModelName[128], sExplodeString[MAXLIST - 6][36]; |
| 76 | int iNum; | |
| 77 | GetEntPropString(iCurrentWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName); | |
| 78 | - | else |
| 78 | + | for(int i; i < MAXLIST; i++) |
| 79 | {
| |
| 80 | - | GetEdictClassname(i, entType, sizeof(entType)); |
| 80 | + | if(strcmp(ModelName, gModelsItemsList[i]) == 0) |
| 81 | - | if(strcmp(entType, "witch") == 0 || strcmp(entType, "infected") == 0) |
| 81 | + | |
| 82 | iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]); | |
| 83 | - | GetEntityAbsOrigin(i, vTargetPos); |
| 83 | + | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", ""); |
| 84 | - | fDistance = GetVectorDistance(vPos, vTargetPos); |
| 84 | + | if(StrContains(sExplodeString[iNum - 1], "knife") > 0) |
| 85 | - | if (fDistance < 150 && IsVisibleTo(vTargetPos, vPos)) |
| 85 | + | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", ""); |
| 86 | - | {
|
| 86 | + | else |
| 87 | - | SDKCall(sdkCallBileJarInfected, i, client); |
| 87 | + | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", ""); |
| 88 | - | } |
| 88 | + | TrimString(sExplodeString[iNum - 1]); |
| 89 | Format(weaponname, sizeof weaponname, "%s", sExplodeString[iNum - 1]); | |
| 90 | break; | |
| 91 | } | |
| 92 | } | |
| 93 | } | |
| 94 | - | stock bool bIsSurvivor(int client) |
| 94 | + | |
| 95 | damagedelta = RoundToNearest((dmg_health * gMeleeModifier[5]) - dmg_health); | |
| 96 | - | return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client); |
| 96 | + | |
| 97 | for(int i; i < 5; i++) | |
| 98 | {
| |
| 99 | - | static bool IsVisibleTo(float position[3], float targetposition[3]) |
| 99 | + | if(strcmp(weaponname, gGeneralMelee[i]) == 0) |
| 100 | {
| |
| 101 | - | float vAngles[3], vLookAt[3]; |
| 101 | + | damagedelta = RoundToNearest((dmg_health * gMeleeModifier[i]) - dmg_health); |
| 102 | break; | |
| 103 | - | MakeVectorFromPoints(position, targetposition, vLookAt); |
| 103 | + | |
| 104 | - | GetVectorAngles(vLookAt, vAngles); |
| 104 | + | |
| 105 | ||
| 106 | - | Handle trace = TR_TraceRayFilterEx(position, vAngles, MASK_SHOT, RayType_Infinite, _TraceFilter); |
| 106 | + | if(damagedelta > 0) |
| 107 | applyDamage(damagedelta, entity, attacker); | |
| 108 | - | bool isVisible = false; |
| 108 | + | else |
| 109 | - | if (TR_DidHit(trace)) |
| 109 | + | |
| 110 | int health = eventhealth - damagedelta; | |
| 111 | - | float vStart[3]; |
| 111 | + | |
| 112 | - | TR_GetEndPosition(vStart, trace); |
| 112 | + | if (health < 1) |
| 113 | {
| |
| 114 | - | if ((GetVectorDistance(position, vStart, false) + 25.0) >= GetVectorDistance(position, targetposition)) |
| 114 | + | damagedelta += (health - 1); |
| 115 | health = 1; | |
| 116 | - | isVisible = true; |
| 116 | + | |
| 117 | SetEntProp(entity, Prop_Data, "m_iHealth", health); | |
| 118 | SetEventInt(event, "amount", damagedelta); | |
| 119 | } | |
| 120 | - | delete trace; |
| 120 | + | |
| 121 | - | return isVisible; |
| 121 | + | |
| 122 | static void applyDamage(int damage, int victim, int attacker) | |
| 123 | {
| |
| 124 | - | public bool _TraceFilter(int entity, int contentsMask) |
| 124 | + | Handle dataPack = CreateDataPack(); |
| 125 | WritePackCell(dataPack, damage); | |
| 126 | - | if (IsValidEntity(entity)) |
| 126 | + | WritePackCell(dataPack, victim); |
| 127 | WritePackCell(dataPack, attacker); | |
| 128 | - | return false; |
| 128 | + | |
| 129 | CreateTimer(0.1, timer_stock_applyDamage, dataPack); | |
| 130 | - | return true; |
| 130 | + | ignoreNextDamageDealt[attacker] = true; |
| 131 | CreateTimer(0.2, timer_resetStop, attacker); | |
| 132 | } | |
| 133 | - | stock void GetEntityAbsOrigin(int entity, float origin[3]) |
| 133 | + | |
| 134 | public Action timer_resetStop(Handle timer, any client) | |
| 135 | - | if (entity && IsValidEntity(entity) |
| 135 | + | |
| 136 | - | && (GetEntSendPropOffs(entity, "m_vecOrigin") != -1) |
| 136 | + | ignoreNextDamageDealt[client] = false; |
| 137 | - | && (GetEntSendPropOffs(entity, "m_vecMins") != -1) |
| 137 | + | |
| 138 | - | && (GetEntSendPropOffs(entity, "m_vecMaxs") != -1)) |
| 138 | + | |
| 139 | public Action timer_stock_applyDamage(Handle timer, Handle dataPack) | |
| 140 | - | float mins[3], maxs[3]; |
| 140 | + | |
| 141 | - | GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin); |
| 141 | + | ResetPack(dataPack); |
| 142 | - | GetEntPropVector(entity, Prop_Send, "m_vecMins", mins); |
| 142 | + | int damage = ReadPackCell(dataPack); |
| 143 | - | GetEntPropVector(entity, Prop_Send, "m_vecMaxs", maxs); |
| 143 | + | int victim = ReadPackCell(dataPack); |
| 144 | - | |
| 144 | + | int attacker = ReadPackCell(dataPack); |
| 145 | - | origin[0] += (mins[0] + maxs[0]) * 0.5; |
| 145 | + | CloseHandle(dataPack); |
| 146 | - | origin[1] += (mins[1] + maxs[1]) * 0.5; |
| 146 | + | |
| 147 | - | origin[2] += (mins[2] + maxs[2]) * 0.5; |
| 147 | + | float victimPos[3]; char strDamage[16], strDamageTarget[16]; |
| 148 | ||
| 149 | if (victim < 20 && IsClientInGame(victim)) | |
| 150 | {
| |
| 151 | GetClientEyePosition(victim, victimPos); | |
| 152 | } | |
| 153 | else if (IsValidEntity(victim)) | |
| 154 | {
| |
| 155 | GetEntityAbsOrigin(victim, victimPos); | |
| 156 | } | |
| 157 | else return; | |
| 158 | ||
| 159 | IntToString(damage, strDamage, sizeof(strDamage)); | |
| 160 | Format(strDamageTarget, sizeof(strDamageTarget), "hurtme%d", victim); | |
| 161 | ||
| 162 | int entPointHurt = CreateEntityByName("point_hurt");
| |
| 163 | if(!entPointHurt) return; | |
| 164 | ||
| 165 | DispatchKeyValue(victim, "targetname", strDamageTarget); | |
| 166 | DispatchKeyValue(entPointHurt, "DamageTarget", strDamageTarget); | |
| 167 | DispatchKeyValue(entPointHurt, "Damage", strDamage); | |
| 168 | DispatchKeyValue(entPointHurt, "DamageType", "0"); | |
| 169 | DispatchSpawn(entPointHurt); | |
| 170 | ||
| 171 | TeleportEntity(entPointHurt, victimPos, NULL_VECTOR, NULL_VECTOR); | |
| 172 | AcceptEntityInput(entPointHurt, "Hurt", (attacker && attacker < 20 && IsClientInGame(attacker)) ? attacker : -1); | |
| 173 | ||
| 174 | DispatchKeyValue(entPointHurt, "classname", "point_hurt"); | |
| 175 | DispatchKeyValue(victim, "targetname", "null"); | |
| 176 | AcceptEntityInput(entPointHurt, "kill"); | |
| 177 | } | |
| 178 | ||
| 179 | stock void GetEntityAbsOrigin( int entity, float origin[3]) | |
| 180 | {
| |
| 181 | if (entity > 0 && IsValidEntity(entity)) | |
| 182 | {
| |
| 183 | float mins[3], maxs[3]; | |
| 184 | GetEntPropVector(entity,Prop_Send,"m_vecOrigin",origin); | |
| 185 | GetEntPropVector(entity,Prop_Send,"m_vecMins",mins); | |
| 186 | GetEntPropVector(entity,Prop_Send,"m_vecMaxs",maxs); | |
| 187 | ||
| 188 | origin[0] += (mins[0] + maxs[0]) * 0.5; | |
| 189 | origin[1] += (mins[1] + maxs[1]) * 0.5; | |
| 190 | origin[2] += (mins[2] + maxs[2]) * 0.5; | |
| 191 | } | |
| 192 | } |