- // Green Arrow - Exploding Arrows (Bullets from Scout)
- // CVARS
- // garrow_arrows- How many Arrows does he get each round
- // garrow_getdeagle - Does he get a free scout on respawn.
- // Edited by ShadowLeader
- #include <amxmod>
- #include <amxmisc>
- #include <superheromod>
- new maxusers
- // Variables
- new gHeroName[]="Green Arrow"
- new gHasgarrowPower[SH_MAXSLOTS+1]
- new gHasgarrowSelected[SH_MAXSLOTS+1]
- new gArrowsFired[SH_MAXSLOTS+1]
- new gPlayerLevels[SH_MAXSLOTS+1]
- new gLastWeapon[SH_MAXSLOTS+1]
- new gLastClipCount[SH_MAXSLOTS+1]
- new lastammo[SH_MAXSLOTS+1]
- new lastweap[SH_MAXSLOTS+1]
- // Sprites
- new spr_laser
- new spr_laser_impact
- new spr_blast_shroom
- new const Model_V_SCOUT[] = "models/shmod/greenarrow_v.mdl"
- new const Model_P_SCOUT[] = "models/shmod/greenarrow_p.mdl"
- //----------------------------------------------------------------------------------------------
- public plugin_init()
- {
- register_plugin("SUPERHERO Green Arrow","1.6","AssKicR/ShadowLeader")
- register_cvar("garrow_level", "0")
- shCreateHero(gHeroName, "Exploding Scout Shots", "You will have 10 exploding shots!!", false, "garrow_level" )
- register_srvcmd("garrow_init", "garrow_init")
- shRegHeroInit(gHeroName, "garrow_init")
- register_logevent("round_Start", 2, "1=Round_Start")
- // GREEN ARROW DAMAGE
- register_event("Damage", "garrow_damage", "b", "2!0")
- // COUTING ARROWS
- register_event("CurWeapon","changeWeapon","be","1=1")
- // MAKE A TRAIL OF THE ARROW
- register_event("CurWeapon","make_tracer", "be", "1=1", "3>0")
- // DEATH
- register_event("DeathMsg", "garrow_death", "a")
- // LEVELS
- register_srvcmd("garrow_levels", "garrow_levels")
- shRegLevels(gHeroName,"garrow_levels")
- // DEFAULT THE CVARS
- register_cvar("garrow_arrows", "10")
- register_cvar("garrow_getscout", "1")
- register_cvar("garrow_maxlevel", "0")
- maxusers = get_maxplayers()
- }
- /*----------------------------------------------------------------------------------------------
- Cuando cambia de arma checkeamos si el arma es la scout y tiene el poder, entonces le ponemos el model.
- ----------------------------------------------------------------------------------------------*/
- public switch_model(id)
- {
- if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id] )
- return PLUGIN_HANDLED
- new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)
- if ( wpnid == CSW_SCOUT )
- {
- set_pev(id, pev_viewmodel2, Model_V_SCOUT)
- set_pev(id, pev_weaponmodel2, Model_P_SCOUT)
- }
- return PLUGIN_CONTINUE
- }
- /*-------------------------------------------------------------------------------------------
- Init del hero
- -------------------------------------------------------------------------------------------*/
- public garrow_init()
- {
- // First Argument is an id
- new temp[5]
- read_argv(1,temp,4)
- new id=str_to_num(temp)
- // 2nd Argument is 0 or 1 depending on whether the id has garrow
- read_argv(2,temp,4)
- new hasPowers = str_to_num(temp)
- gHasgarrowPower[id] = (hasPowers!=0)
- gHasgarrowSelected[id] = gHasgarrowPower[id]
- //Setthe hero up for this player
- if (gHasgarrowPower[id]) {
- roundstart(id)
- }
- }
- /*----------------------------------------------------------------------------------------------*/
- 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")
- if ( file_exists(Model_V_SCOUT) ) {
- precache_model(Model_V_SCOUT)
- }
- if ( file_exists(Model_P_SCOUT) ) {
- precache_model(Model_P_SCOUT)
- }
- }
- /*----------------------------------------------------------------------------------------------*/
- public round_Start()
- {
- for( new i; i< maxusers;i++)
- {
- if(!is_user_alive(i) || !is_user_connected(i))
- return PLUGIN_HANDLED
- roundstart(i)
- }
- return PLUGIN_HANDLED
- }
- /*---------------------------------------------------------
- Checkeamos el lvl del user aver si puede tener el hero y si puede le damos las armas.
- ---------------------------------------------------------*/
- public roundstart(id)
- {
- gArrowsFired[id] = 0
- gPlayerUltimateUsed[id] = false
- gLastWeapon[id] = -1 // I think the change Weapon automatically gets called on spawn death too...
- //Check is this player can use the hero
- garrow_checklevel(id)
- if (gHasgarrowPower[id] && get_cvar_num("garrow_getscout")) {
- set_task(0.1,"garrow_giveweapons",id)
- }
- }
- //----------------------------------------------------------------------------------------------
- public garrow_death()
- {
- new id = read_data(2)
- garrow_checklevel(id)
- }
- /*----------------------------------------------------------------------------------------------
- Funcion para dar las armas
- ----------------------------------------------------------------------------------------------*/
- public garrow_giveweapons(id)
- {
- if ( !is_user_alive(id) || !gHasgarrowPower[id] )
- return PLUGIN_HANDLED
- shGiveWeapon(id,"weapon_scout")
- return PLUGIN_CONTINUE
- }
- /*----------------------------------------------------------------------------------------------
- Evento de Damage provocado por la Green Arrow
- ----------------------------------------------------------------------------------------------*/
- public garrow_damage(id)
- {
- new damage = read_data(2)
- new weapon, bodypart, attacker_id = get_user_attacker(id,weapon,bodypart)
- if ( !shModActive()
- || !is_user_alive(attacker_id)
- || !is_user_connected(attacker_id)
- || !gHasgarrowPower[attacker_id])
- return PLUGIN_HANDLED
- if (weapon == CSW_SCOUT && (!gPlayerUltimateUsed[attacker_id]))
- {
- new health = get_user_health(id)
- // mah nigga $id wasn't attacked by another player
- if (attacker_id == id) return PLUGIN_HANDLED
- // damage is less than 10%
- if (((1.0 * damage) / (1.0 * (health + damage))) < 0.01) return PLUGIN_HANDLED
- new origin[3]
- new attacker_team[2], victim_team[2]
- 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
- // ..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()
- //Edición para que no haga kill
- shExtraDamage(id, attacker_id, 9000, "scout")
- //Fin edición
- //Save Hummiliation
- new namea[24],namev[24],authida[20],authidv[20],teama[8],teamv[8]
- //Info On Attacker
- get_user_name(attacker_id,namea,23)
- get_user_team(attacker_id,teama,7)
- get_user_authid(attacker_id,authida,19)
- //Info On Victim
- get_user_name(id,namev,23)
- get_user_team(id,teamv,7)
- get_user_authid(id,authidv,19)
- //Log This Kill
- log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"garrow^"",
- namea,get_user_userid(attacker_id),authida,teama,namev,get_user_userid(id),authidv,teamv)
- /* 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.
- }
- return PLUGIN_CONTINUE
- }
- /*----------------------------------------------------------------------------------------------*/
- public make_tracer(id)
- {
- if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id]) return PLUGIN_HANDLED
- new weap = read_data(2) // id of the weapon
- new ammo = read_data(3) // ammo left in clip
- if ( weap == CSW_SCOUT && (!gPlayerUltimateUsed[id]) ) {
- 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) // red
- write_byte(0) // green
- write_byte(0) // blue
- 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 changeWeapon(id)
- {
- if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id]) return PLUGIN_HANDLED
- new clip, ammo
- new wpn_id=get_user_weapon(id, clip, ammo);
- if ( wpn_id == CSW_SCOUT )
- switch_model(id)
- if ( wpn_id != gLastWeapon[id] )
- {
- gLastWeapon[id]=wpn_id
- return PLUGIN_CONTINUE // user just switched weapons
- }
- if ( clip >= gLastClipCount[id] )
- {
- gLastClipCount[id]=clip
- return PLUGIN_CONTINUE
- }
- gLastClipCount[id]=clip
- // Ok - if it fell through here - you got a user firing the scout
- // Bullet Count
- gArrowsFired[id]=(gArrowsFired[id] + 1)
- new arrows = (get_cvar_num("garrow_arrows")-gArrowsFired[id])
- if (arrows == 0) {
- gPlayerUltimateUsed[id]=true
- }
- if (arrows <= 0) {
- gPlayerUltimateUsed[id]=true
- }
- if ((arrows != 0) && arrows >= 0 ) {
- new message[128]
- format(message, 127, "Tienes %i disparos de la Green Arrow.",arrows)
- set_hudmessage(255,0,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
- show_hudmessage(id, message)
- }
- return PLUGIN_CONTINUE
- }
- /*----------------------------------------------------------------------------------------------*/
- public garrow_levels()
- {
- new id[5]
- new lev[5]
- read_argv(1,id,4)
- read_argv(2,lev,4)
- gPlayerLevels[str_to_num(id)] = str_to_num(lev)
- garrow_checklevel(str_to_num(id))
- }
- /*----------------------------------------------------------------------------------------------*/
- public garrow_checklevel(id)
- {
- new garrow_maxlvl = get_cvar_num("garrow_maxlevel")
- if (gHasgarrowSelected[id] && gPlayerLevels[id] > garrow_maxlvl) {
- client_print(id,print_chat, "[SH](%s) You must be level %d or lower to use this hero",gHeroName,garrow_maxlvl)
- gHasgarrowPower[id] = false
- client_cmd(id,"say drop %s",gHeroName)
- }
- }
- /*----------------------------------------------------------------------------------------------*/