Advertisement
Guest User

Untitled

a guest
Jan 8th, 2012
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 48.75 KB | None | 0 0
  1. /****************************************************** TODO: Organize skills? More skillz?  ************************************************************/
  2. //                          Exp stealing? More points for hurt higher level? License for attack skills? Jump, Run, Immunity, box Defense skills
  3.  
  4. include("exp_settings.lua")
  5. include("exp_powerups.lua")
  6. AddCSLuaFile("autorun/client/exp_hud.lua")
  7.  
  8. // Let's make the files so we can store the exp
  9. sql.Query("CREATE TABLE IF NOT EXISTS exp_pdata('steam' TEXT NOT NULL, 'exp' INTEGER NOT NULL, 'curlevel' INTEGER NOT NULL, 'nextlevel' INTEGER NOT NULL, 'levelnum' INTEGER NOT NULL, PRIMARY KEY('steam'));")
  10. if not file.Exists("exp_store.txt") and EXP_USETXT == 1 then file.Write("exp_store.txt","") end
  11.  
  12. resource.AddFile("sound/"..EXP_SOUNDPATH) // So everyone gets to hear the fun sound
  13.  
  14. // Just a quick function to print things into everyone's chat
  15. local function PrintAll(msg) for _,v in ipairs(player.GetAll()) do v:ChatPrint(msg) end end
  16.  
  17. local meta = FindMetaTable("Player")
  18.  
  19. CreateConVar("exp_toggle","1",{FCVAR_SERVER_CAN_EXECUTE})
  20.  
  21. // Some writing/reading functions for text/SQL
  22. local function WriteTextData(ply)
  23.     local lines = string.Explode("\n",file.Read("exp_store.txt"))
  24.     local towrite = ""
  25.     for k,v in ipairs(lines) do
  26.         local values = string.Explode(" ",v)
  27.         if values[1] != ply:SteamID() then towrite = towrite..v
  28.         else end
  29.     end
  30.     file.Write("exp_store.txt",
  31.     file.Read("exp_store.txt")..ply:SteamID().." "..ply:GetNWInt("Exp").." "..ply:GetNWInt("CurLevel").." "..ply:GetNWInt("NextLevel").." "..ply:GetNWInt("LevelNum").."\n")
  32. end
  33.  
  34. local function LoadTextData(ply)
  35.     local lines = string.Explode("\n",file.Read("exp_store.txt"))
  36.     for _,v in ipairs(lines) do
  37.         local values = string.Explode(" ",v)
  38.         if values[1] == ply:SteamID() then
  39.             ply:SetNWInt("Exp",values[2])
  40.             ply:SetNWInt("CurLevel",values[3])
  41.             ply:SetNWInt("NextLevel",values[4])
  42.             ply:SetNWInt("LevelNum",values[5])
  43.         end
  44.     end
  45. end
  46.  
  47. local function SaveSQLData(ply)
  48.     local exp = ply:GetNWInt("Exp")
  49.     local cur = ply:GetNWInt("CurLevel")
  50.     local new = ply:GetNWInt("NextLevel")
  51.     local lvl = ply:GetNWInt("LevelNum")
  52.     sql.Begin()
  53.     sql.Query("UPDATE exp_pdata SET exp = "..exp.." WHERE steam = "..sql.SQLStr(ply:SteamID())..";")
  54.     sql.Query("UPDATE exp_pdata SET curlevel = "..cur.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
  55.     sql.Query("UPDATE exp_pdata SET nextlevel = "..new.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
  56.     sql.Query("UPDATE exp_pdata SET levelnum = "..lvl.." WHERE STEAM = "..sql.SQLStr(ply:SteamID())..";")
  57.     sql.Commit()
  58. end
  59.  
  60. local function LoadSQLData(ply)
  61.     sql.Begin()
  62.     ply:SetNWInt("Exp",tonumber(sql.QueryValue("SELECT exp FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  63.     ply:SetNWInt("CurLevel",tonumber(sql.QueryValue("SELECT curlevel FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  64.     ply:SetNWInt("NextLevel",tonumber(sql.QueryValue("SELECT nextlevel FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  65.     ply:SetNWInt("LevelNum",tonumber(sql.QueryValue("SELECT levelnum FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  66.     sql.Commit()
  67. end
  68.  
  69.  
  70.  
  71. /****************************************************** GAMEMODE HOOKS AND STUFF ****************************************************************/
  72.  
  73. // Give experience function
  74. function GiveEXP(ply,amt)
  75.     if EXP_STOPATMAX == 1 and ply:GetNWInt("CurLevel") == levelups[table.Count(levelups)] then return end
  76.     if math.random(1,50-ply:GetNWInt("LevelNum")*4) == 5 then ply:SetNWInt("Exp",ply:GetNWInt("Exp")+amt*EXP_CRIT)
  77.         //ply:ChatPrint("Critical hit!")
  78.     else ply:SetNWInt("Exp",ply:GetNWInt("Exp")+amt) end
  79.     local exp = ply:GetNWInt("Exp")
  80.     if (table.HasValue(levelups,exp) or exp >= ply:GetNWInt("NextLevel")) and amt > 0 then
  81.         local leveln = 1
  82.         for k,v in ipairs(levelups) do if v == ply:GetNWInt("NextLevel") then leveln = k end end
  83.         ply:SetNWInt("NextLevel",levelups[leveln+1])
  84.         ply:SetNWInt("CurLevel",levelups[leveln])
  85.         ply:SetNWInt("LevelNum",leveln)
  86.         hook.Call("LevelGained",nil,ply,leveln)
  87.     end
  88. end
  89.  
  90.  
  91.  
  92. local function GetSkillName(str)
  93.     local ret = ""
  94.     for k,v in ipairs(string.Explode("_",str)) do
  95.         if k != table.Count(string.Explode("_",str)) then ret = ret ..string.upper(string.Left(v,1))..string.Right(v,string.len(v)-1).. " "
  96.         else ret = ret ..string.upper(string.Left(v,1))..string.Right(v,string.len(v)-1) end
  97.     end
  98.     return ret
  99. end
  100.  
  101. // Play some fancy sounds and tell them their prize
  102. hook.Add("LevelGained","LevelTest",function(ply,leveln)
  103.     if leveln == table.Count(levelups) then PrintAll(ply:Name().." has reached the maximum level!")
  104.     else PrintAll(ply:GetName().." has now reached level "..Leveln.."!") end
  105.     ply:ChatPrint("You have new skills available!")
  106.     for _,v in ipairs(skills) do if v.Level == leveln then ply:ChatPrint("  - "..GetSkillName(v.Name)) end end
  107.     ply:SendLua("surface.PlaySound(\""..EXP_SOUNDPATH.."\")")
  108. end)
  109.  
  110.  
  111. // Give experience/level up on hit an npc or player
  112. function AddEXPOnHit( ply, hitgroup, dmginfo )
  113.     local attacker = dmginfo:GetAttacker()
  114.     if attacker:IsPlayer() then
  115.         GiveEXP(attacker,EXP_INC)
  116.     end
  117. end
  118.  
  119. function AddEXPOnDeath(vic,wep,killer)
  120.     if killer:IsPlayer() then GiveEXP(killer,EXP_INC*EXP_DEATHMUL-EXP_INC) end
  121. end
  122.        
  123. // Check if we want to use NPCs or Players as the object of exp
  124. if EXP_USENPC == 1 then
  125.     hook.Add("ScaleNPCDamage","NPCExp",AddEXPOnHit)
  126.     hook.Add("OnNPCKilled","NPCDeath",AddEXPOnDeath)
  127. elseif EXP_USENPC == 2 then
  128.     hook.Add("ScaleNPCDamage","NPCExp",AddEXPOnHit)
  129.     hook.Add("OnNPCKilled","NPCDeath",AddEXPOnDeath)
  130.     hook.Add("ScalePlayerDamage","PlayerExp",AddEXPOnHit)
  131.     hook.Add("PlayerDeath","PlayerDeath",AddEXPOnDeath)
  132. else
  133.     hook.Add("ScalePlayerDamage","PlayerExp",AddEXPOnHit)
  134.     hook.Add("PlayerDeath","PlayerDeath",AddEXPOnDeath)
  135. end
  136.  
  137.  
  138. // Give experience when they throw things with the gravgun
  139. hook.Add("GravGunPunt","GravEXP",function(ply,ent) GiveEXP(ply,EXP_INC) end)
  140.  
  141.  
  142. // Take away experience on death
  143. hook.Add("PlayerDeath","DownEXP",function(ply,wep,killer)
  144.     local exp = ply:GetNWInt("Exp")
  145.     local cur = ply:GetNWInt("CurLevel")
  146.     local loss = math.Round(exp-exp*EXP_DEATHLOSS)
  147.     if loss < 0 then ply:SetNWInt("Exp",0)
  148.     elseif loss < cur then
  149.         if killer:GetNWInt("CurLevel") < cur and killer:IsPlayer() then
  150.             ply:SetNWInt("Exp",loss)
  151.             ply:SetNWInt("NewLevel",cur)
  152.             ply:SetNWInt("LevelNum",ply:GetNWInt("LevelNum")-1)
  153.             ply:SetNWInt("CurLevel",levelups[ply:GetNWInt("LevelNum")])
  154.             killer:ChatPrint("You made "..ply:Name().." lose a level!")
  155.         else ply:SetNWInt("Exp",cur) end
  156.     else ply:SetNWInt("Exp",loss) end
  157. end)
  158.  
  159.  
  160. // Save the values in the SQL on disconnect
  161. hook.Add("PlayerDisconnected","UpdateEXP",function(ply) if EXP_USETXT == 1 then WriteTextData(ply) else WriteSQLData(ply) end end)
  162.  
  163.  
  164. // Load or create the player's values on initial connection
  165. hook.Add("PlayerInitialSpawn","RegisterEXP",function(ply)
  166.     if not tonumber(sql.QueryValue("SELECT exp FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")) then
  167.         sql.Query("INSERT INTO exp_pdata VALUES("..sql.SQLStr(ply:SteamID())..",".. 0 ..",".. 0 ..","..Levelups[2]..",".. 1 ..");")
  168.         ply:SetNWInt("Exp",0)
  169.         ply:SetNWInt("CurLevel",0)
  170.         ply:SetNWInt("NextLevel",levelups[2])
  171.         ply:SetNWInt("LevelNum",1)
  172.     else LoadSQLData(ply) end
  173. end)
  174.  
  175. function meta:UseSkill(skilln)
  176.     if GetConVarNumber("exp_toggle") == 0 then self:ChatPrint("Skills are not enabled at this time.") return end
  177.     local skused
  178.     if type(skilln) == "string" and not tonumber(skilln) then
  179.         for _,v in pairs(skills) do
  180.             if v.Name == string.lower(skilln) or string.lower(GetSkillName(v.Name)) == string.lower(skilln) then skused = v end
  181.         end
  182.         if not skused then self:ChatPrint("That is not a valid skill name.") return end
  183.     elseif type(tonumber(skilln)) == "number" then
  184.         skilln = tonumber(skilln)
  185.         if table.Count(skills) < skilln then self:ChatPrint("There are only "..table.Count(skills).." possible skills at the moment.") return end
  186.         skused = skills[skilln]
  187.         PrintTable(skused)
  188.     end
  189.    
  190.     self._SkillWait = self._SkillWait or {}
  191.     local wait = self._SkillWait[skused.ID] or 0
  192.     if not self._Allowed[tostring(skused.ID)] then self:ChatPrint("You have not bought this skill yet!") return end
  193.     if self:GetNWBool("exp_silence") then self:ChatPrint("You have been silenced!") return end
  194.     //if self:GetNWInt("LevelNum") < skused.Level then self:ChatPrint("You must be level "..skused.Level.." to use this skill!") return end
  195.     if wait > CurTime() then self:ChatPrint("You must wait ".. math.ceil(wait - CurTime()).. " seconds before using "..GetSkillName(skused.Name).." again.") return end
  196.    
  197.     skused.Func(self)
  198.     self._SkillWait[skused.ID] = CurTime() + skused.Wait
  199.     timer.Simple(skused.Wait,function() self:ChatPrint("Your "..GetSkillName(skused.Name).." skill is now recharged.") end)
  200. end
  201.  
  202. function meta:SetTarget(ent)
  203.     if GetConVarNumber("exp_toggle") == 0 then self:ChatPrint("Targets are not enabled at this time.") return end
  204.     if not ent:IsPlayer() and ent:GetClass() != "prop_physics" and not ent:IsNPC() then self:ChatPrint("Not a valid target!") return end
  205.     self._Target = ent
  206.     umsg.Start("exp_target",self)
  207.         umsg.Entity(ent)
  208.     umsg.End()
  209.     //if ent:IsPlayer() then self:ChatPrint("Targeting "..ent:Name()..".")
  210.     //else self:ChatPrint("Targeting " .. ent:GetClass()..".") end
  211. end
  212.  
  213. function meta:GetTarget() return self._Target or false end
  214.  
  215. function meta:RemoveTarget()
  216.     self._Target = false
  217.     umsg.Start("exp_target",self)
  218.         umsg.Entity(GetWorldEntity())
  219.     umsg.End()
  220. end
  221.  
  222. hook.Add("Think","RemoveTargets",function()
  223.     for _,v in ipairs(player.GetAll()) do
  224.         local tar = v:GetTarget()
  225.         if !tar then v:RemoveTarget() return end
  226.         if tar:IsPlayer() then
  227.             if not tar:Alive() then
  228.                 v:RemoveTarget()
  229.             end
  230.         elseif tar:IsNPC() then
  231.             if tar:Health() <= 0 then
  232.                 v:RemoveTarget()
  233.             end
  234.         elseif !tar:IsValid() or !ValidEntity(tar) then
  235.             v:RemoveTarget()
  236.         end
  237.     end
  238. end)
  239.    
  240.  
  241. /********************************************************** CONCOMMANDS **********************************************************************/
  242.  
  243. local chatcommands = {}
  244.  
  245.  
  246. // Allow admins to change the exp level of players
  247. concommand.Add("exp_setlevel",function(ply,cmd,args)
  248.     if ply:IsAdmin() then
  249.         leveln = tonumber(args[2])
  250.        
  251.         local tar
  252.         for _,v in ipairs(player.GetAll()) do if string.match(v:Name(),args[1]) then tar = v end end
  253.        
  254.         if not tar then ply:ChatPrint("Please use a valid target! (format <player name> <level>") return end
  255.         if leveln < 1 or leveln > (table.Count(levelups)+1) then ply:ChatPrint("Please select a valid level between 1 - ".. table.Count(levelups) .. ".") return end
  256.        
  257.         tar:SetNWInt("Exp",levelups[leveln])
  258.         tar:SetNWInt("CurLevel",levelups[leveln])
  259.         if leveln == table.Count(levelups) then tar:SetNWInt("NextLevel",levelups[leveln])
  260.         else tar:SetNWInt("NextLevel",levelups[leveln+1]) end
  261.         ply:SetNWInt("LevelNum",leveln)
  262.        
  263.         ply:ChatPrint("You set "..tar:Name().."'s level to "..Leveln..".")
  264.     else ply:ChatPrint("You must be an admin to use this command.") end
  265. end)
  266. table.insert(chatcommands,{"setlevel","exp_setlevel <player name> <level number>","Set a player's experience level",true})
  267.  
  268. // Set a target
  269. concommand.Add("exp_target",function(pl,cmd,args)
  270.     pl:SetTarget(pl:GetEyeTrace().Entity)
  271. end)
  272.  
  273. // Remove a target
  274. concommand.Add("exp_removetarget",function(pl)
  275.     pl:RemoveTarget()
  276. end)
  277.  
  278. // Allow admins to change the exp increment per hit via console
  279. concommand.Add("exp_setinc",function(ply,cmd,args)
  280.     if ply:IsAdmin() then
  281.         local inc = tonumber(args[1])
  282.         if inc < 1 then ply:ChatPrint("Please use a positive integer above zero.") return end
  283.         EXP_INC = tonumber(args[1])
  284.     else ply:ChatPrint("You must be an admin to use this command.") end
  285. end)
  286. table.insert(chatcommands,{"setinc","exp_setinc <inc number>","Set how much experience you get per hit",true})
  287.  
  288.  
  289. // Allow anyone to check their current level
  290. concommand.Add("exp_curlevel",function(ply,cmd,args)
  291.     for k,v in ipairs(levelups) do if ply:GetNWInt("CurLevel") == v then ply:ChatPrint("You are on level "..k..".") end end
  292. end)
  293. table.insert(chatcommands,{"curlevel","exp_curlevel","Prints your current level",false})
  294.  
  295.  
  296. // Allow admins to save everyone's data in the SQL
  297. concommand.Add("exp_savedata",function(ply,cmd,args)
  298.     if ply:IsAdmin() then
  299.         sql.Begin()
  300.         for _,v in pairs(player.GetAll()) do
  301.             if EXP_USETXT == 1 then WriteTextData(v)
  302.             else SaveSQLData(v) end
  303.         end
  304.         sql.Commit()
  305.         PrintAll("Your Exp data was saved!")
  306.     else ply:ChatPrint("You must be an admin to use this command.") end
  307. end)
  308. table.insert(chatcommands,{"savedata","exp_savedata","Saves all players' current exp to the database",true})
  309.  
  310. concommand.Add("exp_skill",function(pl,cmd,args)
  311.     PrintTable(skills[tonumber(args[1])])
  312. end)
  313.  
  314. // Allow admins to load data from the previous save
  315. concommand.Add("exp_loaddata",function(ply,cmd,args)
  316.     if ply:IsAdmin() then
  317.         if ply:GetNWBool("HasLoaded") == false then
  318.             ply:ChatPrint("WARNING: All players will lose progress made after last save! This loads data from the previous save!")
  319.             ply:ChatPrint("Use this command again if you are sure you want to do this!")
  320.             ply:SetNWBool("HasLoaded",true)
  321.         else
  322.             for _,v in ipairs(player.GetAll()) do LoadSQLData(v) end
  323.             PrintAll(ply:Name().." has loaded all players' previous save!")
  324.             ply:SetNWBool("HasLoaded",false)
  325.         end
  326.         timer.Simple(10,function() ply:SetNWBool("HasLoaded",false) end)
  327.     else ply:ChatPrint("You must be an admin to use this command.") end
  328. end)
  329. table.insert(chatcommands,{"loaddata","exp_loaddata","Loads all players' current exp from the database",true})
  330.  
  331.  
  332. // Just in case the SQL fails, let's check why
  333. concommand.Add("exp_debug",function(ply,cmd,args) if sql.LastError() then ply:ChatPrint(sql.LastError()) else ply:ChatPrint("No SQL errors!") end end)
  334. table.insert(chatcommands,{"debug","exp_debug","Print the last known error in the database",false})
  335.  
  336.  
  337. // Get the data from the last save
  338. concommand.Add("exp_printsql",function(ply,cmd,args)
  339.     ply:ChatPrint("Data from previous save...")
  340.     ply:ChatPrint("Experience: "..tonumber(sql.QueryValue("SELECT exp FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  341.     ply:ChatPrint("Base Level Experience: "..tonumber(sql.QueryValue("SELECT curlevel FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  342.     ply:ChatPrint("Next Level: "..tonumber(sql.QueryValue("SELECT nextlevel FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  343.     ply:ChatPrint("Level Number: "..tonumber(sql.QueryValue("SELECT levelnum FROM exp_pdata WHERE steam =  "..sql.SQLStr(ply:SteamID())..";")))
  344. end)
  345. table.insert(chatcommands,{"printsql","exp_printsql","Print the exp data from your last save",false})
  346.  
  347.  
  348. // Get the data from right now
  349. concommand.Add("exp_printnw",function(ply,cmd,args)
  350.     ply:ChatPrint("Data at this moment...")
  351.     ply:ChatPrint("Experience: "..ply:GetNWInt("Exp"))
  352.     ply:ChatPrint("Base Level Experience: "..ply:GetNWInt("CurLevel"))
  353.     ply:ChatPrint("Next Level: "..ply:GetNWInt("NextLevel"))
  354.     ply:ChatPrint("Level Number: "..ply:GetNWInt("LevelNum"))
  355. end)
  356. table.insert(chatcommands,{"printnw","exp_printnw","Print all of your current exp data",false})
  357.  
  358.    
  359. // Get all the possible levels
  360. concommand.Add("exp_printlevels",function(ply,cmd,args) for k,v in ipairs(levelups) do ply:ChatPrint("Level "..k.." - "..v.." experience") end end)
  361. table.insert(chatcommands,{"printlevels","exp_printlevels","Print all possible levels",false})
  362.  
  363. table.insert(chatcommands,{"menu","exp_menu","Bring up skill menu",false})
  364.  
  365.  
  366. // Use the various skills available
  367. concommand.Add("exp_useskill",function(ply,cmd,args)
  368.     local str = ""
  369.     for k,v in ipairs(args) do if k != table.Count(args) then str = str .. v.. " " else str = str..v end end
  370.     ply:UseSkill(str)
  371. end)
  372. table.insert(chatcommands,{"useskill","exp_useskill <skill number>","Use a skill",false})
  373.  
  374.  
  375. // Let's get a nice view of all the commands available to us
  376. concommand.Add("exp_help",function(ply,cmd,args)
  377.     local function Print(msg) ply:PrintMessage(HUD_PRINTCONSOLE,msg) end
  378.     Print("+++++++++++++++++ ExpPlus Support +++++++++++++++++++++")
  379.     Print("\n-- General Help --")
  380.     Print("  * Chat: To use a chatcommand, precede the command with two asterisks (**). \n    The command is always the concommand name without the \"exp_\" prefix. (i.e. \"**printlevels\")")
  381.     Print("  * Gaining EXP: To get EXP, depending on what your local admin decided, you shoot NPCs or other players.\n    Admins, to change this, edit the \"exp_data.lua\" file.")
  382.     Print("  * Powerups: At every level you get stronger and faster. To know specifically how you're getting better,\n    ask your local admin.")
  383.     Print("  * Skills: Like powerups, new abilities, or skills, become available to you at every level.\n    Look at the skill list for more info.")
  384.     Print("\n-- List of Commands --")
  385.     for _,v in ipairs(chatcommands) do
  386.         if v[4] == false then Print(v[2].." - "..v[3])
  387.         else Print(v[2].." - "..v[3].." - ADMIN ONLY") end
  388.     end
  389.     Print("\n-- List of Skills --")
  390.     table.sort(skills,function(a,b) if a.Level == b.Level then return a.Name < b.Name else return a.Level < b.Level end end)
  391.     for k,v in ipairs(skills) do
  392.         if k < 10 then Print("Level "..v.Level..": "..GetSkillName(v.Name).." - "..v.Desc.." (default "..k..")")
  393.         else Print("Level "..v.Level..": "..GetSkillName(v.Name).." - "..v.Desc) end
  394.     end
  395. end)
  396. table.insert(chatcommands,{"help","exp_help","Show this helpful menu",false})
  397.  
  398. /******************************************************** CHAT COMMANDS **********************************************************************/
  399.  
  400.  
  401. // So the chatcommands will work
  402. hook.Add("PlayerSay","EXP_Chat",function(ply,str,toall)
  403.     if string.Left(str,2) != "**" then return str end
  404.     local cmd = string.Explode(" ",string.sub(str,3,string.len(str)))
  405.     local cmdstr = ""
  406.     for k,v in ipairs(cmd) do if k != 1 then cmdstr = cmdstr .. " ".. v end end
  407.     for _,v in ipairs(chatcommands) do
  408.         if cmd[1] == v[1] then ply:ConCommand("exp_"..v[1].." "..cmdstr) end
  409.     end
  410.     return ""
  411. end)
  412.  
  413.  
  414. /********** LOLWUT **********
  415. for _,v in ipairs(player.GetAll()) do
  416.     hook.Add("Think",v:SteamID().."icon",function()
  417.         local icon = ents.Create("targeticon")
  418.         icon:SetPos(v:GetPos())
  419.     end)
  420. end */
  421.  
  422.  
  423. ---------------------------------------------------------------------------------------
  424. ------------------------------------------------------------------------------------
  425.  
  426. /***************************************** DATA SETTINGS (exp_data, mostly stuff about gaining exp and levels) ***********************************************/
  427.  
  428. EXP_INC = 1                 // The experience gained on every shot
  429. EXP_USENPC = 1              // 0 = Players as exp objects, 1 = NPCs as exp objects, 2 = both
  430. EXP_DEATHLOSS = 0.03            // The percentage of exp you lose on death (3 percent in this case, set to 0 to disable)
  431. EXP_STOPATMAX = 1           // Whether or not player's stop gaining exp at the maximum level (1 for they do)
  432. EXP_USETXT = 0              // Whether or not to use SQL or .txt files to store the data (1 using .txt) -- NOT WORKING, LEAVE AT 0
  433. EXP_SOUNDPATH = "achievements/achievement_earned.mp3"   // The sound it plays on level up
  434. EXP_CRIT = 5                // The multiplier for the random critical attacks
  435. EXP_DEATHMUL = 3            // The multiplier for exp gained for a killing hit
  436.  
  437. // The markers at which you gain a level (always leave the 0, don't go negative or put something before 0)
  438. levelups = {
  439. 0,          // Level 1
  440. 50,         // Level 2
  441. 100,            // Level 3... and so on
  442. 250,
  443. 500,
  444. 1000,
  445. 2500,
  446. 5000,
  447. 10000,
  448. 20000,
  449. 50000}
  450.  
  451. /************************************** POWERUP SETTINGS (exp_powerups,stuff about getting powerups) ***************************************************/
  452.  
  453. // IMPORTANT NOTE FOR DEVELOPERS: If you want to create a new skill, look in the exp_powerups.lua file, and find where I make the "CreateSkill" function for further instruction.
  454.  
  455. UP_RUN = 1              // Increase run speed, set to 0 to disable
  456. UP_WALK = 1             // Increase walk speed
  457. UP_JUMP = 1             // Increase jump power
  458. UP_SWEPS = 1                // Give different weapons
  459. UP_ARMOR = 1                // Increase armor
  460. UP_HP = 1                   // Increase health
  461. UP_DMG = 1              // Increase damage
  462. OVERRIDE_SWEPS = 1          // Whether or not the SWEPs should be the only ones given
  463.  
  464. regweapons = {              // The base weapons given no matter what
  465. "weapon_physgun",
  466. "weapon_physcannon",
  467. "gmod_tool",
  468. "gmod_camera",
  469. }
  470.  
  471. upweapons = {
  472. {"weapon_crowbar"},         // Level 2
  473. {"weapon_pistol","Pistol"},     // Level 3
  474. {"weapon_crossbow","XBowBolt"}, // Level 4
  475. {"weapon_shotgun","Buckshot"},  // Level 5
  476. {"weapon_smg1","smg1"},     // Level 6
  477. {"weapon_frag","grenade"},      // Level 7
  478. {"weapon_ar2","ar2"},           // Level 8
  479. {"weapon_357","357"},           // Level 9
  480. {"weapon_rpg","rpg_round"},     // Level 10
  481. }
  482.  
  483. /******************************************* HUD SETTINGS (exp_hud, stuff about what's on the screen)*****************************************************/
  484.  
  485. barpos = 1          // Where the bar appears on the screen; 1 = over the health bar, 0 = on top of the screen
  486. fadeon = 1          // Whether the bar should fade or not
  487. fadetime = 3        // How long it takes the bar to start fading after appearing
  488.  
  489. -------------------------------------------------------------------------------
  490. ------------------------------------------------------------------------------
  491.  
  492.  
  493. include("exp_settings.lua")
  494.  
  495. local function PrintAll(msg) for _,v in ipairs(player.GetAll()) do v:ChatPrint(msg) end end
  496.  
  497. local meta = FindMetaTable("Player")
  498. function meta:GetTarget() return self._Target or false end
  499.  
  500. hook.Add("PlayerSpawn","EXP_PowerupsSpawn",function(ply)
  501.    
  502.     // Get the player's current level
  503.     local lvl = ply:GetNWInt("LevelNum")-1
  504.    
  505.     // Enhance their jump speed/health/armor
  506.     if UP_JUMP == 1 then ply:SetJumpPower(200+lvl*15) end
  507.     if UP_ARMOR == 1 then ply:SetArmor(0+lvl*10) end
  508.     if UP_HP == 1 then ply:SetHealth(100+lvl*10) end
  509. end)
  510.  
  511. hook.Add("SetupMove","Exp_PowerupsMove",function(ply,move)
  512.     // Get the player's current level
  513.     local lvl = ply:GetNWInt("LevelNum")-1
  514.     if UP_RUN == 1 then ply:SetRunSpeed(500+lvl*100) end
  515.     if UP_WALK == 1 then ply:SetWalkSpeed(250+lvl*30) end
  516. end)
  517.  
  518. hook.Add("PlayerLoadout","EXP_PowerupsLoad",function(ply)
  519.    
  520.     // Get the player's current level
  521.     local lvl = ply:GetNWInt("LevelNum")-1
  522.  
  523.     // Give them weapons based on their level
  524.     if UP_SWEPS == 1 then
  525.         ply:StripWeapons()
  526.         for _,v in ipairs(regweapons) do ply:Give(v) end
  527.         for k,v in ipairs(upweapons) do
  528.             if lvl >= k then
  529.                 ply:Give(v[1])
  530.                 if v[2] then ply:GiveAmmo(15*lvl,v[2],false) end
  531.             end
  532.         end
  533.         if lvl >= 7 then
  534.             ply:GiveAmmo(lvl-6,"SMG1_Grenade",false)
  535.             ply:GiveAmmo(lvl-6,"AR2AltFire",false)
  536.         end
  537.     end
  538.    
  539.     ply:Give("weapon_pointer")
  540.    
  541.     if OVERRIDE_SWEPS == 1 then return true end
  542. end)
  543.  
  544. // Increase damage based on a player's level
  545. local function IncreaseDamage(ply,hitgroup,dmginfo)
  546.     local attacker = dmginfo:GetAttacker()
  547.     if UP_DMG == 1 then dmginfo:ScaleDamage(1+0.1*(attacker:GetNWInt("LevelNum")-1)) end
  548. end
  549.  
  550. // Increase it on NPCs, players, or both
  551. if EXP_USENPC == 0 then hook.Add("ScalePlayerDamage","testply",IncreaseDamage)
  552. elseif EXP_USENPC == 1 then hook.Add("ScaleNPCDamage","testnpc",IncreaseDamage)
  553. else hook.Add("ScalePlayerDamage","testply",IncreaseDamage)
  554.     hook.Add("ScaleNPCDamage","testnpc",IncreaseDamage)
  555. end
  556.  
  557. // SKILLZZZZZZZZZZZZZZ
  558. skills = {}
  559. local function CreateSkill(name,wait,func,level,tex,desc,id,cost)
  560.     local new = {}
  561.     new.Name = name
  562.     new.Wait = wait
  563.     new.Func = func
  564.     new.Level = level
  565.     if tex == "" then tex = "vgui/swepicon" end
  566.     new.Tex = tex
  567.     new.Desc = desc
  568.     new.ID = id
  569.     if cost then new.PermCost = cost else new.PermCost = 100 end
  570.     skills[id] = new
  571. end
  572.  
  573. // HOW TO MAKE A SKILL: <Name of Skill>, <How long to wait after usage>, <function of what happens on usage (ply input)>, <what level you have to be to use>, <texture to use for a vgui icon>, <description>
  574.  
  575. // Skill: Use the Force
  576. // Description: Be a jedi and throw things!
  577.     CreateSkill("use_the_force",5,function(ply)
  578.         local ent = ply:GetTarget() or ply:GetEyeTrace().Entity
  579.         if ent then if ent:GetClass() == "prop_physics" or ent:GetClass() == "prop_vehicle_airboat" or ent:GetClass() == "prop_vehicle_jeep" then
  580.             local obj = ent:GetPhysicsObject()
  581.             obj:ApplyForceCenter(ply:GetForward()*10000*obj:GetMass()+Vector(0,0,10000*obj:GetMass())-obj:GetPos()-obj:GetVelocity()/50)
  582.         end end
  583.     end,3,"","Be a jedi \nand throw things!",1)
  584.    
  585. // Skill: Health Pack
  586. // Descipription: Your own medic! Heal you or your target.
  587.     CreateSkill("health_pack",10,function(ply)
  588.         local heal = math.Clamp((ply:GetNWInt("LevelNum")-4)*10,0,100)
  589.         local tr = ply:GetEyeTrace()
  590.         if tr.Entity:IsPlayer() then tr.Entity:SetHealth(tr.Entity:Health()+heal)
  591.             tr.Entity:ChatPrint(ply:Name().." healed you for "..heal.." hp!")
  592.             ply:ChatPrint("You healed "..tr.Entity:Name().." for "..heal.." hp!")
  593.         else ply:SetHealth(ply:Health()+heal)
  594.             ply:ChatPrint("You healed yourself for "..heal.." hp!")
  595.         end
  596.     end,5,"","Your own medic!\n Heal you or target.",2)
  597.    
  598. // Skill: Hax
  599. // Description: HAAAAAAX!
  600.     // Created by Kwigg, updated by NECROSSIN, adapted by Entoros
  601.     resource.AddFile( "sound/weapons/hacks01.wav" )
  602.      local ShootSound = Sound ("weapons/hacks01.wav");
  603.      local ShootSound2 = Sound ("weapons/iceaxe/iceaxe_swing1.wav");
  604.  
  605.      local function UseHax(ply)
  606.         ply:EmitSound (ShootSound2,300,100)
  607.         ply:SetAnimation(PLAYER_ATTACK1)
  608.         Monitor = ents.Create("monitor")
  609.         Monitor:SetPos(ply:EyePos() + (ply:GetAimVector() * 16))
  610.         Monitor:SetAngles( ply:EyeAngles() )
  611.         Monitor:SetPhysicsAttacker(ply)
  612.         Monitor:SetOwner(ply)
  613.         Monitor:Spawn()
  614.            
  615.         local phys = Monitor:GetPhysicsObject();
  616.         local tr = ply:GetEyeTrace();
  617.         local PlayerPos = ply:GetShootPos()
  618.          
  619.         local shot_length = tr.HitPos:Length();
  620.         phys:ApplyForceCenter (ply:GetAimVector():GetNormalized() *  math.pow(shot_length, 3));
  621.         phys:ApplyForceOffset(VectorRand()*math.Rand(10000,30000),PlayerPos + VectorRand()*math.Rand(0.5,1.5))
  622.     end
  623.      
  624.     CreateSkill("hax",20,function(ply)
  625.         ply:DrawViewModel(false)
  626.         ply:EmitSound(ShootSound,100,100)
  627.         timer.Create("HAX",1.01,1,function() UseHax(ply) end)
  628.         /* timer.Simple(1.02, game.ConsoleCommand, "host_timescale 0.03\n")
  629.         timer.Simple(1.03, game.ConsoleCommand, "pp_motionblur 1\n")
  630.         timer.Simple(1.3, game.ConsoleCommand, "pp_motionblur 0\n")
  631.         timer.Simple(1.3, game.ConsoleCommand, "host_timescale 1\n")*/
  632.         timer.Simple(1.02,function()  ply:ConCommand("host_timescale 0.03\n") end)
  633.         timer.Simple(1.03,function()  ply:ConCommand("pp_motionblur 1\n") end)
  634.         timer.Simple(1.3,function()  ply:ConCommand("pp_motionblur 0\n") end)
  635.         timer.Simple(1.3,function()  ply:ConCommand("host_timescale 1\n")
  636.             ply:DrawViewModel(true) end)
  637.     end,2,"","HAAAAAAX!",3)
  638.  
  639. // Utility stuff for the NPC skills
  640.     local function MakeFriendly(ply,npc)
  641.         npc:AddEntityRelationship(ply,3,99)
  642.         for _,v in ipairs(ents.FindByClass("npc_*")) do if v:Disposition(ply) == 3 then
  643.             npc:AddEntityRelationship(v,3,99)
  644.             v:AddEntityRelationship(npc,3,99)
  645.             else npc:AddEntityRelationship(v,1,99) end
  646.         end
  647.     end
  648.  
  649.     local function MakeNPC(class,ply,num,wep,pos)
  650.         local tr = ply:GetEyeTrace()
  651.         for i=0,num-1 do
  652.             local npc = ents.Create(class)
  653.             if not pos or pos == nil and class != "item_ammo_crate" then npc:SetPos(tr.HitPos+Vector(i*70,i*10,20)) else npc:SetPos(pos) end
  654.             npc:SetHealth(npc:Health()+(ply:GetNWInt("LevelNum")-1)*20)
  655.             npc:SetAngles((ply:GetForward():Normalize()*-1):Angle())
  656.        
  657.             if wep and wep != nil then npc:Give(wep) end
  658.            
  659.             if string.sub(class,1,3) == "npc" then MakeFriendly(ply,npc) end
  660.            
  661.             local function Delete(time) timer.Simple(time,function() if npc:IsValid() and npc then npc:Remove() end end) end
  662.             local function DoAssault(time)
  663.                 timer.Simple(time,function()
  664.                     if npc:IsValid() and npc:GetEnemy() then
  665.                         npc:GetEnemy():SetName(ply:SteamID().."assault")
  666.                         npc:Fire("Assault",ply:SteamID().."assault",0)
  667.                     end
  668.                 end)
  669.             end
  670.            
  671.             local lvl = ply:GetNWInt("LevelNum")
  672.             if class == "npc_strider" then
  673.                 npc:SetKeyValue("squadname",ply:SteamID())
  674.                 if math.random(1,2) == 1 then npc:Fire("crouch","",4) end
  675.                 timer.Simple(8,function()
  676.                     if npc:GetEnemy() then
  677.                         npc:GetEnemy():SetName(ply:SteamID().."cannontarg")
  678.                         npc:Fire("setcannontarget",ply:SteamID().."cannontarg",0)
  679.                     end
  680.                 end)
  681.                 //npc:Fire("break","",20)
  682.                 npc:SetKeyValue("spawnflags",65792)
  683.                 npc:Fire("StartPatrol","",0)
  684.                 //npc:Fire("SetTargetPath",tostring(ply:GetEyeTrace().HitPos),5)
  685.                 npc:Fire("FlickRagdoll","",13)
  686.                 DoAssault(3)
  687.                 Delete(20)
  688.             elseif class == "npc_combine_s" or class == "npc_metropolice" then
  689.                 npc:SetKeyValue("spawnflags",512)
  690.                
  691.                 if class == "npc_combine_s" then
  692.                     npc:SetKeyValue("NumGrenades",999999)
  693.                     if lvl == 8 then npc:SetKeyValue("model","models/combine_super_soldier.mdl")
  694.                     else npc:SetKeyValue("model","models/combine_soldier.mdl") end
  695.                 end
  696.                
  697.                 npc:SetKeyValue("squadname",ply:SteamID())
  698.                 npc:SetKeyValue("waitingtorappel",1)
  699.                 npc:SetPos(npc:GetPos()+Vector(0,0,1000))
  700.                 npc:Fire("BeginRappel","",0)
  701.                 npc:SetKeyValue("tacticalvariant",2)
  702.                
  703.                 npc:Fire("StartPatrolling","",0)
  704.                 npc:CapabilitiesAdd(CAP_OPEN_DOORS | CAP_TURN_HEAD | CAP_DUCK)
  705.                
  706.                 DoAssault(3)
  707.                 Delete(30)
  708.             elseif class == "npc_zombie" or class == "npc_fastzombie" or class == "npc_zombine" or class == "npc_poisonzombie" then
  709.                 npc:SetKeyValue("squadname",ply:SteamID())
  710.                 npc:SetKeyValue("spawnflags",512)
  711.                 npc:CapabilitiesAdd(CAP_OPEN_DOORS | CAP_TURN_HEAD | CAP_DUCK)
  712.                 DoAssault(3)
  713.                 Delete(30)
  714.             elseif class == "npc_manhack" then
  715.                 npc:SetKeyValue("squadname",ply:SteamID())
  716.                 Delete(20)
  717.             elseif class == "item_ammo_crate" then
  718.                 local mul1 = 148
  719.                 local mul2 = 180
  720.                 npc:SetPos(tr.HitPos+Vector(math.sin(i*mul1)*mul2,math.cos(i*mul1)*mul2,npc:BoundingRadius()*2+16)+-1*ply:GetForward()*100)
  721.                 //npc:SetAngles(((ply:GetPos()+npc:GetPos()):Normalize()*-1):Angle())
  722.                 npc:SetAngles((ply:GetForward():Normalize()*-1):Angle())
  723.                 npc:SetKeyValue("AmmoType",i)
  724.                 Delete(20)
  725.             elseif class == "npc_citizen" then
  726.                 npc:SetKeyValue("squadname",ply:SteamID())
  727.                 npc:Fire("StartPatrolling","",0)
  728.                 npc:CapabilitiesAdd(CAP_OPEN_DOORS | CAP_TURN_HEAD | CAP_DUCK)
  729.                 DoAssault(3)
  730.                
  731.                 local rmodel = ""
  732.                 local rnum = 1
  733.                 if math.random(1,2) == 1 then rmodel = "male" else rmodel = "female" end
  734.                 if rmodel == "male" then rnum = math.random(1,9) else rnum = math.random(1,7) end
  735.                 if rnum == 5 and rmodel == "female" then rnum = math.random(1,4) end
  736.                
  737.                 local function ModCitz(t,m,prof)
  738.                     npc:SetKeyValue("cititzentype",t)
  739.                     npc:SetKeyValue("model","models/humans/"..m.."/"..rmodel.."_0"..rnum..".mdl")
  740.                     if prof == 1 then npc:SetKeyValue("spawnflags","131080")
  741.                     elseif prof == 2 then npc:SetKeyValue("spawnflags","524288")
  742.                         npc:SetKeyValue("ammosupply","smg1")
  743.                         npc:SetKeyValue("ammoamount","90")
  744.                     end
  745.                 end
  746.                 if lvl == 9 then ModCitz(3,"group03m",1)
  747.                     npc:SetPos(npc:GetPos()+Vector(70,10,00))
  748.                 elseif lvl == 8 then if i == 0 then ModCitz(3,"group03m",1) else ModCitz(3,"group03",2) end
  749.                 elseif lvl == 7 then if i == 0 then ModCitz(3,"group03m",1) else ModCitz(3,"group03",0) end
  750.                 elseif lvl == 6 then if i == 0 then ModCitz(3,"group03",2) else ModCitz(2,"group01",0) end
  751.                 elseif lvl == 5 then if i == 0 then ModCitz(3,"group03",0) else ModCitz(2,"group01",0) end
  752.                 else ModCitz(2,"group01",0) end
  753.                
  754.                 Delete(30)
  755.             elseif class == "npc_vortigaunt" then
  756.                 npc:SetKeyValue("squadname",ply:SteamID())
  757.                 npc:CapabilitiesAdd(CAP_OPEN_DOORS | CAP_TURN_HEAD | CAP_DUCK)
  758.                 DoAssault(3)
  759.                 npc:SetKeyValue("HealthRegenerationEnabled",1)
  760.                 npc:SetKeyValue("ArmorRegenerationEnabled",1)
  761.                 Delete(30)
  762.             elseif class == "npc_antlionguard" then
  763.                 npc:SetKeyValue("allowbark","true")
  764.                 if lvl >= 11 then npc:SetKeyValue("cavernbreed","true") end
  765.                 Delete(20)
  766.             elseif class == "npc_antlion" then
  767.                 if lvl == 9 or lvl == 8 then npc:SetKeyValue("spawnflags","327680") end
  768.                 npc:Fire("EnableJump","",0)
  769.                 Delete(30)
  770.             elseif class == "prop_vehicle_apc" then
  771.                 npc:SetKeyValue("vehiclescript","scripts/vehicles/apc_npc.txt")
  772.                 npc:SetKeyValue("VehicleLocked","true")
  773.                 npc:SetKeyValue("model","models/combine_apc.mdl")
  774.                 npc:SetKeyValue("actionScale","1")
  775.                 npc:SetName( "Combine_apc" .. ply:SteamID() )
  776.                
  777.                 local driver = ents.Create("npc_apcdriver")
  778.                 if not pos or pos == nil then driver:SetPos(tr.HitPos+Vector(i*70,i*10,20)) else driver:SetPos(pos) end
  779.                 driver:SetHealth(driver:Health()+(ply:GetNWInt("LevelNum")-1)*20)
  780.                 //MakeFriendly(driver)
  781.                 driver:SetKeyValue( "vehicle", "Combine_apc" .. ply:SteamID() )
  782.                 driver:SetName( "Combine_apc" .. ply:SteamID() .. "_driver" )
  783.                 timer.Simple(30,function() if driver and driver:IsValid() then driver:Remove() end end)
  784.                 driver:Activate()
  785.                 driver:Spawn()
  786.                
  787.                 Delete(30)
  788.             else Delete(15) end
  789.            
  790.             if class == "npc_combinegunship" or class == "npc_helicopter" or class == "npc_combinedropship" or class == "npc_spotlight" then
  791.                 npc:SetPos(tr.HitPos+Vector(i*70,i*10,500))
  792.             end
  793.            
  794.             /* local allents = ents.FindByClass("player")
  795.             table.Add(allents,ents.FindByClass("npc_*"))
  796.             table.sort(allents,
  797.             function(a, b)
  798.                 if a == nil || !a:IsValid() then return false end
  799.                 if b == nil || !b:IsValid() then return true end
  800.                 return (a:GetPos() - npc:GetPos()):Length() < (b:GetPos() - npc:GetPos()):Length()
  801.             end
  802.             )
  803.             for _,v in pairs(allents) do if npc:Disposition(v) == 1 or npc:Disposition(v) == 2 then npc:SetEnemy(v) break end end */
  804.             npc:Activate()
  805.             npc:Spawn()
  806.         end
  807.     end
  808.  
  809. // Skill: Combine Help
  810. // Description: Who's the overwatch now?
  811.     CreateSkill("combine_help",2,function(ply)
  812.         local leveln = ply:GetNWInt("LevelNum")
  813.         if leveln >= 10 then MakeNPC("npc_strider",ply,1)
  814.         elseif leveln == 9 then MakeNPC("npc_hunter",ply,2)
  815.         elseif leveln == 8 then MakeNPC("npc_combine_s",ply,2,"ai_weapon_ar2")
  816.         elseif leveln == 7 then MakeNPC("npc_hunter",ply,1)
  817.         elseif leveln == 6 then MakeNPC("npc_combine_s",ply,2,"ai_weapon_smg1")
  818.         elseif leveln == 5 then MakeNPC("npc_combine_s",ply,1,"ai_weapon_shotgun")
  819.         elseif leveln == 4 then MakeNPC("npc_turret_floor",ply,1)
  820.         elseif leveln == 3 then MakeNPC("npc_metropolice",ply,1,"ai_weapon_pistol")
  821.         else MakeNPC("npc_manhack",ply,2)
  822.         end
  823.     end,2,"","Who's the \noverwatch now?",4)
  824.  
  825. // Skill: Zombie Help
  826. // Description: Use zombie minions for your bidding.
  827.     CreateSkill("zombie_help",2,function(ply)
  828.         local leveln = ply:GetNWInt("LevelNum")
  829.         if leveln >= 10 then MakeNPC("npc_fastzombie",ply,3)
  830.         elseif leveln == 9 then MakeNPC("npc_poisonzombie",ply,2)
  831.         elseif leveln == 8 then MakeNPC("npc_zombine",ply,1)
  832.         elseif leveln == 7 then MakeNPC("npc_fastzombie",ply,1)
  833.         elseif leveln == 6 then MakeNPC("npc_zombie",ply,2)
  834.         elseif leveln == 5 then MakeNPC("npc_zombie",ply,1)
  835.         else MakeNPC("npc_zombie",ply,1) end
  836.     end,5,"","Use zombie minions\nfor your bidding.",5)
  837.  
  838. // npc_launcher? npc_particlestorm? npc_spotlight?
  839. // Skill: Rebel Help
  840. // Description: Anarchy! Anarchy!
  841.     CreateSkill("rebel_help",2,function(ply)
  842.         local leveln = ply:GetNWInt("LevelNum")
  843.         if leveln >= 10 then MakeNPC("npc_vortigaunt",ply,2)
  844.         elseif leveln == 9 then MakeNPC("npc_vortigaunt",ply,1)
  845.             MakeNPC("npc_citizen",ply,1,"ai_weapon_ar2")
  846.         elseif leveln == 8 then MakeNPC("npc_citizen",ply,2,"ai_weapon_ar2")
  847.         elseif leveln == 7 then MakeNPC("npc_citizen",ply,2,"ai_weapon_smg1")
  848.         elseif leveln == 6 then MakeNPC("npc_citizen",ply,2,"ai_weapon_smg1")
  849.         elseif leveln == 5 then MakeNPC("npc_citizen",ply,2,"ai_weapon_shotgun")
  850.         elseif leveln == 4 then MakeNPC("npc_citizen",ply,2,"ai_weapon_pistol")
  851.         elseif leveln == 3 then MakeNPC("npc_citizen",ply,1,"ai_weapon_pistol") end
  852.     end,2,"","Anarchy! Anarchy!",6)
  853.  
  854. // Skill: Antlion Help
  855. // Description: Don't step on me!
  856. CreateSkill("antlion_help",2,function(ply)
  857.     local leveln = ply:GetNWInt("LevelNum")
  858.     if leveln >= 10 then MakeNPC("npc_antlionguard",ply,1)
  859.     elseif leveln == 9 then MakeNPC("npc_antlion",ply,2)
  860.     elseif leveln == 8 then MakeNPC("npc_antlion",ply,1)
  861.     elseif leveln == 7 then MakeNPC("npc_antlion",ply,2)
  862.     else MakeNPC("npc_antlion") end
  863. end,5,"","Don't step on\n me!",7)
  864.  
  865. // Skill: Ice Beam
  866. // Description: Ignore your problems by freezing them.
  867.     function SetFreeze(bool,ply)
  868.         umsg.Start( "exp_freeze",ply)
  869.             umsg.Bool(bool)
  870.         umsg.End()
  871.     end
  872.  
  873.     CreateSkill("ice_beam",20,function(ply)
  874.         local ent = ply:GetTarget() or ply:GetEyeTrace().Entity
  875.         if ent:IsPlayer() then
  876.             ent:Freeze(true)
  877.             ent:SetColor(0,0,255,255)
  878.             SetFreeze(true,ply)
  879.             timer.Simple(10,function()
  880.                 ent:Freeze(false)
  881.                 SetFreeze(false,ply)
  882.                 ent:SetColor(255,255,255,255)
  883.             end)
  884.             ent:ChatPrint("You were frozen by "..ply:Name().."!")
  885.         elseif ent:IsNPC() then
  886.             ent:SetMoveType(MOVETYPE_NONE)
  887.             timer.Simple(5+ply:GetNWInt("LevelNum")-7,function() if ent and ent:IsValid() then ent:SetMoveType(MOVETYPE_STEP) end end)
  888.         elseif ent:GetClass() == "prop_physics" then
  889.             ent:SetMoveType(MOVETYPE_NONE)
  890.             ent:SetVelocity(ent:GetPos())
  891.             timer.Simple(5+ply:GetNWInt("LevelNum")-7,function() if ent and ent:IsValid() then ent:SetMoveType(MOVETYPE_VPHYSICS) end end)
  892.         else ply:ChatPrint("Your atttack missed!")
  893.         end
  894.     end,7,"","Ignore your problems\nby freezing them.",8)
  895.    
  896. // Skill: Resupply
  897. // Description: Stock up on ammo.
  898.     CreateSkill("resupply",90,function(ply) MakeNPC("item_ammo_crate",ply,9) end,5,"","Stock up on ammo.",9)
  899.  
  900. // Skill: Fire Blast
  901. // Description: Burn baby burn, Gmod inferno!
  902.     CreateSkill("fire_blast",20,function(ply)
  903.         local tr = ply:GetEyeTrace()
  904.         local ent = ply:GetTarget() or ply:GetEyeTrace().Entity
  905.         if ply:GetTarget() then tr.HitPos = ply:GetTarget():GetPos() end
  906.         local effectdata = EffectData()
  907.         effectdata:SetOrigin(tr.HitPos)
  908.         effectdata:SetStart( ply:GetShootPos() )
  909.         effectdata:SetAttachment( 1 )
  910.         effectdata:SetEntity( ent )
  911.         effectdata:SetScale(2500)
  912.         util.Effect( "GaussTracer", effectdata )
  913.         if ent:IsPlayer() or ent:IsNPC() then ent:Fire("Ignite","",0) end
  914.     end,3,"","Burn baby burn,\nGmod inferno!",10)
  915.  
  916. // Skill: Break
  917. // Description: Lolwut
  918.     CreateSkill("break",20,function(ply)
  919.         local tr = ply:GetEyeTrace()
  920.         if ply:GetTarget() then
  921.             tr.HitPos = ply:GetTarget():GetPos()
  922.             tr.Entity = ply:GetTarget()
  923.         end
  924.         local ed = EffectData()
  925.         ed:SetOrigin(tr.HitPos)
  926.         ed:SetStart(ply:GetShootPos())
  927.         ed:SetAttachment(1)
  928.         ed:SetEntity( ply:GetTarget() or tr.Entity )
  929.         util.Effect("AirboatGunHeavyTracer",ed)
  930.         if tr.Entity:IsNPC() then tr.Entity:Fire("break","",0) end
  931.     end, 8,"","Lolwut",11)
  932.  
  933. // Skill: Mortar
  934. // Description: Fancy FX!
  935.     CreateSkill("mortar",30,function(ply)
  936.         local targetTrace = util.QuickTrace( ply:GetShootPos(),ply:GetAimVector() * 8192, ply )
  937.         local mortar = ents.Create( "func_tankmortar" )
  938.             mortar:SetPos(util.TraceLine( { start = targetTrace.HitPos, endpos = targetTrace.HitPos + Vector( 0, 0, 16383), filter = ply, mask = MASK_NPCWORLDSTATIC } ).HitPos)
  939.             mortar:SetAngles( Angle( 90, 0, 0 ) )
  940.             mortar:SetKeyValue( "iMagnitude", 500) // Damage.
  941.             mortar:SetKeyValue( "firedelay", "1" ) // Time before hitting.
  942.             mortar:SetKeyValue( "warningtime", "1" ) // Time to play incoming sound before hitting.
  943.             mortar:SetKeyValue( "incomingsound", "Weapon_Mortar.Incomming" ) // Incoming sound.
  944.             mortar:SetName(tostring(mortar))
  945.         mortar:Spawn()
  946.        
  947.         // Create the target.
  948.         local target = ents.Create( "info_target" )
  949.             target:SetPos( targetTrace.HitPos )
  950.             target:SetName( tostring( target ) )
  951.         target:Spawn()
  952.         mortar:DeleteOnRemove( target )
  953.        
  954.         // Fire.
  955.         mortar:Fire( "SetTargetEntity", target:GetName(), 0 )
  956.         mortar:Fire( "Activate", "", 0 )
  957.         mortar:Fire( "FireAtWill", "", 0 )
  958.         mortar:Fire( "Deactivate", "", 2 )
  959.         mortar:Fire( "kill", "", 2 )
  960.        
  961.         local beam = ents.Create("env_beam")
  962.        
  963.         local target2 = ents.Create("info_target")
  964.         target2:SetPos(mortar:GetPos()+mortar:GetUp()*100)
  965.         target2:SetName(tostring(target2))
  966.         beam:DeleteOnRemove(target2)
  967.        
  968.         beam:SetAngles(Angle(90,0,0))
  969.         beam:SetName(tostring(beam))
  970.         beam:SetPos(target2:GetPos())
  971.         beam:SetKeyValue("LightningStart",beam:GetName())
  972.         beam:SetKeyValue("LightningEnd",mortar:GetName())
  973.         beam:SetKeyValue("target",mortar:GetName())
  974.         beam:SetKeyValue("renderfx",0)
  975.         beam:SetKeyValue("rendercolor","255 0 0")
  976.         beam:SetKeyValue("life",10)
  977.         beam:SetKeyValue("BoltWidth",5)
  978.         beam:SetKeyValue("TextureScroll",35)
  979.         beam:SetKeyValue("StrikeTime",3)
  980.         beam:SetKeyValue("texture","sprites/laserbeam.spr")
  981.         beam:SetKeyValue("NoiseAmplitude",0)
  982.         beam:SetKeyValue("renderamt",100)
  983.        
  984.         beam:Fire("kill","",5)
  985.         beam:Fire("Alpha",255,0)
  986.         beam:Fire("TurnOn","",0)
  987.        
  988.         for k,v in pairs(beam:GetKeyValues()) do
  989.             //PrintAll(k.." - "..v)
  990.         end
  991.     end,8,"","Fancy FX!",12)
  992.  
  993. // Skill: Mine Layer
  994. // Description: Suprise your pursuers; lay mines!
  995.     CreateSkill("mine_layer",2,function(ply)
  996.         local vec = ply:GetForward()*-200+ply:GetPos()
  997.         MakeNPC("combine_mine",ply,1,nil,vec)
  998.     end,5,"","Surprise your \npursuers; lay mines!",13)
  999.  
  1000. // Skill: Pigeon
  1001. // Description: Up, up, and away!
  1002.     if file.Exists("pigeon.lua") then include('pigeon.lua')
  1003.         AddCSLuaFile('pigeon.lua') end
  1004.     CreateSkill("pigeon",2,function(ply)
  1005.         PIGEON.HooksEnable()
  1006.         PIGEON.Enable(ply)
  1007.         ply:DrawViewModel(false) // this doesn't seem to work in deploy...
  1008.         timer.Create("viewmodel" .. ply:UniqueID(), 0.01, 1, ply.DrawViewModel, ply, false) // so i use a timer
  1009.         ply:DrawWorldModel(false)
  1010.         timer.Simple(30,function()
  1011.             PIGEON.Disable(ply)
  1012.             ply:DrawViewModel(true)
  1013.             ply:DrawWorldModel(true)
  1014.         end)
  1015.     end,3,"","Up, up, and away!",14)
  1016.    
  1017. // Skill: Destroy
  1018. // Description: Make your target just disappear!
  1019.     CreateSkill("destroy",25,function(ply)
  1020.         local tr = ply:GetTarget() or ply:GetEyeTrace().Entity
  1021.         if tr:IsPlayer() then tr:Kill()
  1022.         elseif tr:IsNPC() or tr:GetClass() == "prop_physics" then tr:Remove()
  1023.         end
  1024.     end,10,"","Make your target\njust disappear!",15)
  1025.  
  1026. // Skill: Explode
  1027. // Description: Everything's more fun on fire!
  1028.     CreateSkill("explode",10, function(ply)
  1029.         local trace = ply:GetEyeTrace()
  1030.         local effectdata = EffectData()
  1031.         effectdata:SetOrigin( trace.HitPos )
  1032.         effectdata:SetNormal( trace.HitNormal )
  1033.         effectdata:SetEntity( trace.Entity )
  1034.         effectdata:SetAttachment( trace.PhysicsBone )
  1035.         util.Effect( "super_explosion", effectdata )
  1036.        
  1037.         local explosion = ents.Create( "env_explosion" )
  1038.         explosion:SetPos(trace.HitPos)
  1039.         explosion:SetKeyValue( "iMagnitude" , "200" )
  1040.         explosion:SetPhysicsAttacker(ply)
  1041.         explosion:SetOwner(ply)
  1042.         explosion:Spawn()
  1043.         explosion:Fire("explode","",0)
  1044.         explosion:Fire("kill","",0 )
  1045.     end,9,"","Everything's more\n fun on fire!",16)
  1046.  
  1047. // Skill: Lightning
  1048. // Description: Zap!
  1049.     local function DispEffect( name, data )
  1050.         local data2, k, v
  1051.  
  1052.         data2 = EffectData( )
  1053.             for k, v in pairs( data ) do
  1054.                 data2[ "Set" .. k ]( data2, v )
  1055.             end
  1056.         util.Effect( name, data2 )
  1057.     end
  1058.  
  1059.     // Thanks to weathermod for this...
  1060.     local Thunder = {
  1061.             "ambient/atmosphere/thunder4.wav",
  1062.             "ambient/weather/thunder3.wav"   ,
  1063.             "ambient/atmosphere/thunder1.wav",
  1064.             "ambient/weather/thunder4.wav"   ,
  1065.             "ambient/weather/thunder2.wav"   ,
  1066.             "ambient/weather/thunder6.wav"   ,
  1067.             "ambient/weather/thunder5.wav"   ,
  1068.             "ambient/atmosphere/thunder2.wav",
  1069.             "ambient/atmosphere/thunder3.wav",
  1070.             "ambient/weather/thunder1.wav"    
  1071.     }
  1072.     local Explosion = {
  1073.             "ambient/explosions/explode_6.wav",
  1074.             "ambient/explosions/explode_3.wav",
  1075.             "ambient/explosions/explode_1.wav",
  1076.             "ambient/explosions/explode_7.wav",
  1077.             "ambient/explosions/explode_5.wav",
  1078.             "ambient/explosions/explode_4.wav",
  1079.             "ambient/explosions/explode_2.wav",
  1080.             "ambient/explosions/explode_9.wav",
  1081.             "ambient/explosions/explode_8.wav"
  1082.     }
  1083.  
  1084.     CreateSkill("lightning",20,function(ply)
  1085.         /* local tr = ply:GetEyeTrace()
  1086.         local ed = EffectData()
  1087.         ed:SetOrigin(tr.HitPos)
  1088.         ed:SetStart(tr.HitPos+Vector(0,0,100))
  1089.         ed:SetNormal(tr.HitNormal)
  1090.         ed:SetEntity(tr.Entity)
  1091.         ed:SetAttachment(tr.PhysicsBone)
  1092.         util.Effect("TeslaZap",ed) */
  1093.         local tr = ply:GetEyeTrace()
  1094.         if ply:GetTarget() then tr.HitPos = ply:GetTarget():GetPos() end
  1095.         local ent = ply:GetTarget() or  tr.Entity
  1096.         local res, start, ende
  1097.         start = tr.HitPos + Vector(0,0,1000)
  1098.         ende = tr.HitPos
  1099.         res = util.TraceLine{ start = start, endpos = ende, filter = ent, mask = MASK_SHOT }
  1100.        
  1101.         local effectdata = EffectData()
  1102.         effectdata:SetOrigin(tr.HitPos + Vector(0,0,10000) )
  1103.         effectdata:SetStart( tr.HitPos )
  1104.         effectdata:SetAttachment( 1 )
  1105.         effectdata:SetEntity( ent )
  1106.         util.Effect( "ToolTracer", effectdata )
  1107.        
  1108.         DispEffect( "ThumperDust", { Origin = res.HitPos, Start = res.HitPos, Normal = res.HitNormal, Scale = 500, Radius = 45, Angle = res.HitNormal:Angle( ) } )
  1109.         ply:SendLua("surface.PlaySound(\""..Thunder[math.random(1,table.Count(Thunder))].."\")")
  1110.         ply:SendLua("surface.PlaySound(\"".. Explosion[math.random(1,table.Count(Explosion))].."\")")
  1111.        
  1112.         if ent:IsPlayer() then timer.Simple(0.1,function() ent:Kill() end)
  1113.         elseif ent:IsNPC() or ent:GetClass() == "prop_physics" then timer.Simple(0.1,function() ent:Remove() end) end
  1114.     end,4,"","Zap!",17)
  1115.  
  1116. // Skill: Conversion
  1117. // Description: Annoy everyone: make NPCs yours!
  1118.     CreateSkill("conversion",30,function(ply)
  1119.         local ent = ply:GetEyeTrace().Entity
  1120.         if ent:IsNPC() then MakeFriendly(ply,ent) end
  1121.     end,6,"","Annoy everyone:\nmake NPCs yours!",18)
  1122.  
  1123. // Skill: Blind
  1124. // Description: Carol never wore her safety goggles. Now she doesn't need them.
  1125.     function SetBlind(bool,ply)
  1126.         local rp = RecipientFilter()
  1127.         rp:AddPlayer(ply)
  1128.         umsg.Start( "exp_blind", rp)
  1129.             umsg.Bool( bool )
  1130.         umsg.End()
  1131.     end
  1132.  
  1133.     CreateSkill("blind",2,function(ply)
  1134.         local ent = ply:GetTarget() or ply:GetEyeTrace().Entity
  1135.         if ent:IsPlayer() then
  1136.             SetBlind(true,ent)
  1137.             timer.Simple(10,function() SetBlind(false,ent) end)
  1138.         else ply:ChatPrint("Your attack missed!") end
  1139.     end,3,"","Carol never wore her safety goggles.\n Now she doesn't need them.",19)
  1140.  
  1141. // Skill: Suicide
  1142. // Description: Kill yourself. Duh.
  1143.     CreateSkill("suicide",5,function(ply) ply:Kill() end,1,"","Kill yourself. Duh.",20)
  1144.  
  1145. // Skill: Force Choke
  1146. // Description: Kill people, Darth Vader style.
  1147.     CreateSkill("force_choke",3,function(pl)
  1148.         local ent = pl:GetTarget() or pl:GetEyeTrace().Entity
  1149.         ent = pl
  1150.         if ent:IsPlayer() then
  1151.             umsg.Start("exp_choke",ent)
  1152.                 umsg.Bool(true)
  1153.             umsg.End()
  1154.             timer.Simple(0.1,function()
  1155.                     umsg.Start("exp_choke",ent)
  1156.                         umsg.Bool(false)
  1157.                     umsg.End()
  1158.                 end)
  1159.             pl:SetMoveType(MOVETYPE_NOCLIP)
  1160.             pl:Lock()
  1161.             /*pl:CreateRagdoll()
  1162.             pl:DrawShadow( false )  
  1163.             pl:SetMaterial( "models/effects/vol_light001" )  
  1164.             pl:SetRenderMode( RENDERMODE_TRANSALPHA )  
  1165.             pl:Fire( "alpha", visibility, 0 )  
  1166.             pl:GetTable().invis = { vis=visibility, wep=pl:GetActiveWeapon() }  
  1167.             pl:DrawWorldModel(false)        */ 
  1168.             timer.Create(pl:SteamID().."forcechoke",0.01,50,function()
  1169.                 pl:SetPos(pl:GetPos() + Vector(0,0,1))
  1170.                 //local rag = pl:GetRagdollEntity()
  1171.                 //print(rag:GetPhysicsObjectCount())
  1172.             end)
  1173.             timer.Create(pl:SteamID().."forcechoke2",1,5,function()
  1174.                 if pl:Health() <= 10 then
  1175.                     pl:Kill()
  1176.                     timer.Destroy(pl:SteamID().."forcechoke2")
  1177.                 else
  1178.                     pl:SetHealth(pl:Health()-10)
  1179.                     pl:SendLua("surface.PlaySound(\"player/pl_drown1.wav\")")
  1180.                     umsg.Start("exp_choke",ent)
  1181.                         umsg.Bool(true)
  1182.                     umsg.End()
  1183.                     timer.Simple(0.1,function()
  1184.                         umsg.Start("exp_choke",ent)
  1185.                             umsg.Bool(false)
  1186.                         umsg.End()
  1187.                     end)
  1188.                 end
  1189.             end)
  1190.             timer.Simple(5,function()
  1191.                 pl:UnLock()
  1192.                 pl:SetMoveType(MOVETYPE_WALK)
  1193.             /*  pl:DrawShadow( true )  
  1194.                 pl:SetMaterial( "" )  
  1195.                 pl:SetRenderMode( RENDERMODE_NORMAL )  
  1196.                 pl:Fire( "alpha", 255, 0 )  
  1197.                 pl:DrawWorldModel(true)
  1198.                 pl:GetTable().invis = nil  */
  1199.             end)
  1200.         end
  1201.     end,5,"","Kill people,\nDarth Vader style.",21)
  1202.    
  1203. // Skill: Silence
  1204. // Description: SILENCE! I kill you!
  1205.     CreateSkill("silence",45,function(pl)
  1206.         local ent = pl:GetTarget() or pl:GetEyeTrace().Entity
  1207.         if ent:IsPlayer() then
  1208.             ent:SetNWBool("exp_silence",true)
  1209.             timer.Simple(10,function()
  1210.                 ent:SetNWBool("exp_silence",false)
  1211.             end)
  1212.         end
  1213.     end,3,"","SILENCE!\nI kill you!",22)
  1214.    
  1215. // Skill: Invisibility
  1216. // Description: Sneak behind enemy lines.
  1217.     CreateSkill("invisibility",60,function(pl)
  1218.         pl:SetMaterial("models/effects/vol_light001")
  1219.         pl:DrawWorldModel(false)
  1220.         timer.Simple(15,function()
  1221.             pl:SetMaterial("")
  1222.             pl:DrawWorldModel(true)
  1223.         end)
  1224.     end,8,"","Sneak behind\nenemy lines.",23)
  1225.    
  1226. // NOT WORKING Skill: Slow
  1227. // Description: Nothing moves like a snail.
  1228.     CreateSkill("slow",3,function(pl)
  1229.         local ent = pl:GetTarget() or pl:GetEyeTrace().Entity
  1230.         if ent:IsPlayer() then
  1231.             GAMEMODE:SetPlayerSpeed(pl,100,100)
  1232.             timer.Simple(10,function()
  1233.                 pl:SetRunSpeed(500)
  1234.                 pl:SetRunSpeed(250)
  1235.             end)
  1236.         end
  1237.     end,3,"","Nothing moves\nlike a snail.",24)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement