rockbandcheeseman

RandomWeapon

Mar 17th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 71.59 KB | None | 0 0
  1. -- RandomWeapon 3.0
  2.  
  3. -- Every time you spawn, you will spawn with random attributes.
  4. -- This includes weapons, grenades, ammo, and special abilities.
  5. -- I've written this script intentionally to make it easy for inexperienced scripters to edit and flexible for more experienced scripters to customize.
  6. -- If any of my comments are confusing, or you have any questions about how the script works, you can PM me (Nuggets) at phasor.proboards.com
  7.  
  8. function GetRequiredVersion()
  9.  
  10.     return 10059
  11. end
  12.  
  13. function OnScriptLoad(processId)
  14.  
  15.     -- Probabilities --
  16.    
  17.     probability = {}
  18.        
  19.     -- In each probabilities table, you may create new entries in the same syntax as I've written them, remove any entries I've included, and easily change the probabilities of all attributes.
  20.     -- If you add any probabilities, make sure you give them entries under Player Multipliers, Messages, and Recurrence or they will not work correctly.
  21.    
  22.     -- **If you are using Player Multipliers (see next section entitled "Player Multipliers")**:
  23.     -- Keep in mind these probabilities are for when there are 0 players in your server.
  24.     -- Probabilities that should increase as the number of players increases should therefore be set decently lower than their desired value and vice versa.
  25.  
  26.    
  27.     -- Primary Weapon Probabilities --
  28.  
  29.     probability.primary = {}
  30.  
  31.     --                    Tag:                                      Probability:     Description:
  32.     probability.primary[false] =                                          0          -- No Weapon
  33.     probability.primary["weapons\\assault rifle\\assault rifle"] =        14         -- Assault Rifle
  34.     probability.primary["weapons\\plasma pistol\\plasma pistol"] =        13         -- Plasma Pistol
  35.     probability.primary["weapons\\needler\\mp_needler"] =                 13         -- Needler
  36.     probability.primary["weapons\\plasma rifle\\plasma rifle"] =          13         -- Plasma Rifle
  37.     probability.primary["weapons\\shotgun\\shotgun"] =                    14         -- Shotgun
  38.     probability.primary["weapons\\pistol\\pistol"] =                      13         -- Pistol
  39.     probability.primary["weapons\\sniper rifle\\sniper rifle"] =          12         -- Sniper Rifle
  40.     probability.primary["weapons\\flamethrower\\flamethrower"] =          4          -- Flamethrower
  41.     probability.primary["weapons\\rocket launcher\\rocket launcher"] =    2          -- Rocket Launcher
  42.     probability.primary["weapons\\plasma_cannon\\plasma_cannon"] =        2          -- Fuel Rod
  43.  
  44.     -- Secondary Weapon Probabilities --
  45.    
  46.     probability.secondary = {}
  47.  
  48.     --                    Tag:                                       Probability:     Description:
  49.     probability.secondary[false] =                                        15          -- No Weapon
  50.     probability.secondary["weapons\\assault rifle\\assault rifle"] =      14          -- Assault Rifle
  51.     probability.secondary["weapons\\plasma pistol\\plasma pistol"] =      13          -- Plasma Pistol
  52.     probability.secondary["weapons\\needler\\mp_needler"] =               11          -- Needler
  53.     probability.secondary["weapons\\plasma rifle\\plasma rifle"] =        12          -- Plasma Rifle
  54.     probability.secondary["weapons\\shotgun\\shotgun"] =                  13          -- Shotgun
  55.     probability.secondary["weapons\\pistol\\pistol"] =                    10          -- Pistol
  56.     probability.secondary["weapons\\sniper rifle\\sniper rifle"] =        7           -- Sniper Rifle
  57.     probability.secondary["weapons\\flamethrower\\flamethrower"] =        3           -- Flamethrower
  58.     probability.secondary["weapons\\rocket launcher\\rocket launcher"] =  1           -- Rocket Launcher
  59.     probability.secondary["weapons\\plasma_cannon\\plasma_cannon"] =      1           -- Fuel Rod
  60.    
  61.     -- Tertiary Weapon Probabilities --
  62.  
  63.     probability.tertiary = {}
  64.  
  65.     --                    Tag:                                       Probability:     Description:
  66.     probability.tertiary[false] =                                         100         -- No Weapon
  67.     probability.tertiary["weapons\\assault rifle\\assault rifle"] =       0           -- Assault Rifle
  68.     probability.tertiary["weapons\\plasma pistol\\plasma pistol"] =       0           -- Plasma Pistol
  69.     probability.tertiary["weapons\\needler\\mp_needler"] =                0           -- Needler
  70.     probability.tertiary["weapons\\plasma rifle\\plasma rifle"] =         0           -- Plasma Rifle
  71.     probability.tertiary["weapons\\shotgun\\shotgun"] =                   0           -- Shotgun
  72.     probability.tertiary["weapons\\pistol\\pistol"] =                     0           -- Pistol
  73.     probability.tertiary["weapons\\sniper rifle\\sniper rifle"] =         0           -- Sniper Rifle
  74.     probability.tertiary["weapons\\flamethrower\\flamethrower"] =         0           -- Flamethrower
  75.     probability.tertiary["weapons\\rocket launcher\\rocket launcher"] =   0           -- Rocket Launcher
  76.     probability.tertiary["weapons\\plasma_cannon\\plasma_cannon"] =       0           -- Fuel Rod
  77.    
  78.     -- Quartenary Weapon Probabilities --
  79.  
  80.     probability.quartenary = {}
  81.  
  82.     --                    Tag:                                       Probability:     Description:
  83.     probability.quartenary[false] =                                       100         -- No Weapon
  84.     probability.quartenary["weapons\\assault rifle\\assault rifle"] =     0           -- Assault Rifle
  85.     probability.quartenary["weapons\\plasma pistol\\plasma pistol"] =     0           -- Plasma Pistol
  86.     probability.quartenary["weapons\\needler\\mp_needler"] =              0           -- Needler
  87.     probability.quartenary["weapons\\plasma rifle\\plasma rifle"] =       0           -- Plasma Rifle
  88.     probability.quartenary["weapons\\shotgun\\shotgun"] =                 0           -- Shotgun
  89.     probability.quartenary["weapons\\pistol\\pistol"] =                   0           -- Pistol
  90.     probability.quartenary["weapons\\sniper rifle\\sniper rifle"] =       0           -- Sniper Rifle
  91.     probability.quartenary["weapons\\flamethrower\\flamethrower"] =       0           -- Flamethrower
  92.     probability.quartenary["weapons\\rocket launcher\\rocket launcher"] = 0           -- Rocket Launcher
  93.     probability.quartenary["weapons\\plasma_cannon\\plasma_cannon"] =     0           -- Fuel Rod
  94.  
  95.     -- Grenade Probabilities --
  96.  
  97.     probability.grenades = {}  -- Formatted as probability.grenades[{amount of frag grenades, amount of plasma grenades}] = probability
  98.                                -- This format allows you to add custom grenade loadouts by just adding another entry in the same syntax with whatever numbers you like.
  99.    
  100.     --                  Frag,Plasma:    Probability:   Description:
  101.     probability.grenades[{0, 0}] =          30         -- No grenades
  102.     probability.grenades[{1, 0}] =          20         -- 1 frag, no plasmas
  103.     probability.grenades[{2, 0}] =          10         -- 2 frags, no plasmas
  104.     probability.grenades[{0, 1}] =          20         -- no frags, 1 plasma
  105.     probability.grenades[{0, 2}] =          10         -- no frags, 2 plasmas
  106.     probability.grenades[{2, 2}] =          7          -- 2 frags, 2 plasmas
  107.     probability.grenades[{4, 4}] =          3          -- 4 frags, 4 plasmas
  108.    
  109.     -- Ammo Probabilities --
  110.    
  111.     probability.ammo = {}      -- Formatted as probability.ammo[multiplier] = probability
  112.                                -- This format allows you to add custom ammo multipliers by just adding another entry in the same syntax with whatever number you like.
  113.    
  114.     --             Mult:        Probability:    Description:        Multiplier Description:
  115.     probability.ammo[1] =             60        -- Normal Ammo      (Multiplier x1)
  116.     probability.ammo[2] =             20        -- Double Ammo      (Multiplier x2)
  117.     probability.ammo[3] =             12        -- Triple Ammo      (Multiplier x3)
  118.     probability.ammo[4] =             7.8       -- Quadruple Ammo   (Multiplier x4)
  119.     probability.ammo[math.inf] =      0.2       -- Infinite Ammo    (Mulitplier xInf)
  120.    
  121.     -- Special Probabilities --
  122.    
  123.     probability.special = {}   -- Formatted as probability.special[{function to be called (function name expressed as a string) <, args...>}] = probability
  124.                                -- The function specified should take in a player's memory id as its first argument; all other arguments are defined by the optional <, args...> in the above syntax.
  125.                                -- This function should also return a boolean which specifies if the attribute should be considered (for example, overshield shouldn't be considered in a no-shields gametype).
  126.                                -- Keep in mind your function can have more than the amount of arguments than the functions I've listed below; it just happened that none of my functions exceeded two.
  127.                                -- This format allows you to add custom probability.special spawns by just adding another entry in the same syntax with whatever function you like.
  128.    
  129.     --                        Function:       arg1:     arg2:          Probability:    Description:                            Function Description:
  130.     probability.special[{    "setspeed",       1               }] =         90         -- No Special Attributes                (uses setspeed(player, 1) to reset a player's speed if they received a speed bonus_ammo previously)
  131.     probability.special[{    "applycamo",      0               }] =         2          -- Camo                                 (uses applycamo(player, 0) to give a player camo until death)
  132.     probability.special[{    "applyos"                         }] =         3.25       -- Overshield                           (uses applyos(player) to give the player overshield)
  133.     probability.special[{    "setspeed",       2               }] =         1.5        -- Double Speed                         (uses setspeed(player, 2) to double a player's speed)
  134.     probability.special[{    "oscamo",         0               }] =         1          -- Camo and Overshield                  (uses oscamo(player, 0) to give a player overshield and camo until death)
  135.     probability.special[{    "camospeed",      0,         2    }] =         0.5        -- Camo and Double Speed                (uses camospeed(player, 0, 2) to give a player camo until death and double speed)
  136.     probability.special[{    "speedos",        2               }] =         0.75       -- Overshield and Double Speed          (uses speedos(player, 2) to give a player overshield and double speed)
  137.     probability.special[{    "speedoscamo",    0,         2    }] =         0.25       -- Camo, Overshield and Double Speed    (uses speedoscamo(player, 0, 2) to give a player camo until death, overshield, and double speed)
  138.     probability.special[{    "damagemultiply", 2               }] =         0.5        -- Double Damage                        (uses damagemultiply(player, 2) to give a player double damage
  139.     probability.special[{    "healthmultiply", 2               }] =         0.25       -- Double Health and Shields            (uses healthmultiply(player, 2) to give a player double health and shields
  140.    
  141.    
  142.     -- Player Multipliers --
  143.    
  144.     multiplier = {}             -- Changes attribute probabilities based on the amount of players in the server.
  145.                                 -- Value specifies percentage of probability per player in the server.
  146.                                 -- For example, multiplier.ammo[2] = 0.5 will divide Double Ammo's probability in half per player who joins (if ammo[2] = 10, 2 players = 5, 3 players = 2.5, 4 players = 1.25, etc)
  147.                                 -- Keep in mind that increasing every attribute's probability by the same amount will do nothing since the probability of each attribute is dependent on the probability of every other attribute in that category.
  148.                                 -- In general, 1.0000 ± 0.0025 is a slow increase/decrease, 1.0000 ± 0.0050 is a moderate increase/decrease, and 1.0000 ± 0.0075 is a sharp increase/decrease in probability per joining player.
  149.                                
  150.                                 -- To see how the percentage chance for each attribute changes depending on the amount of players, run this script and search your data folder for a file called "random.data".
  151.                                 -- Use this text file as a reference to percentages to adjust these values and probability values to your liking.
  152.                                 -- The variable player_multipliers must be true in order to see how the multipliers affect the percentage probabilities.
  153.                                
  154.                                 -- Keep in mind that for the most part, these numbers should be extremely close to 1.  Probabilities change drastically faster than you may think.
  155.                                
  156.                                 -- If you don't want to use Player Multipliers, make player_multipliers = false.
  157.  
  158.     player_multipliers = true   -- Use to toggle the use of Player Multipliers.  If false, all values in the multipliers table below are completely ignored (therefore, 1.0000).
  159.    
  160.     multiplier.primary = {}    -- Player Multipliers for Primary Weapons
  161.    
  162.     --                                Tag:                                Multiplier:         Description:
  163.     multiplier.primary[false] =                                             1.0000            -- No Weapon:  We never want this probability to be anything but zero.
  164.     multiplier.primary["weapons\\assault rifle\\assault rifle"] =           1.0050            -- Assault Rifle:  We want this probability to moderately increase as more players join.
  165.     multiplier.primary["weapons\\plasma pistol\\plasma pistol"] =           1.0025            -- Plasma Pistol:  We want this probability to slowly increase as more players join.
  166.     multiplier.primary["weapons\\needler\\mp_needler"] =                    1.0025            -- Needler:  We want this probability to moderately increase as more players join.
  167.     multiplier.primary["weapons\\plasma rifle\\plasma rifle"] =             1.0050            -- Plasma Rifle:  We want this probability to moderately increase as more players join.
  168.     multiplier.primary["weapons\\shotgun\\shotgun"] =                       1.0025            -- Shotgun:  We want this probability to slowly increase as more players join.
  169.     multiplier.primary["weapons\\pistol\\pistol"] =                         1.0000            -- Pistol:  We want this probability to remain the same no matter how many players join.
  170.     multiplier.primary["weapons\\sniper rifle\\sniper rifle"] =             0.9975            -- Sniper Rifle:  We want this probability to slowly decrease as more players join.
  171.     multiplier.primary["weapons\\flamethrower\\flamethrower"] =             0.9950            -- Flamethrower:  We want this probability to moderately decrease as more players join.
  172.     multiplier.primary["weapons\\rocket launcher\\rocket launcher"] =       0.9900            -- Rocket Launcher:  We want this probability to very sharply decrease as more players join.
  173.     multiplier.primary["weapons\\plasma_cannon\\plasma_cannon"] =           0.9875            -- Fuel Rod:  We want this probability to very sharply decrease as more players join.
  174.    
  175.     multiplier.secondary = {}    -- Player Multipliers for Secondary Weapons
  176.    
  177.         --                                Tag:                            Multiplier:         Description:
  178.     multiplier.secondary[false] =                                           1.0125            -- No Weapon:  We want this probability to very sharply increase as more players join.
  179.     multiplier.secondary["weapons\\assault rifle\\assault rifle"] =         1.0050            -- Assault Rifle:  We want this probability to moderately increase as more players join.
  180.     multiplier.secondary["weapons\\plasma pistol\\plasma pistol"] =         1.0000            -- Plasma Pistol:  We want this probability to remain the same as more players join.
  181.     multiplier.secondary["weapons\\needler\\mp_needler"] =                  1.0025            -- Needler:  We want this probability to moderately increase as more players join.
  182.     multiplier.secondary["weapons\\plasma rifle\\plasma rifle"] =           1.0025            -- Plasma Rifle:  We want this probability to slowly increase as more players join.
  183.     multiplier.secondary["weapons\\shotgun\\shotgun"] =                     0.9975            -- Shotgun:  We want this probability to remain the same as more players join.
  184.     multiplier.secondary["weapons\\pistol\\pistol"] =                       0.9950            -- Pistol:  We want this probability to remain the same no matter how many players join.
  185.     multiplier.secondary["weapons\\sniper rifle\\sniper rifle"] =           0.9975            -- Sniper Rifle:  We want this probability to slowly decrease as more players join.
  186.     multiplier.secondary["weapons\\flamethrower\\flamethrower"] =           0.9900            -- Flamethrower:  We want this probability to slowly decrease as more players join.
  187.     multiplier.secondary["weapons\\rocket launcher\\rocket launcher"] =     0.9850            -- Rocket Launcher:  We want this probability to sharply decrease as more players join.
  188.     multiplier.secondary["weapons\\plasma_cannon\\plasma_cannon"] =         0.9800            -- Fuel Rod:  We want this probability to very sharply decrease as more players join.
  189.    
  190.     multiplier.tertiary = {}    -- Player Multipliers for Tertiary Weapons
  191.                                 -- I've set this script up to not include Tertiary Weapon probabilities (other than No Weapon), therefore I have made all of these multipliers 1.0000.
  192.                                 -- Use Primary and Secondary Weapon Player Multipliers for reference if you wish to change these values.
  193.    
  194.     --                                Tag:                                Multiplier:         Description:
  195.     multiplier.tertiary[false] =                                             1.0000           -- No Weapon
  196.     multiplier.tertiary["weapons\\assault rifle\\assault rifle"] =           1.0000           -- Assault Rifle
  197.     multiplier.tertiary["weapons\\plasma pistol\\plasma pistol"] =           1.0000           -- Plasma Pistol
  198.     multiplier.tertiary["weapons\\needler\\mp_needler"] =                    1.0000           -- Needler
  199.     multiplier.tertiary["weapons\\plasma rifle\\plasma rifle"] =             1.0000           -- Plasma Rifle
  200.     multiplier.tertiary["weapons\\shotgun\\shotgun"] =                       1.0000           -- Shotgun
  201.     multiplier.tertiary["weapons\\pistol\\pistol"] =                         1.0000           -- Pistol
  202.     multiplier.tertiary["weapons\\sniper rifle\\sniper rifle"] =             1.0000           -- Sniper Rifle
  203.     multiplier.tertiary["weapons\\flamethrower\\flamethrower"] =             1.0000           -- Flamethrower
  204.     multiplier.tertiary["weapons\\rocket launcher\\rocket launcher"] =       1.0000           -- Rocket Launcher
  205.     multiplier.tertiary["weapons\\plasma_cannon\\plasma_cannon"] =           1.0000           -- Fuel Rod
  206.    
  207.     multiplier.quartenary = {}    -- Player Multipliers for Quartenary Weapons
  208.                                 -- See Tertiary Weapon Player Multipliers if you wish to change these values.
  209.    
  210.     --                                Tag:                                Multiplier:        Description:
  211.     multiplier.quartenary[false] =                                           1.0000           -- No Weapon
  212.     multiplier.quartenary["weapons\\assault rifle\\assault rifle"] =         1.0000           -- Assault Rifle
  213.     multiplier.quartenary["weapons\\plasma pistol\\plasma pistol"] =         1.0000           -- Plasma Pistol
  214.     multiplier.quartenary["weapons\\needler\\mp_needler"] =                  1.0000           -- Needler
  215.     multiplier.quartenary["weapons\\plasma rifle\\plasma rifle"] =           1.0000           -- Plasma Rifle
  216.     multiplier.quartenary["weapons\\shotgun\\shotgun"] =                     1.0000           -- Shotgun
  217.     multiplier.quartenary["weapons\\pistol\\pistol"] =                       1.0000           -- Pistol
  218.     multiplier.quartenary["weapons\\sniper rifle\\sniper rifle"] =           1.0000           -- Sniper Rifle
  219.     multiplier.quartenary["weapons\\flamethrower\\flamethrower"] =           1.0000           -- Flamethrower
  220.     multiplier.quartenary["weapons\\rocket launcher\\rocket launcher"] =     1.0000           -- Rocket Launcher
  221.     multiplier.quartenary["weapons\\plasma_cannon\\plasma_cannon"] =         1.0000           -- Fuel Rod
  222.    
  223.     multiplier.grenades = {}    -- Player Multipliers for Grenades
  224.    
  225.     --                 Frag,Plasma:    Multiplier:        Description:
  226.     multiplier.grenades[{0, 0}] =         1.0075            -- No Grenades
  227.     multiplier.grenades[{1, 0}] =         0.9975            -- One Frag
  228.     multiplier.grenades[{2, 0}] =         0.9975            -- Two Frags
  229.     multiplier.grenades[{0, 1}] =         0.9975            -- One Plasma
  230.     multiplier.grenades[{0, 2}] =         0.9975            -- Two Plasmas
  231.     multiplier.grenades[{2, 2}] =         0.9950            -- Two of Each
  232.     multiplier.grenades[{4, 4}] =         0.9925            -- Four of Each
  233.    
  234.     multiplier.ammo = {}        -- Player Multipliers for Ammo
  235.    
  236.     --    Ammo Multiplier:    Probability Multiplier:        Description:
  237.     multiplier.ammo[1] =                 0.9950                -- Normal Ammo
  238.     multiplier.ammo[2] =                 1.0050                -- Double Ammo
  239.     multiplier.ammo[3] =                 1.0075                -- Triple Ammo
  240.     multiplier.ammo[4] =                 1.0075                -- Ammotacular
  241.     multiplier.ammo[math.inf] =          0.9250                -- Infinite Ammo
  242.    
  243.     multiplier.special = {}        -- Player Multipliers for Special Attributes
  244.    
  245.     --                     Function:                Multiplier:         Description:
  246.     multiplier.special[{"setspeed", 1}] =             1.0075            -- No Special
  247.     multiplier.special[{"applycamo", 0}] =            0.9975            -- Camo
  248.     multiplier.special[{"applyos"}] =                 0.9975            -- Overshield
  249.     multiplier.special[{"setspeed", 2}] =             1.0000            -- Double Speed
  250.     multiplier.special[{"oscamo", 0}] =               0.9975            -- Overshield and Camo
  251.     multiplier.special[{"camospeed", 0, 2}] =         0.9950            -- Double Speed and Camo
  252.     multiplier.special[{"speedos", 2}] =              0.9925            -- Double Speed and Overshield
  253.     multiplier.special[{"speedoscamo", 0, 2}] =       0.9900            -- Double Speed, Overshield and Camo
  254.     multiplier.special[{"damagemultiply", 2}] =       0.9950            -- Double Damage
  255.     multiplier.special[{"healthmultiply", 2}] =       1.0050            -- Double Health and Shields
  256.    
  257.    
  258.     -- Messages --
  259.        
  260.     messages = {}   -- If you add any custom probabilities above, make sure a message accompanies it.
  261.                     -- Use nil as the message if you don't want a message sent.
  262.                     -- All table indexing syntaxes are the same as above.
  263.    
  264.     messages.primary = {}
  265.    
  266.     --                            Tag:                                    Message:
  267.     messages.primary[false] =                                             "No Weapon."
  268.     messages.primary["weapons\\assault rifle\\assault rifle"] =           "Assault Rifle."
  269.     messages.primary["weapons\\plasma pistol\\plasma pistol"] =           "Plasma Pistol."
  270.     messages.primary["weapons\\needler\\mp_needler"] =                    "Needler."
  271.     messages.primary["weapons\\plasma rifle\\plasma rifle"] =             "Plasma Rifle."
  272.     messages.primary["weapons\\shotgun\\shotgun"] =                       "Shotgun."
  273.     messages.primary["weapons\\pistol\\pistol"] =                         "Pistol."
  274.     messages.primary["weapons\\sniper rifle\\sniper rifle"] =             "Sniper."
  275.     messages.primary["weapons\\flamethrower\\flamethrower"] =             "Flamethrower."
  276.     messages.primary["weapons\\rocket launcher\\rocket launcher"] =       "Rocket."
  277.     messages.primary["weapons\\plasma_cannon\\plasma_cannon"] =           "Fuel Rod."
  278.    
  279.     messages.secondary = {}
  280.    
  281.     --                            Tag:                                    Message:
  282.     messages.secondary[false] =                                            nil
  283.     messages.secondary["weapons\\assault rifle\\assault rifle"] =         "Secondary: Assault Rifle"
  284.     messages.secondary["weapons\\plasma pistol\\plasma pistol"] =         "Secondary: Plasma Pistol"
  285.     messages.secondary["weapons\\needler\\mp_needler"] =                  "Secondary: Needler"
  286.     messages.secondary["weapons\\plasma rifle\\plasma rifle"] =           "Secondary: Plasma Rifle"
  287.     messages.secondary["weapons\\shotgun\\shotgun"] =                     "Secondary: Shotgun"
  288.     messages.secondary["weapons\\pistol\\pistol"] =                       "Secondary: Pistol"
  289.     messages.secondary["weapons\\sniper rifle\\sniper rifle"] =           "Secondary: Sniper"
  290.     messages.secondary["weapons\\flamethrower\\flamethrower"] =           "Secondary: Flamethrower"
  291.     messages.secondary["weapons\\rocket launcher\\rocket launcher"] =     "Secondary: Rocket"
  292.     messages.secondary["weapons\\plasma_cannon\\plasma_cannon"] =         "Secondary: Fuel Rod"
  293.    
  294.     messages.tertiary = {}
  295.    
  296.     --                            Tag:                                    Message:
  297.     messages.tertiary[false] =                                             nil
  298.     messages.tertiary["weapons\\assault rifle\\assault rifle"] =          "Tertiary: Assault Rifle"
  299.     messages.tertiary["weapons\\plasma pistol\\plasma pistol"] =          "Tertiary: Plasma Pistol"
  300.     messages.tertiary["weapons\\needler\\mp_needler"] =                   "Tertiary: Needler"
  301.     messages.tertiary["weapons\\plasma rifle\\plasma rifle"] =            "Tertiary: Plasma Rifle"
  302.     messages.tertiary["weapons\\shotgun\\shotgun"] =                      "Tertiary: Shotgun"
  303.     messages.tertiary["weapons\\pistol\\pistol"] =                        "Tertiary: Pistol"
  304.     messages.tertiary["weapons\\sniper rifle\\sniper rifle"] =            "Tertiary: Sniper"
  305.     messages.tertiary["weapons\\flamethrower\\flamethrower"] =            "Tertiary: Flamethrower"
  306.     messages.tertiary["weapons\\rocket launcher\\rocket launcher"] =      "Tertiary: Rocket"
  307.     messages.tertiary["weapons\\plasma_cannon\\plasma_cannon"] =          "Tertiary: Fuel Rod"
  308.    
  309.     messages.quartenary = {}
  310.    
  311.     --                            Tag:                                    Message:
  312.     messages.quartenary[false] =                                           nil
  313.     messages.quartenary["weapons\\assault rifle\\assault rifle"] =        "Quartenary: Assault Rifle"
  314.     messages.quartenary["weapons\\plasma pistol\\plasma pistol"] =        "Quartenary: Plasma Pistol"
  315.     messages.quartenary["weapons\\needler\\mp_needler"] =                 "Quartenary: Needler"
  316.     messages.quartenary["weapons\\plasma rifle\\plasma rifle"] =          "Quartenary: Plasma Rifle"
  317.     messages.quartenary["weapons\\shotgun\\shotgun"] =                    "Quartenary: Shotgun"
  318.     messages.quartenary["weapons\\pistol\\pistol"] =                      "Quartenary: Pistol"
  319.     messages.quartenary["weapons\\sniper rifle\\sniper rifle"] =          "Quartenary: Sniper"
  320.     messages.quartenary["weapons\\flamethrower\\flamethrower"] =          "Quartenary: Flamethrower"
  321.     messages.quartenary["weapons\\rocket launcher\\rocket launcher"] =    "Quartenary: Rocket"
  322.     messages.quartenary["weapons\\plasma_cannon\\plasma_cannon"] =        "Quartenary: Fuel Rod"
  323.    
  324.     messages.grenades = {}
  325.    
  326.     --            Grenades:         Message:
  327.     messages.grenades[{0, 0}] =      nil
  328.     messages.grenades[{1, 0}] =     "A Frag Grenade."
  329.     messages.grenades[{2, 0}] =     "Two Frag Grenades."
  330.     messages.grenades[{0, 1}] =     "A Plasma Grenade."
  331.     messages.grenades[{0, 2}] =     "Two Plasma Grenades."
  332.     messages.grenades[{2, 2}] =     "Two of each Grenade."
  333.     messages.grenades[{4, 4}] =     "Four of each Grenade!"
  334.    
  335.     messages.ammo = {}
  336.    
  337.     --        Multiplier:          Message:
  338.     messages.ammo[1] =              nil
  339.     messages.ammo[2] =             "Double Ammo."
  340.     messages.ammo[3] =             "Triple Ammo."
  341.     messages.ammo[4] =             "Ammotacular!"
  342.     messages.ammo[math.inf] =      "Infinite Ammo!!"
  343.    
  344.     messages.special = {}
  345.    
  346.     --        Function:                            Message:
  347.     messages.special[{"setspeed", 1}] =             nil
  348.     messages.special[{"applycamo", 0}] =           "Invisibility!"
  349.     messages.special[{"applyos"}] =                "Overshield!"
  350.     messages.special[{"setspeed", 2}] =            "Double Speed!"
  351.     messages.special[{"oscamo", 0}] =              "Invisibility and Overshield!"
  352.     messages.special[{"camospeed", 0, 2}] =        "Invisibility and Double Speed!"
  353.     messages.special[{"speedos", 2}] =             "Double Speed and Overshield!"
  354.     messages.special[{"speedoscamo", 0, 2}] =      "Invisibility, Overshield and Double Speed!!"
  355.     messages.special[{"damagemultiply", 2}] =      "Double Damage!"
  356.     messages.special[{"healthmultiply", 2}] =      "Double Health and Shields!"
  357.    
  358.    
  359.     -- Attribute Recurrence Multipliers --
  360.    
  361.     recurrence = {}                            -- Multiplier used to change a player's probability of receiving the same attribute twice.
  362.                                                -- For example, if the recurrence multiplier of an Assault Rifle is 0.5 and a player spawns with an Assault Rifle, they will be half as likely to spawn with one next time.
  363.                                                -- The attribute recurrence multiplier is reversed when a player does not spawn with any given attribute twice in a row.
  364.                                                -- Set to 0 if you want it to be impossible to have the same exact attribute twice in a row; set it to 1 for attribute recurrence to have no effect.
  365.                                                -- These values should probably be below 1 unless you want to make it more likely to spawn with an attribute the more you spawn with it.
  366.    
  367.     recurrence.primary = {}    -- Attribute Recurrence Multipliers for Primary Weapons
  368.    
  369.     --                                Tag:                                Multiplier:       Description:
  370.     recurrence.primary[false] =                                             1.00            -- No Weapon
  371.     recurrence.primary["weapons\\assault rifle\\assault rifle"] =           0.60            -- Assault Rifle
  372.     recurrence.primary["weapons\\plasma pistol\\plasma pistol"] =           0.60            -- Plasma Pistol
  373.     recurrence.primary["weapons\\needler\\mp_needler"] =                    0.60            -- Needler
  374.     recurrence.primary["weapons\\plasma rifle\\plasma rifle"] =             0.65            -- Plasma Rifle
  375.     recurrence.primary["weapons\\shotgun\\shotgun"] =                       0.65            -- Shotgun
  376.     recurrence.primary["weapons\\pistol\\pistol"] =                         0.60            -- Pistol
  377.     recurrence.primary["weapons\\sniper rifle\\sniper rifle"] =             0.55            -- Sniper Rifle
  378.     recurrence.primary["weapons\\flamethrower\\flamethrower"] =             0.40            -- Flamethrower
  379.     recurrence.primary["weapons\\rocket launcher\\rocket launcher"] =       0.30            -- Rocket Launcher
  380.     recurrence.primary["weapons\\plasma_cannon\\plasma_cannon"] =           0.15            -- Fuel Rod
  381.    
  382.     recurrence.secondary = {}    -- Attribute Recurrence Multipliers for Secondary Weapons
  383.    
  384.         --                                Tag:                            Multiplier:       Description:
  385.     recurrence.secondary[false] =                                           1.00            -- No Weapon
  386.     recurrence.secondary["weapons\\assault rifle\\assault rifle"] =         0.60            -- Assault Rifle
  387.     recurrence.secondary["weapons\\plasma pistol\\plasma pistol"] =         0.60            -- Plasma Pistol
  388.     recurrence.secondary["weapons\\needler\\mp_needler"] =                  0.60            -- Needler
  389.     recurrence.secondary["weapons\\plasma rifle\\plasma rifle"] =           0.65            -- Plasma Rifle
  390.     recurrence.secondary["weapons\\shotgun\\shotgun"] =                     0.65            -- Shotgun
  391.     recurrence.secondary["weapons\\pistol\\pistol"] =                       0.60            -- Pistol
  392.     recurrence.secondary["weapons\\sniper rifle\\sniper rifle"] =           0.55            -- Sniper Rifle
  393.     recurrence.secondary["weapons\\flamethrower\\flamethrower"] =           0.40            -- Flamethrower
  394.     recurrence.secondary["weapons\\rocket launcher\\rocket launcher"] =     0.30            -- Rocket Launcher
  395.     recurrence.secondary["weapons\\plasma_cannon\\plasma_cannon"] =         0.15            -- Fuel Rod
  396.    
  397.     recurrence.tertiary = {}    -- Attribute Recurrence Multipliers for Tertiary Weapons
  398.                                 -- I've set this script up to not include Tertiary Weapon probabilities (other than No Weapon), therefore I have made all of these recurrences 1.0000.
  399.                                 -- Use Primary and Secondary Weapon Attribute Recurrence Multipliers for reference if you wish to change these values.
  400.    
  401.     --                                Tag:                                Multiplier:       Description:
  402.     recurrence.tertiary[false] =                                             1.00           -- No Weapon
  403.     recurrence.tertiary["weapons\\assault rifle\\assault rifle"] =           1.00           -- Assault Rifle
  404.     recurrence.tertiary["weapons\\plasma pistol\\plasma pistol"] =           1.00           -- Plasma Pistol
  405.     recurrence.tertiary["weapons\\needler\\mp_needler"] =                    1.00           -- Needler
  406.     recurrence.tertiary["weapons\\plasma rifle\\plasma rifle"] =             1.00           -- Plasma Rifle
  407.     recurrence.tertiary["weapons\\shotgun\\shotgun"] =                       1.00           -- Shotgun
  408.     recurrence.tertiary["weapons\\pistol\\pistol"] =                         1.00           -- Pistol
  409.     recurrence.tertiary["weapons\\sniper rifle\\sniper rifle"] =             1.00           -- Sniper Rifle
  410.     recurrence.tertiary["weapons\\flamethrower\\flamethrower"] =             1.00           -- Flamethrower
  411.     recurrence.tertiary["weapons\\rocket launcher\\rocket launcher"] =       1.00           -- Rocket Launcher
  412.     recurrence.tertiary["weapons\\plasma_cannon\\plasma_cannon"] =           1.00           -- Fuel Rod
  413.    
  414.     recurrence.quartenary = {}    -- Attribute Recurrence Multipliers for Quartenary Weapons
  415.                                   -- See Tertiary Weapon Attribute Recurrence Multipliers if you wish to change these values.
  416.    
  417.     --                                Tag:                                Multiplier:       Description:
  418.     recurrence.quartenary[false] =                                           1.00           -- No Weapon
  419.     recurrence.quartenary["weapons\\assault rifle\\assault rifle"] =         1.00           -- Assault Rifle
  420.     recurrence.quartenary["weapons\\plasma pistol\\plasma pistol"] =         1.00           -- Plasma Pistol
  421.     recurrence.quartenary["weapons\\needler\\mp_needler"] =                  1.00           -- Needler
  422.     recurrence.quartenary["weapons\\plasma rifle\\plasma rifle"] =           1.00           -- Plasma Rifle
  423.     recurrence.quartenary["weapons\\shotgun\\shotgun"] =                     1.00           -- Shotgun
  424.     recurrence.quartenary["weapons\\pistol\\pistol"] =                       1.00           -- Pistol
  425.     recurrence.quartenary["weapons\\sniper rifle\\sniper rifle"] =           1.00           -- Sniper Rifle
  426.     recurrence.quartenary["weapons\\flamethrower\\flamethrower"] =           1.00           -- Flamethrower
  427.     recurrence.quartenary["weapons\\rocket launcher\\rocket launcher"] =     1.00           -- Rocket Launcher
  428.     recurrence.quartenary["weapons\\plasma_cannon\\plasma_cannon"] =         1.00           -- Fuel Rod
  429.    
  430.     recurrence.grenades = {}    -- Attribute Recurrence Multipliers for Grenades
  431.    
  432.     --                 Frag,Plasma:    Multiplier:        Description:
  433.     recurrence.grenades[{0, 0}] =         1.00            -- No Grenades
  434.     recurrence.grenades[{1, 0}] =         0.95            -- One Frag
  435.     recurrence.grenades[{2, 0}] =         0.95            -- Two Frags
  436.     recurrence.grenades[{0, 1}] =         0.95            -- One Plasma
  437.     recurrence.grenades[{0, 2}] =         0.95            -- Two Plasmas
  438.     recurrence.grenades[{2, 2}] =         0.90            -- Two of Each
  439.     recurrence.grenades[{4, 4}] =         0.85            -- Four of Each
  440.    
  441.     recurrence.ammo = {}        -- Attribute Recurrence Multipliers for Ammo
  442.    
  443.     --    Ammo Multiplier:    Probability Multiplier:        Description:
  444.     recurrence.ammo[1] =                 1.00                -- Normal Ammo
  445.     recurrence.ammo[2] =                 0.90                -- Double Ammo
  446.     recurrence.ammo[3] =                 0.90                -- Triple Ammo
  447.     recurrence.ammo[4] =                 0.90                -- Ammotacular
  448.     recurrence.ammo[math.inf] =          0.05                -- Infinite Ammo
  449.    
  450.     recurrence.special = {}        -- Attribute Recurrence Multipliers for Special Attributes
  451.    
  452.     --                     Function:                Multiplier:       Description:
  453.     recurrence.special[{"setspeed", 1}] =             1.00            -- No Special
  454.     recurrence.special[{"applycamo", 0}] =            0.25            -- Camo
  455.     recurrence.special[{"applyos"}] =                 0.60            -- Overshield
  456.     recurrence.special[{"setspeed", 2}] =             0.25            -- Double Speed
  457.     recurrence.special[{"oscamo", 0}] =               0.20            -- Overshield and Camo
  458.     recurrence.special[{"camospeed", 0, 2}] =         0.10            -- Double Speed and Camo
  459.     recurrence.special[{"speedos", 2}] =              0.40            -- Double Speed and Overshield
  460.     recurrence.special[{"speedoscamo", 0, 2}] =       0.05            -- Double Speed, Overshield and Camo
  461.     recurrence.special[{"damagemultiply", 2}] =       0.10            -- Double Damage
  462.     recurrence.special[{"healthmultiply", 2}] =       0.05            -- Double Health and Shields
  463.    
  464.    
  465.     -- Ammo for Kills --
  466.    
  467.     ammo_for_kills =             true          -- Determines if a player receives an ammo prize for killing a player.  If this is false, all values in the bonus_ammo table are treated as 0.
  468.    
  469.     bonus_ammo = {}                            -- Bonus ammo for kills
  470.                                                -- Determines the amount of bonus_ammo ammo a player will receive for a kill depending on what weapon they are carrying.
  471.    
  472.     --       Tag:                                              Bonus Ammo:
  473.     bonus_ammo["weapons\\assault rifle\\assault rifle"] =          45
  474.     bonus_ammo["weapons\\needler\\mp_needler"] =                   15
  475.     bonus_ammo["weapons\\shotgun\\shotgun"] =                      8
  476.     bonus_ammo["weapons\\pistol\\pistol"] =                        8
  477.     bonus_ammo["weapons\\sniper rifle\\sniper rifle"] =            4
  478.     bonus_ammo["weapons\\flamethrower\\flamethrower"] =            25
  479.     bonus_ammo["weapons\\rocket launcher\\rocket launcher"] =      1
  480.    
  481.     -- Grenade Pickup Booleans --
  482.    
  483.     grenade_pickup =             false         -- Determines if players are able to pick up grenades found around the map.  If this is false, grenade_spawnmax is also treated as false.
  484.     grenade_spawnmax =           false         -- If true, players may only pick up grenades up to the amount they spawned with.  If false, players are not restricted to how many grenades they may pick up.
  485.    
  486.    
  487.     -- Jackpot Percentage --
  488.    
  489.     jackpot_percentage =         0.01          -- If the percentage probability of this attribute is less than or equal to the value specified, the word "Jackpot" will be printed before the default message (use 0 to disable).
  490.    
  491.    
  492.     -- Vehicle Weapon Operable Boolean --
  493.    
  494.     vehicle_weapon_operabale =   false         -- Determines if vehicle weapons are able to be used.  Return true if they should be, return false if they shouldn't be.
  495.    
  496.    
  497.     -- Vehicle Entry Booleans --
  498.    
  499.     enter_vehicle =              false         -- Determines if players should be able to enter vehicles.  If this is false, all other vehicle booleans are treated as false.
  500.     enter_vehicle_driver =       false         -- Determines if players should be able to enter vehicle driver's seats.
  501.     enter_vehicle_passenger =    false         -- Determines if players should be able to enter vehicle passenger's seats.
  502.     enter_vehicle_gunner =       false         -- Determines if players should be able to enter vehicle gunner's seats.
  503.    
  504.    
  505.     -- Object Spawn Booleans --
  506.    
  507.     objects = {}                               -- Determines if the specified tag will be spawned in the map.  Use true if you want the object to spawn normally, false if you don't want it to appear.
  508.                                                -- Note that these values are always treated as true when using createobject.
  509.    
  510.     -- Equipment --
  511.    
  512.     objects.eqip = {}
  513.    
  514.     --         Tag:                                              Boolean:         Description:
  515.     objects.eqip["powerups\\active camouflage"] =                true             -- Active Camouflage
  516.     objects.eqip["powerups\\over shield"] =                      true             -- Overshield
  517.     objects.eqip["powerups\\health pack"] =                      true             -- Health Pack
  518.     objects.eqip["weapons\\frag grenade\\frag grenade"] =        false            -- Frag Grenade
  519.     objects.eqip["weapons\\plasma grenade\\plasma grenade"] =    false            -- Plasma Grenade
  520.    
  521.     -- Projectiles --
  522.    
  523.     objects.proj = {}
  524.    
  525.     --         Tag:                                              Boolean:         Description:
  526.     objects.proj["weapons\\frag grenade\\frag grenade"] =        true             -- Frag Grenade
  527.     objects.proj["weapons\\plasma grenade\\plasma grenade"] =    true             -- Plasma Grenade
  528.     objects.proj["vehicles\\banshee\\banshee bolt"] =            true             -- Banshee Bolt
  529.     objects.proj["vehicles\\banshee\\mp_banshee fuel rod"] =     true             -- Banshee Fuel Rod
  530.     objects.proj["vehicles\\c gun turret\\mp gun turret"] =      true             -- Covenant Turret Bolt
  531.     objects.proj["vehicles\\ghost\\ghost bolt"] =                true             -- Ghost Bolt
  532.     objects.proj["vehicles\\scorpion\\bullet"] =                 true             -- Scorpion Bullet
  533.     objects.proj["vehicles\\scorpion\\tank shell"] =             true             -- Scorpion Shell
  534.     objects.proj["vehicles\\warthog\\bullet"] =                  true             -- Warthog Bullet
  535.     objects.proj["weapons\\assault rifle\\bullet"] =             true             -- Assault Rifle Bullet
  536.     objects.proj["weapons\\flamethrower\\flame"] =               true             -- Flamethrower Flame
  537.     objects.proj["weapons\\needler\\mp_needle"] =                true             -- Needler Needle
  538.     objects.proj["weapons\\pistol\\bullet"] =                    true             -- Pistol Bullet
  539.     objects.proj["weapons\\plasma pistol\\bolt"] =               true             -- Plasma Pistol Bolt
  540.     objects.proj["weapons\\plasma rifle\\bolt"] =                true             -- Plasma Rifle Bolt
  541.     objects.proj["weapons\\plasma rifle\\charged bolt"] =        true             -- Plasma Pistol Charged Bolt
  542.     objects.proj["weapons\\plasma_cannon\\plasma_cannon"] =      true             -- Fuel Rod Projectile
  543.     objects.proj["weapons\\rocket launcher\\rocket"] =           true             -- Rocket Launcher Rocket
  544.     objects.proj["weapons\\shotgun\\pellet"] =                   true             -- Shotgun Pellet
  545.     objects.proj["weapons\\sniper rifle\\sniper bullet"] =       true             -- Sniper Rifle Bullet
  546.    
  547.     -- Weapons --
  548.    
  549.     objects.weap = {}
  550.    
  551.     --         Tag:                                              Boolean:         Description:
  552.     objects.weap["vehicles\\banshee\\mp_banshee gun"] =          true             -- Banshee Gun
  553.     objects.weap["vehicles\\c gun turret\\mp gun turret gun"] =  true             -- Covenant Turret Gun
  554.     objects.weap["vehicles\\ghost\\mp_ghost gun"] =              true             -- Ghost Gun
  555.     objects.weap["vehicles\\rwarthog\\rwarthog_gun"] =           true             -- Rocket Warthog Gun
  556.     objects.weap["vehicles\\scorpion\\scorpion cannon"] =        true             -- Scorpion Cannon
  557.     objects.weap["vehicles\\warthog\\warthog gun"] =             true             -- Warthog Gun
  558.     objects.weap["weapons\\assault rifle\\assault rifle"] =      true             -- Assault Rifle
  559.     objects.weap["weapons\\ball\\ball"] =                        true             -- Oddball
  560.     objects.weap["weapons\\flag\\flag"] =                        true             -- Flag
  561.     objects.weap["weapons\\flamethrower\\flamethrower"] =        true             -- Flamethrower
  562.     objects.weap["weapons\\gravity rifle\\gravity rifle"] =      true             -- Gravity Rifle
  563.     objects.weap["weapons\\needler\\mp_needler"] =               true             -- Needler
  564.     objects.weap["weapons\\needler\\needler"] =                  true             -- Campaign Needler
  565.     objects.weap["weapons\\pistol\\pistol"] =                    true             -- Pistol
  566.     objects.weap["weapons\\plasma pistol\\plasma pistol"] =      true             -- Plasma Pistol
  567.     objects.weap["weapons\\plasma rifle\\plasma rifle"] =        true             -- Plasma Rifle
  568.     objects.weap["weapons\\plasma_cannon\\plasma_cannon"] =      true             -- Fuel Rod
  569.     objects.weap["weapons\\rocket launcher\\rocket launcher"] =  true             -- Rocket Launcher
  570.     objects.weap["weapons\\shotgun\\shotgun"] =                  true             -- Shotgun
  571.     objects.weap["weapons\\sniper rifle\\sniper rifle"] =        true             -- Sniper Rifle
  572.    
  573.     -- Vehicles --
  574.    
  575.     objects.vehi = {}
  576.    
  577.     --         Tag:                                              Boolean:         Description:
  578.     objects.vehi["vehicles\\banshee\\banshee_mp"] =              true             -- Banshee
  579.     objects.vehi["vehicles\\c gun turret\\c gun turret_mp"] =    true             -- Covenant Turret
  580.     objects.vehi["vehicles\\ghost\\ghost_mp"] =                  true             -- Ghost
  581.     objects.vehi["vehicles\\rwarthog\\rwarthog"] =               true             -- Rocket Warthog
  582.     objects.vehi["vehicles\\scorpion\\scorpion_mp"] =            true             -- Scorpion
  583.     objects.vehi["vehicles\\warthog\\mp_warthog"] =              true             -- Warthog
  584.    
  585.    
  586. -- **Don't mess with anything below this line unless you know what you're doing** --
  587.    
  588.     -- Individual Probabilities --
  589.    
  590.     players = {}
  591.     attributes = {}
  592.    
  593.     -- Gametype Information --
  594.    
  595.     gametypeinfo()
  596.    
  597.     -- Generate Percentage Text File --
  598.    
  599.     --[[local file = io.open(getprofilepath() .. "\\data\\random.data", "w")
  600.     if file then
  601.         local str = ""
  602.         for i = 0,15 do
  603.             newplayer(i)
  604.             str = str .. "\n\n" .. i + 1 .. " Players:\n\n"
  605.             for type in attpairs(players[i].probability) do
  606.                 local sum = table.sum(players[i].probability[type])
  607.                 str = str .. "\n" ..  type .. ":\n\n"
  608.                 for key,v in pairs(players[i].probability[type]) do
  609.                     str = str .. (getinfo(i, "messages", type, key) or "nil") .. " = " .. math.round((v / sum) * 100, 3) .. "%\n"
  610.                 end
  611.             end
  612.         end
  613.        
  614.         file:write(str)
  615.         file:close()
  616.     end--]]
  617. end
  618.  
  619. --[[
  620. function OnScriptUnload()
  621.  
  622.  
  623. end
  624. --]]
  625.  
  626. --[[
  627. function OnNewGame(map)
  628.  
  629.  
  630. end
  631. --]]
  632.  
  633. --[[
  634. function OnGameEnd(stage)
  635.  
  636.  
  637. end
  638. --]]
  639.  
  640. --[[
  641. function OnServerChat(player, type, message)
  642.    
  643.     --return true
  644. end
  645. --]]
  646.  
  647. --[[
  648. function OnServerCommand(player, command)
  649.  
  650.     --return true
  651. end
  652. --]]
  653.  
  654. --[[
  655. function OnBanCheck(hash, ip)
  656.    
  657.     --return true
  658. end
  659. --]]
  660.  
  661. function OnPlayerJoin(player)
  662.  
  663.     local hash = gethash(player)
  664.     newplayer(hash)
  665.     generate(player)
  666. end
  667.  
  668. function OnPlayerLeave(player)
  669.  
  670.     local hash = gethash(player)
  671.     playerleave(hash)
  672. end
  673.  
  674. function OnPlayerKill(killer, victim, mode)
  675.  
  676.     setspeed(victim, 1)
  677.     damagemultiply(victim, 1)
  678.     healthmultiply(victim, 1)
  679.     generate(victim)
  680.    
  681.     if killer then
  682.         if ammo_for_kills then
  683.             local hash = gethash(killer)
  684.             for type,key in pairs(attributes[hash]) do
  685.                 if bonus_ammo[key] then
  686.                     if type == "primary" or type == "secondary" or type == "tertiary" or type == "quartenary" then
  687.                         local slot = 0x2F8
  688.                         if type == "secondary" then
  689.                             slot = 0x2F8 + 4
  690.                         elseif type == "tertiary" then
  691.                             slot = 0x2F8 + 8
  692.                         elseif type == "quartenary" then
  693.                             slot = 0x2F8 + 12
  694.                         end
  695.                         local m_player = getplayer(killer)
  696.                         if m_player then
  697.                             local objId = readdword(m_player, 0x34)
  698.                             local m_object = getobject(objId)
  699.                             if m_object then
  700.                                 local weapId = readdword(m_object, slot)
  701.                                 local m_weapon = getobject(weapId)
  702.                                 if m_weapon then
  703.                                     local cur_ammo = readword(m_weapon, 0x2B6)
  704.                                     writeword(m_weapon, 0x2B6, cur_ammo + bonus_ammo[key])
  705.                                     updateammo(weapId)
  706.                                 end
  707.                             end
  708.                         end
  709.                     end
  710.                 end
  711.             end
  712.         end
  713.     end
  714. end
  715.  
  716. --[[
  717. function OnKillMultiplier(player, multiplier)
  718.  
  719.  
  720. end
  721. --]]
  722.  
  723. function OnPlayerSpawn(player)
  724.    
  725.     local hash = gethash(player)
  726.    
  727.     local frags = attributes[hash].grenades[1]
  728.     local plasmas = attributes[hash].grenades[2]
  729.    
  730.     local m_player = getplayer(player)
  731.     local objId = readdword(m_player, 0x34)
  732.     local m_object = getobject(objId)
  733.    
  734.     writebyte(m_object, 0x31E, frags)
  735.     writebyte(m_object, 0x31F, plasmas)
  736. end
  737.  
  738. function OnPlayerSpawnEnd(player)
  739.  
  740.     local hash = gethash(player)
  741.    
  742.     -- Additional Weapon Assignments --
  743.    
  744.     if attributes[hash].tertiary and attributes[hash].quartenary then
  745.         local weapId1 = createobject(gettagid("weap", attributes[hash].quartenary), 0, 0, false, 0, 0, -100)
  746.         local m_weapon1 = getobject(weapId1)
  747.         if m_weapon1 then
  748.             assignweapon(player, weapId1)
  749.         end
  750.         local weapId2 = createobject(gettagid("weap", attributes[hash].primary), 0, 0, false, 0, 0, -100)
  751.         local m_weapon2 = getobject(weapId2)
  752.         if m_weapon2 then
  753.             assignweapon(player, weapId2)
  754.         end
  755.     elseif attributes[hash].tertiary then
  756.         local weapId = createobject(gettagid("weap", attributes[hash].primary), 0, 0, false, 0, 0, -100)
  757.         local m_weapon = getobject(weapId)
  758.         if m_weapon then
  759.             assignweapon(player, weapId)
  760.         end
  761.     end
  762.    
  763.     attributeprint(player, "primary", attributes[hash].primary)
  764.     attributeprint(player, "secondary", attributes[hash].secondary)
  765.     attributeprint(player, "tertiary", attributes[hash].tertiary)
  766.     attributeprint(player, "quartenary", attributes[hash].quartenary)
  767.    
  768.     -- Ammo Assignments --
  769.    
  770.     local m_player = getplayer(player)
  771.     local objId = readdword(m_player, 0x34)
  772.     local m_object = getobject(objId)
  773.    
  774.     -- Plasma weapon check
  775.    
  776.     local plasma = false
  777.    
  778.     for i = 0,3 do
  779.         local weapId = readdword(m_object, 0x2F8 + (i * 4))
  780.         local m_weapon = getobject(weapId)
  781.         if m_weapon then
  782.             local mapId = readdword(m_weapon)
  783.             local tagname = gettaginfo(mapId)
  784.             if string.find(tagname, "plasma") then
  785.                 plasma = true
  786.                 break
  787.             end
  788.         end
  789.     end
  790.    
  791.     for i = 0,3 do
  792.         local weapId = readdword(m_object, 0x2F8 + (i * 4))
  793.         local m_weapon = getobject(weapId)
  794.         if m_weapon then
  795.             if attributes[hash].ammo == 0 then
  796.                 writefloat(m_weapon, 0x240, 1)
  797.                 writeword(m_weapon, 0x2B6, 0)
  798.                 writeword(m_weapon, 0x2B8, 0)
  799.             end
  800.            
  801.             if not plasma then
  802.                 if attributes[hash].ammo == math.inf then
  803.                     writeword(m_weapon, 0x2B6, 9999)
  804.                     writeword(m_weapon, 0x2B8, 9999)
  805.                     infiniteammo(player)
  806.                 else
  807.                     local ammo = readword(m_weapon, 0x2B6)
  808.                     writeword(m_weapon, 0x2B6, ammo * attributes[hash].ammo)
  809.                 end
  810.             end
  811.            
  812.             updateammo(weapId)
  813.         end
  814.     end
  815.    
  816.     if not plasma or attributes[hash].ammo == 0 then
  817.         attributeprint(player, "ammo", attributes[hash].ammo)
  818.     end
  819.    
  820.     -- Grenade Message --
  821.    
  822.     attributeprint(player, "grenades", attributes[hash].grenades)
  823.    
  824.     -- Special Assignments --
  825.    
  826.     local foo = _G[attributes[hash].special[1]]
  827.     local executed = foo(player, table.unpack(attributes[hash].special, 2, #attributes[hash].special))
  828.    
  829.     if executed then
  830.         attributeprint(player, "special", attributes[hash].special)
  831.     end
  832. end
  833.  
  834. function OnWeaponAssignment(player, objId, slot, weapId)
  835.    
  836.     if player then
  837.         local hash = gethash(player)
  838.        
  839.         if slot == 0 then
  840.             if attributes[hash].tertiary then
  841.                 return gettagid("weap", attributes[hash].secondary)
  842.             else
  843.                 return gettagid("weap", attributes[hash].primary)
  844.             end
  845.         elseif slot == 1 then
  846.             if attributes[hash].tertiary then
  847.                 return gettagid("weap", attributes[hash].tertiary)
  848.             else
  849.                 if attributes[hash].secondary then
  850.                     return gettagid("weap", attributes[hash].secondary)
  851.                 end
  852.             end
  853.         end
  854.        
  855.         return -1
  856.     else
  857.         if not vehicle_weapon_operable then
  858.             return -1
  859.         end
  860.     end
  861. end
  862.  
  863. function OnObjectCreationAttempt(mapId, parentId, player)
  864.    
  865.     local tagname, tagtype = gettaginfo(mapId)
  866.     if objects[tagtype] then
  867.         return objects[tagtype][tagname]
  868.     end
  869. end
  870.  
  871. --[[
  872. function OnObjectCreation(objId)
  873.  
  874.  
  875. end
  876. --]]
  877.  
  878. function OnObjectInteraction(player, objId, mapId)
  879.    
  880.     local hash = gethash(player)
  881.    
  882.     local tagname, tagtype = gettaginfo(mapId)
  883.     if tagtype == "weap" then
  884.         if tagname == attributes[hash].primary or tagname == attributes[hash].secondary or tagname == attributes[hash].tertiary or tagname == attributes[hash].quartenary or tagname == "weapons\\flag\\flag" or tagname == "weapons\\ball\\ball" then
  885.             return true
  886.         else
  887.             return false
  888.         end
  889.     elseif tagtype == "eqip" then
  890.         if string.find(tagname, "grenade") then
  891.             if grenade_pickup then
  892.                 if grenade_spawnmax then
  893.                     local max_frags = attributes[hash].grenades[1]
  894.                     local max_plasmas = attributes[hash].grenades[2]
  895.                     local m_player = getplayer(player)
  896.                     if m_player then
  897.                         local objId = readdword(m_player, 0x34)
  898.                         local m_object = getobject(objId)
  899.                         if m_object then
  900.                             local frags = readbyte(m_object, 0x31E)
  901.                             local plasmas = readbyte(m_object, 0x31F)
  902.                             if tagname == "weapons\\frag grenade\\frag grenade" then
  903.                                 if frags < max_frags then
  904.                                     return true
  905.                                 else
  906.                                     return false
  907.                                 end
  908.                             elseif tagname == "weapons\\plasma grenade\\plasma grenade" then
  909.                                 if plasmas < max_plasmas then
  910.                                     return true
  911.                                 else
  912.                                     return false
  913.                                 end
  914.                             end
  915.                         end
  916.                     end
  917.                    
  918.                     return true
  919.                 end
  920.                
  921.                 return true
  922.             else
  923.                 return false
  924.             end
  925.         end
  926.     end
  927. end
  928.  
  929. --[[
  930. function OnTeamDecision(team)
  931.    
  932.     --return team
  933. end
  934. --]]
  935.  
  936. --[[
  937. function OnTeamChange(player, old_team, new_team, voluntary)
  938.    
  939.     --return true
  940. end
  941. --]]
  942.  
  943. damage_multiplier = {}
  944. health_multiplier = {}
  945.  
  946. function OnDamageLookup(receiver, causer, tagdata, mapId)
  947.    
  948.     if causer then
  949.         local c_player = objecttoplayer(causer)
  950.         if c_player then
  951.             local m_player = getplayer(c_player)
  952.             if m_player then
  953.                 local hash = gethash(c_player)
  954.                 if hash then
  955.                     for k,v in pairs(damage_multiplier) do
  956.                         if k == hash then
  957.                             local min_damage = readfloat(tagdata, 0x1D0)
  958.                             local med_damage = readfloat(tagdata, 0x1D4)
  959.                             local max_damage = readfloat(tagdata, 0x1D8)
  960.                             writefloat(tagdata, 0x1D0, min_damage * v)
  961.                             writefloat(tagdata, 0x1D4, med_damage * v)
  962.                             writefloat(tagdata, 0x1D8, max_damage * v)
  963.                         end
  964.                     end
  965.                 end
  966.             end
  967.         end
  968.     end
  969.    
  970.     if receiver then
  971.         local r_player = objecttoplayer(receiver)
  972.         if r_player then
  973.             local m_player = getplayer(r_player)
  974.             if m_player then
  975.                 local hash = gethash(r_player)
  976.                 if hash then
  977.                     for k,v in pairs(health_multiplier) do
  978.                         if k == hash then
  979.                             local min_damage = readfloat(tagdata, 0x1D0)
  980.                             local med_damage = readfloat(tagdata, 0x1D4)
  981.                             local max_damage = readfloat(tagdata, 0x1D8)
  982.                             writefloat(tagdata, 0x1D0, min_damage / v)
  983.                             writefloat(tagdata, 0x1D4, med_damage / v)
  984.                             writefloat(tagdata, 0x1D8, max_damage / v)
  985.                         end
  986.                     end
  987.                 end
  988.             end
  989.         end
  990.     end
  991. end
  992.  
  993. function OnVehicleEntry(player, m_vehiId, seat, mapId, voluntary)
  994.    
  995.     if enter_vehicle then
  996.         if seat == 0 then
  997.             return enter_vehicle_driver
  998.         elseif seat == 2 then
  999.             local tagname = gettaginfo(mapId)
  1000.             if tagname == "vehicles\\warthog\\mp_warthog" or tagname == "vehicles\\rwarthog\\rwarthog" then
  1001.                 return enter_vehicle_gunner
  1002.             else
  1003.                 return enter_vehicle_passenger
  1004.             end
  1005.         else
  1006.             return enter_vehicle_passenger
  1007.         end
  1008.     else
  1009.         return false
  1010.     end
  1011. end
  1012.  
  1013. --[[
  1014. function OnVehicleEject(player, voluntary)
  1015.  
  1016.     --return true
  1017. end
  1018. --]]
  1019.  
  1020. --[[
  1021. function OnClientUpdate(player)
  1022.  
  1023.    
  1024. end
  1025. --]]
  1026.  
  1027. -- Global Variables --
  1028.  
  1029. cur_players = 0
  1030. math.inf = 1 / 0
  1031. math.randomseed(os.time())
  1032.  
  1033. function gametypeinfo()
  1034.  
  1035.     local gametype_base = 0x671340
  1036.     local gametype_game = readbyte(gametype_base, 0x30)
  1037.     local gametype_parameters = readbyte(gametype_base, 0x38)
  1038.     local binary = convertbase(gametype_parameters, 2)
  1039.     gametype_shields = false
  1040.     gametype_speed = false
  1041.     gametype_phantom = false
  1042.  
  1043.     if string.sub(binary, -4, -4) == "0" then
  1044.         gametype_shields = true
  1045.     end
  1046.    
  1047.     if string.sub(binary, -5, -5) == "1" then
  1048.         gametype_phantom = true
  1049.     end
  1050.    
  1051.     if gametype_game == 1 or gametype_game == 2 or gametype_game == 4 then
  1052.         gametype_speed = true
  1053.     end
  1054. end
  1055.  
  1056. -- General Functions --
  1057.  
  1058. phasor_createobject = createobject
  1059.  
  1060. function createobject(mapId, parentId, respawn_time, respawn_bool, x, y, z)
  1061.  
  1062.     local tagname, tagtype = gettaginfo(mapId)
  1063.     if tagname then
  1064.         local orig = objects[tagtype][tagname]
  1065.         objects[tagtype][tagname] = true
  1066.         local objId = phasor_createobject(mapId, parentId, respawn_time, respawn_bool, x, y, z)
  1067.         objects[tagtype][tagname] = orig
  1068.         return objId
  1069.     end
  1070. end
  1071.  
  1072. function objecttoplayer(objId)
  1073.  
  1074.     for i = 0,15 do
  1075.         local m_player = getplayer(i)
  1076.         if m_player then
  1077.             local pl_objId = readdword(m_player, 0x34)
  1078.             if pl_objId == objId then
  1079.                 return i
  1080.             end
  1081.         end
  1082.     end
  1083. end
  1084.  
  1085. function newplayer(hash)
  1086.  
  1087.     players[hash] = {}
  1088.     players[hash].probability = probability
  1089.     players[hash].messages = messages
  1090.     players[hash].multiplier = multiplier
  1091.     players[hash].recurrence = recurrence
  1092.    
  1093.     for type,_ in pairs(players[hash].probability) do
  1094.         for key,v in pairs(players[hash].probability[type]) do
  1095.             local mult = getinfo(nil, "multiplier", type, key)
  1096.             local prob = getinfo(hash, "probability", type, key)
  1097.             setinfo(hash, "probability", type, key, prob * (mult ^ cur_players))
  1098.         end
  1099.     end
  1100.    
  1101.     cur_players = cur_players + 1
  1102.    
  1103.     for i = 0,15 do
  1104.         if getplayer(i) then
  1105.             local hash = gethash(i)
  1106.             for type,_ in pairs(players[hash].probability) do
  1107.                 for key,v in pairs(players[hash].probability[type]) do
  1108.                     local mult = getinfo(nil, "multiplier", type, key)
  1109.                     local prob = getinfo(hash, "probability", type, key)
  1110.                     setinfo(hash, "probability", type, key, prob * mult)
  1111.                 end
  1112.             end
  1113.         end
  1114.     end
  1115. end
  1116.  
  1117. function playerleave(hash)
  1118.  
  1119.     for i = 0,15 do
  1120.         if getplayer(i) then
  1121.             local hash = gethash(i)
  1122.             for type,_ in pairs(players[hash].probability) do
  1123.                 for key,v in pairs(players[hash].probability[type]) do
  1124.                     local mult = getinfo(nil, "multiplier", type, key)
  1125.                     local prob = getinfo(hash, "probability", type, key)
  1126.                     setinfo(hash, "probability", type, key, prob / mult)
  1127.                 end
  1128.             end
  1129.         end
  1130.     end
  1131.    
  1132.     players[hash] = nil
  1133.     cur_players = cur_players - 1
  1134. end
  1135.  
  1136. function getinfo(hash, table, type, key)
  1137.  
  1138.     if hash then
  1139.         if players[hash] then
  1140.             if players[hash][table] then
  1141.                 if players[hash][table][type] then
  1142.                     for k,v in pairs(players[hash][table][type]) do
  1143.                         if equals(k, key) then
  1144.                             return players[hash][table][type][k]
  1145.                         end
  1146.                     end
  1147.                 end
  1148.             end
  1149.         end
  1150.     else
  1151.         for k,v in pairs(_G[table][type]) do
  1152.             if equals(k, key) then
  1153.                 return _G[table][type][k]
  1154.             end
  1155.         end
  1156.     end
  1157. end
  1158.  
  1159. function setinfo(hash, table, type, key, val)
  1160.  
  1161.     if hash then
  1162.         if players[hash] then
  1163.             if players[hash][table] then
  1164.                 if players[hash][table][type] then
  1165.                     for k,v in pairs(players[hash][table][type]) do
  1166.                         if equals(k, key) then
  1167.                             players[hash][table][type][k] = val
  1168.                         end
  1169.                     end
  1170.                 end
  1171.             end
  1172.         end
  1173.     else
  1174.         for k,v in pairs(_G[table][type]) do
  1175.             if equals(k, key) then
  1176.                 _G[table][type][k] = val
  1177.             end
  1178.         end
  1179.     end
  1180. end
  1181.  
  1182. function equals(val1, val2)
  1183.  
  1184.     if type(val1) == type(val2) then
  1185.         if type(val1) == "number" or type(val1) == "string" or type(val1) == "boolean" then
  1186.             return val1 == val2
  1187.         elseif type(val1) == "table" then
  1188.             for k,v in pairs(val1) do
  1189.                 local found = false
  1190.                 for k2,v2 in pairs(val2) do
  1191.                     if equals(k, k2) then
  1192.                         found = true
  1193.                         if not equals(v, v2) then
  1194.                             return false
  1195.                         end
  1196.                         break
  1197.                     end
  1198.                 end
  1199.  
  1200.                 if not found then
  1201.                     return false
  1202.                 end
  1203.             end
  1204.  
  1205.             return true
  1206.         end
  1207.     end
  1208. end
  1209.  
  1210. function generate(player)
  1211.  
  1212.     local hash = gethash(player)
  1213.    
  1214.     attributes[hash] = attributes[hash] or {}
  1215.    
  1216.     local temp = {}
  1217.     local override = {}
  1218.    
  1219.     temp.primary = {}
  1220.     temp.secondary = {}
  1221.     temp.tertiary = {}
  1222.     temp.quartenary = {}
  1223.     temp.grenades = {}
  1224.     temp.ammo = {}
  1225.     temp.special = {}
  1226.    
  1227.     for type,_ in pairs(players[hash].probability) do
  1228.        
  1229.         if attributes[hash][type] then
  1230.             -- Attribute Recurrence Multiplier
  1231.             local prob = getinfo(hash, "probability", type, attributes[hash][type])
  1232.             local attribute_recurrence = getinfo(hash, "recurrence", type, attributes[hash][type])
  1233.             if attribute_recurrence == 0 then
  1234.                 temp[type][attributes[hash][type]] = getinfo(hash, "probability", type, attributes[hash][type])
  1235.             end
  1236.             setinfo(hash, "probability", type, attributes[hash][type], prob * attribute_recurrence)
  1237.         end
  1238.        
  1239.         local sum = table.sum(players[hash].probability[type])
  1240.         local rand = randomnumber(0, sum)      
  1241.         local max = 0
  1242.         local found = false
  1243.        
  1244.         for key,v in pairs(players[hash].probability[type]) do
  1245.             if v ~= 0 then
  1246.                 max = max + v
  1247.                 if rand < max then
  1248.                     if not found then
  1249.                         attributes[hash][type] = key
  1250.                         found = true
  1251.                     end
  1252.                 else
  1253.                     -- Attribute Recurrence Cooldown
  1254.                     local attribute_recurrence = getinfo(hash, "recurrence", type, key)
  1255.                     if attribute_recurrence < 1 then
  1256.                         setinfo(hash, "probability", type, key, math.min(getinfo(hash, "probability", type, key) / attribute_recurrence, getinfo(nil, "probability", type, key)))
  1257.                     elseif attribute_recurrence > 1 then
  1258.                         setinfo(hash, "probability", type, key, math.max(getinfo(hash, "probability", type, key) / attribute_recurrence, getinfo(nil, "probability", type, key)))
  1259.                     end
  1260.                 end
  1261.             end
  1262.         end
  1263.        
  1264.         if type == "primary" then
  1265.             if attributes[hash][type] == false then
  1266.                 override.secondary = false
  1267.                 override.tertiary = false
  1268.                 override.quartenary = false
  1269.             else
  1270.                 temp.secondary[attributes[hash][type]] = getinfo(hash, "probability", "secondary", attributes[hash][type])
  1271.                 temp.tertiary[attributes[hash][type]] = getinfo(hash, "probability", "tertiary", attributes[hash][type])
  1272.                 temp.quartenary[attributes[hash][type]] = getinfo(hash, "probability", "quartenary", attributes[hash][type])
  1273.                 setinfo(hash, "probability", "secondary", attributes[hash][type], 0)
  1274.                 setinfo(hash, "probability", "tertiary", attributes[hash][type], 0)
  1275.                 setinfo(hash, "probability", "quartenary", attributes[hash][type], 0)
  1276.             end
  1277.         elseif type == "secondary" then
  1278.             if attributes[hash][type] == false then
  1279.                 override.tertiary = false
  1280.                 override.quartenary = false
  1281.             else
  1282.                 temp.tertiary[attributes[hash][type]] = getinfo(hash, "probability", "tertiary", attributes[hash][type])
  1283.                 temp.quartenary[attributes[hash][type]] = getinfo(hash, "probability", "quartenary", attributes[hash][type])
  1284.                 setinfo(hash, "probability", "tertiary", attributes[hash][type], 0)
  1285.                 setinfo(hash, "probability", "quartenary", attributes[hash][type], 0)
  1286.             end
  1287.         elseif type == "tertiary" then
  1288.             if attributes[hash][type] == false then
  1289.                 override.quartenary = false
  1290.             else
  1291.                 temp.quartenary[attributes[hash][type]] = getinfo(hash, "probability", "quartenary", attributes[hash][type])
  1292.                 setinfo(hash, "probability", "quartenary", attributes[hash][type], 0)
  1293.             end
  1294.         end
  1295.     end
  1296.    
  1297.     for type,_ in pairs(temp) do
  1298.         for key,v in pairs(temp) do
  1299.             setinfo(hash, "probability", type, key, v)
  1300.         end
  1301.     end
  1302.    
  1303.     for type,v in pairs(override) do
  1304.         attributes[hash][type] = v
  1305.     end
  1306. end
  1307.  
  1308. console = {}
  1309. console.__index = console
  1310. registertimer(100, "ConsoleTimer")
  1311. cur_ticks = getticks()
  1312. phasor_sendconsoletext = sendconsoletext
  1313. math.inf = 1 / 0
  1314.  
  1315. function sendconsoletext(player, text, time, align, func)
  1316.  
  1317.     console[player] = console[player] or {}
  1318.     local id = nextindex(player)
  1319.     console[player][id] = {}
  1320.     console[player][id].p = player
  1321.     console[player][id].id = id
  1322.     console[player][id].msg = text
  1323.     console[player][id].t = time or 5
  1324.     console[player][id].r = time or 5
  1325.     console[player][id].f = func
  1326.     console[player][id].a = align or "left"
  1327.    
  1328.     setmetatable(console[player][id], console)
  1329.     return console[player][id]
  1330. end
  1331.  
  1332. function nextindex(player)
  1333.    
  1334.     local max = 0
  1335.     for k,v in pairs(console[player]) do
  1336.         if k > max then
  1337.             max = k
  1338.         end
  1339.     end
  1340.    
  1341.     return max + 1
  1342. end
  1343.  
  1344. function getmessages(player)
  1345.  
  1346.     return console[player]
  1347. end
  1348.  
  1349. function console:append(text, time_reset)
  1350.  
  1351.     local player = self.p
  1352.     if getplayer(player) then
  1353.         local id = self.id
  1354.         if console[player] then
  1355.             if console[player][id] then
  1356.                 console[player][id].msg = text
  1357.                 if time_reset == true or time_reset == nil then
  1358.                     console[player][id].r = console[player][id].t
  1359.                 end
  1360.             end
  1361.         end
  1362.     end
  1363. end
  1364.  
  1365. function console:message()
  1366.  
  1367.     return self.msg
  1368. end
  1369.  
  1370. function console:player()
  1371.  
  1372.     return self.p
  1373. end
  1374.  
  1375. function console:time()
  1376.  
  1377.     return self.t
  1378. end
  1379.  
  1380. function console:remaining()
  1381.  
  1382.     return self.r
  1383. end
  1384.  
  1385. function console:index()
  1386.  
  1387.     return self.id
  1388. end
  1389.  
  1390. function console:func()
  1391.  
  1392.     return self.f
  1393. end
  1394.  
  1395. function console:alignment()
  1396.  
  1397.     return self.a
  1398. end
  1399.  
  1400. function console:delete()
  1401.  
  1402.     console[self.p][self.id] = nil
  1403. end
  1404.  
  1405. function console:pause(duration)
  1406.  
  1407.     duration = duration or 5
  1408.     console[self.p][self.id].pa = duration
  1409. end
  1410.  
  1411. function console:paused()
  1412.  
  1413.     return self.pa
  1414. end
  1415.  
  1416. function ConsoleTimer(id, count)
  1417.  
  1418.     for player,t in opairs(console) do
  1419.         if type(t) == "table" and player ~= "__index" then
  1420.             for id,t2 in opairs(t) do
  1421.                 if console[player][id].pa then
  1422.                     console[player][id].pa = console[player][id].pa - (getticks() - cur_ticks) / 1000
  1423.                     if console[player][id].pa <= 0 then
  1424.                         console[player][id].pa = nil
  1425.                     end
  1426.                 else
  1427.                     console[player][id].r = console[player][id].r - (getticks() - cur_ticks) / 1000
  1428.                     if console[player][id].r <= 0 then
  1429.                         console[player][id] = nil
  1430.                     end
  1431.                 end
  1432.                
  1433.                 if console[player][id] then
  1434.                     if console[player][id].f then
  1435.                         if not console[player][id].f(player) then
  1436.                             console[player][id] = nil
  1437.                         end
  1438.                     end
  1439.                 end
  1440.             end
  1441.         end
  1442.     end
  1443.    
  1444.     for player,t in opairs(console) do
  1445.         if type(t) == "table" and player ~= "__index" then
  1446.             if getplayer(player) then
  1447.                 if table.len(t) > 0 then
  1448.                     local paused = 0
  1449.                     for id,t2 in pairs(t) do
  1450.                         if console[player][id].pa then
  1451.                             paused = paused + 1
  1452.                         end
  1453.                     end
  1454.                    
  1455.                     if paused < table.len(t) then
  1456.                         local str = ""
  1457.                         for i = 0,30 do
  1458.                             str = str .. "\n "
  1459.                         end
  1460.                         phasor_sendconsoletext(player, str)
  1461.                         for id,t2 in opairs(t) do
  1462.                             if console[player][id].a == "left" then
  1463.                                 phasor_sendconsoletext(player, console[player][id].msg)
  1464.                             elseif console[player][id].a == "right" then
  1465.                                 phasor_sendconsoletext(player, consolerightalign(console[player][id].msg))
  1466.                             end
  1467.                         end
  1468.                     end
  1469.                 end
  1470.             else
  1471.                 console[player] = nil
  1472.             end
  1473.         end
  1474.     end
  1475.    
  1476.     cur_ticks = getticks()
  1477.  
  1478.     return true
  1479. end
  1480.  
  1481. function attributeprint(player, type, key)
  1482.  
  1483.     local hash = gethash(player)
  1484.    
  1485.     local message = getinfo(hash, "messages", type, key)
  1486.     if message then
  1487.         local percent = getinfo(hash, "probability", type, key) / table.sum(players[hash].probability[type])
  1488.         if percent < jackpot_percentage and percent > 0 then
  1489.             message = "JACKPOT: " .. message .. " [" .. math.round(percent * 100, 2) .. "%]"
  1490.         end
  1491.        
  1492.         sendconsoletext(player, message, 10, "right", isalive)
  1493.     end
  1494. end
  1495.  
  1496. -- Console text length limit = 78
  1497. function consolerightalign(text)
  1498.  
  1499.     local len = string.len(text)
  1500.     for i = len + 1, 78 do
  1501.         text = " " .. text
  1502.     end
  1503.    
  1504.     return text
  1505. end
  1506.  
  1507. function isalive(player)
  1508.  
  1509.     local m_player = getplayer(player)
  1510.     if m_player then
  1511.         local objId = readdword(m_player, 0x34)
  1512.         local m_object = getobject(objId)
  1513.         if m_object then
  1514.             return true
  1515.         end
  1516.     end
  1517. end
  1518.  
  1519. function infiniteammo(player)
  1520.  
  1521.     registertimer(1000, "InfiniteAmmo", player)
  1522. end
  1523.  
  1524. function InfiniteAmmo(id, count, player)
  1525.  
  1526.     local m_player = getplayer(player)
  1527.     if m_player then
  1528.         local objId = readdword(m_player, 0x34)
  1529.         local m_object = getobject(objId)
  1530.         if m_object then
  1531.             for i = 0,3 do
  1532.                 local weapId = readdword(m_object, 0x2F8 + (i * 4))
  1533.                 local m_weapon = getobject(weapId)
  1534.                 if m_weapon then
  1535.                     writeword(m_weapon, 0x2B6, 9999)
  1536.                     writeword(m_weapon, 0x2B8, 9999)
  1537.                     updateammo(weapId)
  1538.                 end
  1539.             end
  1540.            
  1541.             return true
  1542.         end
  1543.     end
  1544.    
  1545.     return false
  1546. end
  1547.  
  1548. function convertbase(input, base)
  1549.  
  1550.     if not base or base == 10 then return tostring(input) end
  1551.  
  1552.     local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  1553.     local answer = {}
  1554.  
  1555.     repeat
  1556.         local digit = (input % base) + 1
  1557.         input = math.floor(input / base)
  1558.         table.insert(answer, 1, string.sub(digits, digit, digit))
  1559.     until input == 0
  1560.  
  1561.     return table.concat(answer, "")
  1562. end
  1563.  
  1564. function math.round(input, precision)
  1565.  
  1566.     return math.floor(input * (10 ^ precision) + 0.5) / (10 ^ precision)
  1567. end
  1568.  
  1569. function table.len(t)
  1570.  
  1571.     local count = 0
  1572.    
  1573.     for k,v in pairs(t) do
  1574.         count = count + 1
  1575.     end
  1576.    
  1577.     return count
  1578. end
  1579.  
  1580. function table.sum(t)
  1581.  
  1582.     local sum = 0
  1583.     for k,v in pairs(t) do
  1584.         if type(v) == "number" then
  1585.             sum = sum + v
  1586.         end
  1587.     end
  1588.    
  1589.     return sum
  1590. end
  1591.  
  1592. function randomnumber(min, max)
  1593.  
  1594.     local diff = max - min
  1595.     local rand = math.random()
  1596.     local weighted = rand * diff
  1597.     return weighted + min
  1598. end
  1599.  
  1600. function opairs(t)
  1601.    
  1602.     local keys = {}
  1603.     for k,v in pairs(t) do
  1604.         table.insert(keys, k)
  1605.     end    
  1606.     table.sort(keys,
  1607.     function(a,b)
  1608.         if type(a) == "number" and type(b) == "number" then
  1609.             return a < b
  1610.         end
  1611.         an = string.lower(tostring(a))
  1612.         bn = string.lower(tostring(b))
  1613.         if an ~= bn then
  1614.             return an < bn
  1615.         else
  1616.             return tostring(a) < tostring(b)
  1617.         end
  1618.     end)
  1619.     local count = 1
  1620.     return function()
  1621.         if table.unpack(keys) then
  1622.             local key = keys[count]
  1623.             local value = t[key]
  1624.             count = count + 1
  1625.             return key,value
  1626.         end
  1627.     end
  1628. end
  1629.  
  1630. function attpairs(t)
  1631.  
  1632.     local count = 0
  1633.     local temp = {"primary", "secondary", "tertiary", "quartenary", "ammo", "grenades", "special"}
  1634.     return function()
  1635.         count = count + 1
  1636.         return temp[count]
  1637.     end
  1638. end
  1639.  
  1640. -- Special Attributes Functions --
  1641.  
  1642. phasor_setspeed = setspeed
  1643. phasor_applycamo = applycamo
  1644.  
  1645. function applycamo(player, duration)
  1646.  
  1647.     duration = tonumber(duration or 0) or 0
  1648.    
  1649.     if not gametype_phantom then
  1650.         local m_player = getplayer(player)
  1651.         if m_player then
  1652.             local objId = readdword(m_player, 0x34)
  1653.             local m_object = getobject(objId)
  1654.             if m_object then
  1655.                 phasor_applycamo(player, duration)
  1656.                 return true
  1657.             end
  1658.         end
  1659.     end
  1660.    
  1661.     return false
  1662. end
  1663.  
  1664. function setspeed(player, speed)
  1665.  
  1666.     speed = tonumber(speed or 1) or 1
  1667.    
  1668.     if gametype_speed then
  1669.         local m_player = getplayer(player)
  1670.         if m_player then
  1671.             local objId = readdword(m_player, 0x34)
  1672.             local m_object = getobject(objId)
  1673.             if m_object then
  1674.                 phasor_setspeed(player, speed)
  1675.                 return true
  1676.             end
  1677.         end
  1678.     end
  1679.    
  1680.     return false
  1681. end
  1682.  
  1683. function applyos(player)
  1684.  
  1685.     if gametype_shields then
  1686.         local m_player = getplayer(player)
  1687.         if m_player then
  1688.             local objId = readdword(m_player, 0x34)
  1689.             local m_object = getobject(objId)
  1690.             if m_object then
  1691.                 local x, y, z = getobjectcoords(objId)
  1692.                 local mapId = gettagid("eqip", "powerups\\over shield")
  1693.                 local eqipId = createobject(mapId, 0, 0, false, x, y, z)
  1694.                 if eqipId then
  1695.                     return true
  1696.                 end
  1697.             end
  1698.         end
  1699.     end
  1700.    
  1701.     return false
  1702. end
  1703.  
  1704. function oscamo(player, duration)
  1705.    
  1706.     if gametype_shields and not gametype_phantom then
  1707.         local bool = applyos(player)
  1708.         if bool then
  1709.             applycamo(player, duration)
  1710.             return true
  1711.         end
  1712.     end
  1713.    
  1714.     return false
  1715. end
  1716.  
  1717. function camospeed(player, duration, speed)
  1718.  
  1719.     if not gametype_phantom then
  1720.         local bool = setspeed(player, speed)
  1721.         if bool then
  1722.             applycamo(player, duration)
  1723.             return true
  1724.         end
  1725.     end
  1726.    
  1727.     return false
  1728. end
  1729.  
  1730. function speedos(player, speed)
  1731.  
  1732.     if gametype_speed and gametype_shields then
  1733.         local bool = setspeed(player, speed)
  1734.         if bool then
  1735.             applyos(player)
  1736.             return true
  1737.         end
  1738.     end
  1739.    
  1740.     return false
  1741. end
  1742.  
  1743. function speedoscamo(player, duration, speed)
  1744.  
  1745.     if gametype_speed and gametype_shields and not gametype_phantom then
  1746.         local bool = setspeed(player, speed)
  1747.         if bool then
  1748.             local bool2 = oscamo(player, duration)
  1749.             if bool2 then
  1750.                 return true
  1751.             end
  1752.         end
  1753.     end
  1754.    
  1755.     return false
  1756. end
  1757.  
  1758. function damagemultiply(player, multiplier)
  1759.  
  1760.     if getplayer(player) then
  1761.         local hash = gethash(player)
  1762.         if hash then
  1763.             damage_multiplier[hash] = tonumber(multiplier)
  1764.             return true
  1765.         end
  1766.     end
  1767.    
  1768.     return false
  1769. end
  1770.  
  1771. function healthmultiply(player, multiplier)
  1772.  
  1773.     if getplayer(player) then
  1774.         local hash = gethash(player)
  1775.         if hash then
  1776.             health_multiplier[hash] = tonumber(multiplier)
  1777.             return true
  1778.         end
  1779.     end
  1780.    
  1781.     return false
  1782. end
Advertisement
Add Comment
Please, Sign In to add comment