Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 11.42 KB  |  hits: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Green Arrow - Exploding Arrows (Bullets from Scout)
  2.  
  3. // CVARS
  4. // garrow_arrows- How many Arrows does he get each round
  5. // garrow_getdeagle - Does he get a free scout on respawn.
  6.  
  7. // Edited by ShadowLeader
  8.  
  9. #include <amxmod>
  10. #include <amxmisc>
  11. #include <superheromod>
  12.  
  13. new maxusers
  14. // Variables
  15. new gHeroName[]="Green Arrow"
  16. new gHasgarrowPower[SH_MAXSLOTS+1]
  17. new gHasgarrowSelected[SH_MAXSLOTS+1]
  18. new gArrowsFired[SH_MAXSLOTS+1]
  19. new gPlayerLevels[SH_MAXSLOTS+1]
  20.  
  21. new gLastWeapon[SH_MAXSLOTS+1]
  22. new gLastClipCount[SH_MAXSLOTS+1]
  23. new lastammo[SH_MAXSLOTS+1]
  24. new lastweap[SH_MAXSLOTS+1]
  25.  
  26. // Sprites
  27. new spr_laser
  28. new spr_laser_impact
  29. new spr_blast_shroom
  30.  
  31. new const Model_V_SCOUT[] = "models/shmod/greenarrow_v.mdl"
  32. new const Model_P_SCOUT[] = "models/shmod/greenarrow_p.mdl"
  33.  
  34. //----------------------------------------------------------------------------------------------
  35. public plugin_init()
  36. {
  37.         register_plugin("SUPERHERO Green Arrow","1.6","AssKicR/ShadowLeader")
  38.  
  39.         register_cvar("garrow_level", "0")
  40.         shCreateHero(gHeroName, "Exploding Scout Shots", "You will have 10 exploding shots!!", false, "garrow_level" )
  41.  
  42.         register_srvcmd("garrow_init", "garrow_init")
  43.         shRegHeroInit(gHeroName, "garrow_init")
  44.         register_logevent("round_Start", 2, "1=Round_Start")
  45.         // GREEN ARROW DAMAGE
  46.         register_event("Damage", "garrow_damage", "b", "2!0")
  47.         // COUTING ARROWS
  48.         register_event("CurWeapon","changeWeapon","be","1=1")
  49.         // MAKE A TRAIL OF THE ARROW
  50.         register_event("CurWeapon","make_tracer", "be", "1=1", "3>0")
  51.         // DEATH
  52.         register_event("DeathMsg", "garrow_death", "a")
  53.         // LEVELS
  54.         register_srvcmd("garrow_levels", "garrow_levels")
  55.         shRegLevels(gHeroName,"garrow_levels")
  56.  
  57.         // DEFAULT THE CVARS
  58.         register_cvar("garrow_arrows", "10")
  59.         register_cvar("garrow_getscout", "1")
  60.         register_cvar("garrow_maxlevel", "0")
  61.         maxusers = get_maxplayers()
  62. }
  63. /*----------------------------------------------------------------------------------------------
  64. Cuando cambia de arma checkeamos si el arma es la scout y tiene el poder, entonces le ponemos el model.
  65. ----------------------------------------------------------------------------------------------*/
  66.  
  67. public switch_model(id)
  68. {
  69.         if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id] )
  70.                 return PLUGIN_HANDLED
  71.  
  72.         new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)
  73.  
  74.         if ( wpnid == CSW_SCOUT )
  75.         {
  76.                 set_pev(id, pev_viewmodel2, Model_V_SCOUT)
  77.                 set_pev(id, pev_weaponmodel2, Model_P_SCOUT)
  78.         }
  79.         return PLUGIN_CONTINUE
  80. }
  81. /*-------------------------------------------------------------------------------------------
  82. Init del hero
  83. -------------------------------------------------------------------------------------------*/
  84. public garrow_init()
  85. {
  86.         // First Argument is an id
  87.         new temp[5]
  88.         read_argv(1,temp,4)
  89.         new id=str_to_num(temp)
  90.  
  91.         // 2nd Argument is 0 or 1 depending on whether the id has garrow
  92.         read_argv(2,temp,4)
  93.         new hasPowers = str_to_num(temp)
  94.  
  95.         gHasgarrowPower[id] = (hasPowers!=0)
  96.         gHasgarrowSelected[id] = gHasgarrowPower[id]
  97.  
  98.         //Setthe hero up for this player
  99.         if (gHasgarrowPower[id]) {
  100.                 roundstart(id)
  101.         }
  102. }
  103. /*----------------------------------------------------------------------------------------------*/
  104. public plugin_precache() {
  105.         spr_laser = precache_model("sprites/laserbeam.spr")
  106.         spr_laser_impact = precache_model("sprites/zerogxplode.spr")
  107.         spr_blast_shroom = precache_model("sprites/mushroom.spr")
  108.         if ( file_exists(Model_V_SCOUT) ) {
  109.                 precache_model(Model_V_SCOUT)
  110.         }
  111.         if ( file_exists(Model_P_SCOUT) ) {
  112.                 precache_model(Model_P_SCOUT)
  113.         }
  114. }
  115. /*----------------------------------------------------------------------------------------------*/
  116. public round_Start()
  117. {
  118.         for( new i; i< maxusers;i++)
  119.         {
  120.                 if(!is_user_alive(i) || !is_user_connected(i))
  121.                         return PLUGIN_HANDLED
  122.                        
  123.                 roundstart(i)
  124.         }
  125.         return PLUGIN_HANDLED
  126. }
  127. /*---------------------------------------------------------
  128. Checkeamos el lvl del user aver si puede tener el hero y si puede le damos las armas.
  129. ---------------------------------------------------------*/
  130. public roundstart(id)
  131. {
  132.         gArrowsFired[id] = 0
  133.         gPlayerUltimateUsed[id] = false
  134.         gLastWeapon[id] = -1  // I think the change Weapon automatically gets called on spawn death too...
  135.  
  136.         //Check is this player can use the hero
  137.         garrow_checklevel(id)
  138.  
  139.         if (gHasgarrowPower[id] && get_cvar_num("garrow_getscout")) {
  140.                 set_task(0.1,"garrow_giveweapons",id)
  141.         }
  142. }
  143.  
  144. //----------------------------------------------------------------------------------------------
  145. public garrow_death()
  146. {
  147.         new id = read_data(2)
  148.  
  149.         garrow_checklevel(id)
  150. }
  151. /*----------------------------------------------------------------------------------------------
  152. Funcion para dar las armas
  153. ----------------------------------------------------------------------------------------------*/
  154. public garrow_giveweapons(id)
  155. {
  156.         if ( !is_user_alive(id) || !gHasgarrowPower[id] )
  157.                 return PLUGIN_HANDLED
  158.        
  159.         shGiveWeapon(id,"weapon_scout")
  160.         return PLUGIN_CONTINUE
  161. }
  162. /*----------------------------------------------------------------------------------------------
  163. Evento de Damage provocado por la Green Arrow
  164. ----------------------------------------------------------------------------------------------*/
  165. public garrow_damage(id)
  166. {
  167.         new damage = read_data(2)
  168.         new weapon, bodypart, attacker_id = get_user_attacker(id,weapon,bodypart)
  169.  
  170.         if ( !shModActive()
  171.         || !is_user_alive(attacker_id)
  172.         || !is_user_connected(attacker_id)
  173.         || !gHasgarrowPower[attacker_id])
  174.                 return PLUGIN_HANDLED
  175.  
  176.         if (weapon == CSW_SCOUT && (!gPlayerUltimateUsed[attacker_id]))
  177.         {
  178.                 new health = get_user_health(id)
  179.  
  180.                 // mah nigga $id wasn't attacked by another player
  181.                 if (attacker_id == id) return PLUGIN_HANDLED
  182.  
  183.                 // damage is less than 10%
  184.                 if (((1.0 * damage) / (1.0 * (health + damage))) < 0.01) return PLUGIN_HANDLED
  185.  
  186.                 new origin[3]
  187.                 new attacker_team[2], victim_team[2]
  188.  
  189.                 get_user_origin(id, origin)
  190.  
  191.                 // player fades..
  192.                 set_user_rendering(id, kRenderFxFadeSlow, 255, 255, 255, kRenderTransColor, 4);
  193.  
  194.                 // beeeg explody!
  195.                 message_begin(MSG_ALL, SVC_TEMPENTITY)
  196.                 write_byte(3)            // TE_EXPLOSION
  197.                 write_coord(origin[0])
  198.                 write_coord(origin[1])
  199.                 write_coord(origin[2]-22)
  200.                 write_short(spr_blast_shroom)    // mushroom cloud
  201.                 write_byte(40)            // scale in 0.1u
  202.                 write_byte(12)            // frame rate
  203.                 write_byte(12)            // TE_EXPLFLAG_NOPARTICLES & TE_EXPLFLAG_NOSOUND
  204.                 message_end()
  205.  
  206.  
  207.                 // do turn down that awful racket
  208.  
  209.                 // ..to be replaced by a blood spurt!
  210.                 message_begin(MSG_ALL, SVC_TEMPENTITY)
  211.                 write_byte(10)        // TE_LAVASPLASH
  212.                 write_coord(origin[0])
  213.                 write_coord(origin[1])
  214.                 write_coord(origin[2]-26)
  215.                 message_end()
  216.  
  217.                 //Edición para que no haga kill
  218.                 shExtraDamage(id, attacker_id, 9000, "scout")
  219.                 //Fin edición
  220.  
  221.                 //Save Hummiliation
  222.                 new namea[24],namev[24],authida[20],authidv[20],teama[8],teamv[8]
  223.                 //Info On Attacker
  224.                 get_user_name(attacker_id,namea,23)
  225.                 get_user_team(attacker_id,teama,7)
  226.                 get_user_authid(attacker_id,authida,19)
  227.                 //Info On Victim
  228.                 get_user_name(id,namev,23)
  229.                 get_user_team(id,teamv,7)
  230.                 get_user_authid(id,authidv,19)
  231.                 //Log This Kill
  232.                 log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"garrow^"",
  233.                 namea,get_user_userid(attacker_id),authida,teama,namev,get_user_userid(id),authidv,teamv)
  234.  
  235.                 /* set_user_health(id, 0) */
  236.  
  237.                 // team check!
  238.                 get_user_team(attacker_id, attacker_team, 1)
  239.                 get_user_team(id, victim_team, 1)
  240.  
  241.                 // for some reason this doesn't update in the hud until the next round.. whatever.
  242.         }
  243.         return PLUGIN_CONTINUE
  244. }
  245. /*----------------------------------------------------------------------------------------------*/
  246. public make_tracer(id)
  247. {
  248.         if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id]) return PLUGIN_HANDLED
  249.  
  250.         new weap = read_data(2)        // id of the weapon
  251.         new ammo = read_data(3)        // ammo left in clip
  252.  
  253.         if ( weap == CSW_SCOUT && (!gPlayerUltimateUsed[id]) ) {
  254.  
  255.                 if (lastweap[id] == 0) lastweap[id] = weap
  256.  
  257.                 if ((lastammo[id] > ammo) && (lastweap[id] == weap)) {
  258.  
  259.                         new vec1[3], vec2[3]
  260.                         get_user_origin(id, vec1, 1) // origin; where you are
  261.                         get_user_origin(id, vec2, 4) // termina; where your bullet goes
  262.  
  263.                         // tracer beam
  264.                         message_begin(MSG_PAS, SVC_TEMPENTITY, vec1)
  265.                         write_byte(0)        // TE_BEAMPOINTS
  266.                         write_coord(vec1[0])
  267.                         write_coord(vec1[1])
  268.                         write_coord(vec1[2])
  269.                         write_coord(vec2[0])
  270.                         write_coord(vec2[1])
  271.                         write_coord(vec2[2])
  272.                         write_short(spr_laser)    // laserbeam sprite
  273.                         write_byte(0)        // starting frame
  274.                         write_byte(10)        // frame rate
  275.                         write_byte(2)        // life in 0.1s
  276.                         write_byte(4)        // line width in 0.1u
  277.                         write_byte(1)        // noise in 0.1u
  278.                         write_byte(153)        // red
  279.                         write_byte(0)      // green
  280.                         write_byte(0)        // blue
  281.                         write_byte(80)        // brightness
  282.                         write_byte(100)        // scroll speed
  283.                         message_end()
  284.  
  285.                         // bullet impact explosion
  286.                         message_begin(MSG_PAS, SVC_TEMPENTITY, vec2)
  287.                         write_byte(3)        // TE_EXPLOSION
  288.                         write_coord(vec2[0])    // end point of beam
  289.                         write_coord(vec2[1])
  290.                         write_coord(vec2[2])
  291.                         write_short(spr_laser_impact)    // blast sprite
  292.                         write_byte(10)            // scale in 0.1u
  293.                         write_byte(30)            // frame rate
  294.                         write_byte(8)            // TE_EXPLFLAG_NOPARTICLES
  295.                         message_end()            // ..unless i'm mistaken, noparticles helps avoid a crash
  296.                 }
  297.  
  298.                 lastammo[id] = ammo
  299.                 lastweap[id] = weap
  300.         }
  301.         return PLUGIN_CONTINUE
  302. }
  303. /*----------------------------------------------------------------------------------------------*/
  304. public changeWeapon(id)
  305. {
  306.         if ( !shModActive() || !is_user_alive(id) || !gHasgarrowPower[id]) return PLUGIN_HANDLED
  307.  
  308.         new  clip, ammo
  309.         new wpn_id=get_user_weapon(id, clip, ammo);
  310.  
  311.         if ( wpn_id == CSW_SCOUT )
  312.                 switch_model(id)
  313.  
  314.         if ( wpn_id != gLastWeapon[id] )
  315.         {
  316.                 gLastWeapon[id]=wpn_id
  317.                 return PLUGIN_CONTINUE // user just switched weapons
  318.         }
  319.  
  320.         if ( clip >= gLastClipCount[id] )
  321.         {
  322.                 gLastClipCount[id]=clip
  323.                 return PLUGIN_CONTINUE
  324.         }
  325.         gLastClipCount[id]=clip
  326.  
  327.         // Ok - if it fell through here - you got a user firing the scout
  328.  
  329.         // Bullet Count
  330.         gArrowsFired[id]=(gArrowsFired[id] + 1)
  331.         new arrows = (get_cvar_num("garrow_arrows")-gArrowsFired[id])
  332.  
  333.         if (arrows == 0) {
  334.                 gPlayerUltimateUsed[id]=true
  335.         }
  336.         if (arrows <= 0) {
  337.                 gPlayerUltimateUsed[id]=true
  338.         }
  339.         if ((arrows != 0) && arrows >= 0 ) {
  340.                 new message[128]
  341.                 format(message, 127, "Tienes %i disparos de la Green Arrow.",arrows)
  342.                 set_hudmessage(255,0,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
  343.                 show_hudmessage(id, message)
  344.         }
  345.         return PLUGIN_CONTINUE
  346. }
  347. /*----------------------------------------------------------------------------------------------*/
  348. public garrow_levels()
  349. {
  350.         new id[5]
  351.         new lev[5]
  352.  
  353.         read_argv(1,id,4)
  354.         read_argv(2,lev,4)
  355.  
  356.         gPlayerLevels[str_to_num(id)] = str_to_num(lev)
  357.  
  358.         garrow_checklevel(str_to_num(id))
  359. }
  360. /*----------------------------------------------------------------------------------------------*/
  361. public garrow_checklevel(id)
  362. {
  363.         new garrow_maxlvl = get_cvar_num("garrow_maxlevel")
  364.         if (gHasgarrowSelected[id] && gPlayerLevels[id] > garrow_maxlvl) {
  365.                 client_print(id,print_chat, "[SH](%s) You must be level %d or lower to use this hero",gHeroName,garrow_maxlvl)
  366.                 gHasgarrowPower[id] = false
  367.                 client_cmd(id,"say drop %s",gHeroName)
  368.         }
  369.  
  370. }
  371. /*----------------------------------------------------------------------------------------------*/