Resolved [ZE] Extra Red Dragon Cannon

Unpaid Requests, Public Plugins
Post Reply
Mystic Viper
Member
Member
Romania
Posts: 96
Joined: 10 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

[ZE] Extra Red Dragon Cannon

#1

Post by Mystic Viper » 3 Months Ago

Can someone convert this to our mode? Please
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <xs>
  5. #include <cstrike>
  6. #include <zombieplague>
  7.  
  8. // Mofiying Plugin Info Will Violate CopyRight///////////
  9. #define PLUGIN "[Z47] RED AND GOLDEN DRAGON CANNON" /////
  10. #define VERSION "1.0"                               /////
  11. #define AUTHOR "ZinoZack47"                         /////
  12. ////////////////////////////////////////////////////////
  13.  
  14.  
  15. /*
  16.     -if you want to use the Golden Dragon Cannon only, delete #define RED
  17.     -if you want to use Both Red and Golden Dragon Cannon, then make sure #define RED and #define GOLD are added. May cause crashes so be warned.
  18.     -if you want to use the Red Dragon Cannon only, delete #define GOLD
  19. */
  20.  
  21. #define RED
  22. //#define GOLD
  23.  
  24. #define RDC_WEAPONKEY                   118639647
  25.  
  26. #define WEAP_LINUX_XTRA_OFF             4
  27. #define PLAYER_LINUX_XTRA_OFF           5
  28.  
  29. #define m_pPlayer                       41
  30. #define m_flNextPrimaryAttack           46
  31. #define m_flNextSecondaryAttack         47
  32. #define m_flTimeWeaponIdle              48
  33.  
  34. #define m_flNextAttack                  83
  35. #define m_pActiveItem                   373
  36.  
  37. #define RDC_DRAW_TIME                   1.0
  38.  
  39. #define CSW_RDC                         CSW_P90
  40. #define weapon_rdc                      "weapon_p90"
  41.  
  42. #define RDC_FIRE_CLASSNAME              "rdc_fire"
  43. #define RDC_DRAGON_CLASSNAME            "rdc_dragon"
  44. #define RDC_DRAGONSPIRIT_CLASSNAME      "rdc_dragon_spirit"
  45. #define RDC_EXPLOSION_CLASSNAME         "rdc_explosion"
  46.  
  47. #define WEAPON_ATTACH_F                 30.0
  48. #define WEAPON_ATTACH_R                 10.0
  49. #define WEAPON_ATTACH_U                 -5.0
  50.  
  51. const pev_mode = pev_iuser1
  52. const pev_life = pev_fuser1
  53. const pev_rate = pev_fuser2
  54.  
  55. enum ( += 47)
  56. {
  57.     RDC_TASK_SHOOT =  45756778,
  58.     RDC_TASK_UNLEASH,
  59.     RDC_TASK_RESET,
  60.     RDC_TASK_COOLDOWN,
  61.     RDC_TASK_REFILL
  62. }
  63.  
  64. enum
  65. {
  66.     MODE_A = 0,
  67.     MODE_B
  68. }
  69.  
  70. enum
  71. {
  72.     RDC_IDLE = 0,
  73.     RDC_IDLEB,
  74.     RDC_DRAW,
  75.     RDC_DRAWB,
  76.     RDC_SHOOTA,
  77.     RDC_SHOOTB,
  78.     RDC_D_TRANSFORM,
  79.     RDC_D_RELOAD1,
  80.     RDC_D_RELOAD2
  81. }
  82.  
  83. enum
  84. {
  85.     RDC_P_MODEL = 0,
  86.     RDC_P_MODELB,
  87.     RDC_W_MODEL,
  88.     RDC_W_MODELB
  89. }
  90.  
  91. #if (defined GOLD) && (!defined RED)
  92. new const GDC_V_MODEL[64] = "models/z47_cannonex/v_cannonexgold.mdl"
  93. #endif
  94. #if (defined GOLD) && (defined RED)
  95. new const RDC_V_MODEL[64] = "models/z47_cannonex/v_cannonex.mdl"
  96. new const GDC_V_MODEL[64] = "models/z47_cannonex/v_cannonexgold.mdl"
  97. #endif
  98. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  99. new const RDC_V_MODEL[64] = "models/z47_cannonex/v_cannonex.mdl"
  100. #endif
  101.  
  102. new const RDC_Models[][] =
  103. {
  104.     "models/z47_cannonex/p_cannonex.mdl",
  105.     "models/z47_cannonex/p_cannonexb.mdl",
  106.     "models/z47_cannonex/w_cannonex.mdl",
  107.     "models/z47_cannonex/w_cannonexb.mdl"
  108. }
  109.  
  110. new const RDC_Sounds[][] =
  111. {
  112.     "weapons/z47_cannonex/cannonex_shoota.wav",
  113.     "weapons/z47_cannonex/cannonex_d_reload1.wav",
  114.     "weapons/z47_cannonex/cannonex_d_reload2.wav",
  115.     "weapons/z47_cannonex/cannonex_dtransform.wav",
  116.     "weapons/z47_cannonex/cannonex_dragon_fire_end.wav",
  117.     "weapons/z47_cannonex/cannonexplo.wav"
  118. }
  119.  
  120. new const RDC_Effects[][] =
  121. {
  122.     "models/z47_cannonex/cannonexdragon.mdl",
  123.     "models/z47_cannonex/p_cannonexdragonfx.mdl",
  124.     "models/z47_cannonex/p_cannonexplo.mdl"
  125. }
  126.  
  127. new const RDC_Sprites[][] =
  128. {
  129.     "sprites/weapon_cannonex.txt",
  130.     "sprites/640hud2_47.spr",
  131.     "sprites/640hud161.spr",
  132.     "sprites/fire_cannon.spr"
  133. }
  134.  
  135. #if (defined GOLD) && (!defined RED)
  136. new cvar_dmg_rdc, cvar_rdc_ammo, cvar_rdc_duration, cvar_rdc_cooldown, cvar_rdc_refill, cvar_one_round
  137. #endif
  138. #if (defined RED) && (defined GOLD)
  139. new cvar_dmg_rdc[2], cvar_rdc_ammo[2], cvar_rdc_duration[2], cvar_rdc_cooldown[2], cvar_rdc_refill[2], cvar_one_round[2]
  140. #endif
  141. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  142. new cvar_dmg_rdc, cvar_rdc_ammo, cvar_rdc_duration, cvar_rdc_cooldown, cvar_rdc_refill, cvar_one_round
  143. #endif
  144.  
  145. new g_maxplayers
  146. new m_iBlood[2], g_explo_spr
  147. new g_current_mode[33], g_rdc_ammo[33], g_rdc_dragon[33], bool:g_rdc_preventmode[33]
  148. new g_MsgWeaponList, g_MsgCurWeapon, g_MsgAmmoX, g_MsgEffect[3]
  149.  
  150. #if (defined GOLD) && (!defined RED)
  151. new g_subpmodel[33]
  152. new bool:g_has_rdc[33]
  153. new g_itemid
  154. #endif
  155. #if (defined RED) && (defined GOLD)
  156. new g_subpmodel[33]
  157. new g_has_rdc[33]
  158. new g_itemid[2]
  159. #endif
  160. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  161. new bool:g_has_rdc[33]
  162. new g_itemid
  163. #endif
  164.  
  165. const PRIMARY_WEAPONS_BIT_SUM =
  166. (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|
  167. (1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  168.  
  169. public plugin_init()
  170. {
  171.     register_plugin(PLUGIN, VERSION, AUTHOR)
  172.  
  173.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  174.  
  175.     register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
  176.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  177.  
  178.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  179.     RegisterHam(Ham_Item_Deploy, weapon_rdc, "fw_DragonCannon_Deploy_Post", 1)
  180.     RegisterHam(Ham_Item_AddToPlayer, weapon_rdc, "fw_DragonCannon_AddToPlayer")
  181.     RegisterHam(Ham_Weapon_WeaponIdle, weapon_rdc, "fw_DragonCannon_WeaponIdle_Post", 1)
  182.  
  183.     register_forward(FM_CmdStart, "fw_CmdStart")
  184.     register_forward(FM_Think, "fw_Think")
  185.     register_forward(FM_Touch, "fw_Touch")
  186.     register_forward(FM_SetModel, "fw_SetModel")
  187.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  188.  
  189.     #if (defined GOLD) && (!defined RED)
  190.     cvar_rdc_ammo = register_cvar("zp_cannonexgold_ammo", "50")
  191.     cvar_dmg_rdc = register_cvar("zp_cannonexgold_dmg", "500.0")
  192.     cvar_rdc_duration = register_cvar("zp_cannonexgold_dragonduration", "20.0")
  193.     cvar_rdc_cooldown = register_cvar("zp_cannonexgold_mode_cooldown", "20.0")
  194.     cvar_rdc_refill = register_cvar("zp_cannonexgold_refill", "40.0")
  195.     cvar_one_round = register_cvar("zp_cannonexgold_one_round", "0")
  196.    
  197.     #endif
  198.     #if (defined RED) && (defined GOLD)
  199.     cvar_rdc_ammo[0] = register_cvar("zp_cannonexred_ammo", "50")
  200.     cvar_dmg_rdc[0] = register_cvar("zp_cannonexred_dmg", "500.0")
  201.     cvar_rdc_duration[0] = register_cvar("zp_cannonexred_dragonduration", "20.0")
  202.     cvar_rdc_cooldown[0] = register_cvar("zp_cannonexred_mode_cooldown", "20.0")
  203.     cvar_rdc_refill[0] = register_cvar("zp_cannonexred_refill", "40.0")
  204.     cvar_one_round[0] = register_cvar("zp_cannonexred_one_round", "0")
  205.    
  206.     cvar_rdc_ammo[1] = register_cvar("zp_cannonexgold_ammo", "100")
  207.     cvar_dmg_rdc[1] = register_cvar("zp_cannonexgold_dmg", "700.0")
  208.     cvar_rdc_duration[1] = register_cvar("zp_cannonexgold_dragonduration", "30.0")
  209.     cvar_rdc_cooldown[1] = register_cvar("zp_cannonexgold_mode_cooldown", "15.0")
  210.     cvar_rdc_refill[1] = register_cvar("zp_cannonexgold_refill", "30.0")
  211.     cvar_one_round[1] = register_cvar("zp_cannonexgold_one_round", "0")
  212.  
  213.     #endif
  214.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  215.     cvar_rdc_ammo = register_cvar("zp_cannonexred_ammo", "50")
  216.     cvar_dmg_rdc = register_cvar("zp_cannonexred_dmg", "500.0")
  217.     cvar_rdc_duration = register_cvar("zp_cannonexred_dragonduration", "20.0")
  218.     cvar_rdc_cooldown = register_cvar("zp_cannonexred_mode_cooldown", "20.0")
  219.     cvar_rdc_refill = register_cvar("zp_cannonexred_refill", "40.0")
  220.     cvar_one_round = register_cvar("zp_cannonexred_one_round", "0")
  221.     #endif
  222.  
  223.     g_MsgWeaponList = get_user_msgid("WeaponList")
  224.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
  225.     g_MsgAmmoX = get_user_msgid("AmmoX")
  226.     g_MsgEffect[0] = get_user_msgid("Damage")
  227.     g_MsgEffect[1] = get_user_msgid("ScreenFade")
  228.     g_MsgEffect[2] = get_user_msgid("ScreenShake")
  229.  
  230.     #if (defined GOLD) && (!defined RED)
  231.     g_itemid = zp_register_extra_item("Golden Dragon Cannon", 10, ZP_TEAM_HUMAN)
  232.     #endif
  233.     #if (defined RED) && (defined GOLD)
  234.     g_itemid[0] = zp_register_extra_item("Red Dragon Cannon", 10, ZP_TEAM_HUMAN)
  235.     g_itemid[1] = zp_register_extra_item("Golden Dragon Cannon", 10, ZP_TEAM_HUMAN)
  236.     #endif
  237.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  238.     g_itemid = zp_register_extra_item("Red Dragon Cannon", 10, ZP_TEAM_HUMAN)
  239.     #endif
  240.  
  241.     register_clcmd("weapon_cannonex", "select_cannonex")
  242.     g_maxplayers = get_maxplayers()
  243. }
  244.  
  245. public plugin_precache()
  246. {
  247.     #if (defined GOLD) && (!defined RED)
  248.     precache_model(GDC_V_MODEL)
  249.     #endif
  250.     #if (defined RED) && (defined GOLD)
  251.     precache_model(RDC_V_MODEL)
  252.     precache_model(GDC_V_MODEL)
  253.     #endif
  254.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  255.     precache_model(RDC_V_MODEL)
  256.     #endif
  257.  
  258.     for(new i = 0; i < sizeof(RDC_Models); i++)
  259.         precache_model(RDC_Models[i])
  260.  
  261.     for(new i = 0; i < sizeof(RDC_Sounds); i++)
  262.         precache_sound(RDC_Sounds[i])  
  263.    
  264.     for(new i = 0; i < sizeof(RDC_Effects); i++)
  265.         precache_model(RDC_Effects[i])
  266.  
  267.     for(new i = 0; i < sizeof(RDC_Sprites); i++)
  268.         0 <= i <= 2 ? precache_generic(RDC_Sprites[i]) : precache_model(RDC_Sprites[i])
  269.  
  270.     m_iBlood[0] = precache_model("sprites/blood.spr")
  271.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  272.     g_explo_spr = precache_model("sprites/ef_cannonex.spr")
  273. }
  274.  
  275. public plugin_natives()
  276. {
  277.     #if (defined GOLD) && (!defined RED)
  278.     register_native("z47_give_gdc", "native_give_gdc_add", 1)
  279.     #endif
  280.     #if (defined GOLD) && (defined RED)
  281.     register_native("z47_give_rdc", "native_give_rdc_add", 1)
  282.     register_native("z47_give_gdc", "native_give_gdc_add", 1)
  283.     #endif
  284.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  285.     register_native("z47_give_rdc", "native_give_rdc_add", 1)
  286.     #endif
  287. }
  288.  
  289. #if (defined GOLD) && (!defined RED)
  290. public native_give_gdc_add(id)
  291.     give_cannonex(id)
  292. #endif
  293. #if (defined RED) && (defined GOLD)
  294. public native_give_rdc_add(id)
  295.     give_cannonex(id, 1)
  296. public native_give_gdc_add(id)
  297.     give_cannonex(id, 2)
  298. #endif
  299. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  300. public native_give_rdc_add(id)
  301.     give_cannonex(id)
  302. #endif
  303. public select_cannonex(id)
  304. {
  305.     engclient_cmd(id, weapon_rdc)
  306.     return PLUGIN_HANDLED
  307. }
  308.  
  309. public Event_CurWeapon(id)
  310. {
  311.     new weapon = read_data(2)
  312.  
  313.     if(weapon != CSW_RDC || !g_has_rdc[id])
  314.     {
  315.         #if defined GOLD
  316.         if(pev_valid(g_subpmodel[id]))
  317.         {
  318.             set_pev(g_subpmodel[id], pev_body, 0)
  319.             set_pev(g_subpmodel[id], pev_flags, FL_KILLME)
  320.             engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  321.         }
  322.         #endif
  323.         return
  324.     }
  325.  
  326.     update_ammo(id)
  327. }
  328.  
  329. public Event_NewRound()
  330. {
  331.     for(new id = 0; id <= g_maxplayers; id++)
  332.     {
  333.         if(!g_has_rdc[id])
  334.             continue
  335.        
  336.         #if (defined GOLD) && (!defined RED)   
  337.         if(get_pcvar_num(cvar_one_round))
  338.             remove_cannonex(id)
  339.  
  340.         else
  341.         {
  342.             if(g_rdc_dragon[id])
  343.             {
  344.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  345.                 g_rdc_dragon[id] = 0
  346.                
  347.                 fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  348.                 set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  349.                
  350.                 remove_task(id+RDC_TASK_RESET)
  351.                 ResetMode(id+RDC_TASK_RESET)
  352.             }
  353.  
  354.             remove_task(id+RDC_TASK_COOLDOWN)
  355.             g_rdc_preventmode[id] = false
  356.  
  357.             remove_task(id+RDC_TASK_REFILL)
  358.             Refill_Cannon(id+RDC_TASK_REFILL)
  359.         }
  360.         #endif
  361.         #if (defined RED) && (defined GOLD)
  362.         switch(g_has_rdc[id])
  363.         {
  364.             case 1:
  365.             {
  366.                 if(get_pcvar_num(cvar_one_round[0]))
  367.                     remove_cannonex(id)
  368.  
  369.                 else
  370.                 {
  371.                     if(g_rdc_dragon[id])
  372.                     {
  373.                         engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  374.                         g_rdc_dragon[id] = 0
  375.                        
  376.                         fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  377.                         set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  378.                        
  379.                         remove_task(id+RDC_TASK_RESET)
  380.                         ResetMode(id+RDC_TASK_RESET)
  381.                     }
  382.  
  383.                     remove_task(id+RDC_TASK_COOLDOWN)
  384.                     g_rdc_preventmode[id] = false
  385.  
  386.                     remove_task(id+RDC_TASK_REFILL)
  387.                     Refill_Cannon(id+RDC_TASK_REFILL)
  388.                 }
  389.             }
  390.             case 2:
  391.             {
  392.                 if(get_pcvar_num(cvar_one_round[1]))
  393.                     remove_cannonex(id)
  394.  
  395.                 else
  396.                 {
  397.                     if(g_rdc_dragon[id])
  398.                     {
  399.                         engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  400.                         g_rdc_dragon[id] = 0
  401.                        
  402.                         fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  403.                         set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  404.                        
  405.                         remove_task(id+RDC_TASK_RESET)
  406.                         ResetMode(id+RDC_TASK_RESET)
  407.                     }
  408.  
  409.                     remove_task(id+RDC_TASK_COOLDOWN)
  410.                     g_rdc_preventmode[id] = false
  411.  
  412.                     remove_task(id+RDC_TASK_REFILL)
  413.                     Refill_Cannon(id+RDC_TASK_REFILL)
  414.                 }
  415.             }
  416.         }
  417.         #endif
  418.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  419.         if(get_pcvar_num(cvar_one_round))
  420.             remove_cannonex(id)
  421.  
  422.         else
  423.         {
  424.             if(g_rdc_dragon[id])
  425.             {
  426.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  427.                 g_rdc_dragon[id] = 0
  428.                
  429.                 fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  430.                 set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  431.                
  432.                 remove_task(id+RDC_TASK_RESET)
  433.                 ResetMode(id+RDC_TASK_RESET)
  434.             }
  435.  
  436.             remove_task(id+RDC_TASK_COOLDOWN)
  437.             g_rdc_preventmode[id] = false
  438.  
  439.             remove_task(id+RDC_TASK_REFILL)
  440.             Refill_Cannon(id+RDC_TASK_REFILL)
  441.         }
  442.         #endif
  443.     }
  444. }
  445.  
  446. public fw_PlayerKilled(id)
  447.     remove_cannonex(id)
  448.  
  449. public zp_user_humanized_post(id)
  450.     remove_cannonex(id)
  451.  
  452. public client_disconnect(id)
  453.     remove_cannonex(id)
  454.  
  455. public zp_user_infected_post(id)
  456.     remove_cannonex(id)
  457.  
  458. public fw_DragonCannon_Deploy_Post(weapon_ent)
  459. {
  460.     if(!pev_valid(weapon_ent))
  461.         return
  462.  
  463.     static id
  464.     id = fm_cs_get_weapon_ent_owner(weapon_ent)
  465.    
  466.     if(fm_cs_get_current_weapon_ent(id) != weapon_ent)
  467.         return
  468.  
  469.     if(!g_has_rdc[id])
  470.         return
  471.  
  472.     #if (defined GOLD) && (!defined RED)
  473.     set_pev(id, pev_viewmodel2, GDC_V_MODEL)
  474.     switch(g_current_mode[id])
  475.     {
  476.         case MODE_A: sub_p_model(id, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  477.         case MODE_B: sub_p_model(id, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  478.     }
  479.     #endif
  480.     #if (defined RED) && (defined GOLD)
  481.     switch(g_has_rdc[id])
  482.     {
  483.         case 1:
  484.         {
  485.             set_pev(id, pev_viewmodel2, RDC_V_MODEL)
  486.             switch(g_current_mode[id])
  487.             {
  488.                 case MODE_A: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  489.                 case MODE_B: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  490.             }
  491.         }
  492.         case 2:
  493.         {
  494.             set_pev(id, pev_viewmodel2, GDC_V_MODEL)
  495.             switch(g_current_mode[id])
  496.             {
  497.                 case MODE_A: sub_p_model(id, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  498.                 case MODE_B: sub_p_model(id, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  499.             }
  500.         }
  501.     }
  502.     #endif
  503.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  504.     set_pev(id, pev_viewmodel2, RDC_V_MODEL)
  505.     switch(g_current_mode[id])
  506.     {
  507.         case MODE_A: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  508.         case MODE_B: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  509.     }
  510.     #endif
  511.  
  512.     fm_set_weapon_idle_time(id, weapon_rdc, RDC_DRAW_TIME)
  513. }
  514.  
  515. public fw_CmdStart(id, uc_handle, seed)
  516. {
  517.     if(!is_user_alive(id) || !is_user_connected(id))
  518.         return FMRES_IGNORED
  519.  
  520.     if(get_user_weapon(id) != CSW_RDC || !g_has_rdc[id])
  521.         return FMRES_IGNORED
  522.    
  523.     if(get_pdata_float(id, m_flNextAttack) > 0.0)
  524.             return FMRES_IGNORED
  525.  
  526.     static CurButton
  527.     CurButton = get_uc(uc_handle, UC_Buttons)
  528.    
  529.     if(CurButton & IN_ATTACK)
  530.     {
  531.         CurButton &= ~IN_ATTACK
  532.         set_uc(uc_handle, UC_Buttons, CurButton)
  533.  
  534.         if(get_pdata_float(id, m_flNextPrimaryAttack, PLAYER_LINUX_XTRA_OFF) <= 0.0 && g_rdc_ammo[id] > 0)
  535.         {
  536.             #if (defined GOLD) && (!defined RED)
  537.             if(get_pcvar_float(cvar_rdc_refill) && !task_exists(id+RDC_TASK_REFILL))
  538.             {
  539.                 if(g_rdc_ammo[id] == 1)
  540.                     set_task(get_pcvar_float(cvar_rdc_refill), "Refill_Cannon", id+RDC_TASK_REFILL)
  541.             }
  542.             #endif
  543.             #if (defined RED) && (defined GOLD)
  544.             switch(g_has_rdc[id])
  545.             {
  546.                 case 1:
  547.                 {
  548.                     if(get_pcvar_float(cvar_rdc_refill[0]) && !task_exists(id+RDC_TASK_REFILL))
  549.                     {
  550.                         if(g_rdc_ammo[id] == 1)
  551.                             set_task(get_pcvar_float(cvar_rdc_refill[0]), "Refill_Cannon", id+RDC_TASK_REFILL)
  552.                     }
  553.                 }
  554.                 case 2:
  555.                 {
  556.                     if(get_pcvar_float(cvar_rdc_refill[1]) && !task_exists(id+RDC_TASK_REFILL))
  557.                     {
  558.                         if(g_rdc_ammo[id] == 1)
  559.                             set_task(get_pcvar_float(cvar_rdc_refill[1]), "Refill_Cannon", id+RDC_TASK_REFILL)
  560.                     }
  561.                 }
  562.             }
  563.             #endif
  564.             #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  565.             if(get_pcvar_float(cvar_rdc_refill) && !task_exists(id+RDC_TASK_REFILL))
  566.             {
  567.                 if(g_rdc_ammo[id] == 1)
  568.                     set_task(get_pcvar_float(cvar_rdc_refill), "Refill_Cannon", id+RDC_TASK_REFILL)
  569.             }
  570.             #endif
  571.  
  572.             g_rdc_ammo[id]--
  573.             update_ammo(id)
  574.            
  575.             fm_set_weapon_idle_time(id, weapon_rdc, g_rdc_dragon[id] && pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0 ? 5.0 : 3.5)
  576.             set_pdata_float(id, m_flNextAttack, g_rdc_dragon[id] && pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0 ? 5.0 : 3.5, PLAYER_LINUX_XTRA_OFF)
  577.  
  578.             Set_1st_Attack(id)
  579.             set_task(0.1, "Set_2nd_Attack", id + RDC_TASK_SHOOT)
  580.         }
  581.     }
  582.     else if(CurButton & IN_ATTACK2)
  583.     {
  584.         CurButton &= ~IN_ATTACK2
  585.         set_uc(uc_handle, UC_Buttons, CurButton)
  586.  
  587.         if(get_pdata_float(id, m_flNextSecondaryAttack, PLAYER_LINUX_XTRA_OFF) <= 0.0 && !g_rdc_preventmode[id] && g_rdc_ammo[id] > 0)
  588.             Switch_Mode(id)
  589.  
  590.     }
  591.    
  592.     return FMRES_HANDLED
  593. }
  594.  
  595. public Refill_Cannon(id)
  596. {
  597.     id -= RDC_TASK_REFILL
  598.    
  599.     if(!g_has_rdc[id])
  600.         return
  601.  
  602.     #if (defined GOLD) && (!defined RED)
  603.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  604.  
  605.     #endif
  606.     #if (defined RED) && (defined GOLD)
  607.     switch(g_has_rdc[id])
  608.     {
  609.         case 1: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[0])
  610.         case 2: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[1])
  611.     }
  612.     #endif
  613.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  614.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  615.     #endif
  616.  
  617.     update_ammo(id)
  618. }
  619.  
  620. public Switch_Mode(id)
  621. {
  622.     if(!g_has_rdc[id])
  623.         return
  624.  
  625.     if(g_current_mode[id])
  626.         return
  627.  
  628.     g_current_mode[id] = MODE_B
  629.    
  630.     #if (defined GOLD) && (!defined RED)
  631.     sub_p_model(id, RDC_Models[RDC_P_MODELB])
  632.     #endif
  633.    
  634.     #if (defined RED) && (defined GOLD)
  635.     if(g_has_rdc[id] == 1)
  636.         set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB])
  637.     else if(g_has_rdc[id] == 2)
  638.         sub_p_model(id, RDC_Models[RDC_P_MODELB])
  639.     #endif
  640.  
  641.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  642.     set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB])
  643.     #endif
  644.  
  645.     fm_play_weapon_animation(id, RDC_D_TRANSFORM)
  646.     fm_set_weapon_idle_time(id, weapon_rdc, 3.5)
  647.     set_pdata_float(id, m_flNextAttack, 3.5, PLAYER_LINUX_XTRA_OFF)
  648.     make_dragon_spirit(id)
  649. }
  650.  
  651. public Allow_Mode(id)
  652. {
  653.     id -= RDC_TASK_COOLDOWN
  654.  
  655.     if(!g_has_rdc[id])
  656.         return
  657.  
  658.     g_rdc_preventmode[id] = false
  659. }
  660.  
  661. public make_dragon_spirit(id)
  662. {
  663.     if(!g_has_rdc[id])
  664.         return
  665.  
  666.     new Float:flOrigin[3]
  667.    
  668.     pev(id, pev_origin, flOrigin)
  669.  
  670.     new rdc_dragonspirit = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  671.  
  672.     if(!pev_valid(rdc_dragonspirit))
  673.         return
  674.  
  675.     set_pev(rdc_dragonspirit, pev_classname, RDC_DRAGONSPIRIT_CLASSNAME)
  676.  
  677.     engfunc(EngFunc_SetOrigin, rdc_dragonspirit, flOrigin)
  678.  
  679.     set_pev(rdc_dragonspirit, pev_movetype, MOVETYPE_FOLLOW)
  680.  
  681.     set_pev(rdc_dragonspirit, pev_aiment, id)
  682.  
  683.     engfunc(EngFunc_SetModel, rdc_dragonspirit, RDC_Effects[1])
  684.  
  685.     set_pev(rdc_dragonspirit, pev_solid, SOLID_NOT)
  686.  
  687.     set_pev(rdc_dragonspirit, pev_animtime, get_gametime())
  688.    
  689.     set_pev(rdc_dragonspirit, pev_framerate, 1.0)
  690.    
  691.     set_pev(rdc_dragonspirit, pev_sequence, 1)
  692.  
  693.     set_task(3.5, "unleash_dragon", rdc_dragonspirit + RDC_TASK_UNLEASH)
  694.  
  695.     set_pev(rdc_dragonspirit, pev_nextthink, get_gametime() + 1.0)
  696. }
  697.  
  698. public make_explosion(iEnt)
  699. {
  700.     new Float:flOrigin[3]
  701.     pev(iEnt, pev_origin, flOrigin)
  702.  
  703.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  704.     write_byte(TE_EXPLOSION)
  705.     engfunc(EngFunc_WriteCoord, flOrigin[0])
  706.     engfunc(EngFunc_WriteCoord, flOrigin[1])
  707.     engfunc(EngFunc_WriteCoord, flOrigin[2])
  708.     write_short(g_explo_spr)
  709.     write_byte(22)
  710.     write_byte(35)
  711.     write_byte(TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND)
  712.     message_end()
  713. }
  714.  
  715. stock make_explosion2(id)
  716. {
  717.     if(!g_has_rdc[id])
  718.         return
  719.  
  720.     static flOrigin[3]
  721.     pev(id, pev_origin, flOrigin)
  722.  
  723.     new rdc_hole = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  724.  
  725.     if(!pev_valid(rdc_hole))
  726.         return
  727.  
  728.     set_pev(rdc_hole, pev_classname, RDC_EXPLOSION_CLASSNAME)
  729.    
  730.     engfunc(EngFunc_SetModel, rdc_hole, RDC_Effects[2])
  731.  
  732.     set_pev(rdc_hole, pev_rendermode, kRenderTransAdd)
  733.  
  734.     set_pev(rdc_hole, pev_renderamt, 200.0)
  735.  
  736.     engfunc(EngFunc_SetOrigin, rdc_hole, flOrigin)
  737.  
  738.     set_pev(rdc_hole, pev_solid, SOLID_NOT)
  739.  
  740.     set_pev(rdc_hole, pev_scale, 0.1)
  741.  
  742.     set_pev(rdc_hole, pev_animtime, get_gametime())
  743.  
  744.     set_pev(rdc_hole, pev_framerate, 1.0)
  745.    
  746.     set_pev(rdc_hole, pev_sequence, 1)
  747.  
  748.     set_pev(rdc_hole, pev_life, get_gametime() + 0.5)
  749.  
  750.     set_pev(rdc_hole, pev_nextthink, get_gametime() + 0.1)
  751.  
  752.     emit_sound(id, CHAN_WEAPON, RDC_Sounds[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  753.    
  754.     static victim
  755.     victim = -1
  756.    
  757.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, flOrigin, 400.0)) != 0)
  758.     {
  759.         if (!is_user_alive(victim) || !zp_get_user_zombie(victim))
  760.             continue
  761.        
  762.         fm_create_velocity_vector(victim, id, 200.0)
  763.     }
  764.    
  765. }
  766.  
  767. public Set_1st_Attack(id)
  768. {
  769.     create_fake_attack(id)
  770.  
  771.     switch(g_current_mode[id])
  772.     {
  773.         case MODE_A: fm_play_weapon_animation(id, RDC_SHOOTA)
  774.         case MODE_B: fm_play_weapon_animation(id, RDC_SHOOTB)
  775.     }
  776.  
  777.     emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  778.    
  779.     make_fire_effect(id)
  780.    
  781.     static Float:cl_pushangle[3]
  782.     cl_pushangle[0] = random_float(-3.5, -7.0)
  783.     cl_pushangle[1] = random_float(3.0, -3.0)
  784.     cl_pushangle[2] = 0.0
  785.    
  786.     set_pev(id, pev_punchangle, cl_pushangle)  
  787. }
  788.  
  789. public create_fake_attack(id)
  790. {
  791.     static fake_weapon
  792.     fake_weapon = fm_find_ent_by_owner(-1, "weapon_knife", id)
  793.    
  794.     if(pev_valid(fake_weapon))
  795.         ExecuteHamB(Ham_Weapon_PrimaryAttack, fake_weapon)
  796. }
  797.  
  798.  
  799. public Set_2nd_Attack(id)
  800. {
  801.     id -= RDC_TASK_SHOOT
  802.  
  803.     if(!g_has_rdc[id])
  804.         return
  805.  
  806.     create_fake_attack(id)
  807.  
  808.     switch(g_current_mode[id])
  809.     {
  810.         case MODE_A:
  811.         {
  812.             fm_play_weapon_animation(id, RDC_SHOOTA)
  813.             emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) 
  814.         }
  815.         case MODE_B:
  816.         {
  817.             if(pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0)
  818.             {
  819.                 fm_play_weapon_animation(id, RDC_D_RELOAD1)
  820.                 emit_sound(id, CHAN_WEAPON, RDC_Sounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  821.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  822.                 g_rdc_dragon[id] = 0
  823.                 set_task(2.5, "ResetMode", id + RDC_TASK_RESET)
  824.  
  825.                 #if (defined GOLD) && (!defined RED)
  826.                 if(get_pcvar_float(cvar_rdc_cooldown))
  827.                 {
  828.                     g_rdc_preventmode[id] = true
  829.                     set_task(get_pcvar_float(cvar_rdc_cooldown), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  830.                 }
  831.                 #endif
  832.                 #if (defined RED) && (defined GOLD)
  833.                 switch(g_has_rdc[id])
  834.                 {
  835.                     case 1:
  836.                     {
  837.                         if(get_pcvar_float(cvar_rdc_cooldown[0]))
  838.                         {
  839.                             g_rdc_preventmode[id] = true
  840.                             set_task(get_pcvar_float(cvar_rdc_cooldown[0]), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  841.                         }
  842.                     }
  843.                     case 2:
  844.                     {
  845.                         if(get_pcvar_float(cvar_rdc_cooldown[1]))
  846.                         {
  847.                             g_rdc_preventmode[id] = true
  848.                             set_task(get_pcvar_float(cvar_rdc_cooldown[1]), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  849.                         }
  850.                     }
  851.                 }
  852.                 #endif
  853.                 #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  854.                 if(get_pcvar_float(cvar_rdc_cooldown))
  855.                 {
  856.                     g_rdc_preventmode[id] = true
  857.                     set_task(get_pcvar_float(cvar_rdc_cooldown), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  858.                 }
  859.                 #endif
  860.             }
  861.             else
  862.             {
  863.                 fm_play_weapon_animation(id, RDC_SHOOTB)
  864.                 emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM) 
  865.             }
  866.  
  867.         }
  868.     }
  869.    
  870.     make_fire_effect(id)
  871.     check_radius_damage(id)
  872. }
  873.  
  874. public ResetMode(id)
  875. {
  876.     id -= RDC_TASK_RESET
  877.  
  878.     if(!g_has_rdc[id])
  879.         return
  880.  
  881.     fm_play_weapon_animation(id, RDC_D_RELOAD2)
  882.     g_current_mode[id] = MODE_A
  883.  
  884.     #if (defined GOLD) && (!defined RED)
  885.     sub_p_model(id, RDC_Models[RDC_P_MODEL])
  886.     #endif
  887.    
  888.     #if (defined RED) && (defined GOLD)
  889.     switch(g_has_rdc[id])
  890.     {
  891.         case 1: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL])
  892.         case 2: sub_p_model(id, RDC_Models[RDC_P_MODEL])
  893.     }
  894.     #endif
  895.    
  896.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  897.     set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL])
  898.     #endif
  899. }
  900.  
  901. public make_fire_effect(id)
  902. {
  903.     const MAX_FIRE = 12
  904.     static Float:StartOrigin[3], Float:TargetOrigin[MAX_FIRE][3], Float:Speed[MAX_FIRE]
  905.  
  906.     // Get Target
  907.    
  908.     // -- Left
  909.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[0]); Speed[0] = 150.0
  910.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[1]); Speed[1] = 180.0
  911.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[2]); Speed[2] = 210.0
  912.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[3]); Speed[3] = 240.0
  913.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[4]); Speed[4] = 300.0
  914.  
  915.     // -- Center
  916.     get_position(id, 100.0, 0.0, WEAPON_ATTACH_U, TargetOrigin[5]); Speed[5] = 150.0
  917.     get_position(id, 100.0, 0.0, WEAPON_ATTACH_U, TargetOrigin[6]); Speed[6] = 300.0
  918.    
  919.     // -- Right
  920.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[7]); Speed[7] = 150.0
  921.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[8]); Speed[8] = 180.0
  922.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[9]); Speed[9] = 210.0
  923.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[10]); Speed[10] = 240.0
  924.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[11]); Speed[11] = 300.0
  925.  
  926.     for(new i = 0; i < MAX_FIRE; i++)
  927.     {
  928.         // Get Start
  929.         get_position(id, random_float(30.0, 40.0), 0.0, WEAPON_ATTACH_U, StartOrigin)
  930.         create_fire(id, StartOrigin, TargetOrigin[i], Speed[i])
  931.     }
  932. }
  933.  
  934. public check_radius_damage(id)
  935. {
  936.     static Float:Origin[3]
  937.    
  938.     for(new i = 0; i <= g_maxplayers; i++)
  939.     {
  940.         if(!is_user_alive(i))
  941.             continue
  942.        
  943.         if(!zp_get_user_zombie(i))
  944.             continue
  945.  
  946.         if(id == i)
  947.             continue
  948.        
  949.         pev(i, pev_origin, Origin)
  950.        
  951.         if(!fm_is_in_viewcone(id, Origin))
  952.             continue
  953.  
  954.         if(fm_entity_range(id, i) >= 600.0)
  955.             continue
  956.  
  957.         #if (defined GOLD) && (!defined RED)
  958.         new Float:flDamageBase = get_pcvar_float(cvar_dmg_rdc)
  959.         #endif
  960.         #if (defined RED) && (defined GOLD)
  961.         static Float:flDamageBase
  962.         switch(g_has_rdc[id])
  963.         {
  964.             case 1: flDamageBase = get_pcvar_float(cvar_dmg_rdc[0])
  965.             case 2: flDamageBase = get_pcvar_float(cvar_dmg_rdc[1])
  966.         }
  967.         #endif
  968.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  969.         new Float:flDamageBase = get_pcvar_float(cvar_dmg_rdc)
  970.         #endif
  971.  
  972.         new Float:flDamage = flDamageBase * (fm_entity_range(id, i) + 100.0) / fm_entity_range(id, i)
  973.        
  974.         if(!is_user_bot(i))
  975.         make_victim_effects(i, DMG_BURN, 226, 88, 34)
  976.         fm_create_velocity_vector(i, id, 50.0)
  977.  
  978.         ExecuteHamB(Ham_TakeDamage, i, id, id, flDamage, DMG_NEVERGIB | DMG_BULLET)
  979.         make_blood(i, flDamage)
  980.     }
  981. }
  982.  
  983. stock create_fire(id, Float:Origin[3], Float:TargetOrigin[3], Float:Speed, bool:dragon = false)
  984. {
  985.     new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
  986.    
  987.     set_pev(iEnt, pev_classname, RDC_FIRE_CLASSNAME)
  988.     engfunc(EngFunc_SetModel, iEnt, RDC_Sprites[3])
  989.  
  990.     static Float:vfAngle[3], Float:Velocity[3]
  991.     pev(id, pev_angles, vfAngle)
  992.  
  993.     vfAngle[2] = float(random(18) * 20)
  994.  
  995.     // set info for ent
  996.     set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
  997.     set_pev(iEnt, pev_rendermode, kRenderTransAdd)
  998.     set_pev(iEnt, pev_renderamt, 250.0)
  999.    
  1000.    
  1001.     if(dragon)
  1002.     {
  1003.         set_pev(iEnt, pev_life, get_gametime() + 1.5)
  1004.         set_pev(iEnt, pev_owner, id)
  1005.     }
  1006.     else
  1007.         set_pev(iEnt, pev_life, get_gametime() + 3.0)
  1008.        
  1009.     set_pev(iEnt, pev_scale, dragon ? 0.1 : 1.0)
  1010.    
  1011.     set_pev(iEnt, pev_mins, Float:{-1.0, -1.0, -1.0})
  1012.     set_pev(iEnt, pev_maxs, Float:{1.0, 1.0, 1.0})
  1013.    
  1014.     engfunc(EngFunc_SetOrigin, iEnt, Origin)
  1015.     set_pev(iEnt, pev_gravity, 0.01)
  1016.     set_pev(iEnt, pev_angles, vfAngle)
  1017.    
  1018.     set_pev(iEnt, pev_solid, SOLID_TRIGGER)
  1019.    
  1020.     set_pev(iEnt, pev_frame, 0.0)
  1021.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  1022.  
  1023.     get_speed_vector(Origin, TargetOrigin, Speed, Velocity)
  1024.     set_pev(iEnt, pev_velocity, Velocity)
  1025. }
  1026.  
  1027. public update_ammo(id)
  1028. {
  1029.     if(!is_user_alive(id))
  1030.         return
  1031.        
  1032.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
  1033.     write_byte(1)
  1034.     write_byte(CSW_RDC)
  1035.     write_byte(-1)
  1036.     message_end()
  1037.    
  1038.     message_begin(MSG_ONE_UNRELIABLE, g_MsgAmmoX, .player = id)
  1039.     write_byte(7)
  1040.     write_byte(g_rdc_ammo[id])
  1041.     message_end()
  1042. }
  1043.  
  1044. public fw_SetModel(entity, model[])
  1045. {
  1046.     if(!pev_valid(entity))
  1047.         return FMRES_IGNORED
  1048.  
  1049.     static weapon[32], old_rdc[64]
  1050.  
  1051.     if(!fm_is_ent_classname(entity, "weaponbox"))
  1052.         return FMRES_IGNORED
  1053.  
  1054.     copy(weapon, charsmax(weapon), weapon_rdc)
  1055.     replace(weapon, charsmax(weapon), "weapon_", "")
  1056.  
  1057.     formatex(old_rdc, charsmax(old_rdc), "models/w_%s.mdl", weapon)
  1058.  
  1059.     static owner
  1060.     owner = pev(entity, pev_owner)
  1061.  
  1062.     if(equal(model, old_rdc))
  1063.     {
  1064.         static StoredWepID
  1065.        
  1066.         StoredWepID = fm_find_ent_by_owner(-1, weapon_rdc, entity)
  1067.    
  1068.         if(!pev_valid(StoredWepID))
  1069.             return FMRES_IGNORED
  1070.    
  1071.         if(g_has_rdc[owner])
  1072.         {
  1073.             #if (defined GOLD) && (!defined RED)
  1074.             set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1075.             switch(g_current_mode[owner])
  1076.             {
  1077.                 case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1078.                 case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1079.             }
  1080.             set_pev(entity, pev_body, 1)
  1081.             #endif
  1082.             #if (defined RED) && (defined GOLD)
  1083.             switch(g_has_rdc[owner])
  1084.             {
  1085.                 case 1:
  1086.                 {
  1087.                     set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1088.                     switch(g_current_mode[owner])
  1089.                     {
  1090.                         case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1091.                         case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1092.                     }
  1093.                 }
  1094.                 case 2:
  1095.                 {
  1096.                     set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY + 1)
  1097.                     switch(g_current_mode[owner])
  1098.                     {
  1099.                         case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1100.                         case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1101.                     }
  1102.                     set_pev(entity, pev_body, 1)
  1103.                 }
  1104.             }
  1105.             #endif
  1106.             #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1107.             set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1108.             switch(g_current_mode[owner])
  1109.             {
  1110.                 case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1111.                 case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1112.             }
  1113.             #endif
  1114.             set_pev(StoredWepID, pev_mode, g_current_mode[owner])
  1115.  
  1116.             remove_cannonex(owner)
  1117.  
  1118.             return FMRES_SUPERCEDE
  1119.         }
  1120.     }
  1121.     return FMRES_IGNORED
  1122. }
  1123.  
  1124. #if (defined GOLD) && (!defined RED)
  1125. public give_cannonex(id)
  1126. #endif
  1127. #if (defined RED) && (defined GOLD)
  1128. public give_cannonex(id, mode)
  1129. #endif
  1130. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1131. public give_cannonex(id)
  1132. #endif
  1133. {
  1134.     #if defined GOLD
  1135.     if(pev_valid(g_subpmodel[id]))
  1136.     {
  1137.         set_pev(g_subpmodel[id], pev_body, 0)
  1138.         set_pev(g_subpmodel[id], pev_flags, FL_KILLME)
  1139.         engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  1140.     }
  1141.  
  1142.     #endif
  1143.     drop_weapons(id)
  1144.  
  1145.     #if (defined GOLD) && (!defined RED)
  1146.     g_has_rdc[id] = true
  1147.     #endif
  1148.     #if (defined RED) && (defined GOLD)
  1149.     g_has_rdc[id] = mode
  1150.     #endif
  1151.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1152.     g_has_rdc[id] = true
  1153.     #endif
  1154.  
  1155.     g_current_mode[id] = MODE_A
  1156.  
  1157.     fm_give_item(id, weapon_rdc)
  1158.    
  1159.     static weapon_ent
  1160.     weapon_ent = fm_find_ent_by_owner(-1, weapon_rdc, id)
  1161.  
  1162.     message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1163.     write_string("weapon_cannonex")
  1164.     write_byte(7)
  1165.     write_byte(100)
  1166.     write_byte(-1)
  1167.     write_byte(-1)
  1168.     write_byte(0)
  1169.     write_byte(8)
  1170.     write_byte(CSW_RDC)
  1171.     write_byte(0)
  1172.     message_end()
  1173.    
  1174.     cs_set_weapon_ammo(weapon_ent, 50)
  1175.  
  1176.     #if (defined GOLD) && (!defined RED)
  1177.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  1178.     #endif
  1179.     #if (defined RED) && (defined GOLD)
  1180.     switch(g_has_rdc[id])
  1181.     {
  1182.         case 1: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[0])
  1183.         case 2: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[1])
  1184.     }
  1185.     #endif
  1186.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1187.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  1188.     #endif
  1189. }
  1190.  
  1191. public remove_cannonex(id)
  1192. {
  1193.     #if defined GOLD
  1194.     if(pev_valid(g_subpmodel[id]))
  1195.     {
  1196.         set_pev(g_subpmodel[id], pev_body, 0)
  1197.         engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  1198.     }
  1199.     #endif
  1200.  
  1201.     g_has_rdc[id] = false
  1202.     g_current_mode[id] = 0
  1203.     engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  1204.     g_rdc_dragon[id] = 0
  1205.     drop_weapons(id, CSW_RDC)
  1206.     remove_task(id+RDC_TASK_SHOOT)
  1207.     remove_task(id+RDC_TASK_RESET)
  1208.     remove_task(id+RDC_TASK_REFILL)
  1209. }
  1210.  
  1211. public zp_extra_item_selected(id, itemid)
  1212. {
  1213.     #if (defined GOLD) && (!defined RED)
  1214.     if(itemid != g_itemid)
  1215.         return
  1216.  
  1217.     give_cannonex(id)
  1218.     #endif
  1219.     #if (defined RED) && (defined GOLD)
  1220.     if(itemid == g_itemid[0])
  1221.         give_cannonex(id, 1)
  1222.     else if(itemid == g_itemid[1])
  1223.         give_cannonex(id, 2)
  1224.     #endif
  1225.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1226.     if(itemid != g_itemid)
  1227.         return
  1228.  
  1229.     give_cannonex(id)
  1230.     #endif
  1231. }
  1232.  
  1233. public fw_DragonCannon_AddToPlayer(item, id)
  1234. {
  1235.     if(!pev_valid(item))
  1236.         return HAM_IGNORED
  1237.  
  1238.     switch(pev(item, pev_impulse))
  1239.     {
  1240.         case 0:
  1241.         {
  1242.             message_begin(MSG_ONE, g_MsgWeaponList, .player = id)
  1243.             write_string(weapon_rdc)
  1244.             write_byte(7)
  1245.             write_byte(100)
  1246.             write_byte(-1)
  1247.             write_byte(-1)
  1248.             write_byte(0)
  1249.             write_byte(8)
  1250.             write_byte(CSW_RDC)
  1251.             write_byte(0)
  1252.             message_end()
  1253.            
  1254.             return HAM_IGNORED
  1255.         }
  1256.         #if (defined GOLD) && (!defined RED)
  1257.         case RDC_WEAPONKEY:
  1258.         {
  1259.             g_has_rdc[id] = true
  1260.  
  1261.             if(pev(item, pev_mode))
  1262.                 ResetMode(id+RDC_TASK_RESET)
  1263.  
  1264.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1265.             write_string("weapon_cannonex")
  1266.             write_byte(7)
  1267.             write_byte(100)
  1268.             write_byte(-1)
  1269.             write_byte(-1)
  1270.             write_byte(0)
  1271.             write_byte(8)
  1272.             write_byte(CSW_RDC)
  1273.             write_byte(0)
  1274.             message_end()
  1275.  
  1276.             set_pev(item, pev_impulse, 0)
  1277.             set_pev(item, pev_mode, 0)
  1278.  
  1279.             return HAM_HANDLED
  1280.         }
  1281.         #endif
  1282.         #if (defined RED) && (defined GOLD)
  1283.         case RDC_WEAPONKEY:
  1284.         {
  1285.             g_has_rdc[id] = 1
  1286.  
  1287.             if(pev(item, pev_mode))
  1288.                 ResetMode(id+RDC_TASK_RESET)
  1289.  
  1290.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1291.             write_string("weapon_cannonex")
  1292.             write_byte(7)
  1293.             write_byte(100)
  1294.             write_byte(-1)
  1295.             write_byte(-1)
  1296.             write_byte(0)
  1297.             write_byte(8)
  1298.             write_byte(CSW_RDC)
  1299.             write_byte(0)
  1300.             message_end()
  1301.  
  1302.             set_pev(item, pev_impulse, 0)
  1303.             set_pev(item, pev_mode, 0)
  1304.  
  1305.             return HAM_HANDLED
  1306.         }
  1307.         case RDC_WEAPONKEY + 1:
  1308.         {
  1309.             g_has_rdc[id] = 2
  1310.  
  1311.             if(pev(item, pev_mode))
  1312.                 ResetMode(id+RDC_TASK_RESET)
  1313.  
  1314.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1315.             write_string("weapon_cannonex")
  1316.             write_byte(7)
  1317.             write_byte(100)
  1318.             write_byte(-1)
  1319.             write_byte(-1)
  1320.             write_byte(0)
  1321.             write_byte(8)
  1322.             write_byte(CSW_RDC)
  1323.             write_byte(0)
  1324.             message_end()
  1325.  
  1326.             set_pev(item, pev_impulse, 0)
  1327.             set_pev(item, pev_mode, 0)
  1328.  
  1329.             return HAM_HANDLED
  1330.         }
  1331.         #endif
  1332.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1333.         case RDC_WEAPONKEY:
  1334.         {
  1335.             g_has_rdc[id] = true
  1336.  
  1337.             if(pev(item, pev_mode))
  1338.                 ResetMode(id+RDC_TASK_RESET)
  1339.  
  1340.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1341.             write_string("weapon_cannonex")
  1342.             write_byte(7)
  1343.             write_byte(100)
  1344.             write_byte(-1)
  1345.             write_byte(-1)
  1346.             write_byte(0)
  1347.             write_byte(8)
  1348.             write_byte(CSW_RDC)
  1349.             write_byte(0)
  1350.             message_end()
  1351.  
  1352.             set_pev(item, pev_impulse, 0)
  1353.             set_pev(item, pev_mode, 0)
  1354.  
  1355.             return HAM_HANDLED
  1356.         }
  1357.         #endif
  1358.     }
  1359.  
  1360.     return HAM_IGNORED
  1361. }
  1362.  
  1363. public fw_DragonCannon_WeaponIdle_Post(rdc)
  1364. {
  1365.     if(pev_valid(rdc) != 2)
  1366.         return HAM_IGNORED
  1367.  
  1368.     new id = fm_cs_get_weapon_ent_owner(rdc)
  1369.    
  1370.     if(fm_cs_get_current_weapon_ent(id) != rdc)
  1371.         return HAM_IGNORED
  1372.  
  1373.     if (!g_has_rdc[id])
  1374.         return HAM_IGNORED;
  1375.  
  1376.     if(get_pdata_float(rdc, m_flTimeWeaponIdle, WEAP_LINUX_XTRA_OFF) <= 0.1)
  1377.     {
  1378.         switch(g_current_mode[id])
  1379.         {
  1380.             case MODE_A: fm_play_weapon_animation(id, RDC_IDLE)
  1381.             case MODE_B: fm_play_weapon_animation(id, RDC_IDLEB)
  1382.         }
  1383.  
  1384.         set_pdata_float(rdc, m_flTimeWeaponIdle, 10.0, WEAP_LINUX_XTRA_OFF)
  1385.     }
  1386.  
  1387.     return HAM_IGNORED
  1388. }
  1389.  
  1390. public fw_UpdateClientData_Post(id, SendWeapons, CD_Handle)
  1391. {
  1392.     if(!is_user_alive(id) || get_user_weapon(id) != CSW_RDC || !g_has_rdc[id])
  1393.         return FMRES_IGNORED
  1394.    
  1395.     set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
  1396.     return FMRES_HANDLED
  1397. }
  1398.  
  1399. public message_DeathMsg(msg_id, msg_dest, id)
  1400. {
  1401.     static TruncatedWeapon[33], iAttacker, iVictim, weapon[32]
  1402.    
  1403.     copy(weapon, charsmax(weapon), weapon_rdc)
  1404.     replace(weapon, charsmax(weapon), "weapon_", "")
  1405.  
  1406.     get_msg_arg_string(4, TruncatedWeapon, charsmax(TruncatedWeapon))
  1407.  
  1408.     iAttacker = get_msg_arg_int(1)
  1409.     iVictim = get_msg_arg_int(2)
  1410.  
  1411.     if(!is_user_connected(iAttacker) || iAttacker == iVictim)
  1412.         return PLUGIN_CONTINUE
  1413.  
  1414.     if(equal(TruncatedWeapon, weapon) && get_user_weapon(iAttacker) == CSW_RDC && g_has_rdc[iAttacker])
  1415.             set_msg_arg_string(4, "cannonex")
  1416.  
  1417.     return PLUGIN_CONTINUE
  1418. }
  1419.  
  1420. public fw_Touch(iEnt, iTouchedEnt)
  1421. {
  1422.     if (!pev_valid(iEnt) || !pev_valid(iTouchedEnt))
  1423.         return FMRES_IGNORED
  1424.  
  1425.     if(fm_is_ent_classname(iEnt, RDC_FIRE_CLASSNAME) && !fm_is_ent_classname(iTouchedEnt, RDC_FIRE_CLASSNAME))
  1426.     {
  1427.         set_pev(iEnt, pev_movetype, MOVETYPE_NONE)
  1428.         set_pev(iEnt, pev_solid, SOLID_NOT)
  1429.  
  1430.         new id = pev(iEnt, pev_owner)
  1431.  
  1432.         if(id)
  1433.         {
  1434.             if(is_user_alive(iTouchedEnt) && zp_get_user_zombie(iTouchedEnt))
  1435.             {
  1436.                 #if (defined GOLD) && (!defined RED)
  1437.                 new Float:flDamage = get_pcvar_float(cvar_dmg_rdc)
  1438.                 #endif
  1439.                 #if (defined RED) && (defined GOLD)
  1440.                 static Float:flDamage
  1441.                 switch(g_has_rdc[id])
  1442.                 {
  1443.                     case 1: flDamage = get_pcvar_float(cvar_dmg_rdc[0])
  1444.                     case 2: flDamage = get_pcvar_float(cvar_dmg_rdc[1])
  1445.                 }
  1446.                 #endif
  1447.                 #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1448.                 new Float:flDamage = get_pcvar_float(cvar_dmg_rdc)
  1449.                 #endif
  1450.  
  1451.                 if(!is_user_bot(iTouchedEnt))
  1452.                 make_victim_effects(iTouchedEnt, DMG_BURN, 226, 88, 34)
  1453.                 fm_create_velocity_vector(iTouchedEnt, id, 50.0)
  1454.                 ExecuteHamB(Ham_TakeDamage, iTouchedEnt, id, id, flDamage, DMG_NEVERGIB | DMG_BULLET)
  1455.             }
  1456.         }
  1457.     }
  1458.  
  1459.     return FMRES_IGNORED
  1460. }
  1461.  
  1462. public fw_Think(iEnt)
  1463. {
  1464.     if(!pev_valid(iEnt))
  1465.         return FMRES_IGNORED
  1466.  
  1467.     if(fm_is_ent_classname(iEnt, RDC_FIRE_CLASSNAME))
  1468.     {
  1469.         new Float:fFrame, Float:fNextThink, Float:fScale
  1470.         pev(iEnt, pev_frame, fFrame)
  1471.         pev(iEnt, pev_scale, fScale)
  1472.        
  1473.         // effect exp
  1474.         new iMoveType = pev(iEnt, pev_movetype)
  1475.        
  1476.         if (iMoveType == MOVETYPE_NONE)
  1477.         {
  1478.             fNextThink = 0.0015
  1479.             fFrame += 0.5
  1480.            
  1481.             if (fFrame > 21.0)
  1482.             {
  1483.                 engfunc(EngFunc_RemoveEntity, iEnt)
  1484.                 return FMRES_IGNORED
  1485.             }
  1486.         }
  1487.        
  1488.         // effect normal
  1489.         else
  1490.         {
  1491.             fNextThink = 0.045
  1492.            
  1493.             fFrame += 0.5
  1494.             fScale += 0.01
  1495.            
  1496.             fFrame = floatmin(21.0, fFrame)
  1497.             fScale = floatmin(2.0, fFrame)
  1498.         }
  1499.        
  1500.         set_pev(iEnt, pev_frame, fFrame)
  1501.         set_pev(iEnt, pev_scale, fScale)
  1502.         set_pev(iEnt, pev_nextthink, get_gametime() + fNextThink)
  1503.        
  1504.         // time remove
  1505.         new Float:fTimeRemove
  1506.         pev(iEnt, pev_life, fTimeRemove)
  1507.        
  1508.         if (get_gametime() >= fTimeRemove)
  1509.         {
  1510.             if(!pev(iEnt, pev_owner))
  1511.                 emit_sound(iEnt, CHAN_BODY, RDC_Sounds[4], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1512.  
  1513.             engfunc(EngFunc_RemoveEntity, iEnt)
  1514.         }
  1515.     }
  1516.     else if(fm_is_ent_classname(iEnt, RDC_DRAGONSPIRIT_CLASSNAME))
  1517.     {
  1518.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.1)
  1519.     }
  1520.     else if(fm_is_ent_classname(iEnt, RDC_EXPLOSION_CLASSNAME))
  1521.     {
  1522.         if(pev(iEnt, pev_life) - get_gametime() <= 0.0)
  1523.         {
  1524.             set_pev(iEnt, pev_flags, FL_KILLME)
  1525.             engfunc(EngFunc_RemoveEntity, iEnt)
  1526.             return FMRES_IGNORED
  1527.         }
  1528.  
  1529.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.1)
  1530.     }
  1531.     else if(fm_is_ent_classname(iEnt, RDC_DRAGON_CLASSNAME))
  1532.     {
  1533.         static Float:flOrigin[3], Float:TargetOrigin[3], Float:flSpeed, Float:flRate
  1534.        
  1535.         flRate = 0.2
  1536.  
  1537.         static id
  1538.         id = pev(iEnt, pev_owner)
  1539.        
  1540.         if(!g_has_rdc[id])
  1541.         {
  1542.             engfunc(EngFunc_RemoveEntity, iEnt)
  1543.             return FMRES_IGNORED
  1544.         }
  1545.  
  1546.         pev(iEnt, pev_origin, flOrigin)
  1547.  
  1548.         flSpeed = pev(id, pev_maxspeed) - 5.0
  1549.  
  1550.         fm_get_aim_origin(id, TargetOrigin)
  1551.         npc_turntotarget(iEnt, TargetOrigin)
  1552.  
  1553.         if(pev(iEnt, pev_life) - get_gametime() >= 0.0 && pev(iEnt, pev_rate) - get_gametime() <= 0.0)
  1554.         {
  1555.             create_fire(id, flOrigin, TargetOrigin, 300.0, true)
  1556.             set_pev(iEnt, pev_rate, get_gametime() + flRate)
  1557.         }
  1558.  
  1559.         hook_ent2(iEnt, id, flSpeed)
  1560.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.1)
  1561.     }
  1562.  
  1563.     return FMRES_IGNORED
  1564. }
  1565.  
  1566. public unleash_dragon(rdc_dragonspirit)
  1567. {
  1568.     rdc_dragonspirit -= RDC_TASK_UNLEASH
  1569.  
  1570.     new id = pev(rdc_dragonspirit, pev_aiment)
  1571.  
  1572.     set_pev(rdc_dragonspirit, pev_flags, FL_KILLME)
  1573.     engfunc(EngFunc_RemoveEntity, rdc_dragonspirit)
  1574.  
  1575.     if(!is_user_alive(id) || !g_has_rdc[id])
  1576.         return
  1577.  
  1578.     g_rdc_dragon[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  1579.  
  1580.     if(!pev_valid(g_rdc_dragon[id]))
  1581.         return
  1582.  
  1583.     new Float:flOrigin[3]
  1584.    
  1585.     pev(id, pev_origin, flOrigin)
  1586.    
  1587.     flOrigin[2] += 75.0
  1588.  
  1589.     set_pev(g_rdc_dragon[id], pev_classname, RDC_DRAGON_CLASSNAME)
  1590.     engfunc(EngFunc_SetModel, g_rdc_dragon[id], RDC_Effects[0])
  1591.  
  1592.     #if (defined GOLD) && (!defined RED)
  1593.     set_pev(g_rdc_dragon[id], pev_body, 1)
  1594.     #endif
  1595.  
  1596.     #if (defined RED) && (defined GOLD)
  1597.     if(g_has_rdc[id] == 2)
  1598.         set_pev(g_rdc_dragon[id], pev_body, 1)
  1599.     #endif
  1600.  
  1601.     engfunc(EngFunc_SetOrigin, g_rdc_dragon[id], flOrigin)
  1602.  
  1603.     make_explosion(g_rdc_dragon[id])
  1604.    
  1605.     make_explosion2(id)
  1606.  
  1607.     set_pev(g_rdc_dragon[id], pev_movetype, MOVETYPE_FLY)
  1608.    
  1609.     set_pev(g_rdc_dragon[id], pev_owner, id)
  1610.  
  1611.     set_pev(g_rdc_dragon[id], pev_solid, SOLID_NOT)
  1612.  
  1613.     set_pev(g_rdc_dragon[id], pev_animtime, get_gametime())
  1614.  
  1615.     set_pev(g_rdc_dragon[id], pev_framerate, 1.0)
  1616.    
  1617.     set_pev(g_rdc_dragon[id], pev_sequence, 1)
  1618.  
  1619.     #if (defined GOLD) && (!defined RED)
  1620.     set_pev(g_rdc_dragon[id], pev_life, get_gametime() + get_pcvar_float(cvar_rdc_duration))
  1621.     #endif
  1622.     #if (defined RED) && (defined GOLD)
  1623.     switch(g_has_rdc[id])
  1624.     {
  1625.         case 1: set_pev(g_rdc_dragon[id], pev_life, get_gametime() + get_pcvar_float(cvar_rdc_duration[0]))
  1626.         case 2: set_pev(g_rdc_dragon[id], pev_life, get_gametime() + get_pcvar_float(cvar_rdc_duration[1]))
  1627.     }
  1628.     #endif
  1629.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1630.     set_pev(g_rdc_dragon[id], pev_life, get_gametime() + get_pcvar_float(cvar_rdc_duration))
  1631.     #endif
  1632.  
  1633.     set_pev(g_rdc_dragon[id], pev_nextthink, get_gametime() + 0.1)
  1634. }
  1635.  
  1636. #if defined GOLD
  1637. stock sub_p_model(id, const weapon_model[], submodel = 1)
  1638. {
  1639.     if(pev_valid(g_subpmodel[id]))
  1640.     {
  1641.         engfunc(EngFunc_SetModel, g_subpmodel[id], weapon_model)
  1642.         return
  1643.     }
  1644.  
  1645.     g_subpmodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  1646.  
  1647.     if (!pev_valid(g_subpmodel[id]))
  1648.         return
  1649.  
  1650.     set_pev(id, pev_weaponmodel2, "")
  1651.     set_pev(g_subpmodel[id], pev_classname, "SubPCannonexModel")
  1652.     engfunc(EngFunc_SetModel, g_subpmodel[id], weapon_model)
  1653.     set_pev(g_subpmodel[id], pev_movetype, MOVETYPE_FOLLOW)
  1654.     set_pev(g_subpmodel[id], pev_aiment, id)
  1655.     set_pev(g_subpmodel[id], pev_body, submodel)
  1656. }
  1657. #endif
  1658.  
  1659. stock make_blood(id, Float:Damage)
  1660. {
  1661.     new bloodColor = ExecuteHam(Ham_BloodColor, id)
  1662.     new Float:origin[3]
  1663.     pev(id, pev_origin, origin)
  1664.  
  1665.     if (bloodColor == -1)
  1666.         return
  1667.  
  1668.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  1669.     write_byte(TE_BLOODSPRITE)
  1670.     write_coord(floatround(origin[0]))
  1671.     write_coord(floatround(origin[1]))
  1672.     write_coord(floatround(origin[2]))
  1673.     write_short(m_iBlood[1])
  1674.     write_short(m_iBlood[0])
  1675.     write_byte(bloodColor)
  1676.     write_byte(min(max(3, floatround(Damage)/5), 16))
  1677.     message_end()
  1678. }
  1679.  
  1680. stock fm_get_aim_origin(index, Float:origin[3])
  1681. {
  1682.     new Float:start[3], Float:view_ofs[3];
  1683.     pev(index, pev_origin, start);
  1684.     pev(index, pev_view_ofs, view_ofs);
  1685.     xs_vec_add(start, view_ofs, start);
  1686.  
  1687.     new Float:dest[3];
  1688.     pev(index, pev_v_angle, dest);
  1689.     engfunc(EngFunc_MakeVectors, dest);
  1690.     global_get(glb_v_forward, dest);
  1691.     xs_vec_mul_scalar(dest, 9999.0, dest);
  1692.     xs_vec_add(start, dest, dest);
  1693.  
  1694.     engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
  1695.     get_tr2(0, TR_vecEndPos, origin);
  1696.  
  1697.     return 1;
  1698. }
  1699.  
  1700. stock npc_turntotarget(ent, Float:Vic_Origin[3])
  1701. {
  1702.     static Float:newAngle[3], Float:EntOrigin[3]
  1703.     static Float:x, Float:z, Float:radians
  1704.  
  1705.     pev(ent, pev_angles, newAngle)
  1706.     pev(ent, pev_origin, EntOrigin)
  1707.  
  1708.     x = Vic_Origin[0] - EntOrigin[0]
  1709.     z = Vic_Origin[1] - EntOrigin[1]
  1710.  
  1711.     radians = floatatan(z / x, radian)
  1712.     newAngle[1] = radians * (180 / 3.14)
  1713.  
  1714.     if(Vic_Origin[0] < EntOrigin[0]) newAngle[1] -= 180.00
  1715.  
  1716.     set_pev(ent, pev_angles, newAngle)
  1717. }
  1718.  
  1719.  
  1720. stock fm_cs_get_current_weapon_ent(id)
  1721.     return get_pdata_cbase(id, m_pActiveItem, PLAYER_LINUX_XTRA_OFF)
  1722.  
  1723. stock fm_cs_get_weapon_ent_owner(ent)
  1724.     return get_pdata_cbase(ent, m_pPlayer, WEAP_LINUX_XTRA_OFF)
  1725.  
  1726. stock fm_set_weapon_idle_time(id, const class[], Float:IdleTime)
  1727. {
  1728.     static weapon_ent
  1729.     weapon_ent = fm_find_ent_by_owner(-1, class, id)
  1730.  
  1731.     if(!pev_valid(weapon_ent))
  1732.         return
  1733.  
  1734.     set_pdata_float(weapon_ent, m_flNextPrimaryAttack, IdleTime, WEAP_LINUX_XTRA_OFF)
  1735.     set_pdata_float(weapon_ent, m_flNextSecondaryAttack, IdleTime, WEAP_LINUX_XTRA_OFF)
  1736.     set_pdata_float(weapon_ent, m_flTimeWeaponIdle, IdleTime + 0.50, WEAP_LINUX_XTRA_OFF)
  1737. }
  1738.  
  1739. stock fm_play_weapon_animation(const id, const Sequence)
  1740. {
  1741.     set_pev(id, pev_weaponanim, Sequence)
  1742.    
  1743.     message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = id)
  1744.     write_byte(Sequence)
  1745.     write_byte(pev(id, pev_body))
  1746.     message_end()
  1747. }
  1748.  
  1749. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
  1750. {
  1751.     new strtype[11] = "classname", ent = index;
  1752.  
  1753.     switch (jghgtype)
  1754.     {
  1755.         case 1: strtype = "target";
  1756.         case 2: strtype = "targetname";
  1757.     }
  1758.  
  1759.     while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
  1760.  
  1761.     return ent;
  1762. }
  1763.  
  1764. stock fm_give_item(index, const item[])
  1765. {
  1766.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  1767.         return 0;
  1768.  
  1769.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
  1770.    
  1771.     if (!pev_valid(ent))
  1772.         return 0;
  1773.  
  1774.     new Float:origin[3];
  1775.     pev(index, pev_origin, origin);
  1776.     set_pev(ent, pev_origin, origin);
  1777.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  1778.     dllfunc(DLLFunc_Spawn, ent);
  1779.  
  1780.     new save = pev(ent, pev_solid);
  1781.     dllfunc(DLLFunc_Touch, ent, index);
  1782.     if (pev(ent, pev_solid) != save)
  1783.         return ent;
  1784.  
  1785.     engfunc(EngFunc_RemoveEntity, ent);
  1786.  
  1787.     return -1;
  1788. }
  1789.  
  1790. stock fm_get_user_weapon_entity(id, wid = 0)
  1791. {
  1792.     new weap = wid, clip, ammo;
  1793.     if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
  1794.         return 0;
  1795.  
  1796.     if(!pev_valid(weap))
  1797.         return 0
  1798.  
  1799.     new class[32];
  1800.     get_weaponname(weap, class, sizeof class - 1);
  1801.  
  1802.     return fm_find_ent_by_owner(-1, class, id);
  1803. }
  1804.  
  1805. stock bool:fm_is_ent_classname(index, const classname[])
  1806. {
  1807.     if (!pev_valid(index))
  1808.         return false;
  1809.  
  1810.     new class[32];
  1811.     pev(index, pev_classname, class, sizeof class - 1);
  1812.  
  1813.     if (equal(class, classname))
  1814.         return true;
  1815.  
  1816.     return false;
  1817. }
  1818.  
  1819. stock Float:fm_entity_range(ent1, ent2)
  1820. {
  1821.     new Float:origin1[3], Float:origin2[3]
  1822.    
  1823.     pev(ent1, pev_origin, origin1)
  1824.     pev(ent2, pev_origin, origin2)
  1825.  
  1826.     return get_distance_f(origin1, origin2)
  1827. }
  1828.  
  1829. stock hook_ent2(ent, id, Float:speed)
  1830. {
  1831.     if(!pev_valid(ent))
  1832.         return
  1833.    
  1834.     static Float:flVelocity[3], Float:EntOrigin[3], Float:flOrigin[3], Float:flDistance, Float:flTime
  1835.    
  1836.     pev(ent, pev_origin, EntOrigin)
  1837.     pev(id, pev_origin, flOrigin)
  1838.  
  1839.     flDistance = get_distance_f(EntOrigin, flOrigin)
  1840.    
  1841.     flTime = flDistance / speed
  1842.  
  1843.     if(pev(ent, pev_life) - get_gametime() <= 0.0)
  1844.     {
  1845.         flOrigin[2] += 50.0
  1846.  
  1847.         if(flDistance >= 20.0)
  1848.         {
  1849.             flVelocity[0] = (flOrigin[0] - EntOrigin[0]) / flTime
  1850.             flVelocity[1] = (flOrigin[1] - EntOrigin[1]) / flTime
  1851.             flVelocity[2] = (flOrigin[2] - EntOrigin[2]) / flTime
  1852.         }
  1853.         else
  1854.         {
  1855.             flVelocity[0] = 1.0
  1856.             flVelocity[1] = 1.0
  1857.             flVelocity[2] = 1.0
  1858.         }
  1859.     }
  1860.  
  1861.     else
  1862.     {
  1863.         if(flDistance >= 150.0)
  1864.         {
  1865.             flVelocity[0] = (flOrigin[0] - EntOrigin[0]) / flTime
  1866.             flVelocity[1] = (flOrigin[1] - EntOrigin[1]) / flTime
  1867.             flVelocity[2] = (flOrigin[2] - EntOrigin[2]) / flTime + 125.0
  1868.         }
  1869.         else
  1870.         {
  1871.             flVelocity[0] = 1.0
  1872.             flVelocity[1] = 1.0
  1873.             flVelocity[2] = 1.0
  1874.         }
  1875.     }
  1876.     set_pev(ent, pev_velocity, flVelocity)
  1877. }
  1878.  
  1879. stock bool:fm_is_in_viewcone(index, const Float:point[3])
  1880. {
  1881.     new Float:angles[3];
  1882.     pev(index, pev_angles, angles);
  1883.     engfunc(EngFunc_MakeVectors, angles);
  1884.     global_get(glb_v_forward, angles);
  1885.     angles[2] = 0.0;
  1886.  
  1887.     new Float:origin[3], Float:diff[3], Float:norm[3];
  1888.     pev(index, pev_origin, origin);
  1889.     xs_vec_sub(point, origin, diff);
  1890.     diff[2] = 0.0;
  1891.     xs_vec_normalize(diff, norm);
  1892.  
  1893.     new Float:dot, Float:fov;
  1894.     dot = xs_vec_dot(norm, angles);
  1895.     pev(index, pev_fov, fov);
  1896.    
  1897.     if (dot >= floatcos(fov * M_PI / 360))
  1898.         return true;
  1899.  
  1900.     return false;
  1901. }
  1902.  
  1903. stock get_position(id,Float:forw, Float:right, Float:up, Float:vStart[])
  1904. {
  1905.     new Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
  1906.    
  1907.     pev(id, pev_origin, vOrigin)
  1908.     pev(id, pev_view_ofs,vUp) //for player
  1909.     xs_vec_add(vOrigin,vUp,vOrigin)
  1910.     pev(id, pev_v_angle, vAngle) // if normal entity ,use pev_angles
  1911.    
  1912.     angle_vector(vAngle, ANGLEVECTOR_FORWARD, vForward) //or use EngFunc_AngleVectors
  1913.     angle_vector(vAngle, ANGLEVECTOR_RIGHT, vRight)
  1914.     angle_vector(vAngle, ANGLEVECTOR_UP, vUp)
  1915.    
  1916.     vStart[0] = vOrigin[0] + vForward[0] * forw + vRight[0] * right + vUp[0] * up
  1917.     vStart[1] = vOrigin[1] + vForward[1] * forw + vRight[1] * right + vUp[1] * up
  1918.     vStart[2] = vOrigin[2] + vForward[2] * forw + vRight[2] * right + vUp[2] * up
  1919. }
  1920.  
  1921. stock get_angle_to_target(id, const Float:fTarget[3], Float:TargetSize = 0.0)
  1922. {
  1923.     new Float:fOrigin[3], iAimOrigin[3], Float:fAimOrigin[3], Float:fV1[3]
  1924.     pev(id, pev_origin, fOrigin)
  1925.     get_user_origin(id, iAimOrigin, 3) // end position from eyes
  1926.     IVecFVec(iAimOrigin, fAimOrigin)
  1927.     xs_vec_sub(fAimOrigin, fOrigin, fV1)
  1928.    
  1929.     new Float:fV2[3]
  1930.     xs_vec_sub(fTarget, fOrigin, fV2)
  1931.    
  1932.     new iResult = get_angle_between_vectors(fV1, fV2)
  1933.    
  1934.     if (TargetSize > 0.0)
  1935.     {
  1936.         new Float:fTan = TargetSize / get_distance_f(fOrigin, fTarget)
  1937.         new fAngleToTargetSize = floatround( floatatan(fTan, degrees) )
  1938.         iResult -= (iResult > 0) ? fAngleToTargetSize : -fAngleToTargetSize
  1939.     }
  1940.    
  1941.     return iResult
  1942. }
  1943.  
  1944. stock get_angle_between_vectors(const Float:fV1[3], const Float:fV2[3])
  1945. {
  1946.     new Float:fA1[3], Float:fA2[3]
  1947.     engfunc(EngFunc_VecToAngles, fV1, fA1)
  1948.     engfunc(EngFunc_VecToAngles, fV2, fA2)
  1949.    
  1950.     new iResult = floatround(fA1[1] - fA2[1])
  1951.     iResult = iResult % 360
  1952.     iResult = (iResult > 180) ? (iResult - 360) : iResult
  1953.    
  1954.     return iResult
  1955. }
  1956.  
  1957. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  1958. {
  1959.     new_velocity[0] = origin2[0] - origin1[0]
  1960.     new_velocity[1] = origin2[1] - origin1[1]
  1961.     new_velocity[2] = origin2[2] - origin1[2]
  1962.  
  1963.     new Float:num = floatsqroot(speed * speed / (new_velocity[0] * new_velocity[0] + new_velocity[1] * new_velocity[1] + new_velocity[2] * new_velocity[2]))
  1964.    
  1965.     new_velocity[0] *= num
  1966.     new_velocity[1] *= num
  1967.     new_velocity[2] *= num
  1968.    
  1969.     return 1;
  1970. }
  1971.  
  1972. stock fm_create_velocity_vector(victim, attacker, Float:Coef)
  1973. {
  1974.     if(is_user_connected(victim))
  1975.     {
  1976.         if(!zp_get_user_zombie(victim) || !is_user_alive(attacker))
  1977.         return 0;
  1978.  
  1979.         new Float:velocity[3], Float:oldvelo[3]
  1980.  
  1981.         pev(victim, pev_velocity, oldvelo)
  1982.  
  1983.         new Float:vicorigin[3], Float:attorigin[3]
  1984.  
  1985.         pev(victim, pev_origin, vicorigin)
  1986.         pev(attacker, pev_origin, attorigin)
  1987.  
  1988.         new Float:origin2[3]
  1989.  
  1990.         origin2[0] = vicorigin[0] - attorigin[0]
  1991.         origin2[1] = vicorigin[1] - attorigin[1]
  1992.        
  1993.         new Float:largestnum
  1994.        
  1995.         if(floatabs(origin2[0]) > largestnum)
  1996.             largestnum = floatabs(origin2[0])
  1997.        
  1998.         if(floatabs(origin2[1]) > largestnum)
  1999.             largestnum = floatabs(origin2[1])
  2000.        
  2001.         origin2[0] /= largestnum
  2002.         origin2[1] /= largestnum
  2003.        
  2004.         velocity[0] = (origin2[0] * (Coef * 1000)) / floatround(fm_entity_range(victim, attacker))
  2005.         velocity[1] = (origin2[1] * (Coef * 1000)) / floatround(fm_entity_range(victim, attacker))
  2006.        
  2007.         if(velocity[0] <= 20.0 || velocity[1] <= 20.0)
  2008.             velocity[2] = random_float(200.0 , 275.0)
  2009.  
  2010.         velocity[0] += oldvelo[0]
  2011.         velocity[1] += oldvelo[1]
  2012.        
  2013.         set_pev(victim, pev_velocity, velocity)
  2014.     }
  2015.     return 1;
  2016. }
  2017.  
  2018. stock make_victim_effects(victim, DMG_MESSAGE, FadeR, FadeG, FadeB)
  2019. {
  2020.     message_begin(MSG_ONE_UNRELIABLE, g_MsgEffect[0], .player = victim)
  2021.     write_byte(0)
  2022.     write_byte(0)
  2023.     write_long(DMG_MESSAGE)
  2024.     write_coord(0)
  2025.     write_coord(0)
  2026.     write_coord(0)
  2027.     message_end()
  2028.    
  2029.     message_begin(MSG_ONE_UNRELIABLE, g_MsgEffect[1], .player = victim)
  2030.     write_short(1<<13)
  2031.     write_short(1<<14)
  2032.     write_short(0x0000)
  2033.     write_byte(FadeR)
  2034.     write_byte(FadeG)
  2035.     write_byte(FadeB)
  2036.     write_byte(100)
  2037.     message_end()
  2038.        
  2039.     message_begin(MSG_ONE, g_MsgEffect[2], .player = victim)
  2040.     write_short(0xFFFF)
  2041.     write_short(1<<13)
  2042.     write_short(0xFFFF)
  2043.     message_end()
  2044. }
  2045.  
  2046. stock bool:drop_weapons(id, wid = 0)
  2047. {
  2048.     static wname[32]
  2049.  
  2050.     if(wid)
  2051.     {
  2052.         new weapon = wid, clip, ammo;
  2053.        
  2054.         if (!weapon && !(weapon = get_user_weapon(id, clip, ammo)))
  2055.             return false
  2056.        
  2057.         get_weaponname(weapon, wname, sizeof wname - 1)
  2058.         engclient_cmd(id, "drop", wname)
  2059.     }
  2060.  
  2061.     else
  2062.     {
  2063.         static weapons[32], num, i, weaponid
  2064.         num = 0
  2065.         get_user_weapons(id, weapons, num)
  2066.  
  2067.         for (i = 0; i < num; i++)
  2068.         {
  2069.             weaponid = weapons[i]
  2070.  
  2071.             if((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
  2072.             {
  2073.                 get_weaponname(weaponid, wname, sizeof wname - 1)
  2074.                 engclient_cmd(id, "drop", wname)
  2075.             }
  2076.         }
  2077.     }
  2078.  
  2079.     return true
  2080. }

Mystic Viper
Member
Member
Romania
Posts: 96
Joined: 10 Months Ago
Has thanked: 1 time
Been thanked: 3 times
Contact:

#2

Post by Mystic Viper » 3 Months Ago

up pls

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 11 Months Ago
Location: Des Moines/USA
Has thanked: 6 times
Been thanked: 21 times
Age: 33
Contact:

#3

Post by Mark » 3 Months Ago

Did you try this?

viewtopic.php?f=7&t=73

karan
Mod Tester
Mod Tester
India
Posts: 53
Joined: 1 Year Ago
Location: India
Has thanked: 1 time
Been thanked: 3 times
Age: 21
Contact:

#4

Post by karan » 3 Months Ago

  1. #include <zombie_escape>
  2. #include <amxmodx>
  3. #include <fakemeta>
  4. #include <hamsandwich>
  5. #include <xs>
  6. #include <cstrike>
  7.  
  8. // Mofiying Plugin Info Will Violate CopyRight///////////
  9. #define PLUGIN "[Z47] RED AND GOLDEN DRAGON CANNON" /////
  10. #define VERSION "1.0"                               /////
  11. #define AUTHOR "ZinoZack47"                         /////
  12. ////////////////////////////////////////////////////////
  13.  
  14.  
  15. /*
  16.     -if you want to use the Golden Dragon Cannon only, delete #define RED
  17.     -if you want to use Both Red and Golden Dragon Cannon, then make sure #define RED and #define GOLD are added. May cause crashes so be warned.
  18.     -if you want to use the Red Dragon Cannon only, delete #define GOLD
  19. */
  20.  
  21. #define RED
  22. #define GOLD
  23.  
  24. #define RDC_WEAPONKEY                   118639647
  25.  
  26. #define WEAP_LINUX_XTRA_OFF             4
  27. #define PLAYER_LINUX_XTRA_OFF           5
  28.  
  29. #define m_pPlayer                       41
  30. #define m_flNextPrimaryAttack           46
  31. #define m_flNextSecondaryAttack         47
  32. #define m_flTimeWeaponIdle              48
  33.  
  34. #define m_flNextAttack                  83
  35. #define m_pActiveItem                   373
  36.  
  37. #define RDC_DRAW_TIME                   1.0
  38.  
  39. #define CSW_RDC                         CSW_P90
  40. #define weapon_rdc                      "weapon_p90"
  41.  
  42. #define RDC_FIRE_CLASSNAME              "rdc_fire"
  43. #define RDC_DRAGON_CLASSNAME            "rdc_dragon"
  44. #define RDC_DRAGONSPIRIT_CLASSNAME      "rdc_dragon_spirit"
  45. #define RDC_EXPLOSION_CLASSNAME         "rdc_explosion"
  46.  
  47. #define WEAPON_ATTACH_F                 30.0
  48. #define WEAPON_ATTACH_R                 10.0
  49. #define WEAPON_ATTACH_U                 -5.0
  50.  
  51. const pev_mode = pev_iuser1
  52. const pev_life = pev_fuser1
  53. const pev_rate = pev_fuser2
  54.  
  55. enum ( += 47)
  56. {
  57.     RDC_TASK_SHOOT =  45756778,
  58.     RDC_TASK_UNLEASH,
  59.     RDC_TASK_RESET,
  60.     RDC_TASK_COOLDOWN,
  61.     RDC_TASK_REFILL
  62. }
  63.  
  64. enum
  65. {
  66.     MODE_A = 0,
  67.     MODE_B
  68. }
  69.  
  70. enum
  71. {
  72.     RDC_IDLE = 0,
  73.     RDC_IDLEB,
  74.     RDC_DRAW,
  75.     RDC_DRAWB,
  76.     RDC_SHOOTA,
  77.     RDC_SHOOTB,
  78.     RDC_D_TRANSFORM,
  79.     RDC_D_RELOAD1,
  80.     RDC_D_RELOAD2
  81. }
  82.  
  83. enum
  84. {
  85.     RDC_P_MODEL = 0,
  86.     RDC_P_MODELB,
  87.     RDC_W_MODEL,
  88.     RDC_W_MODELB
  89. }
  90.  
  91. #if (defined GOLD) && (!defined RED)
  92. new const GDC_V_MODEL[64] = "models/z47_cannonex/v_cannonexgold.mdl"
  93. #endif
  94. #if (defined GOLD) && (defined RED)
  95. new const RDC_V_MODEL[64] = "models/z47_cannonex/v_cannonex.mdl"
  96. new const GDC_V_MODEL[64] = "models/z47_cannonex/v_cannonexgold.mdl"
  97. #endif
  98. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  99. new const RDC_V_MODEL[64] = "models/z47_cannonex/v_cannonex.mdl"
  100. #endif
  101.  
  102. new const RDC_Models[][] =
  103. {
  104.     "models/z47_cannonex/p_cannonex.mdl",
  105.     "models/z47_cannonex/p_cannonexb.mdl",
  106.     "models/z47_cannonex/w_cannonex.mdl",
  107.     "models/z47_cannonex/w_cannonexb.mdl"
  108. }
  109.  
  110. new const RDC_Sounds[][] =
  111. {
  112.     "weapons/z47_cannonex/cannonex_shoota.wav",
  113.     "weapons/z47_cannonex/cannonex_d_reload1.wav",
  114.     "weapons/z47_cannonex/cannonex_d_reload2.wav",
  115.     "weapons/z47_cannonex/cannonex_dtransform.wav",
  116.     "weapons/z47_cannonex/cannonex_dragon_fire_end.wav",
  117.     "weapons/z47_cannonex/cannonexplo.wav"
  118. }
  119.  
  120. new const RDC_Effects[][] =
  121. {
  122.     "models/z47_cannonex/cannonexdragon.mdl",
  123.     "models/z47_cannonex/p_cannonexdragonfx.mdl",
  124.     "models/z47_cannonex/p_cannonexplo.mdl"
  125. }
  126.  
  127. new const RDC_Sprites[][] =
  128. {
  129.     "sprites/weapon_cannonex.txt",
  130.     "sprites/640hud2_47.spr",
  131.     "sprites/640hud161.spr",
  132.     "sprites/fire_cannon.spr"
  133. }
  134.  
  135. #if (defined GOLD) && (!defined RED)
  136. new cvar_dmg_rdc, cvar_rdc_ammo, cvar_rdc_duration, cvar_rdc_cooldown, cvar_rdc_refill, cvar_one_round
  137. #endif
  138. #if (defined RED) && (defined GOLD)
  139. new cvar_dmg_rdc[2], cvar_rdc_ammo[2], cvar_rdc_duration[2], cvar_rdc_cooldown[2], cvar_rdc_refill[2], cvar_one_round[2]
  140. #endif
  141. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  142. new cvar_dmg_rdc, cvar_rdc_ammo, cvar_rdc_duration, cvar_rdc_cooldown, cvar_rdc_refill, cvar_one_round
  143. #endif
  144.  
  145. new g_maxplayers
  146. new m_iBlood[2], g_explo_spr
  147. new g_current_mode[33], g_rdc_ammo[33], g_rdc_dragon[33], bool:g_rdc_preventmode[33]
  148. new g_MsgWeaponList, g_MsgCurWeapon, g_MsgAmmoX, g_MsgEffect[3]
  149.  
  150. #if (defined GOLD) && (!defined RED)
  151. new g_subpmodel[33]
  152. new bool:g_has_rdc[33]
  153. new g_itemid
  154. #endif
  155. #if (defined RED) && (defined GOLD)
  156. new g_subpmodel[33]
  157. new g_has_rdc[33]
  158. new g_itemid[2]
  159. #endif
  160. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  161. new bool:g_has_rdc[33]
  162. new g_itemid
  163. new g_itemid[0], g_itemid[1]
  164. #endif
  165.  
  166. const PRIMARY_WEAPONS_BIT_SUM =
  167. (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|
  168. (1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
  169.  
  170. public plugin_init()
  171. {
  172.     register_plugin(PLUGIN, VERSION, AUTHOR)
  173.  
  174.     register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
  175.  
  176.     register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0")
  177.     register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
  178.  
  179.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  180.     RegisterHam(Ham_Item_Deploy, weapon_rdc, "fw_DragonCannon_Deploy_Post", 1)
  181.     RegisterHam(Ham_Item_AddToPlayer, weapon_rdc, "fw_DragonCannon_AddToPlayer")
  182.     RegisterHam(Ham_Weapon_WeaponIdle, weapon_rdc, "fw_DragonCannon_WeaponIdle_Post", 1)
  183.  
  184.     register_forward(FM_CmdStart, "fw_CmdStart")
  185.     register_forward(FM_Think, "fw_Think")
  186.     register_forward(FM_Touch, "fw_Touch")
  187.     register_forward(FM_SetModel, "fw_SetModel")
  188.     register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
  189.  
  190.     #if (defined GOLD) && (!defined RED)
  191.     cvar_rdc_ammo = register_cvar("ze_cannonexgold_ammo", "50")
  192.     cvar_dmg_rdc = register_cvar("ze_cannonexgold_dmg", "500.0")
  193.     cvar_rdc_duration = register_cvar("ze_cannonexgold_dragonduration", "20.0")
  194.     cvar_rdc_cooldown = register_cvar("ze_cannonexgold_mode_cooldown", "20.0")
  195.     cvar_rdc_refill = register_cvar("ze_cannonexgold_refill", "40.0")
  196.     cvar_one_round = register_cvar("ze_cannonexgold_one_round", "0")
  197.    
  198.     #endif
  199.     #if (defined RED) && (defined GOLD)
  200.     cvar_rdc_ammo[0] = register_cvar("ze_cannonexred_ammo", "50")
  201.     cvar_dmg_rdc[0] = register_cvar("ze_cannonexred_dmg", "500.0")
  202.     cvar_rdc_duration[0] = register_cvar("ze_cannonexred_dragonduration", "20.0")
  203.     cvar_rdc_cooldown[0] = register_cvar("ze_cannonexred_mode_cooldown", "20.0")
  204.     cvar_rdc_refill[0] = register_cvar("ze_cannonexred_refill", "40.0")
  205.     cvar_one_round[0] = register_cvar("ze_cannonexred_one_round", "0")
  206.    
  207.     cvar_rdc_ammo[1] = register_cvar("ze_cannonexgold_ammo", "100")
  208.     cvar_dmg_rdc[1] = register_cvar("ze_cannonexgold_dmg", "700.0")
  209.     cvar_rdc_duration[1] = register_cvar("ze_cannonexgold_dragonduration", "30.0")
  210.     cvar_rdc_cooldown[1] = register_cvar("ze_cannonexgold_mode_cooldown", "15.0")
  211.     cvar_rdc_refill[1] = register_cvar("ze_cannonexgold_refill", "30.0")
  212.     cvar_one_round[1] = register_cvar("ze_cannonexgold_one_round", "0")
  213.  
  214.     #endif
  215.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  216.     cvar_rdc_ammo = register_cvar("ze_cannonexred_ammo", "50")
  217.     cvar_dmg_rdc = register_cvar("ze_cannonexred_dmg", "500.0")
  218.     cvar_rdc_duration = register_cvar("ze_cannonexred_dragonduration", "20.0")
  219.     cvar_rdc_cooldown = register_cvar("ze_cannonexred_mode_cooldown", "20.0")
  220.     cvar_rdc_refill = register_cvar("ze_cannonexred_refill", "40.0")
  221.     cvar_one_round = register_cvar("ze_cannonexred_one_round", "0")
  222.     #endif
  223.  
  224.     g_MsgWeaponList = get_user_msgid("WeaponList")
  225.     g_MsgCurWeapon = get_user_msgid("CurWeapon")
  226.     g_MsgAmmoX = get_user_msgid("AmmoX")
  227.     g_MsgEffect[0] = get_user_msgid("Damage")
  228.     g_MsgEffect[1] = get_user_msgid("ScreenFade")
  229.     g_MsgEffect[2] = get_user_msgid("ScreenShake")
  230.  
  231.     #if (defined GOLD) && (!defined RED)
  232.     //g_itemid = ze_register_item("Golden Dragon Cannon", 10, 0)
  233.     #endif
  234.     #if (defined RED) && (defined GOLD)
  235.     g_itemid[0] = ze_register_item("Red Dragon Cannon", 10, 0)
  236.     //g_itemid[1] = ze_register_item("Golden Dragon Cannon", 10, 0)
  237.     #endif
  238.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  239.     //g_itemid = ze_register_item("Red Dragon Cannon", 10, 0)
  240.     #endif
  241.  
  242.     register_clcmd("weapon_cannonex", "select_cannonex")
  243.     g_maxplayers = get_maxplayers()
  244. }
  245.  
  246. public plugin_precache()
  247. {
  248.     #if (defined GOLD) && (!defined RED)
  249.     precache_model(GDC_V_MODEL)
  250.     #endif
  251.     #if (defined RED) && (defined GOLD)
  252.     precache_model(RDC_V_MODEL)
  253.     precache_model(GDC_V_MODEL)
  254.     #endif
  255.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  256.     precache_model(RDC_V_MODEL)
  257.     #endif
  258.  
  259.     for(new i = 0; i < sizeof(RDC_Models); i++)
  260.         precache_model(RDC_Models[i])
  261.  
  262.     for(new i = 0; i < sizeof(RDC_Sounds); i++)
  263.         precache_sound(RDC_Sounds[i])  
  264.    
  265.     for(new i = 0; i < sizeof(RDC_Effects); i++)
  266.         precache_model(RDC_Effects[i])
  267.  
  268.     for(new i = 0; i < sizeof(RDC_Sprites); i++)
  269.         0 <= i <= 2 ? precache_generic(RDC_Sprites[i]) : precache_model(RDC_Sprites[i])
  270.  
  271.     m_iBlood[0] = precache_model("sprites/blood.spr")
  272.     m_iBlood[1] = precache_model("sprites/bloodspray.spr")
  273.     g_explo_spr = precache_model("sprites/ef_cannonex.spr")
  274. }
  275.  
  276. public plugin_natives()
  277. {
  278.     #if (defined GOLD) && (!defined RED)
  279.     register_native("z47_give_gdc", "native_give_gdc_add", 1)
  280.     #endif
  281.     #if (defined GOLD) && (defined RED)
  282.     register_native("z47_give_rdc", "native_give_rdc_add", 1)
  283.     register_native("z47_give_gdc", "native_give_gdc_add", 1)
  284.     #endif
  285.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  286.     register_native("z47_give_rdc", "native_give_rdc_add", 1)
  287.     #endif
  288. }
  289.  
  290. #if (defined GOLD) && (!defined RED)
  291. public native_give_gdc_add(id)
  292.     give_cannonex(id)
  293. #endif
  294. #if (defined RED) && (defined GOLD)
  295. public native_give_rdc_add(id)
  296.     give_cannonex(id, 1)
  297. public native_give_gdc_add(id)
  298.     give_cannonex(id, 2)
  299. #endif
  300. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  301. public native_give_rdc_add(id)
  302.     give_cannonex(id)
  303. #endif
  304. public select_cannonex(id)
  305. {
  306.     engclient_cmd(id, weapon_rdc)
  307.     return PLUGIN_HANDLED
  308. }
  309.  
  310. public Event_CurWeapon(id)
  311. {
  312.     new weapon = read_data(2)
  313.  
  314.     if(weapon != CSW_RDC || !g_has_rdc[id])
  315.     {
  316.         #if defined GOLD
  317.         if(pev_valid(g_subpmodel[id]))
  318.         {
  319.             set_pev(g_subpmodel[id], pev_body, 0)
  320.             set_pev(g_subpmodel[id], pev_flags, FL_KILLME)
  321.             engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  322.         }
  323.         #endif
  324.         return
  325.     }
  326.  
  327.     update_ammo(id)
  328. }
  329.  
  330. public Event_NewRound()
  331. {
  332.     for(new id = 0; id <= g_maxplayers; id++)
  333.     {
  334.         if(!g_has_rdc[id])
  335.             continue
  336.        
  337.         #if (defined GOLD) && (!defined RED)  
  338.         if(get_pcvar_num(cvar_one_round))
  339.             remove_cannonex(id)
  340.  
  341.         else
  342.         {
  343.             if(g_rdc_dragon[id])
  344.             {
  345.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  346.                 g_rdc_dragon[id] = 0
  347.                
  348.                 fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  349.                 set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  350.                
  351.                 remove_task(id+RDC_TASK_RESET)
  352.                 ResetMode(id+RDC_TASK_RESET)
  353.             }
  354.  
  355.             remove_task(id+RDC_TASK_COOLDOWN)
  356.             g_rdc_preventmode[id] = false
  357.  
  358.             remove_task(id+RDC_TASK_REFILL)
  359.             Refill_Cannon(id+RDC_TASK_REFILL)
  360.         }
  361.         #endif
  362.         #if (defined RED) && (defined GOLD)
  363.         switch(g_has_rdc[id])
  364.         {
  365.             case 1:
  366.             {
  367.                 if(get_pcvar_num(cvar_one_round[0]))
  368.                     remove_cannonex(id)
  369.  
  370.                 else
  371.                 {
  372.                     if(g_rdc_dragon[id])
  373.                     {
  374.                         engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  375.                         g_rdc_dragon[id] = 0
  376.                        
  377.                         fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  378.                         set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  379.                        
  380.                         remove_task(id+RDC_TASK_RESET)
  381.                         ResetMode(id+RDC_TASK_RESET)
  382.                     }
  383.  
  384.                     remove_task(id+RDC_TASK_COOLDOWN)
  385.                     g_rdc_preventmode[id] = false
  386.  
  387.                     remove_task(id+RDC_TASK_REFILL)
  388.                     Refill_Cannon(id+RDC_TASK_REFILL)
  389.                 }
  390.             }
  391.             case 2:
  392.             {
  393.                 if(get_pcvar_num(cvar_one_round[1]))
  394.                     remove_cannonex(id)
  395.  
  396.                 else
  397.                 {
  398.                     if(g_rdc_dragon[id])
  399.                     {
  400.                         engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  401.                         g_rdc_dragon[id] = 0
  402.                        
  403.                         fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  404.                         set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  405.                        
  406.                         remove_task(id+RDC_TASK_RESET)
  407.                         ResetMode(id+RDC_TASK_RESET)
  408.                     }
  409.  
  410.                     remove_task(id+RDC_TASK_COOLDOWN)
  411.                     g_rdc_preventmode[id] = false
  412.  
  413.                     remove_task(id+RDC_TASK_REFILL)
  414.                     Refill_Cannon(id+RDC_TASK_REFILL)
  415.                 }
  416.             }
  417.         }
  418.         #endif
  419.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  420.         if(get_pcvar_num(cvar_one_round))
  421.             remove_cannonex(id)
  422.  
  423.         else
  424.         {
  425.             if(g_rdc_dragon[id])
  426.             {
  427.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  428.                 g_rdc_dragon[id] = 0
  429.                
  430.                 fm_set_weapon_idle_time(id, weapon_rdc, 2.5)
  431.                 set_pdata_float(id, m_flNextAttack, 2.5, PLAYER_LINUX_XTRA_OFF)
  432.                
  433.                 remove_task(id+RDC_TASK_RESET)
  434.                 ResetMode(id+RDC_TASK_RESET)
  435.             }
  436.  
  437.             remove_task(id+RDC_TASK_COOLDOWN)
  438.             g_rdc_preventmode[id] = false
  439.  
  440.             remove_task(id+RDC_TASK_REFILL)
  441.             Refill_Cannon(id+RDC_TASK_REFILL)
  442.         }
  443.         #endif
  444.     }
  445. }
  446.  
  447. public fw_PlayerKilled(id)
  448.     remove_cannonex(id)
  449.  
  450. public ze_user_humanized(id)
  451.     remove_cannonex(id)
  452.  
  453. public client_disconnected(id)
  454.     remove_cannonex(id)
  455.  
  456. public ze_user_infected(id)
  457.     remove_cannonex(id)
  458.  
  459. public fw_DragonCannon_Deploy_Post(weapon_ent)
  460. {
  461.     if(!pev_valid(weapon_ent))
  462.         return
  463.  
  464.     static id
  465.     id = fm_cs_get_weapon_ent_owner(weapon_ent)
  466.    
  467.     if(fm_cs_get_current_weapon_ent(id) != weapon_ent)
  468.         return
  469.  
  470.     if(!g_has_rdc[id])
  471.         return
  472.  
  473.     #if (defined GOLD) && (!defined RED)
  474.     set_pev(id, pev_viewmodel2, GDC_V_MODEL)
  475.     switch(g_current_mode[id])
  476.     {
  477.         case MODE_A: sub_p_model(id, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  478.         case MODE_B: sub_p_model(id, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  479.     }
  480.     #endif
  481.     #if (defined RED) && (defined GOLD)
  482.     switch(g_has_rdc[id])
  483.     {
  484.         case 1:
  485.         {
  486.             set_pev(id, pev_viewmodel2, RDC_V_MODEL)
  487.             switch(g_current_mode[id])
  488.             {
  489.                 case MODE_A: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  490.                 case MODE_B: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  491.             }
  492.         }
  493.         case 2:
  494.         {
  495.             set_pev(id, pev_viewmodel2, GDC_V_MODEL)
  496.             switch(g_current_mode[id])
  497.             {
  498.                 case MODE_A: sub_p_model(id, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  499.                 case MODE_B: sub_p_model(id, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  500.             }
  501.         }
  502.     }
  503.     #endif
  504.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  505.     set_pev(id, pev_viewmodel2, RDC_V_MODEL)
  506.     switch(g_current_mode[id])
  507.     {
  508.         case MODE_A: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL]), fm_play_weapon_animation(id, RDC_DRAW)
  509.         case MODE_B: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB]), fm_play_weapon_animation(id, RDC_DRAWB)
  510.     }
  511.     #endif
  512.  
  513.     fm_set_weapon_idle_time(id, weapon_rdc, RDC_DRAW_TIME)
  514. }
  515.  
  516. public fw_CmdStart(id, uc_handle, seed)
  517. {
  518.     if(!is_user_alive(id) || !is_user_connected(id))
  519.         return FMRES_IGNORED
  520.  
  521.     if(get_user_weapon(id) != CSW_RDC || !g_has_rdc[id])
  522.         return FMRES_IGNORED
  523.    
  524.     if(get_pdata_float(id, m_flNextAttack) > 0.0)
  525.             return FMRES_IGNORED
  526.  
  527.     static CurButton
  528.     CurButton = get_uc(uc_handle, UC_Buttons)
  529.    
  530.     if(CurButton & IN_ATTACK)
  531.     {
  532.         CurButton &= ~IN_ATTACK
  533.         set_uc(uc_handle, UC_Buttons, CurButton)
  534.  
  535.         if(get_pdata_float(id, m_flNextPrimaryAttack, PLAYER_LINUX_XTRA_OFF) <= 0.0 && g_rdc_ammo[id] > 0)
  536.         {
  537.             #if (defined GOLD) && (!defined RED)
  538.             if(get_pcvar_float(cvar_rdc_refill) && !task_exists(id+RDC_TASK_REFILL))
  539.             {
  540.                 if(g_rdc_ammo[id] == 1)
  541.                     set_task(get_pcvar_float(cvar_rdc_refill), "Refill_Cannon", id+RDC_TASK_REFILL)
  542.             }
  543.             #endif
  544.             #if (defined RED) && (defined GOLD)
  545.             switch(g_has_rdc[id])
  546.             {
  547.                 case 1:
  548.                 {
  549.                     if(get_pcvar_float(cvar_rdc_refill[0]) && !task_exists(id+RDC_TASK_REFILL))
  550.                     {
  551.                         if(g_rdc_ammo[id] == 1)
  552.                             set_task(get_pcvar_float(cvar_rdc_refill[0]), "Refill_Cannon", id+RDC_TASK_REFILL)
  553.                     }
  554.                 }
  555.                 case 2:
  556.                 {
  557.                     if(get_pcvar_float(cvar_rdc_refill[1]) && !task_exists(id+RDC_TASK_REFILL))
  558.                     {
  559.                         if(g_rdc_ammo[id] == 1)
  560.                             set_task(get_pcvar_float(cvar_rdc_refill[1]), "Refill_Cannon", id+RDC_TASK_REFILL)
  561.                     }
  562.                 }
  563.             }
  564.             #endif
  565.             #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  566.             if(get_pcvar_float(cvar_rdc_refill) && !task_exists(id+RDC_TASK_REFILL))
  567.             {
  568.                 if(g_rdc_ammo[id] == 1)
  569.                     set_task(get_pcvar_float(cvar_rdc_refill), "Refill_Cannon", id+RDC_TASK_REFILL)
  570.             }
  571.             #endif
  572.  
  573.             g_rdc_ammo[id]--
  574.             update_ammo(id)
  575.            
  576.             fm_set_weapon_idle_time(id, weapon_rdc, g_rdc_dragon[id] && pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0 ? 5.0 : 3.5)
  577.             set_pdata_float(id, m_flNextAttack, g_rdc_dragon[id] && pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0 ? 5.0 : 3.5, PLAYER_LINUX_XTRA_OFF)
  578.  
  579.             Set_1st_Attack(id)
  580.             set_task(0.1, "Set_2nd_Attack", id + RDC_TASK_SHOOT)
  581.         }
  582.     }
  583.     else if(CurButton & IN_ATTACK2)
  584.     {
  585.         CurButton &= ~IN_ATTACK2
  586.         set_uc(uc_handle, UC_Buttons, CurButton)
  587.  
  588.         if(get_pdata_float(id, m_flNextSecondaryAttack, PLAYER_LINUX_XTRA_OFF) <= 0.0 && !g_rdc_preventmode[id] && g_rdc_ammo[id] > 0)
  589.             Switch_Mode(id)
  590.  
  591.     }
  592.    
  593.     return FMRES_HANDLED
  594. }
  595.  
  596. public Refill_Cannon(id)
  597. {
  598.     id -= RDC_TASK_REFILL
  599.    
  600.     if(!g_has_rdc[id])
  601.         return
  602.  
  603.     #if (defined GOLD) && (!defined RED)
  604.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  605.  
  606.     #endif
  607.     #if (defined RED) && (defined GOLD)
  608.     switch(g_has_rdc[id])
  609.     {
  610.         case 1: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[0])
  611.         case 2: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[1])
  612.     }
  613.     #endif
  614.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  615.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  616.     #endif
  617.  
  618.     update_ammo(id)
  619. }
  620.  
  621. public Switch_Mode(id)
  622. {
  623.     if(!g_has_rdc[id])
  624.         return
  625.  
  626.     if(g_current_mode[id])
  627.         return
  628.  
  629.     g_current_mode[id] = MODE_B
  630.    
  631.     #if (defined GOLD) && (!defined RED)
  632.     sub_p_model(id, RDC_Models[RDC_P_MODELB])
  633.     #endif
  634.    
  635.     #if (defined RED) && (defined GOLD)
  636.     if(g_has_rdc[id] == 1)
  637.         set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB])
  638.     else if(g_has_rdc[id] == 2)
  639.         sub_p_model(id, RDC_Models[RDC_P_MODELB])
  640.     #endif
  641.  
  642.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  643.     set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODELB])
  644.     #endif
  645.  
  646.     fm_play_weapon_animation(id, RDC_D_TRANSFORM)
  647.     fm_set_weapon_idle_time(id, weapon_rdc, 3.5)
  648.     set_pdata_float(id, m_flNextAttack, 3.5, PLAYER_LINUX_XTRA_OFF)
  649.     make_dragon_spirit(id)
  650. }
  651.  
  652. public Allow_Mode(id)
  653. {
  654.     id -= RDC_TASK_COOLDOWN
  655.  
  656.     if(!g_has_rdc[id])
  657.         return
  658.  
  659.     g_rdc_preventmode[id] = false
  660. }
  661.  
  662. public make_dragon_spirit(id)
  663. {
  664.     if(!g_has_rdc[id])
  665.         return
  666.  
  667.     new Float:flOrigin[3]
  668.    
  669.     pev(id, pev_origin, flOrigin)
  670.  
  671.     new rdc_dragonspirit = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  672.  
  673.     if(!pev_valid(rdc_dragonspirit))
  674.         return
  675.  
  676.     set_pev(rdc_dragonspirit, pev_classname, RDC_DRAGONSPIRIT_CLASSNAME)
  677.  
  678.     engfunc(EngFunc_SetOrigin, rdc_dragonspirit, flOrigin)
  679.  
  680.     set_pev(rdc_dragonspirit, pev_movetype, MOVETYPE_FOLLOW)
  681.  
  682.     set_pev(rdc_dragonspirit, pev_aiment, id)
  683.  
  684.     engfunc(EngFunc_SetModel, rdc_dragonspirit, RDC_Effects[1])
  685.  
  686.     set_pev(rdc_dragonspirit, pev_solid, SOLID_NOT)
  687.  
  688.     set_pev(rdc_dragonspirit, pev_animtime, get_gametime())
  689.    
  690.     set_pev(rdc_dragonspirit, pev_framerate, 1.0)
  691.    
  692.     set_pev(rdc_dragonspirit, pev_sequence, 1)
  693.  
  694.     set_task(3.5, "unleash_dragon", rdc_dragonspirit + RDC_TASK_UNLEASH)
  695.  
  696.     set_pev(rdc_dragonspirit, pev_nextthink, get_gametime() + 1.0)
  697. }
  698.  
  699. public make_explosion(iEnt)
  700. {
  701.     new Float:flOrigin[3]
  702.     pev(iEnt, pev_origin, flOrigin)
  703.  
  704.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  705.     write_byte(TE_EXPLOSION)
  706.     engfunc(EngFunc_WriteCoord, flOrigin[0])
  707.     engfunc(EngFunc_WriteCoord, flOrigin[1])
  708.     engfunc(EngFunc_WriteCoord, flOrigin[2])
  709.     write_short(g_explo_spr)
  710.     write_byte(22)
  711.     write_byte(35)
  712.     write_byte(TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND)
  713.     message_end()
  714. }
  715.  
  716. stock make_explosion2(id)
  717. {
  718.     if(!g_has_rdc[id])
  719.         return
  720.  
  721.     static flOrigin[3]
  722.     pev(id, pev_origin, flOrigin)
  723.  
  724.     new rdc_hole = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  725.  
  726.     if(!pev_valid(rdc_hole))
  727.         return
  728.  
  729.     set_pev(rdc_hole, pev_classname, RDC_EXPLOSION_CLASSNAME)
  730.    
  731.     engfunc(EngFunc_SetModel, rdc_hole, RDC_Effects[2])
  732.  
  733.     set_pev(rdc_hole, pev_rendermode, kRenderTransAdd)
  734.  
  735.     set_pev(rdc_hole, pev_renderamt, 200.0)
  736.  
  737.     engfunc(EngFunc_SetOrigin, rdc_hole, flOrigin)
  738.  
  739.     set_pev(rdc_hole, pev_solid, SOLID_NOT)
  740.  
  741.     set_pev(rdc_hole, pev_scale, 0.1)
  742.  
  743.     set_pev(rdc_hole, pev_animtime, get_gametime())
  744.  
  745.     set_pev(rdc_hole, pev_framerate, 1.0)
  746.    
  747.     set_pev(rdc_hole, pev_sequence, 1)
  748.  
  749.     set_pev(rdc_hole, pev_life, get_gametime() + 0.5)
  750.  
  751.     set_pev(rdc_hole, pev_nextthink, get_gametime() + 0.1)
  752.  
  753.     emit_sound(id, CHAN_WEAPON, RDC_Sounds[5], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  754.    
  755.     static victim
  756.     victim = -1
  757.    
  758.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, flOrigin, 400.0)) != 0)
  759.     {
  760.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim))
  761.             continue
  762.        
  763.         fm_create_velocity_vector(victim, id, 200.0)
  764.     }
  765.    
  766. }
  767.  
  768. public Set_1st_Attack(id)
  769. {
  770.     create_fake_attack(id)
  771.  
  772.     switch(g_current_mode[id])
  773.     {
  774.         case MODE_A: fm_play_weapon_animation(id, RDC_SHOOTA)
  775.         case MODE_B: fm_play_weapon_animation(id, RDC_SHOOTB)
  776.     }
  777.  
  778.     emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  779.    
  780.     make_fire_effect(id)
  781.    
  782.     static Float:cl_pushangle[3]
  783.     cl_pushangle[0] = random_float(-3.5, -7.0)
  784.     cl_pushangle[1] = random_float(3.0, -3.0)
  785.     cl_pushangle[2] = 0.0
  786.    
  787.     set_pev(id, pev_punchangle, cl_pushangle)  
  788. }
  789.  
  790. public create_fake_attack(id)
  791. {
  792.     static fake_weapon
  793.     fake_weapon = fm_find_ent_by_owner(-1, "weapon_knife", id)
  794.    
  795.     if(pev_valid(fake_weapon))
  796.         ExecuteHamB(Ham_Weapon_PrimaryAttack, fake_weapon)
  797. }
  798.  
  799.  
  800. public Set_2nd_Attack(id)
  801. {
  802.     id -= RDC_TASK_SHOOT
  803.  
  804.     if(!g_has_rdc[id])
  805.         return
  806.  
  807.     create_fake_attack(id)
  808.  
  809.     switch(g_current_mode[id])
  810.     {
  811.         case MODE_A:
  812.         {
  813.             fm_play_weapon_animation(id, RDC_SHOOTA)
  814.             emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  815.         }
  816.         case MODE_B:
  817.         {
  818.             if(pev(g_rdc_dragon[id], pev_life) - get_gametime() <= 0.0)
  819.             {
  820.                 fm_play_weapon_animation(id, RDC_D_RELOAD1)
  821.                 emit_sound(id, CHAN_WEAPON, RDC_Sounds[1], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  822.                 engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  823.                 g_rdc_dragon[id] = 0
  824.                 set_task(2.5, "ResetMode", id + RDC_TASK_RESET)
  825.  
  826.                 #if (defined GOLD) && (!defined RED)
  827.                 if(get_pcvar_float(cvar_rdc_cooldown))
  828.                 {
  829.                     g_rdc_preventmode[id] = true
  830.                     set_task(get_pcvar_float(cvar_rdc_cooldown), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  831.                 }
  832.                 #endif
  833.                 #if (defined RED) && (defined GOLD)
  834.                 switch(g_has_rdc[id])
  835.                 {
  836.                     case 1:
  837.                     {
  838.                         if(get_pcvar_float(cvar_rdc_cooldown[0]))
  839.                         {
  840.                             g_rdc_preventmode[id] = true
  841.                             set_task(get_pcvar_float(cvar_rdc_cooldown[0]), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  842.                         }
  843.                     }
  844.                     case 2:
  845.                     {
  846.                         if(get_pcvar_float(cvar_rdc_cooldown[1]))
  847.                         {
  848.                             g_rdc_preventmode[id] = true
  849.                             set_task(get_pcvar_float(cvar_rdc_cooldown[1]), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  850.                         }
  851.                     }
  852.                 }
  853.                 #endif
  854.                 #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  855.                 if(get_pcvar_float(cvar_rdc_cooldown))
  856.                 {
  857.                     g_rdc_preventmode[id] = true
  858.                     set_task(get_pcvar_float(cvar_rdc_cooldown), "Allow_Mode", id + RDC_TASK_COOLDOWN)
  859.                 }
  860.                 #endif
  861.             }
  862.             else
  863.             {
  864.                 fm_play_weapon_animation(id, RDC_SHOOTB)
  865.                 emit_sound(id, CHAN_WEAPON, RDC_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  866.             }
  867.  
  868.         }
  869.     }
  870.    
  871.     make_fire_effect(id)
  872.     check_radius_damage(id)
  873. }
  874.  
  875. public ResetMode(id)
  876. {
  877.     id -= RDC_TASK_RESET
  878.  
  879.     if(!g_has_rdc[id])
  880.         return
  881.  
  882.     fm_play_weapon_animation(id, RDC_D_RELOAD2)
  883.     g_current_mode[id] = MODE_A
  884.  
  885.     #if (defined GOLD) && (!defined RED)
  886.     sub_p_model(id, RDC_Models[RDC_P_MODEL])
  887.     #endif
  888.    
  889.     #if (defined RED) && (defined GOLD)
  890.     switch(g_has_rdc[id])
  891.     {
  892.         case 1: set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL])
  893.         case 2: sub_p_model(id, RDC_Models[RDC_P_MODEL])
  894.     }
  895.     #endif
  896.    
  897.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  898.     set_pev(id, pev_weaponmodel2, RDC_Models[RDC_P_MODEL])
  899.     #endif
  900. }
  901.  
  902. public make_fire_effect(id)
  903. {
  904.     const MAX_FIRE = 12
  905.     static Float:StartOrigin[3], Float:TargetOrigin[MAX_FIRE][3], Float:Speed[MAX_FIRE]
  906.  
  907.     // Get Target
  908.    
  909.     // -- Left
  910.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[0]); Speed[0] = 150.0
  911.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[1]); Speed[1] = 180.0
  912.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[2]); Speed[2] = 210.0
  913.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[3]); Speed[3] = 240.0
  914.     get_position(id, 100.0, random_float(-10.0, -30.0), WEAPON_ATTACH_U, TargetOrigin[4]); Speed[4] = 300.0
  915.  
  916.     // -- Center
  917.     get_position(id, 100.0, 0.0, WEAPON_ATTACH_U, TargetOrigin[5]); Speed[5] = 150.0
  918.     get_position(id, 100.0, 0.0, WEAPON_ATTACH_U, TargetOrigin[6]); Speed[6] = 300.0
  919.    
  920.     // -- Right
  921.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[7]); Speed[7] = 150.0
  922.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[8]); Speed[8] = 180.0
  923.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[9]); Speed[9] = 210.0
  924.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[10]); Speed[10] = 240.0
  925.     get_position(id, 100.0, random_float(10.0, 30.0), WEAPON_ATTACH_U, TargetOrigin[11]); Speed[11] = 300.0
  926.  
  927.     for(new i = 0; i < MAX_FIRE; i++)
  928.     {
  929.         // Get Start
  930.         get_position(id, random_float(30.0, 40.0), 0.0, WEAPON_ATTACH_U, StartOrigin)
  931.         create_fire(id, StartOrigin, TargetOrigin[i], Speed[i])
  932.     }
  933. }
  934.  
  935. public check_radius_damage(id)
  936. {
  937.     static Float:Origin[3]
  938.    
  939.     for(new i = 0; i <= g_maxplayers; i++)
  940.     {
  941.         if(!is_user_alive(i))
  942.             continue
  943.        
  944.         if(!ze_is_user_zombie(i))
  945.             continue
  946.  
  947.         if(id == i)
  948.             continue
  949.        
  950.         pev(i, pev_origin, Origin)
  951.        
  952.         if(!fm_is_in_viewcone(id, Origin))
  953.             continue
  954.  
  955.         if(fm_entity_range(id, i) >= 600.0)
  956.             continue
  957.  
  958.         #if (defined GOLD) && (!defined RED)
  959.         new Float:flDamageBase = get_pcvar_float(cvar_dmg_rdc)
  960.         #endif
  961.         #if (defined RED) && (defined GOLD)
  962.         static Float:flDamageBase
  963.         switch(g_has_rdc[id])
  964.         {
  965.             case 1: flDamageBase = get_pcvar_float(cvar_dmg_rdc[0])
  966.             case 2: flDamageBase = get_pcvar_float(cvar_dmg_rdc[1])
  967.         }
  968.         #endif
  969.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  970.         new Float:flDamageBase = get_pcvar_float(cvar_dmg_rdc)
  971.         #endif
  972.  
  973.         new Float:flDamage = flDamageBase * (fm_entity_range(id, i) + 100.0) / fm_entity_range(id, i)
  974.        
  975.         if(!is_user_bot(i))
  976.         make_victim_effects(i, DMG_BURN, 226, 88, 34)
  977.         fm_create_velocity_vector(i, id, 50.0)
  978.  
  979.         ExecuteHamB(Ham_TakeDamage, i, id, id, flDamage, DMG_NEVERGIB | DMG_BULLET)
  980.         make_blood(i, flDamage)
  981.     }
  982. }
  983.  
  984. stock create_fire(id, Float:Origin[3], Float:TargetOrigin[3], Float:Speed, bool:dragon = false)
  985. {
  986.     new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "env_sprite"))
  987.    
  988.     set_pev(iEnt, pev_classname, RDC_FIRE_CLASSNAME)
  989.     engfunc(EngFunc_SetModel, iEnt, RDC_Sprites[3])
  990.  
  991.     static Float:vfAngle[3], Float:Velocity[3]
  992.     pev(id, pev_angles, vfAngle)
  993.  
  994.     vfAngle[2] = float(random(18) * 20)
  995.  
  996.     // set info for ent
  997.     set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
  998.     set_pev(iEnt, pev_rendermode, kRenderTransAdd)
  999.     set_pev(iEnt, pev_renderamt, 250.0)
  1000.    
  1001.    
  1002.     if(dragon)
  1003.     {
  1004.         set_pev(iEnt, pev_life, get_gametime() + 1.5)
  1005.         set_pev(iEnt, pev_owner, id)
  1006.     }
  1007.     else
  1008.         set_pev(iEnt, pev_life, get_gametime() + 3.0)
  1009.        
  1010.     set_pev(iEnt, pev_scale, dragon ? 0.1 : 1.0)
  1011.    
  1012.     set_pev(iEnt, pev_mins, Float:{-1.0, -1.0, -1.0})
  1013.     set_pev(iEnt, pev_maxs, Float:{1.0, 1.0, 1.0})
  1014.    
  1015.     engfunc(EngFunc_SetOrigin, iEnt, Origin)
  1016.     set_pev(iEnt, pev_gravity, 0.01)
  1017.     set_pev(iEnt, pev_angles, vfAngle)
  1018.    
  1019.     set_pev(iEnt, pev_solid, SOLID_TRIGGER)
  1020.    
  1021.     set_pev(iEnt, pev_frame, 0.0)
  1022.     set_pev(iEnt, pev_nextthink, get_gametime() + 0.05)
  1023.  
  1024.     get_speed_vector(Origin, TargetOrigin, Speed, Velocity)
  1025.     set_pev(iEnt, pev_velocity, Velocity)
  1026. }
  1027.  
  1028. public update_ammo(id)
  1029. {
  1030.     if(!is_user_alive(id))
  1031.         return
  1032.        
  1033.     message_begin(MSG_ONE_UNRELIABLE, g_MsgCurWeapon, _, id)
  1034.     write_byte(1)
  1035.     write_byte(CSW_RDC)
  1036.     write_byte(-1)
  1037.     message_end()
  1038.    
  1039.     message_begin(MSG_ONE_UNRELIABLE, g_MsgAmmoX, .player = id)
  1040.     write_byte(7)
  1041.     write_byte(g_rdc_ammo[id])
  1042.     message_end()
  1043. }
  1044.  
  1045. public fw_SetModel(entity, model[])
  1046. {
  1047.     if(!pev_valid(entity))
  1048.         return FMRES_IGNORED
  1049.  
  1050.     static weapon[32], old_rdc[64]
  1051.  
  1052.     if(!fm_is_ent_classname(entity, "weaponbox"))
  1053.         return FMRES_IGNORED
  1054.  
  1055.     copy(weapon, charsmax(weapon), weapon_rdc)
  1056.     replace(weapon, charsmax(weapon), "weapon_", "")
  1057.  
  1058.     formatex(old_rdc, charsmax(old_rdc), "models/w_%s.mdl", weapon)
  1059.  
  1060.     static owner
  1061.     owner = pev(entity, pev_owner)
  1062.  
  1063.     if(equal(model, old_rdc))
  1064.     {
  1065.         static StoredWepID
  1066.        
  1067.         StoredWepID = fm_find_ent_by_owner(-1, weapon_rdc, entity)
  1068.    
  1069.         if(!pev_valid(StoredWepID))
  1070.             return FMRES_IGNORED
  1071.    
  1072.         if(g_has_rdc[owner])
  1073.         {
  1074.             #if (defined GOLD) && (!defined RED)
  1075.             set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1076.             switch(g_current_mode[owner])
  1077.             {
  1078.                 case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1079.                 case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1080.             }
  1081.             set_pev(entity, pev_body, 1)
  1082.             #endif
  1083.             #if (defined RED) && (defined GOLD)
  1084.             switch(g_has_rdc[owner])
  1085.             {
  1086.                 case 1:
  1087.                 {
  1088.                     set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1089.                     switch(g_current_mode[owner])
  1090.                     {
  1091.                         case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1092.                         case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1093.                     }
  1094.                 }
  1095.                 case 2:
  1096.                 {
  1097.                     set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY + 1)
  1098.                     switch(g_current_mode[owner])
  1099.                     {
  1100.                         case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1101.                         case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1102.                     }
  1103.                     set_pev(entity, pev_body, 1)
  1104.                 }
  1105.             }
  1106.             #endif
  1107.             #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1108.             set_pev(StoredWepID, pev_impulse, RDC_WEAPONKEY)
  1109.             switch(g_current_mode[owner])
  1110.             {
  1111.                 case MODE_A: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODEL])
  1112.                 case MODE_B: engfunc(EngFunc_SetModel, entity, RDC_Models[RDC_W_MODELB])
  1113.             }
  1114.             #endif
  1115.             set_pev(StoredWepID, pev_mode, g_current_mode[owner])
  1116.  
  1117.             remove_cannonex(owner)
  1118.  
  1119.             return FMRES_SUPERCEDE
  1120.         }
  1121.     }
  1122.     return FMRES_IGNORED
  1123. }
  1124.  
  1125. #if (defined GOLD) && (!defined RED)
  1126. public give_cannonex(id)
  1127. #endif
  1128. #if (defined RED) && (defined GOLD)
  1129. public give_cannonex(id, mode)
  1130. #endif
  1131. #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1132. public give_cannonex(id)
  1133. #endif
  1134. {
  1135.     #if defined GOLD
  1136.     if(pev_valid(g_subpmodel[id]))
  1137.     {
  1138.         set_pev(g_subpmodel[id], pev_body, 0)
  1139.         set_pev(g_subpmodel[id], pev_flags, FL_KILLME)
  1140.         engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  1141.     }
  1142.  
  1143.     #endif
  1144.     drop_weapons(id)
  1145.  
  1146.     #if (defined GOLD) && (!defined RED)
  1147.     g_has_rdc[id] = true
  1148.     #endif
  1149.     #if (defined RED) && (defined GOLD)
  1150.     g_has_rdc[id] = mode
  1151.     #endif
  1152.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1153.     g_has_rdc[id] = true
  1154.     #endif
  1155.  
  1156.     g_current_mode[id] = MODE_A
  1157.  
  1158.     fm_give_item(id, weapon_rdc)
  1159.    
  1160.     static weapon_ent
  1161.     weapon_ent = fm_find_ent_by_owner(-1, weapon_rdc, id)
  1162.  
  1163.     message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1164.     write_string("weapon_cannonex")
  1165.     write_byte(7)
  1166.     write_byte(100)
  1167.     write_byte(-1)
  1168.     write_byte(-1)
  1169.     write_byte(0)
  1170.     write_byte(8)
  1171.     write_byte(CSW_RDC)
  1172.     write_byte(0)
  1173.     message_end()
  1174.    
  1175.     cs_set_weapon_ammo(weapon_ent, 50)
  1176.  
  1177.     #if (defined GOLD) && (!defined RED)
  1178.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  1179.     #endif
  1180.     #if (defined RED) && (defined GOLD)
  1181.     switch(g_has_rdc[id])
  1182.     {
  1183.         case 1: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[0])
  1184.         case 2: g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo[1])
  1185.     }
  1186.     #endif
  1187.     #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1188.     g_rdc_ammo[id] = get_pcvar_num(cvar_rdc_ammo)
  1189.     #endif
  1190. }
  1191.  
  1192. public remove_cannonex(id)
  1193. {
  1194.     #if defined GOLD
  1195.     if(pev_valid(g_subpmodel[id]))
  1196.     {
  1197.         set_pev(g_subpmodel[id], pev_body, 0)
  1198.         engfunc(EngFunc_RemoveEntity, g_subpmodel[id])
  1199.     }
  1200.     #endif
  1201.  
  1202.     g_has_rdc[id] = false
  1203.     g_current_mode[id] = 0
  1204.     engfunc(EngFunc_RemoveEntity, g_rdc_dragon[id])
  1205.     g_rdc_dragon[id] = 0
  1206.     drop_weapons(id, CSW_RDC)
  1207.     remove_task(id+RDC_TASK_SHOOT)
  1208.     remove_task(id+RDC_TASK_RESET)
  1209.     remove_task(id+RDC_TASK_REFILL)
  1210. }
  1211.  
  1212. public ze_select_item_pre(id, itemid)
  1213. {
  1214.     // This not our item?
  1215.     if (itemid != g_itemid[0])
  1216.     //if (itemid != g_itemid[1])
  1217.         return ZE_ITEM_AVAILABLE
  1218.    
  1219.     // Available for Humans only, So don't show it for zombies
  1220.     if (ze_is_user_zombie(id))
  1221.         return ZE_ITEM_DONT_SHOW
  1222.    
  1223.     // Finally return that it's available
  1224.     return ZE_ITEM_AVAILABLE
  1225. }  
  1226.  
  1227. public ze_select_item_post(id, itemid)
  1228. {
  1229.     // This is not our item, Block it here and don't execute the blew code    
  1230.     if (itemid != g_itemid[0])
  1231.     //if (itemid != g_itemid[1])
  1232.        return
  1233.  
  1234.     give_cannonex(id, 1)
  1235.     //give_cannonex(id, 2)    
  1236. }
  1237.  
  1238. public fw_DragonCannon_AddToPlayer(item, id)
  1239. {
  1240.     if(!pev_valid(item))
  1241.         return HAM_IGNORED
  1242.  
  1243.     switch(pev(item, pev_impulse))
  1244.     {
  1245.         case 0:
  1246.         {
  1247.             message_begin(MSG_ONE, g_MsgWeaponList, .player = id)
  1248.             write_string(weapon_rdc)
  1249.             write_byte(7)
  1250.             write_byte(100)
  1251.             write_byte(-1)
  1252.             write_byte(-1)
  1253.             write_byte(0)
  1254.             write_byte(8)
  1255.             write_byte(CSW_RDC)
  1256.             write_byte(0)
  1257.             message_end()
  1258.            
  1259.             return HAM_IGNORED
  1260.         }
  1261.         #if (defined GOLD) && (!defined RED)
  1262.         case RDC_WEAPONKEY:
  1263.         {
  1264.             g_has_rdc[id] = true
  1265.  
  1266.             if(pev(item, pev_mode))
  1267.                 ResetMode(id+RDC_TASK_RESET)
  1268.  
  1269.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1270.             write_string("weapon_cannonex")
  1271.             write_byte(7)
  1272.             write_byte(100)
  1273.             write_byte(-1)
  1274.             write_byte(-1)
  1275.             write_byte(0)
  1276.             write_byte(8)
  1277.             write_byte(CSW_RDC)
  1278.             write_byte(0)
  1279.             message_end()
  1280.  
  1281.             set_pev(item, pev_impulse, 0)
  1282.             set_pev(item, pev_mode, 0)
  1283.  
  1284.             return HAM_HANDLED
  1285.         }
  1286.         #endif
  1287.         #if (defined RED) && (defined GOLD)
  1288.         case RDC_WEAPONKEY:
  1289.         {
  1290.             g_has_rdc[id] = 1
  1291.  
  1292.             if(pev(item, pev_mode))
  1293.                 ResetMode(id+RDC_TASK_RESET)
  1294.  
  1295.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1296.             write_string("weapon_cannonex")
  1297.             write_byte(7)
  1298.             write_byte(100)
  1299.             write_byte(-1)
  1300.             write_byte(-1)
  1301.             write_byte(0)
  1302.             write_byte(8)
  1303.             write_byte(CSW_RDC)
  1304.             write_byte(0)
  1305.             message_end()
  1306.  
  1307.             set_pev(item, pev_impulse, 0)
  1308.             set_pev(item, pev_mode, 0)
  1309.  
  1310.             return HAM_HANDLED
  1311.         }
  1312.         case RDC_WEAPONKEY + 1:
  1313.         {
  1314.             g_has_rdc[id] = 2
  1315.  
  1316.             if(pev(item, pev_mode))
  1317.                 ResetMode(id+RDC_TASK_RESET)
  1318.  
  1319.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1320.             write_string("weapon_cannonex")
  1321.             write_byte(7)
  1322.             write_byte(100)
  1323.             write_byte(-1)
  1324.             write_byte(-1)
  1325.             write_byte(0)
  1326.             write_byte(8)
  1327.             write_byte(CSW_RDC)
  1328.             write_byte(0)
  1329.             message_end()
  1330.  
  1331.             set_pev(item, pev_impulse, 0)
  1332.             set_pev(item, pev_mode, 0)
  1333.  
  1334.             return HAM_HANDLED
  1335.         }
  1336.         #endif
  1337.         #if (!defined GOLD) && (defined RED) || (!defined GOLD) && (!defined RED)
  1338.         case RDC_WEAPONKEY:
  1339.         {
  1340.             g_has_rdc[id] = true
  1341.  
  1342.             if(pev(item, pev_mode))
  1343.                 ResetMode(id+RDC_TASK_RESET)
  1344.  
  1345.             message_begin(MSG_ONE_UNRELIABLE, g_MsgWeaponList, .player = id)
  1346.             write_string("weapon_cannonex")
  1347.             write_byte(7)
  1348.             write_byte(100)
  1349.             write_byte(-1)
  1350.             write_byte(-1)
  1351.             write_byte(0)
  1352.             write_byte(8)
  1353.             write_byte(CSW_RDC)
  1354.             write_byte(0)
  1355.             message_end()
  1356.  
  1357.             set_pev(item, pev_impulse, 0)
  1358.             set_pev(item, pev_mode, 0)
  1359.  
  1360.             return HAM_HANDLED
  1361.         }
  1362.         #endif
  1363.     }
  1364.  
  1365.     return HAM_IGNORED
  1366. }
  1367.  
  1368. public fw_DragonCannon_WeaponIdle_Post(rdc)
  1369. {
  1370.     if(pev_valid(rdc) != 2)
  1371.         return HAM_IGNORED
  1372.  
  1373.     new id = fm_cs_get_weapon_ent_owner(rdc)
  1374.    
  1375.     if(fm_cs_get_current_weapon_ent(id) != rdc)
  1376.         return HAM_IGNORED
  1377.  
  1378.     if (!g_has_rdc[id])
  1379.         return HAM_IGNORED;
  1380.  
  1381.     if(get_pdata_float(rdc, m_flTimeWeaponIdle, WEAP_LINUX_XTRA_OFF) <= 0.1)
  1382.     {
  1383.         switch(g_current_mode[id])
  1384.         {
  1385.             case MODE_A: fm_play_weapon_animation(id, RDC_IDLE)
  1386.             case MODE_B: fm_play_weapon_animation(id, RDC_IDLEB)
  1387.         }
  1388.  
  1389.         set_pdata_float(rdc, m_flTimeWeaponIdle, 10.0, WEAP_LINUX_XTRA_OFF)
  1390.     }
  1391.  
  1392.     return HAM_IGNORED
  1393. }
  1394.  
  1395. public fw_UpdateClientData_Post(id, SendWeapons, CD_Handle)
  1396. {
  1397.     if(!is_user_alive(id) || get_user_weapon(id) != CSW_RDC || !g_has_rdc[id])
  1398.         return FMRES_IGNORED
  1399.    
  1400.     set_cd(CD_Handle, CD_flNextAttack, get_gametime() + 0.001)
  1401.     return FMRES_HANDLED
  1402. }
  1403.  
  1404. public message_DeathMsg(msg_id, msg_dest, id)
  1405. {
  1406.     static TruncatedWeapon[33], iAttacker, iVictim, weapon[32]
  1407.    
  1408.     copy(weapon, charsmax(weapon), weapon_rdc)
  1409.     replace(weapon, charsmax(weapon), "weapon_", "")
  1410.  
  1411.     get_msg_arg_string(4, TruncatedWeapon, charsmax(TruncatedWeapon))
  1412.  
  1413.     iAttacker = get_msg_arg_int(1)
  1414.     iVictim = get_msg_arg_int(2)
  1415.  
  1416.     if(!is_user_connected(iAttacker) || iAttack