/* Plugin generated by AMXX-Studio */ #include #include #include #include #include #include #define PLUGIN "Flara" #define VERSION "1.0" #define AUTHOR "Jagoda" const NADE_TYPE_FLARE = 4444 const PEV_FLARE_COLOR = pev_punchangle const PEV_FLARE_DURATION = pev_flSwimTime const PEV_NADE_TYPE = pev_flTimeStepSound new model_grenade_flare[64] new Array:grenade_flare new cvar_flareduration, cvar_flarecolor, cvar_flaregrenades, cvar_flaresize public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_forward(FM_SetModel, "fw_SetModel") RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade") } public plugin_precache() { grenade_flare = ArrayCreate(64, 1) engfunc(EngFunc_PrecacheModel, model_grenade_flare) new i, buffer[100] for (i = 0; i < ArraySize(grenade_flare); i++) { ArrayGetString(grenade_flare, i, buffer, charsmax(buffer)) engfunc(EngFunc_PrecacheSound, buffer) } cvar_flaregrenades = register_cvar("zp_flare_grenades","1") cvar_flareduration = register_cvar("zp_flare_duration", "60") cvar_flaresize = register_cvar("zp_flare_size", "25") cvar_flarecolor = register_cvar("zp_flare_color", "0") } public fw_SetModel(entity, const model[]) { if (model[9] == 's' && model[10] == 'm' && get_pcvar_num(cvar_flaregrenades)) // Flare { // Build flare's color static rgb[3] switch (get_pcvar_num(cvar_flarecolor)) { case 0: // white { rgb[0] = 255 // r rgb[1] = 255 // g rgb[2] = 255 // b } case 1: // red { rgb[0] = random_num(50,255) // r rgb[1] = 0 // g rgb[2] = 0 // b } case 2: // green { rgb[0] = 0 // r rgb[1] = random_num(50,255) // g rgb[2] = 0 // b } case 3: // blue { rgb[0] = 0 // r rgb[1] = 0 // g rgb[2] = random_num(50,255) // b } case 4: // random (all colors) { rgb[0] = random_num(50,200) // r rgb[1] = random_num(50,200) // g rgb[2] = random_num(50,200) // b } case 5: // random (r,g,b) { switch (random_num(1, 3)) { case 1: // red { rgb[0] = random_num(50,255) // r rgb[1] = 0 // g rgb[2] = 0 // b } case 2: // green { rgb[0] = 0 // r rgb[1] = random_num(50,255) // g rgb[2] = 0 // b } case 3: // blue { rgb[0] = 0 // r rgb[1] = 0 // g rgb[2] = random_num(50,255) // b } } } } set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_FLARE) set_pev(entity, PEV_FLARE_COLOR, rgb) } } public fw_ThinkGrenade(entity) { // Invalid entity if (!pev_valid(entity)) return HAM_IGNORED; // Get damage time of grenade static Float:dmgtime, Float:current_time pev(entity, pev_dmgtime, dmgtime) current_time = get_gametime() // Check if it's time to go off if (dmgtime > current_time) return HAM_IGNORED; // Check if it's one of our custom nades switch (pev(entity, PEV_NADE_TYPE)) { case NADE_TYPE_FLARE: // Flare { // Get its duration static duration duration = pev(entity, PEV_FLARE_DURATION) // Already went off, do lighting loop for the duration of PEV_FLARE_DURATION if (duration > 0) { // Check whether this is the last loop if (duration == 1) { // Get rid of the flare entity engfunc(EngFunc_RemoveEntity, entity) return HAM_SUPERCEDE; } // Light it up! flare_lighting(entity, duration) // Set time for next loop set_pev(entity, PEV_FLARE_DURATION, --duration) set_pev(entity, pev_dmgtime, current_time + 5.0) } // Light up when it's stopped on ground else if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10) { // Flare sound static sound[64] ArrayGetString(grenade_flare, random_num(0, ArraySize(grenade_flare) - 1), sound, charsmax(sound)) emit_sound(entity, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM) // Set duration and start lightning loop on next think set_pev(entity, PEV_FLARE_DURATION, 1 + get_pcvar_num(cvar_flareduration)/5) set_pev(entity, pev_dmgtime, current_time + 0.1) } else { // Delay explosion until we hit ground set_pev(entity, pev_dmgtime, current_time + 0.5) } } } return HAM_IGNORED; } // Flare Lighting Effects flare_lighting(entity, duration) { // Get origin and color static Float:originF[3], color[3] pev(entity, pev_origin, originF) pev(entity, PEV_FLARE_COLOR, color) // Lighting engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0) write_byte(TE_DLIGHT) // TE id engfunc(EngFunc_WriteCoord, originF[0]) // x engfunc(EngFunc_WriteCoord, originF[1]) // y engfunc(EngFunc_WriteCoord, originF[2]) // z write_byte(get_pcvar_num(cvar_flaresize)) // radius write_byte(color[0]) // r write_byte(color[1]) // g write_byte(color[2]) // b write_byte(51) //life write_byte((duration < 2) ? 3 : 0) //decay rate message_end() // Sparks engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0) write_byte(TE_SPARKS) // TE id engfunc(EngFunc_WriteCoord, originF[0]) // x engfunc(EngFunc_WriteCoord, originF[1]) // y engfunc(EngFunc_WriteCoord, originF[2]) // z message_end() } stock fm_get_speed(entity) { static Float:velocity[3] pev(entity, pev_velocity, velocity) return floatround(vector_length(velocity)); }