#include <sourcemod> #include <sdkhooks> #include <sdktools> #include <codmod> #include <codmod_def> #include <codmod_wpn_id> #include <codmod_wpn_name> new String:nazwa[] = "Inzynier (Od 1800Lv)"; new String:opis[] = "Posiada dzialko straznicze, ktorego wytrzymalosc i obrazenia rosna wraz z inteligencja"; new bronie = 1<<CSW_P90 | 1<<CSW_P228; new bronie_druzyn = 0; new inteligencja = 0; new zdrowie = 100; new obrazenia = 0; new wytrzymalosc = 100; new kondycja = 100; new bool:ma_klase[65], uzyta_klasa[65][2], procent_dziala[65]; public Plugin:myinfo = { name = "Inzynier (Od 1800Lv)", description = "Cod Klasa", author = "Linux`", version = "1.0", url = "http://steamcommunity.com/id/linux2006" }; public OnPluginStart() { cod_register_class(nazwa, opis, bronie, bronie_druzyn, inteligencja, zdrowie, obrazenia, wytrzymalosc, kondycja); HookEvent("player_spawn", OdrodzenieGracza); } public OnMapStart() { PrecacheModel("models/items/ammocrate_smg1.mdl"); PrecacheModel("models/props_combine/bunker_gun01.mdl"); PrecacheSound("weapons/smg1/smg1_fire1.wav"); PrecacheSound("vehicles/tank_readyfire1.wav"); PrecacheSound("physics/metal/metal_box_impact_bullet1.wav"); PrecacheSound("physics/metal/metal_box_impact_bullet2.wav"); PrecacheSound("physics/metal/metal_box_impact_bullet3.wav"); PrecacheSound("physics/metal/metal_box_impact_hard1.wav"); PrecacheSound("physics/metal/metal_box_impact_hard2.wav"); PrecacheSound("physics/metal/metal_box_impact_hard3.wav"); PrecacheSound("physics/metal/metal_barrel_impact_hard5.wav"); } public cod_class_enabled(client) { new level = 1800; if (cod_get_user_level_all(client) >= level) { ma_klase[client] = true; uzyta_klasa[client][0] = -1; uzyta_klasa[client][1] = -1; return COD_CONTINUE; } PrintToChat(client, "[COD:MW] Klasa %s dostepna jest po osiagnieciu %i poziomu!", nazwa, level); return COD_STOP; } public cod_class_disabled(client) { ma_klase[client] = false; StopDzialo(client, 1); } public cod_class_skill_used(client) { if(uzyta_klasa[client][0] != -1 || uzyta_klasa[client][1] != -1) PrintCenterText(client, "Wykorzystales juz moc swojej klasy w tym zyciu!"); else { uzyta_klasa[client][0] = CreateEntityByName("hegrenade_projectile"); if (uzyta_klasa[client][0] != -1) { if (!cod_get_user_intelligence(client, 1, 0, 0)) PrintCenterText(client, "Aby dokonczyc stawianie dzialka, uderzaj w jego podstawe nozem!"); new Float:forigin[3]; GetClientEyePosition(client, forigin); new Float:fangles[3]; GetClientEyeAngles(client, fangles); new Float:iangles[3]; iangles[1] = fangles[1]; DispatchSpawn(uzyta_klasa[client][0]); ActivateEntity(uzyta_klasa[client][0]); SetEntityModel(uzyta_klasa[client][0], "models/items/ammocrate_smg1.mdl"); SetEntityMoveType(uzyta_klasa[client][0], MOVETYPE_STEP); TeleportEntity(uzyta_klasa[client][0], forigin, iangles, NULL_VECTOR); SetEntProp(uzyta_klasa[client][0], Prop_Data, "m_takedamage", 2); SetEntProp(uzyta_klasa[client][0], Prop_Data, "m_iHealth", 200+RoundFloat(cod_get_user_maks_intelligence(client)*1.0)); SetEntProp(uzyta_klasa[client][0], Prop_Send, "m_usSolidFlags", 12); SetEntProp(uzyta_klasa[client][0], Prop_Data, "m_nSolidType", 6); SetEntProp(uzyta_klasa[client][0], Prop_Send, "m_CollisionGroup", 1); SetEntPropEnt(uzyta_klasa[client][0], Prop_Send, "m_hOwnerEntity", client); procent_dziala[client] = 0; SDKHook(uzyta_klasa[client][0], SDKHook_OnTakeDamage, TakeDamage); EmitSoundToAll("physics/metal/metal_barrel_impact_hard5.wav", uzyta_klasa[client][0]); } } } public Action:TakeDamage(ent, &attacker, &inflictor, &Float:damage, &damagetype) { if (!IsValidEntity(ent) || !IsValidClient(attacker)) return Plugin_Continue; new owner = GetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity"); if (!IsValidClient(owner)) { AcceptEntityInput(ent, "Kill"); return Plugin_Continue; } if (owner == attacker) { new String:weapon[32]; GetClientWeapon(attacker, weapon, sizeof(weapon)); if(StrEqual(weapon, nazwy_broni[CSW_KNIFE]) && damagetype & (DMG_BULLET| DMG_SLASH)) { if (procent_dziala[owner] >= 100) { if (uzyta_klasa[owner][1] == -1) StartDzialo(ent, owner); } else { new String:sound[128]; Format(sound, sizeof(sound), "physics/metal/metal_box_impact_hard%i.wav", GetRandomInt(1, 3)); EmitSoundToAll(sound, ent); procent_dziala[owner] += 4; PrintCenterText(attacker, "Zbudowano %i%", procent_dziala[owner]); } } return Plugin_Handled; } Format(sound, sizeof(sound), "physics/metal/metal_box_impact_bullet%i.wav", GetRandomInt(1, 3)); EmitSoundToAll(sound, ent); if (damage > float(GetEntProp(ent, Prop_Data, "m_iHealth"))) StopDzialo(owner, 0); return Plugin_Continue; } public Action:OdrodzenieGracza(Handle:event, String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid", 0)); if (!IsValidClient(client) || !ma_klase[client]) return Plugin_Continue; StopDzialo(client, 1); return Plugin_Continue; } public Action:StartDzialo(ent, client) { uzyta_klasa[client][1] = CreateEntityByName("hegrenade_projectile"); if(uzyta_klasa[client][1] != -1) { if (!cod_get_user_intelligence(client, 1, 0, 0)) PrintCenterText(client, "Aby wzmocnic moc swojej klasy, zwieksz inteligencje!"); new Float:forigin[3]; GetEntPropVector(ent, Prop_Send, "m_vecOrigin", forigin); forigin[2] += 15.0; new Float:iangles[3]; GetEntPropVector(ent, Prop_Data, "m_angRotation", iangles); DispatchSpawn(uzyta_klasa[client][1]); ActivateEntity(uzyta_klasa[client][1]); SetEntityModel(uzyta_klasa[client][1], "models/props_combine/bunker_gun01.mdl"); SetEntityMoveType(uzyta_klasa[client][1], MOVETYPE_FLY); TeleportEntity(uzyta_klasa[client][1], forigin, iangles, NULL_VECTOR); SetEntProp(uzyta_klasa[client][1], Prop_Data, "m_takedamage", 2); SetEntProp(uzyta_klasa[client][1], Prop_Data, "m_iHealth", 200+RoundFloat(cod_get_user_maks_intelligence(client)*1.0)); SetEntProp(uzyta_klasa[client][1], Prop_Send, "m_usSolidFlags", 12); SetEntProp(uzyta_klasa[client][1], Prop_Data, "m_nSolidType", 6); SetEntProp(uzyta_klasa[client][1], Prop_Send, "m_CollisionGroup", 1); SetEntPropEnt(uzyta_klasa[client][1], Prop_Send, "m_hOwnerEntity", client); SDKHook(uzyta_klasa[client][1], SDKHook_OnTakeDamage, TakeDamage); CreateTimer(2.5, ThinkGun, EntIndexToEntRef(uzyta_klasa[client][1]), TIMER_FLAG_NO_MAPCHANGE); EmitSoundToAll("vehicles/tank_readyfire1.wav", uzyta_klasa[client][1]); } return Plugin_Continue; } public Action:StopDzialo(client, reset) { if (uzyta_klasa[client][0] > 0 && IsValidEntity(uzyta_klasa[client][0])) AcceptEntityInput(uzyta_klasa[client][0], "Kill"); if (uzyta_klasa[client][1] > 0 && IsValidEntity(uzyta_klasa[client][1])) AcceptEntityInput(uzyta_klasa[client][1], "Kill"); uzyta_klasa[client][0] = reset? -1: 0; uzyta_klasa[client][1] = reset? -1: 0; return Plugin_Continue; } public Action:ThinkGun(Handle:timer, any:ref) { new ent = EntRefToEntIndex(ref); if (ent == -1 || !IsValidEntity(ent)) return Plugin_Continue; new client = GetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity"); if (!IsValidClient(client) || !IsValidEntity(uzyta_klasa[client][0])) { AcceptEntityInput(ent, "Kill"); return Plugin_Continue; } new Float:forigin[3]; GetEntPropVector(ent, Prop_Send, "m_vecOrigin", forigin); new target = sentry_find_player(client, ent, forigin); if (target) { new Float:iorigin[3]; GetClientEyePosition(target, iorigin); new Float:iangles[3]; GetEntPropVector(ent, Prop_Data, "m_angRotation", iangles); new Float:x = iorigin[0] - forigin[0]; new Float:z = iorigin[1] - forigin[1]; new Float:radians = ArcTangent(z / x); iangles[1] = radians * 180.0 / 3.14159; if (iorigin[0] < forigin[0]) iangles[1] -= 180.0; TeleportEntity(ent, NULL_VECTOR, iangles, NULL_VECTOR); forigin[2] += 10.0; iorigin[0] = iorigin[0] + GetRandomFloat(-16.0, 16.0); iorigin[1] += GetRandomFloat(-16.0, 16.0); iorigin[2] += GetRandomFloat(-16.0, 16.0); new Float:fdistance = GetVectorDistance(forigin, iorigin, false); new Float:fpercent = 0.4 / fdistance / 100.0; new Float:fdifference[3]; fdifference[0] = forigin[0] + iorigin[0] - forigin[0] * fpercent; fdifference[1] = forigin[1] + iorigin[1] - forigin[1] * fpercent - 0.08; fdifference[2] = forigin[2] + iorigin[2] - forigin[2] * fpercent; StworzSprite(fdifference, iorigin, 2500.0); EmitSoundToAll("weapons/smg1/smg1_fire1.wav", ent); static itemid[2]; if(!itemid[0]) itemid[0] = cod_get_itemid("Plaszcz Predatora"); if(!itemid[1]) itemid[1] = cod_get_itemid("Nano Kevlar"); if(cod_get_user_item(target) == itemid[0] && cod_get_user_item(client) != itemid[1]) cod_inflict_damage(target, client, 4+RoundFloat(cod_get_user_maks_intelligence(client)*0.02), ""); } CreateTimer(0.4, ThinkGun, EntIndexToEntRef(ent), TIMER_FLAG_NO_MAPCHANGE); return Plugin_Continue; } public Action:StworzSprite(Float:origin[3], Float:dest[3], Float:speed) { new ent = CreateEntityByName("env_spritetrail"); if (ent != -1) { DispatchKeyValue(ent, "classname", "bullet_trace"); DispatchKeyValue(ent, "spritename", "materials/sprites/laser.vmt"); DispatchKeyValue(ent, "renderamt", "255"); DispatchKeyValue(ent, "rendercolor", "255 255 255"); DispatchKeyValue(ent, "rendermode", "5"); DispatchKeyValueFloat(ent, "startwidth", 5.0); DispatchKeyValueFloat(ent, "endwidth", 2.0); DispatchKeyValueFloat(ent, "lifetime", 240.0 / speed); DispatchSpawn(ent); SetEntPropFloat(ent, Prop_Send, "m_flTextureRes", 0.05, 0); new Float:vecVeloc[3]; MakeVectorFromPoints(origin, dest, vecVeloc); new Float:angRotation[3]; GetVectorAngles(vecVeloc, angRotation); NormalizeVector(vecVeloc, vecVeloc); ScaleVector(vecVeloc, speed); TeleportEntity(ent, origin, angRotation, vecVeloc); new String:tmp[128]; FormatEx(tmp, sizeof(tmp), "OnUser1 !self:kill::%f:-1", GetVectorDistance(origin, dest, false) / speed); SetVariantString(tmp); AcceptEntityInput(ent, "AddOutput"); AcceptEntityInput(ent, "FireUser1"); } return Plugin_Continue; } public sentry_find_player(client, ent, Float:forigin[3]) { new Float:iorigin[3], Float:idistance, Float:fdistance = 5000.0; new target, hit; for(new i = 1; i <= MaxClients; i ++) { if (!IsClientInGame(i) || !IsPlayerAlive(i)) continue; if (GetClientTeam(client) == GetClientTeam(i)) continue; GetClientAbsOrigin(i, iorigin); new Handle:trace = TR_TraceRayFilterEx(forigin, iorigin, 24705, RayType_EndPoint, TraceEntityFilterPlayer, ent); if (TR_DidHit(trace)) hit = TR_GetEntityIndex(trace); CloseHandle(trace); if (i == hit) { idistance = GetVectorDistance(forigin, iorigin, false); if (fdistance > idistance) { fdistance = idistance; target = i; } } } return target; } public bool:TraceEntityFilterPlayer(ent, contents, any:data) { return ent != data; }