Help Nemesis Gamemod

Coding Help/Re-API Supported
Post Reply
Fgh
Member
Member
Romania
Posts: 1
Joined: 2 years ago
Contact:

Help Nemesis Gamemod

#1

Post by Fgh » 2 years ago

Hi, I have a problem with speed when I turn on the gamemod at nemesis it keeps it at maximum 250 speed
but if I do ze_nemesis "name" the maximum speed set on the "ze_zombie_speed" quartz works
  1. #include <zombie_escape>
  2. #include <cstrike>
  3. #include <fun>
  4.  
  5.  
  6. // Uncomment to use custom model for nemesis
  7. // Note: This includes player model & claws
  8. #define USE_NEMESIS_MODEL
  9.  
  10. // Uncomment to use leap for nemesis
  11. // Leap Code: https://escapers-zone.net/viewtopic.php?p=10582#p10582
  12. #define USE_NEMESIS_LEAP
  13.  
  14. #define TASK_MAKE_NEMESIS 4949849
  15. #define TASK_AMBIENCESOUND 2020
  16. #define TASK_REAMBIENCESOUND 5050
  17.  
  18. // Access to start nemesis round
  19. #define STARTNEMESIS_ACCESS ADMIN_MENU
  20.  
  21. // Settings file
  22. new const ZE_SETTING_FILE[] = "zombie_escape.ini"
  23.  
  24. #if defined USE_NEMESIS_MODEL
  25. // Default models
  26. new const g_szModels_Nemesis_Player[][] = { "nemesis_llg" }
  27. new const g_szModels_Nemesis_Claws[][] = { "models/zombie_escape/v_nemesis_llg.mdl" }
  28.  
  29. new Array:g_aModels_Nemesis_Player,
  30.     Array:g_aModels_Nemesis_Claws
  31. #endif
  32.  
  33. #if defined USE_NEMESIS_LEAP
  34. native ze_get_longjump(id)
  35. native ze_remove_longjump(id)
  36. #endif
  37.  
  38. enum _:Colors
  39. {
  40.     Red = 0,
  41.     Green,
  42.     Blue
  43. }
  44.  
  45. new g_iAmbianceSoundDuration = 160  // Set ambience duration = highest sound duration
  46. new const szAmbianceSound[][] =
  47. {
  48.     //"zombie_escape/ze_ambiance1.mp3"
  49.     "zombie_escape/nemesis2.wav"
  50. }
  51.  
  52. new bool:g_bIsNemesis[33],
  53.     bool:g_bIsNextRoundNemesis = false,
  54.     g_iCountDown,
  55.     Array:g_szAmbianceSound,
  56.         g_iNemesisNum = 0
  57.  
  58. new g_pCvarNemesisHP,
  59.     g_pCvarNemesisGravity,
  60.     g_pCvarNemesisSpeed,
  61.     g_pCvarNemesisGlow,
  62.     g_pCvarNemesisGlowColor[Colors],
  63.     g_pCvarNemesisKB,
  64.     //g_pCvarNemesisDmg,
  65.     g_pCvarNemesisFreeze,
  66.     g_pCvarNemesisFire
  67.    
  68.  
  69. public plugin_natives()
  70. {
  71.     register_native("ze_is_user_nemesis", "native_ze_is_user_nemesis", 1)
  72.     register_native("ze_set_user_nemesis", "native_ze_set_user_nemesis", 1)
  73. }
  74.  
  75. public plugin_precache()
  76. {
  77.     g_szAmbianceSound = ArrayCreate(64, 1)
  78.     amx_load_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)
  79.  
  80.     new iIndex, szSound[64]
  81.     if (ArraySize(g_szAmbianceSound) == 0)
  82.     {
  83.         for (iIndex = 0; iIndex < sizeof szAmbianceSound; iIndex++)
  84.             ArrayPushString(g_szAmbianceSound, szAmbianceSound[iIndex])
  85.        
  86.         // Save to external file
  87.         amx_save_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)
  88.     }
  89.  
  90.     for (iIndex = 0; iIndex < ArraySize(g_szAmbianceSound); iIndex++)
  91.     {
  92.         ArrayGetString(g_szAmbianceSound, iIndex, szSound, charsmax(szSound))
  93.        
  94.         if (equal(szSound[strlen(szSound)-4], ".mp3"))
  95.         {
  96.             format(szSound, charsmax(szSound), "sound/%s", szSound)
  97.             precache_generic(szSound)
  98.         }
  99.         else
  100.         {
  101.             precache_sound(szSound)
  102.         }
  103.     }
  104.  
  105.     #if defined USE_NEMESIS_MODEL
  106.         // Initialize arrays
  107.         g_aModels_Nemesis_Player = ArrayCreate(32, 1)
  108.         g_aModels_Nemesis_Claws = ArrayCreate(64, 1)
  109.        
  110.         // Load from external file
  111.         amx_load_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS MODEL", g_aModels_Nemesis_Player)
  112.         amx_load_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
  113.        
  114.         // If we couldn't load from file, use and save default ones
  115.         if (ArraySize(g_aModels_Nemesis_Player) == 0)
  116.         {
  117.             for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Player; iIndex++)
  118.                 ArrayPushString(g_aModels_Nemesis_Player, g_szModels_Nemesis_Player[iIndex])
  119.            
  120.             // Save to external file
  121.             amx_save_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS", g_aModels_Nemesis_Player)
  122.         }
  123.  
  124.         if (ArraySize(g_aModels_Nemesis_Claws) == 0)
  125.         {
  126.             for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Claws; iIndex++)
  127.                 ArrayPushString(g_aModels_Nemesis_Claws, g_szModels_Nemesis_Claws[iIndex])
  128.            
  129.             // Save to external file
  130.             amx_save_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
  131.         }
  132.        
  133.         // Precache models
  134.         new player_model[32], model[64], model_path[128]
  135.  
  136.         for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Player); iIndex++)
  137.         {
  138.             ArrayGetString(g_aModels_Nemesis_Player, iIndex, player_model, charsmax(player_model))
  139.             formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
  140.             precache_model(model_path)
  141.             // Support modelT.mdl files
  142.             formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
  143.             if (file_exists(model_path)) precache_model(model_path)
  144.         }
  145.  
  146.         for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Claws); iIndex++)
  147.         {
  148.             ArrayGetString(g_aModels_Nemesis_Claws, iIndex, model, charsmax(model))
  149.             precache_model(model)
  150.         }
  151.     #endif
  152. }
  153.  
  154. public plugin_init()
  155. {
  156.     register_plugin("[ZE] Addons: Nemesis", "2.0", "Jack")
  157.  
  158.     RegisterHam(Ham_TakeDamage, "player", "Fw_TakeDamage")
  159.  
  160.     register_clcmd("ze_start_nemesis_next", "cmd_start_nemesis", ADMIN_MENU)
  161.     register_concmd("ze_nemesis", "cmd_nemsis", ADMIN_MENU)
  162.  
  163.     g_pCvarNemesisHP = register_cvar("ze_nemesis_hp", "20000")  // Nemesis health - Set 0 to use zombie HP
  164.     g_pCvarNemesisGravity = register_cvar("ze_nemesis_gravity", "600")  // Nemesis gravity - Set 0 to use zombie gravity
  165.     g_pCvarNemesisSpeed = register_cvar("ze_nemesis_speed", "320.0")  // Nemesis speed - Set 0 to use zombie speed
  166.     g_pCvarNemesisGlow = register_cvar("ze_nemesis_glow", "1")    // Nemesis glow - 1 = enable | 0 = disable
  167.     g_pCvarNemesisGlowColor[Red] = register_cvar("ze_nemesis_glow_r", "255")    // Nemesis glow color RED
  168.     g_pCvarNemesisGlowColor[Green] = register_cvar("ze_nemesis_glow_g", "0")  // Nemesis glow color GREEN
  169.     g_pCvarNemesisGlowColor[Blue] = register_cvar("ze_nemesis_glow_b", "0")   // Nemesis glow color BLUE
  170.     g_pCvarNemesisKB = register_cvar("ze_nemesis_kb", "150.0")  // Nemesis knockback - Set 0 to use zombie knockback
  171.     //g_pCvarNemesisDmg = register_cvar("ze_nemesis_dmg", "200.0")    // Nemesis damage
  172.     g_pCvarNemesisFreeze = register_cvar("ze_nemesis_freeze", "0")  // Nemesis get frozen? - 1 = doesn't get frozen | 0 = gets frozen
  173.     g_pCvarNemesisFire = register_cvar("ze_nemesis_fire", "1")  // Nemesis set on fire? - 1 = doesn't set on fire | 0 = set on fire
  174. }
  175.  
  176. public client_disconnected(id)
  177. {
  178.     if (g_bIsNemesis[id])
  179.     {
  180.         new szPlayerName[2][32], iNewNemId
  181.         get_user_name(id, szPlayerName[0], charsmax(szPlayerName))
  182.         iNewNemId = GetRandomNemesis()
  183.         get_user_name(iNewNemId, szPlayerName[1], charsmax(szPlayerName))
  184.         g_bIsNemesis[id] = false
  185.         Set_Nemesis(iNewNemId)
  186.         ze_colored_print(0, "!g%s !thas left !n& !g%s !thas become nemesis!", szPlayerName[0], szPlayerName[1])
  187.     }
  188. }
  189.  
  190. public client_putinserver(id)
  191. {
  192.     if (g_bIsNemesis[id])
  193.         g_bIsNemesis[id] = false
  194. }
  195.  
  196. public ze_user_infected_pre(iVictim, iAttacker)
  197. {
  198.     if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim))
  199.     {
  200.     ExecuteHamB(Ham_Killed, iVictim, iAttacker, 0)
  201.     return 1
  202.     }
  203.  
  204.     return 0
  205. }
  206.  
  207. public Fw_TakeDamage(iVictim, iInfector, iAttacker, Float:iDamage)
  208. {
  209.     if (iVictim == iAttacker || !is_user_alive(iAttacker))
  210.         return HAM_IGNORED
  211.  
  212.     if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim) && iInfector == iAttacker)
  213.     {
  214.     ExecuteHamB(Ham_Killed, iVictim, iAttacker, 0)
  215.     return 1
  216.     }
  217.  
  218.     return HAM_IGNORED
  219. }
  220.  
  221. public ze_fire_pre(id)
  222. {
  223.     if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFire))
  224.         return PLUGIN_HANDLED
  225.     return PLUGIN_CONTINUE
  226. }
  227.  
  228. public ze_frost_pre(id)
  229. {
  230.     if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFreeze))
  231.         return PLUGIN_HANDLED
  232.     return PLUGIN_CONTINUE
  233. }
  234.  
  235. public ze_user_humanized(id)
  236. {
  237.     UnSet_Nemesis(id)
  238. }
  239.  
  240. public ze_roundend()
  241. {
  242.     remove_task(TASK_AMBIENCESOUND)
  243.     remove_task(TASK_REAMBIENCESOUND)
  244.     remove_task(TASK_MAKE_NEMESIS)
  245.    
  246.     for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
  247.     {
  248.         if (is_user_alive(id) && g_bIsNemesis[id])
  249.             UnSet_Nemesis(id)
  250.     }
  251. }
  252.  
  253. public ze_game_started_pre()
  254. {
  255.     if (get_playersnum())
  256.     {
  257.         if (g_bIsNextRoundNemesis)
  258.         {
  259.             g_bIsNextRoundNemesis = true
  260.             g_iCountDown = 17
  261.             set_task(1.0, "StartNemesis", TASK_MAKE_NEMESIS, _, _, "b")
  262.             set_task(5.0, "AmbianceSound", TASK_AMBIENCESOUND)
  263.             return PLUGIN_HANDLED
  264.         }
  265.     }
  266.     else
  267.     {
  268.         g_bIsNextRoundNemesis = false
  269.         ze_colored_print(0, "!gThe server doesn't have enough players to start nemesis round !n(!tat least 1!n)!")
  270.     }
  271.  
  272.     return PLUGIN_CONTINUE
  273. }
  274.  
  275. public AmbianceSound()
  276. {
  277.     // Stop All Sounds
  278.     StopSound()
  279.    
  280.     // Play The Ambiance Sound For All Players
  281.     new szSound[64]
  282.     ArrayGetString(g_szAmbianceSound, random_num(0, ArraySize(g_szAmbianceSound) - 1), szSound, charsmax(szSound))
  283.    
  284.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  285.     {
  286.         if (!is_user_connected(id))
  287.         continue
  288.  
  289.         PlaySound(id, szSound)
  290.     }
  291.  
  292.     // We should Set Task back again to replay (Repeated 5 times MAX)
  293.     set_task(float(g_iAmbianceSoundDuration), "AmbianceSound", TASK_REAMBIENCESOUND, _, _, "a", 5)
  294. }
  295.  
  296. public StartNemesis(taskid)
  297. {
  298.     if (!g_iCountDown)
  299.     {
  300.     new iNemesis, id
  301.     while (iNemesis < RequiredNemesis())
  302.     {
  303.     id = GetRandomAlive(random_num(1, GetAllAlivePlayersNum()))
  304.        
  305.     if (!is_user_alive(id) || g_bIsNemesis[id])
  306.     continue
  307.  
  308.     Set_Nemesis(id)
  309.     iNemesis++
  310.     }
  311.  
  312.     g_iNemesisNum = iNemesis
  313.     remove_task(taskid)
  314.     return
  315.     }
  316.  
  317.     set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 0.8, 0.8)
  318.     show_hudmessage(0, "Nemesis starts in %d second(s).", g_iCountDown--)
  319. }
  320.  
  321. public cmd_start_nemesis(id, level, cid)
  322. {
  323.     if (!cmd_access(id, ADMIN_MENU, cid, 0))
  324.     {
  325.         client_print(id, print_console, "You have not access.")
  326.         ze_colored_print(id, "%L", id, "NEMESIS_CHAT_COMMAND")
  327.         return PLUGIN_HANDLED
  328.     }
  329.    
  330.     g_bIsNextRoundNemesis = true
  331.     client_print(id, print_console, "Nemesis round will start next round.")
  332.     ze_colored_print(id, "Nemesis round will start next round.")
  333.  
  334.    
  335.     return PLUGIN_HANDLED
  336. }
  337.  
  338. public cmd_nemsis(id, level, cid)
  339. {
  340.     if (!cmd_access(id, ADMIN_MENU, cid, 0))
  341.     {
  342.         client_print(id, print_console, "You have not access.")
  343.         ze_colored_print(id, "%L", id, "NEMESIS_CHAT_COMMAND")
  344.         return PLUGIN_HANDLED
  345.     }
  346.    
  347.     // Retrieve arguments
  348.     new arg[32], player
  349.     read_argv(1, arg, charsmax(arg))
  350.     player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  351.    
  352.     // Invalid target
  353.     if (!player || !is_user_alive(player))
  354.     {
  355.         ze_colored_print(id, "Invalid player.")
  356.         return PLUGIN_HANDLED
  357.     }
  358.    
  359.     // Target not allowed to be nemesis
  360.     if (g_bIsNemesis[player])
  361.     {
  362.         new player_name[32]
  363.         get_user_name(player, player_name, charsmax(player_name))
  364.         client_print(id, print_console, "[ZE] %s is already nemesis.", player_name)
  365.         return PLUGIN_HANDLED
  366.     }
  367.    
  368.     Set_Nemesis(player)
  369.     return PLUGIN_HANDLED
  370. }
  371.  
  372. public Set_Nemesis(id)
  373. {
  374.     g_bIsNemesis[id] = true
  375.  
  376.     if (!ze_is_user_zombie(id))
  377.         ze_set_user_zombie(id)
  378.  
  379.     #if defined USE_NEMESIS_LEAP
  380.         ze_get_longjump(id)
  381.     #endif
  382.  
  383.     #if defined USE_NEMESIS_MODEL
  384.         new szPlayerModel[32], szModel[64]
  385.         ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
  386.         cs_set_user_model(id, szPlayerModel)
  387.  
  388.         ArrayGetString(g_aModels_Nemesis_Claws, random_num(0, ArraySize(g_aModels_Nemesis_Claws) - 1), szModel, charsmax(szModel))
  389.         cs_set_player_view_model(id, CSW_KNIFE, szModel)
  390.     #endif
  391.    
  392.     if (get_pcvar_num(g_pCvarNemesisHP))
  393.     {
  394.         set_entvar(id, var_health, get_pcvar_float(g_pCvarNemesisHP))
  395.     }
  396.    
  397.     if (get_pcvar_num(g_pCvarNemesisSpeed) >= 0)
  398.     {
  399.     ze_set_zombie_speed(id, get_pcvar_num(g_pCvarNemesisSpeed))
  400.     }
  401.    
  402.     if (get_pcvar_num(g_pCvarNemesisGravity))
  403.     {
  404.         ze_set_user_gravity(id, get_pcvar_num(g_pCvarNemesisGravity))
  405.     }
  406.  
  407.     if (get_pcvar_num(g_pCvarNemesisKB))
  408.     {
  409.         ze_set_user_knockback(id, get_pcvar_float(g_pCvarNemesisKB))
  410.     }
  411.  
  412.     /*if (get_pcvar_num(g_pCvarNemesisGlow))
  413.     {
  414.         set_user_rendering(id, fx = kRenderFxNone, r = 255, g = 0, b = 0, render = kRenderNormal, amount = 10)
  415.     }*/
  416.     if (get_pcvar_num(g_pCvarNemesisGlow) > 0)
  417.        Set_Rendering(id, kRenderFxGlowShell, get_pcvar_num(g_pCvarNemesisGlowColor[Red]), get_pcvar_num(g_pCvarNemesisGlowColor[Green]), get_pcvar_num(g_pCvarNemesisGlowColor[Blue]), kRenderNormal, 84);
  418.        
  419.     new szName[32]
  420.     get_user_name(id, szName, charsmax(szName))
  421.     set_hudmessage(255, 0, 0, -1.0, 0.21, 0, 0.0, 5.0, 0.1, 1.5)
  422.     show_hudmessage(id, "%s became Nemesis", szName)
  423.     ze_colored_print(0, "!g%s !tbecame !gNemesis!", szName)
  424.     ze_colored_print(id, "!gYou !tbecame !gNemesis!")
  425. }
  426.  
  427. public UnSet_Nemesis(id)
  428. {
  429.     if (!g_bIsNemesis[id] || !is_user_alive(id))
  430.         return
  431.  
  432.     g_bIsNemesis[id] = false
  433.  
  434.     #if defined USE_NEMESIS_LEAP
  435.         ze_remove_longjump(id)
  436.     #endif
  437.  
  438.     #if defined USE_NEMESIS_MODEL
  439.         new szPlayerModel[32]
  440.         ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
  441.         cs_reset_user_model(id)
  442.     #endif
  443.  
  444.     if (get_pcvar_num(g_pCvarNemesisSpeed))
  445.     {
  446.         ze_reset_zombie_speed(id)
  447.     }
  448.  
  449.     if (get_pcvar_num(g_pCvarNemesisGravity))
  450.     {
  451.         ze_reset_user_gravity(id)
  452.     }
  453.  
  454.     if (get_pcvar_num(g_pCvarNemesisKB))
  455.     {
  456.         ze_reset_user_knockback(id)
  457.     }
  458.  
  459.     if (get_pcvar_num(g_pCvarNemesisGlow))
  460.     {
  461.         Set_Rendering(id) // Remove rendering (Glow Shell).
  462.     }
  463. }
  464.  
  465. public GetRandomNemesis()
  466. {
  467.     new iPlayers[32], iSelected[33], iCount = 0, iTotalPlayers, iRandomIndex
  468.     get_players(iPlayers, iTotalPlayers)
  469.  
  470.     if (iTotalPlayers > 0)
  471.     {
  472.         for (new i = 0; i < iTotalPlayers; i++)
  473.         {
  474.             iRandomIndex = iPlayers[i]
  475.  
  476.             if (is_user_alive(iRandomIndex))
  477.             {
  478.                 iSelected[iCount++] = iRandomIndex
  479.             }
  480.         }
  481.  
  482.         return iSelected[random(--iCount)]
  483.     }
  484.  
  485.     return 0
  486. }
  487.  
  488. public native_ze_is_user_nemesis(id)
  489. {
  490.     if (!is_user_connected(id))
  491.     {
  492.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  493.         return -1
  494.     }
  495.  
  496.     return g_bIsNemesis[id]
  497. }
  498.  
  499. public native_ze_set_user_nemesis(id, bool:set)
  500. {
  501.     if (!is_user_connected(id))
  502.     {
  503.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  504.         return false
  505.     }
  506.  
  507.     if (set)
  508.     {
  509.         if (!g_bIsNemesis[id])
  510.             Set_Nemesis(id)
  511.     }
  512.     else
  513.     {
  514.         if (g_bIsNemesis[id])
  515.             UnSet_Nemesis(id)
  516.     }
  517.  
  518.     return true
  519. }
  520.  
  521. stock RequiredNemesis()
  522. {
  523.     switch(GetAllAlivePlayersNum())
  524.     {
  525.         case 2..5: return 1
  526.         case 6..15: return 2
  527.         case 16..25: return 3
  528.         case 26..32: return 4
  529.     }
  530.     return 0
  531. }
  532.  
  533. public native_ze_get_nemesis_number()
  534. {
  535.     return g_iNemesisNum
  536. }

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#2

Post by z0h1r-LK » 1 year ago

Check nemesis mode in Gameplay forum, It's compatible with v1.6

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 3 guests