
   /* AMX Mod script.
   *
   * instagib! by jon
   *
   * this script basically just does a shitload
   * of extra damage to anyone that gets pelted for
   * at least 10% of their remaining life. in english:
   * if you have 100 life and you get hit for 10 or more,
   * you explode into a bloody, firey goo.
   * if get hit for 8 damage, nothing happens, and the next
   * time you get hit (you only have 92 life) the cutoff point
   * is of course now 9 damage.
   *
   * this is probably a nice balance between getting gibbed
   * for being tagged in the foot and it taking too long to
   * blow an opponent apart for a 'realistic' instagib match.
   *
   * amx_instagib <1|0> - on or off, baby.
   *
   * note: i obviously borrowed code from tracer_fire to write
   * this, so you probably shouldn't use both at the same time.
   * however, you may find it to be best experienced with
   * pistols-only mode.
   *
   * because of the method in which the player is killed, this
   * plug-in isnt compatible with shit like warcraft3xp. there's
   * probably some way to fix this that's beyond me.
   *
   */
   #include <amxconst>
   #include <amxmod>
   #include <amxmisc>
   #include <fun>
   // current version
   new const CURR_VERSION[] = "1.6"
   // hudmessage channel
   static curr_chan = 0
   // random phrases to make kills more interesting, since
   // i have to display them with a custom message anyways.
   static adverb[7][] = {    "gibbed",
               "raped",
               "blasted",
               "violated",
               "blew",
               "blew the shit out of",
               "vaporized" }
   static  predicate[7][]  =  { "!", "!", "to bits!", "!", "apart!", "!",
   "!" }
   // tables[playerid] store ammo count, last weapon id, and team name.
   new lastammo[33]
   new lastweap[33]
   // instagib sprites!
   new spr_laser
   new spr_laser_impact
   new spr_blast_shroom
   // instagib enabled?
   new bool:instagib_enabled = true
   public amx_enableinstagib(id, level, cid) {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new arg[3]
       read_argv(1, arg, 2)
       if (equal(arg,"1") || equali(arg, "on")) instagib_enabled = true
       else instagib_enabled = false
       return PLUGIN_HANDLED
   }
   public make_tracer(id) {
       if (!instagib_enabled) return PLUGIN_CONTINUE
       new weap = read_data(2)        // id of the weapon
       new ammo = read_data(3)        // ammo left in clip
       if (lastweap[id] == 0) lastweap[id] = weap
       if ((lastammo[id] > ammo) && (lastweap[id] == weap)) {
           new vec1[3], vec2[3]
           get_user_origin(id, vec1, 1) // origin; where you are
           get_user_origin(id,  vec2,  4)  //  termina; where your bullet
   goes
           // tracer beam
           message_begin(MSG_PAS, SVC_TEMPENTITY, vec1)
           write_byte(0)        // TE_BEAMPOINTS
           write_coord(vec1[0])
           write_coord(vec1[1])
           write_coord(vec1[2])
           write_coord(vec2[0])
           write_coord(vec2[1])
           write_coord(vec2[2])
           write_short(spr_laser)    // laserbeam sprite
           write_byte(0)        // starting frame
           write_byte(10)        // frame rate
           write_byte(2)        // life in 0.1s
           write_byte(4)        // line width in 0.1u
           write_byte(1)        // noise in 0.1u
           write_byte(153)        // r
           write_byte(0)        // g
           write_byte(0)        // b
           write_byte(80)        // brightness
           write_byte(100)        // scroll speed
           message_end()
           // bullet impact explosion
           message_begin(MSG_PAS, SVC_TEMPENTITY, vec2)
           write_byte(3)        // TE_EXPLOSION
           write_coord(vec2[0])    // end point of beam
           write_coord(vec2[1])
           write_coord(vec2[2])
           write_short(spr_laser_impact)    // blast sprite
           write_byte(10)            // scale in 0.1u
           write_byte(30)            // frame rate
           write_byte(8)            // TE_EXPLFLAG_NOPARTICLES
           message_end()            // ..unless i'm mistaken, noparticles
   helps avoid a crash
       }
       lastammo[id] = ammo
       lastweap[id] = weap
       return PLUGIN_CONTINUE
   }
   public big_hurt(id) {
       if (!instagib_enabled) return PLUGIN_CONTINUE
       new health = get_user_health(id)
       new damage = read_data(2)
       new attacker_id    = get_user_attacker(id)
       // mah nigga $id wasn't attacked by another player
       if (!is_user_connected(attacker_id)) return PLUGIN_CONTINUE
       // as cool as it is to he grenade yourself and instagib, this
       // prevents you from needlessly exploding when you fall off
       // a cliff for a substantial amount of damage.
       //  i  can  only  assume  there's  a  way to check which weapon is
   causing the damage.
       if (attacker_id == id) return PLUGIN_CONTINUE
       // damage is less than 10%
       if  (((1.0  *  damage)  / (1.0 * (health + damage))) < 0.1) return
   PLUGIN_CONTINUE
       new origin[3]
       new    attacker_name[33],    victim_name[33],    attacker_team[2],
   victim_team[2]
       new rval
       get_user_origin(id, origin)
       // player fades..
       set_user_rendering(id,    kRenderFxFadeSlow,    255,   255,   255,
   kRenderTransColor, 4);
       // beeeg explody!
       message_begin(MSG_ALL, SVC_TEMPENTITY)
       write_byte(3)            // TE_EXPLOSION
       write_coord(origin[0])
       write_coord(origin[1])
       write_coord(origin[2]-22)
       write_short(spr_blast_shroom)    // mushroom cloud
       write_byte(40)            // scale in 0.1u
       write_byte(12)            // frame rate
       write_byte(12)            //       TE_EXPLFLAG_NOPARTICLES       &
   TE_EXPLFLAG_NOSOUND
       message_end()
       // do turn down that awful racket
       emit_sound(id,  CHAN_ITEM,  "misc/missile.wav", 1.0, ATTN_NORM, 0,
   PITCH_LOW)
       // ..to be replaced by a blood spurt!
       message_begin(MSG_ALL, SVC_TEMPENTITY)
       write_byte(10)        // TE_LAVASPLASH
       write_coord(origin[0])
       write_coord(origin[1])
       write_coord(origin[2]-26)
       message_end()
       // kill victim
       user_kill(id, 1)
       /* set_user_health(id, 0) */
       // team check!
       get_user_team(attacker_id, attacker_team, 1)
       get_user_team(id, victim_team, 1)
       //  for  some reason this doesn't update in the hud until the next
   round.. whatever.
       if (!equali(attacker_team, victim_team)) {
           //  diff. team;    $attacker_id gets credited for the kill and
   $250.
           //        $id gets their suicidal -1 frag back.
           set_user_frags(attacker_id, get_user_frags(attacker_id)+1)
           set_user_money(attacker_id, get_user_money(attacker_id)+150)
       }
       else {
           // same team;    $attacker loses a frag and $500.
           set_user_frags(attacker_id, get_user_frags(attacker_id)-1)
           set_user_money(attacker_id,   get_user_money(attacker_id)-500,
   0)
       }
       // publically humiliate $id
       get_user_name(attacker_id, attacker_name, 32)
       get_user_name(id, victim_name, 32)
       rval = random_num(0, 6)
       curr_chan += 1
       if (curr_chan > 10) curr_chan = 1
       set_hudmessage(255,   255,   255,   0.01,   (0.25   +   (0.025   *
   (curr_chan-1))), 0, 0.0, 1.0, 0.1, 2.0, curr_chan)
       show_hudmessage(0,  "%s  %s  %s  %s", attacker_name, adverb[rval],
   victim_name, predicate[rval])
       return PLUGIN_CONTINUE
   }
   public plugin_init() {
       register_concmd("amx_instagib",              "amx_enableinstagib",
   ADMIN_LEVEL_B, "<0|1> - turn instagib on or off")
       register_plugin("instagib",CURR_VERSION,"jon")
       register_event("CurWeapon", "make_tracer", "be", "1=1", "3>0")
       register_event("Damage", "big_hurt", "b");
       return PLUGIN_CONTINUE
   }
   public plugin_precache() {
       spr_laser = precache_model("sprites/laserbeam.spr")
       spr_laser_impact = precache_model("sprites/zerogxplode.spr")
       spr_blast_shroom = precache_model("sprites/mushroom.spr")
       precache_sound("misc/missile.wav")
       return PLUGIN_CONTINUE
   }
