#pragma semicolon 1 #include #include #include #define PLUGIN_NAME "HGRP" #define PLUGIN_VERS "1.2" #define PLUGIN_AUTH "PurposeLess" //************************ Burayi Kendinize Gore Ayarlayin ************************/ /* Eger adminlerin kullanmasini istiyorsaniz burada kullanacak adminin yetkisini ayarlayin. */ #define HOOK_YETKI ADMIN_CVAR #define GRAB_YETKI ADMIN_CVAR #define ROPE_YETKI ADMIN_CVAR #define POWER1_YETKI ADMIN_CVAR /* Eger dokunulmazlarin grablanmasini istiyorsaniz #define DONT_GRAB_IMMUNITY onune // isaretini koyunuz. */ //#define DONT_GRAB_IMMUNITY /* Eger hook rengini rengarenk istiyorsaniz #define RENKLI_HOOK onundeki // isaretini silin. */ //#define RENKLI_HOOK /* Eger Hook-Grab-Rope sesi istemiyorsaniz #define HOOKGRABROPEPOWER1_SOUNDS onune // isaretini koyun. */ #define HOOKGRABROPEPOWER1_SOUNDS /* Burada sadece ses dosyalarinin ismini degistirin. */ #if defined HOOKGRABROPEPOWER1_SOUNDS new const sesdosyalari[][] = { "weapons/xbow_hit2.wav", // hook sesi "weapons/xbow_fire1.wav", // grab sesi "weapons/xbow_hit2.wav", // rope sesi "bullchicken/bc_bite2.wav" // power1 sesi }; #endif //*********************************************************************************/ enum (+= 1000) { TASKID_HOOK = 1000, TASKID_GRAB, TASKID_ROPE, TASKID_POWER1 }; new bool:hook[MAX_CLIENTS + 1], grab[MAX_CLIENTS + 1], bool:rope[MAX_CLIENTS + 1], bool:power1[MAX_CLIENTS + 1], Float:power1_location[MAX_CLIENTS + 1][3], Float:power1_length[MAX_CLIENTS + 1], Float:power1_created[MAX_CLIENTS + 1], Float:hook_to[MAX_CLIENTS + 1][3], Float:rope_to[MAX_CLIENTS + 1][3], Float:grab_totaldis[MAX_CLIENTS + 1], Float:rope_totaldis[MAX_CLIENTS + 1], Float:hook_speed, Float:grab_speed, Float:rope_speed, Float:power1_speed, hook_usage, grab_usage, rope_usage, power1_usage, Float:power1_moveacc, bool:power1_hookstyle, sv_gravity, dot, zbeam4; public plugin_init() { register_plugin(PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH); register_clcmd("+hook", "@hook_on"); register_clcmd("+grab", "@grab_on"); register_clcmd("+rope", "@rope_on"); register_clcmd("+power1", "@power1_on"); register_clcmd("-hook", "@hook_off"); register_clcmd("-grab", "@grab_off"); register_clcmd("-rope", "@rope_off"); register_clcmd("-power1", "@power1_off"); bind_pcvar_float(create_cvar("hook_speed", "5", _, _, true, 0.0, true, 20.0), hook_speed); bind_pcvar_float(create_cvar("grab_speed", "5", _, _, true, 0.0, true, 20.0), grab_speed); bind_pcvar_float(create_cvar("rope_speed", "5", _, _, true, 0.0, true, 20.0), rope_speed); bind_pcvar_float(create_cvar("power1_speed", "400", _, _, true, 0.0, true, 800.0), power1_speed); bind_pcvar_num(create_cvar("hook_usage", "1", _, _, true, 0.0, true, 9.0), hook_usage); bind_pcvar_num(create_cvar("grab_usage", "1", _, _, true, 0.0, true, 9.0), grab_usage); bind_pcvar_num(create_cvar("rope_usage", "1", _, _, true, 0.0, true, 9.0), rope_usage); bind_pcvar_num(create_cvar("power1_usage", "1", _, _, true, 0.0, true, 9.0), power1_usage); bind_pcvar_num(create_cvar("power1_hookstyle", "1", _, _, true, 0.0, true, 1.0), power1_hookstyle); bind_pcvar_num(create_cvar("power1_moveacc", "140", _, _, true, 0.0), power1_moveacc); sv_gravity = get_cvar_pointer("sv_gravity"); RegisterHookChain(RG_CBasePlayer_Spawn, "@CBasePlayer_Spawn", .post=false); } public plugin_precache() { dot = precache_model("sprites/dot.spr"); zbeam4 = precache_model("sprites/zbeam4.spr"); #if defined HOOKGRABROPEPOWER1_SOUNDS for(new i=0; i < sizeof(sesdosyalari); i++) { precache_sound(sesdosyalari[i]); } #endif } @CBasePlayer_Spawn(const id) { hook[id] = false; grab[id] = false; rope[id] = false; power1[id] = false; } @hook_on(const id) { if(!is_continue(id, hook_usage, HOOK_YETKI) || hook[id]) { return PLUGIN_HANDLED; } set_entvar(id, var_gravity, 0.0); set_task(0.1, "@hook_prethink", id + TASKID_HOOK, .flags = "b"); hook[id] = true; hook_to[id][0] = 999999.0; @hook_prethink(id + TASKID_HOOK); #if defined HOOKGRABROPEPOWER1_SOUNDS rh_emit_sound2(id, 0, CHAN_AUTO, sesdosyalari[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM); #endif return PLUGIN_HANDLED; } @hook_off(const id) { if(!hook[id]) { return PLUGIN_HANDLED; } if(is_user_alive(id)) { set_entvar(id, var_gravity, 1.0); } hook[id] = false; return PLUGIN_HANDLED; } @hook_prethink(TaskId) { new id = TaskId - TASKID_HOOK; if(!is_continue(id, hook_usage, HOOK_YETKI)) { hook[id] = false; } if(!hook[id]) { remove_task(id + TASKID_HOOK); return; } if(hook_to[id][0] == 999999) { static origin2[3], Float:origin2_f[3]; get_user_origin(id, origin2, 3); xs_vec_set_float(origin2, origin2_f); xs_vec_copy(origin2_f, hook_to[id]); } #if defined RENKLI_HOOK static rgb[3]; choose_random(rgb); create_message(id, hook_to[id], rgb[0], rgb[1], rgb[2], true); #else create_message(id, hook_to[id], 0, 0, 255, true); #endif static Float:origin1_f[3]; get_entvar(id, var_origin, origin1_f); static Float:velocity[3]; xs_vec_sub_scaled_fix(hook_to[id], origin1_f, 3.0, velocity); static Float:y; y = velocity[0] * velocity[0] + velocity[1] * velocity[1] + velocity[2] * velocity[2]; static Float:x; x = (hook_speed * 120.0)/ floatsqroot(y); xs_vec_mul_scalar(velocity, x, velocity); set_entvar(id, var_velocity, velocity); } #if defined RENKLI_HOOK choose_random(rgb[3]) { rgb[0] = random(255); rgb[1] = random(255); rgb[2] = random(255); if(rgb[0] < 50 && rgb[1] < 50 && rgb[2] < 50) { rgb[random(2)] = random_num(150,255); } } #endif @grab_on(const id) { if(!is_continue(id, grab_usage, GRAB_YETKI) || grab[id]) { return PLUGIN_HANDLED; } new Uid; get_user_aiming(id, Uid); if(is_user_alive(Uid)) { #if defined DONT_GRAB_IMMUNITY if(get_user_flags(Uid) & ADMIN_IMMUNITY) { return PLUGIN_HANDLED; } #endif @grabem(id, Uid); } return PLUGIN_HANDLED; } @grabem(const id, const Uid) { grab[id] = Uid; set_entvar(Uid, var_gravity, 0.0); rg_set_user_rendering(Uid, kRenderFxGlowShell, {255.0,0.0,0.0}, kRenderTransAlpha, 70.0); grab_totaldis[id] = 0.0; set_task(0.1, "@grab_prethink", id+TASKID_GRAB, .flags = "b"); @grab_prethink(id+TASKID_GRAB); #if defined HOOKGRABROPEPOWER1_SOUNDS rh_emit_sound2(id, 0, CHAN_VOICE, sesdosyalari[1], 1.0, ATTN_NORM, 0, PITCH_NORM); #endif } @grab_off(const id) { if(grab[id]) { if(is_user_alive(grab[id])) { rg_set_user_rendering(grab[id], kRenderFxNone, {255.0,255.0,255.0}, kRenderNormal, 16.0); set_entvar(grab[id], var_gravity, 1.0); } grab[id] = 0; } return PLUGIN_HANDLED; } @grab_prethink(TaskId) { new id = TaskId - TASKID_GRAB; if(!is_continue(id, grab_usage, GRAB_YETKI)) { if(is_user_alive(grab[id])) { rg_set_user_rendering(grab[id], kRenderFxNone, {255.0,255.0,255.0}, kRenderNormal, 16.0); set_entvar(grab[id], var_gravity, 1.0); } grab[id] = 0; } if(!grab[id]) { remove_task(id + TASKID_GRAB); return; } static Float:origin2_f[3]; get_entvar(grab[id], var_origin, origin2_f); create_message(id, origin2_f, 255, 0, 0); static Float:origin1_f[3], Float:distance[3]; get_entvar(id, var_origin, origin1_f); if(!grab_totaldis[id]) { xs_vec_set_floatabs(origin1_f, origin2_f, distance); grab_totaldis[id] = xs_vec_dot_sqroot(distance); } static origin3[3], Float:origin3_f[3]; get_user_origin(id, origin3, 3); xs_vec_set_float(origin3, origin3_f); xs_vec_sub(origin3_f, origin1_f, distance); static Float:grab_totaldis2; grab_totaldis2 = xs_vec_dot_sqroot(distance); static Float:que; que = grab_totaldis[id] / grab_totaldis2; static Float:origin4[3]; origin4[0] = (distance[0] * que) + origin1_f[0]; origin4[1] = (distance[1] * que) + origin1_f[1]; origin4[2] = (distance[2] * que) + origin1_f[2]; static Float:velocity[3]; velocity[0] = (origin4[0] - origin2_f[0]) * (grab_speed / 1.666667); velocity[1] = (origin4[1] - origin2_f[1]) * (grab_speed / 1.666667); velocity[2] = (origin4[2] - origin2_f[2]) * (grab_speed / 1.666667); set_entvar(grab[id], var_velocity, velocity); } @rope_on(const id) { if(!is_continue(id, rope_usage, ROPE_YETKI) || rope[id]) { return PLUGIN_HANDLED; } set_task(0.1,"@rope_prethink",id + TASKID_ROPE, .flags = "b"); rope[id] = true; rope_to[id][0] = 999999.0; @rope_prethink(id + TASKID_ROPE); #if defined HOOKGRABROPEPOWER1_SOUNDS rh_emit_sound2(id, 0, CHAN_VOICE, sesdosyalari[2], 1.0, ATTN_NORM, 0, PITCH_NORM); #endif return PLUGIN_HANDLED; } @rope_off(const id) { if(!rope[id]) { return PLUGIN_HANDLED; } rope[id] = false; return PLUGIN_HANDLED; } @rope_prethink(TaskId) { new id = TaskId - TASKID_ROPE; if(!is_continue(id, rope_usage, ROPE_YETKI)) { rope[id] = false; } if(!rope[id]) { remove_task(id + TASKID_ROPE); return; } static Float:origin1[3]; get_entvar(id, var_origin, origin1); if(rope_to[id][0]== 999999.0) { static origin2[3]; get_user_origin(id,origin2,3); xs_vec_set_float(origin2, rope_to[id]); static Float:distance[3]; xs_vec_set_floatabs(origin1, rope_to[id], distance); rope_totaldis[id] = xs_vec_dot_sqroot(distance); } create_message(id, rope_to[id], 0, 255, 0); static Float:velocity[3]; get_entvar(id, var_velocity, velocity); static Float:velocity2[3]; velocity2[0] = (rope_to[id][0] - origin1[0]) * 3.0; velocity2[1] = (rope_to[id][1] - origin1[1]) * 3.0; static Float:y; y = velocity2[0] * velocity2[0] + velocity2[1] * velocity2[1]; static Float:x; x = (rope_speed * 20.0) / floatsqroot(y); velocity[0] += velocity2[0] * x; velocity[1] += velocity2[1] * x; if(rope_to[id][2] - origin1[2] >= rope_totaldis[id] && velocity[2] < 0.0) { velocity[2] *= -1; } set_entvar(id, var_velocity, velocity); } @power1_on(const id) { if(!is_continue(id, power1_usage, POWER1_YETKI) || power1[id]) { return PLUGIN_HANDLED; } new Float:origin[3], location[3]; get_entvar(id, var_origin, origin); get_user_origin(id, location, 3); xs_vec_set_float(location, power1_location[id]); power1_length[id] = get_distance_f(power1_location[id], origin); set_entvar(id, var_gravity, 0.001); power1[id] = true; beamentpoint(id); set_task(0.1, "@power1_prethink", id + TASKID_POWER1, .flags = "b"); #if defined HOOKGRABROPEPOWER1_SOUNDS rh_emit_sound2(id, 0, CHAN_STATIC, sesdosyalari[3], 1.0, ATTN_NORM, 0, PITCH_NORM); #endif return PLUGIN_HANDLED; } @power1_off(const id) { if(!power1[id]) { return PLUGIN_HANDLED; } if(is_user_alive(id)) { set_entvar(id, var_gravity, 1.0); killbeam(id); remove_task(id + TASKID_POWER1); } power1[id] = false; return PLUGIN_HANDLED; } @power1_prethink(TaskId) { new id = TaskId - TASKID_POWER1; if(!is_continue(id, power1_usage, POWER1_YETKI)) { power1[id] = false; } if(!power1[id]) { remove_task(id + TASKID_POWER1); return; } if(power1_created[id] + 100/10 <= get_gametime()) { beamentpoint(id); } static Float:origin[3], Float:velocity[3], Float:user_direction[3], Float:move_direction[3], Float:vTowards_A, Float:DvTowards_A, Float:acceleration, Float:aDistance, Float:A[3], Float:D[3], Float:buttonadjust[3], Float:null[3], origin2[3], buttonpress; get_entvar(id, var_origin, origin); get_entvar(id, var_velocity, velocity); get_user_origin(id, origin2, charsmax(origin2)); buttonpress = get_entvar(id, var_button); switch(buttonpress) { case IN_FORWARD: buttonadjust[0]++; case IN_BACK: buttonadjust[0]--; case IN_MOVERIGHT: buttonadjust[1]++; case IN_MOVELEFT: buttonadjust[1]--; case IN_JUMP: buttonadjust[2]++; case IN_DUCK: buttonadjust[2]--; } if(buttonadjust[0] || buttonadjust[1]) { user_direction[0] = origin2[0] - origin[0]; user_direction[1] = origin2[1] - origin[1]; move_direction[0] = buttonadjust[0] * user_direction[0] + user_direction[1] * buttonadjust[1]; move_direction[1] = buttonadjust[0] * user_direction[1] - user_direction[0] * buttonadjust[1]; move_direction[2] = 0.0; velocity[0] += move_direction[0] * power1_moveacc * 0.1 / get_distance_f(null, move_direction); velocity[1] += move_direction[1] * power1_moveacc * 0.1 / get_distance_f(null, move_direction); } if(buttonadjust[2] < 0 || (buttonadjust[2] && power1_length[id] >= 60)) { power1_length[id] -= buttonadjust[2] * power1_speed * 0.1; } else if (power1_hookstyle && !(buttonpress&IN_DUCK) && power1_length[id] >= 200) { buttonadjust[2]++; power1_length[id] -= buttonadjust[2] * power1_speed * 0.1; } arrayset(buttonadjust, 0, sizeof buttonadjust); xs_vec_sub(power1_location[id], origin, A); D[0] = A[0] * A[2] / get_distance_f(null, A); D[1] = A[1] * A[2] / get_distance_f(null, A); D[2] = -(A[1] * A[1] + A[0] * A[0]) / get_distance_f(null, A); aDistance = get_distance_f(null,D) ? get_distance_f(null,D) : 1.0; acceleration = (-get_pcvar_num(sv_gravity)) * D[2] / aDistance; vTowards_A = (velocity[0] * A[0] + velocity[1] * A[1] + velocity[2] * A[2]) / get_distance_f(null, A); DvTowards_A = (get_distance_f(origin, power1_location[id]) - power1_length[id]) * 4; if(get_distance_f(null,D) > 10) { velocity[0] += (acceleration * 0.1 * D[0]) / get_distance_f(null, D); velocity[1] += (acceleration * 0.1 * D[1]) / get_distance_f(null, D); velocity[2] += (acceleration * 0.1 * D[2]) / get_distance_f(null, D); } velocity[0] += ((DvTowards_A - vTowards_A) * A[0]) / get_distance_f(null, A); velocity[1] += ((DvTowards_A - vTowards_A) * A[1]) / get_distance_f(null, A); velocity[2] += ((DvTowards_A - vTowards_A) * A[2]) / get_distance_f(null, A); set_entvar(id, var_velocity, velocity); } rg_set_user_rendering(const id, const fx, const {Float,_}:color[3], const render, const Float:amount) { set_entvar(id, var_renderfx, fx); set_entvar(id, var_rendercolor, color); set_entvar(id, var_rendermode, render); set_entvar(id, var_renderamt, amount); } bool:is_continue(const id, const usage, const flag) { if(!is_user_alive(id)) { return false; } switch(usage) { case 1: { return bool:(get_member(id, m_iTeam) == TEAM_CT); } case 2: { return bool:(get_member(id, m_iTeam) == TEAM_CT && get_entvar(id, var_takedamage) == DAMAGE_NO); } case 3: { return bool:((get_member(id, m_iTeam) == TEAM_CT || get_user_flags(id) & flag)); } case 4: { return bool:((get_member(id, m_iTeam) == TEAM_CT && get_entvar(id, var_takedamage) == DAMAGE_NO) || get_user_flags(id) & flag); } case 5: { return bool:(get_member(id, m_iTeam) == TEAM_CT && get_user_flags(id) & flag); } case 6: { return bool:(get_member(id, m_iTeam) == TEAM_CT && get_entvar(id, var_takedamage) == DAMAGE_NO && get_user_flags(id) & flag); } case 7: { return bool:(get_entvar(id, var_takedamage) == DAMAGE_NO); } case 8: { return bool:(get_user_flags(id) & flag); } case 9: { return true; } } return false; } xs_vec_set_float(const in[], Float:out[]) { out[0] = float(in[0]); out[1] = float(in[1]); out[2] = float(in[2]); } xs_vec_set_floatabs(const Float:in1[], const Float:in2[], Float:out[]) { out[0] = floatabs(in1[0] - in2[0]); out[1] = floatabs(in1[1] - in2[1]); out[2] = floatabs(in1[2] - in2[2]); } xs_vec_sub_scaled_fix(const Float:in1[], const Float:in2[], Float:scalar, Float:out[]) { out[0] = (in1[0] - in2[0]) * scalar; out[1] = (in1[1] - in2[1]) * scalar; out[2] = (in1[2] - in2[2]) * scalar; } Float:xs_vec_dot_sqroot(const Float:vec[]) { return floatsqroot(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); } create_message(const id, const Float:coord[3], const R, const G, const B, bool:hook = false) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY); write_byte(1); write_short(id); write_coord_f(coord[0]); write_coord_f(coord[1]); write_coord_f(coord[2]); write_short(dot); write_byte(1); write_byte(1); write_byte(hook ? 2 : 1); write_byte(5); write_byte(0); write_byte(R); write_byte(G); write_byte(B); write_byte(200); write_byte(0); message_end(); } beamentpoint(const id) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY); write_byte(TE_BEAMENTPOINT); write_short(id); write_coord_f(power1_location[id][0]); write_coord_f(power1_location[id][1]); write_coord_f(power1_location[id][2]); write_short(zbeam4); write_byte(0); write_byte(0); write_byte(100); write_byte(10); write_byte(0); write_byte(255); write_byte(255); write_byte(255); write_byte(150); write_byte(0); message_end(); power1_created[id] = get_gametime(); } killbeam(id) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY); write_byte(TE_KILLBEAM); write_short(id); message_end(); }