#include #include #include #include #include new ModelWeapon[] = "models/p_glock18.mdl" new ModelWeaponID new CheckVisibilityForward = 0; new Models[CsTeams][] = { "", "models/player/leet/leet.mdl", "models/player/sas/sas.mdl", "" } new ModelsIDs[CsTeams] new CurrentEnt new const Plugin[] = "Lucia Hallucination" new const Author[] = "joaquimandrade" new const Version[] = "1.0" enum EntityData { Origin[3], Angles[3], CsTeams:Team } const MaxSlots = 32 new UserEntityData[MaxSlots+1][EntityData] new Float:LastTimeViewedAnEntity[MaxSlots+1] const PermissionFlag = ADMIN_BAN new CurrentHost; new Float:VectorNormalHideStartFactor = 46.0 new Float:VectorNormalHideEndFactor = 40.0 new Float:VectorNormalHideStep = 1.0 new const Float:PlayerRay = 22.0 new const Float:HullFactor = 0.5 const Float:PlayerHideMaxDistance = 1200.0 new CsTeams:Teams = CS_TEAM_T + CS_TEAM_CT new OnFirstPersonViewN new ForwardAddToFullPackPre new ForwardAddToFullPackPost new bool:obserwowany[33]; public plugin_precache() { ModelWeaponID = precache_model(ModelWeapon) ModelsIDs[CS_TEAM_T] = precache_model(Models[CS_TEAM_T]) ModelsIDs[CS_TEAM_CT] = precache_model(Models[CS_TEAM_CT]) } public plugin_init() { register_plugin(Plugin,Version,Author) register_cvar("luciaHallucination",Version,FCVAR_SERVER|FCVAR_SPONLY); register_event("CurWeapon","CurWeapon","be", "1=1") } public addToFullPackPre(es, e, ent, host, hostflags, player, pSet) { if(player && (host != ent) && is_user_alive(ent)) { if(LastTimeViewedAnEntity[host] != get_gametime() && is_user_alive(host) && obserwowany[host] && cs_get_user_team(host) != cs_get_user_team(ent)) { if(!engfunc(EngFunc_CheckVisibility, ent, pSet)) { CurrentEnt = ent CurrentHost = host if(!CheckVisibilityForward) { CheckVisibilityForward = register_forward(FM_CheckVisibility,"checkVisibility") } } } } } public checkVisibility(id,pset) { if(CurrentEnt == id) { unregister_forward(FM_CheckVisibility,CheckVisibilityForward) CheckVisibilityForward = 0 forward_return(FMV_CELL,1) return FMRES_SUPERCEDE } return FMRES_IGNORED } public addToFullPackPost(es, e, ent, host, hostflags, player, pSet) { if((host == CurrentHost) && (ent == CurrentEnt)) { LastTimeViewedAnEntity[CurrentHost] = get_gametime(); new CsTeams:team new spectated = host team = UserEntityData[spectated][Team] set_es(es,ES_Origin,Float:UserEntityData[host][Origin]); set_es(es,ES_Angles,Float:UserEntityData[spectated][Angles]); set_es(es,ES_RenderMode,kRenderTransAlpha); set_es(es,ES_RenderAmt,170); new CsTeams:enemyTeam = Teams - team set_es(es,ES_Team,_:enemyTeam); set_es(es,ES_ModelIndex,ModelsIDs[enemyTeam]); set_es(es,ES_WeaponModel,ModelWeaponID); set_es(es,ES_Effects,EF_INVLIGHT); } CurrentHost = CurrentEnt = 0 } public DodajemyGracza(id) { if(is_user_alive(id)){ obserwowany[id] = true; remove_task(id); set_task(5.0, "PobierajOriginGracza", id, _,_, "b"); if(!OnFirstPersonViewN++) { ForwardAddToFullPackPre = register_forward(FM_AddToFullPack,"addToFullPackPre",0); ForwardAddToFullPackPost = register_forward(FM_AddToFullPack,"addToFullPackPost",1) } getEntityData(id); } else set_task(6.0, "DodajemyGracza", id); } UsuwamyGracza(id) { obserwowany[id] = false; remove_task(id); if(!--OnFirstPersonViewN) { unregister_forward(FM_AddToFullPack,ForwardAddToFullPackPre) unregister_forward(FM_AddToFullPack,ForwardAddToFullPackPost,1) } } public client_disconnect(id){ if(obserwowany[id]) UsuwamyGracza(id); remove_task(id); } public client_putinserver(id){ set_task(6.0, "DodajemyGracza", id); // Wiem ze da to wszystkim graczom, ale i tak to jest tylko do testow i tylko ja jestem i boty na serwerze :D } hullCheck(Float:origin[3]) { static Float:margin[3] xs_vec_copy(origin,margin) for(new i=0;i<3;i++) margin[i] += HullFactor engfunc(EngFunc_TraceHull,origin,margin,1,HULL_POINT,0,0) return get_tr2(0,TR_AllSolid) } bool:isSafeHideOrigin(Float:origin[3]) { static Float:centerPointsZDistanceMultiply[] = {1.2,0.5,0.0,-0.5,-1.0,-1.5} static Float:centerPoints[sizeof centerPointsZDistanceMultiply][3] for(new i=0;i=VectorNormalHideEndFactor;i-=VectorNormalHideStep) { xs_vec_mul_scalar(normal,-i,normalPath) xs_vec_add(end,normalPath,normalPath) if(isSafeHideOrigin(normalPath)) { static Float:angles[3] vector_to_angle(normal,angles) if(angles[0] > 0.0) angles[0] = 0.0 xs_vec_copy(angles,Float:UserEntityData[id][Angles]) xs_vec_copy(normalPath,Float:UserEntityData[id][Origin]) UserEntityData[id][Team] = _:cs_get_user_team(id) return true } } } return false } getEntityData2(id) { static Float:origin[3],Float:viewAngles[3],Float:viewOfs[3] pev(id,pev_origin,origin) pev(id,pev_view_ofs,viewOfs) xs_vec_add(origin,viewOfs,origin) pev(id,pev_v_angle,viewAngles) static Float:path[3] angle_vector(viewAngles,ANGLEVECTOR_FORWARD,path) xs_vec_normalize(path,path) xs_vec_mul_scalar(path,PlayerHideMaxDistance,path) static Float:end[3] xs_vec_add(origin,path,end) engfunc(EngFunc_TraceLine,origin,end,0,id,0); static Float:fraction get_tr2(0,TR_flFraction,fraction) if((fraction != 1.0) && (get_tr2(0,TR_Hit) == -1)) { get_tr2(0,TR_EndPos,end) static Float:normal[3] get_tr2(0,TR_vecPlaneNormal,normal) static Float:normalPath[3] for(new Float:i=VectorNormalHideStartFactor;i>=VectorNormalHideEndFactor;i-=VectorNormalHideStep) { xs_vec_mul_scalar(normal,-i,normalPath) xs_vec_add(end,normalPath,normalPath) if(isSafeHideOrigin(normalPath)) { xs_vec_copy(normalPath,Float:UserEntityData[id][Origin]) return true } } } return false } public PobierajOriginGracza(id){ if(is_user_alive(id)) getEntityData2(id); } public CurWeapon(id) { if(!obserwowany[id]) return; if(!is_user_alive(id)) return; new wid = read_data(2); if(wid == CSW_KNIFE || wid == CSW_HEGRENADE || wid == CSW_SMOKEGRENADE || wid == CSW_FLASHBANG) return; if(get_user_button(id) & IN_ATTACK){ // XX // UserEntityData[id][Origin] - origin es (bytu [gracza] ktory jest w scianie) } }