From c938d041633104340f866a5906f6dbaffaf1f459 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 18 Oct 2016 18:22:54 -0400 Subject: Bugfixes in spells and misc linting --- entities/entities/ws_researchtable/init.lua | 4 +-- gamemode/itemsystem/items/magicwood.lua | 51 +++++++++++++-------------- gamemode/itemsystem/items/runeblank.lua | 4 +-- gamemode/itemsystem/items/runeblink.lua | 26 +++++++------- gamemode/itemsystem/items/runeenergy.lua | 10 +++--- gamemode/itemsystem/items/runeexplosive.lua | 32 ++++++++--------- gamemode/itemsystem/items/runefeatherfall.lua | 4 +-- gamemode/itemsystem/items/runefire.lua | 12 +++---- gamemode/itemsystem/items/runemagic.lua | 2 +- gamemode/itemsystem/items/runenature.lua | 6 ++-- gamemode/itemsystem/items/spell_fireball.lua | 51 +++++++++++++++------------ gamemode/itemsystem/items/spell_teleport.lua | 33 +++++++++-------- 12 files changed, 122 insertions(+), 113 deletions(-) diff --git a/entities/entities/ws_researchtable/init.lua b/entities/entities/ws_researchtable/init.lua index 3fc4233..1a3a07b 100644 --- a/entities/entities/ws_researchtable/init.lua +++ b/entities/entities/ws_researchtable/init.lua @@ -1,7 +1,7 @@ AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") -include('shared.lua') +include("shared.lua") --[[An item to give hints to players that are just starting out]] local PossibleRecipies = { @@ -41,7 +41,7 @@ function ENT:Think() end for k,v in pairs(player.GetAll()) do if (v:Alive() and v:GetPos():Distance(self:GetPos()) < 200) then - v:ChatPrint("Perhaps you can make a " .. randomrecipie[0] .. " with " .. randomrecipie[1]) + v:ChatPrint("Perhaps you can make a " .. randomrecipie[1] .. " with " .. randomrecipie[2]) end end diff --git a/gamemode/itemsystem/items/magicwood.lua b/gamemode/itemsystem/items/magicwood.lua index 00c1605..a871c72 100644 --- a/gamemode/itemsystem/items/magicwood.lua +++ b/gamemode/itemsystem/items/magicwood.lua @@ -1,25 +1,24 @@ - -ITEM.Name = "Magic Wood" -ITEM.Class = "weapon" -ITEM.Desc = "Some magically infused wood" -ITEM.Model = "models/props_debris/wood_board02a.mdl" -ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_magicwood.png") +ITEM.Name = "Magic Wood" +ITEM.Class = "weapon" +ITEM.Desc = "Some magically infused wood" +ITEM.Model = "models/props_debris/wood_board02a.mdl" +ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_magicwood.png") ITEM.Structure = { { Bone = "ValveBiped.Bip01_R_Hand", Model = "models/props_debris/wood_board02a.mdl", - Size = Vector(.5,.5,.5), - Pos = Vector(3,-1.5,-12), - Ang = Angle(0,0,0), - }, + Size = Vector(.5, .5, .5), + Pos = Vector(3, -1.5, -12), + Ang = Angle(0, 0, 0) + } } ITEM.Damage = 2 ITEM.Range = 60 ITEM.CD = 1.0 -function ITEM:OnPrimary(pl,tr) +function ITEM:OnPrimary(pl, tr) if (CLIENT) then return end if (tr.Hit) then @@ -28,31 +27,31 @@ function ITEM:OnPrimary(pl,tr) local class = ent:GetClass() if (class == "player" or class:find("npc_") or class == "ws_pigeon" or class == "ws_prop") then - ent:TakeDamage(self.Damage,pl) + ent:TakeDamage(self.Damage, pl) - if (class == "ws_prop") then pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard"..math.random(1,3)..".wav"),100,math.random(90,110)) - else pl:EmitSound(Sound("physics/flesh/flesh_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) end + if (class == "ws_prop") then + pl:EmitSound(Sound("physics/wood/wood_plank_impact_hard" .. math.random(1, 3) .. ".wav"), 100, math.random(90, 110)) + else + pl:EmitSound(Sound("physics/flesh/flesh_impact_hard" .. math.random(1, 6) .. ".wav"), 100, math.random(90, 110)) + end elseif (ent:GetModel():find("tree")) then - pl:EmitSound(Sound("physics/concrete/rock_impact_hard"..math.random(1,6)..".wav"),100,math.random(90,110)) + pl:EmitSound(Sound("physics/concrete/rock_impact_hard" .. math.random(1, 6) .. ".wav"), 100, math.random(90, 110)) else - pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet" .. math.random(1, 4) .. ".wav"), 100, math.random(90, 110)) end else - pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet"..math.random(1,4)..".wav"),100,math.random(90,110)) + pl:EmitSound(Sound("physics/surfaces/sand_impact_bullet" .. math.random(1, 4) .. ".wav"), 100, math.random(90, 110)) end else - pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110)) + pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"), 100, math.random(90, 110)) end end -function ITEM:OnSecondary(pl,tr) +function ITEM:OnSecondary(pl, tr) if (CLIENT) then return end - if (!pl:HasItem(self.Name)) then return end - - local drop = SpawnWSItem(self.Name,pl:GetShootPos()+pl:GetAimVector()*20) + if (not pl:HasItem(self.Name)) then return end + local drop = SpawnWSItem(self.Name, pl:GetShootPos() + pl:GetAimVector() * 20) drop:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * 200) - - pl:RemoveItem(self.Name,1) - - pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(40,60)) + pl:RemoveItem(self.Name, 1) + pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"), 100, math.random(40, 60)) end diff --git a/gamemode/itemsystem/items/runeblank.lua b/gamemode/itemsystem/items/runeblank.lua index 2935b4e..c5da275 100644 --- a/gamemode/itemsystem/items/runeblank.lua +++ b/gamemode/itemsystem/items/runeblank.lua @@ -2,7 +2,7 @@ ITEM.Name = "Blank Rune" ITEM.Class = "resource" ITEM.Desc = "A blank peice of stone" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_rune.png") ITEM.Structure = { @@ -30,5 +30,5 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnEnchanted(enchanttable, nearbyrunes) - enchanttable:AddItem("Magic Rune", 1) + enchanttable:AddItem("Magic Rune", 1) end diff --git a/gamemode/itemsystem/items/runeblink.lua b/gamemode/itemsystem/items/runeblink.lua index 4a48b20..c1c2694 100644 --- a/gamemode/itemsystem/items/runeblink.lua +++ b/gamemode/itemsystem/items/runeblink.lua @@ -2,7 +2,7 @@ ITEM.Name = "Blink Rune" ITEM.Class = "resource" ITEM.Desc = "Jump Forward a little" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runeblink.png") ITEM.Structure = { @@ -30,7 +30,7 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnPrimary(user) - if(user:HasItem(self.Name,1)) then + if user:HasItem(self.Name,1) then self:OnUse(user) else if not user.UnEquipWeaponSlot then return end @@ -40,15 +40,15 @@ function ITEM:OnPrimary(user) end function ITEM:OnUse(user) - if(CLIENT) then return end - local tr = user:GetEyeTrace() - local edist = tr.HitPos:Distance(user:GetPos()+Vector(0,0,72)) - if(edist < 400) then - user:SetPos(tr.HitPos + (user:GetAimVector()*-32)) - else - user:SetPos(user:GetPos() + user:GetAimVector()*300) - end - - local adjustedlen = math.min(250,edist) - user:RemoveItem(self.Name,1) + if CLIENT then return end + local tr = user:GetEyeTrace() + local edist = tr.HitPos:Distance(user:GetPos() + Vector(0,0,72)) + if edist < 400 then + user:SetPos(tr.HitPos + (user:GetAimVector() * -32)) + else + user:SetPos(user:GetPos() + user:GetAimVector() * 300) + end + + --local adjustedlen = math.min(250,edist) + user:RemoveItem(self.Name,1) end diff --git a/gamemode/itemsystem/items/runeenergy.lua b/gamemode/itemsystem/items/runeenergy.lua index a4d9080..9230984 100644 --- a/gamemode/itemsystem/items/runeenergy.lua +++ b/gamemode/itemsystem/items/runeenergy.lua @@ -2,7 +2,7 @@ ITEM.Name = "Energy Rune" ITEM.Class = "resource" ITEM.Desc = "A rune infused with energy!\nYou could probably run really far with one of these" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runeelectric.png") ITEM.Structure = { @@ -30,7 +30,7 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnPrimary(user) - if(user:HasItem("Energy Rune",1)) then + if user:HasItem("Energy Rune",1) then self:OnUse(user) else user:UnEquipWeaponSlot(user:GetSelectedWeapon()) @@ -39,11 +39,11 @@ function ITEM:OnPrimary(user) end function ITEM:OnUse(user) - if(CLIENT) then return end + if CLIENT then return end user:SetFatigue(math.max(0,user:GetFatigue()-20)) - user:RemoveItem(self.Name,1) + user:RemoveItem(self.Name,1) end function ITEM:OnCraft(ply) - ply:AddFatigue(25) + ply:AddFatigue(25) end diff --git a/gamemode/itemsystem/items/runeexplosive.lua b/gamemode/itemsystem/items/runeexplosive.lua index 15479f2..4e7436c 100644 --- a/gamemode/itemsystem/items/runeexplosive.lua +++ b/gamemode/itemsystem/items/runeexplosive.lua @@ -2,7 +2,7 @@ ITEM.Name = "Explosive Rune" ITEM.Class = "resource" ITEM.Desc = "A highly volitile rune! Handle with care." -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runeexplosive.png") ITEM.Structure = { @@ -30,7 +30,7 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnPrimary(user) - if(user:HasItem("Explosive Rune",1)) then + if user:HasItem("Explosive Rune",1) then self:OnUse(user) else if not user.UnEquipWeaponSlot then return end @@ -40,20 +40,20 @@ function ITEM:OnPrimary(user) end function ITEM:OnUse(user) - if( not user:IsOnGround()) then - user:SetVelocity(Vector(0,0,500)) - if(SERVER) then - user:TakeDamage(30) + if not user:IsOnGround() then + user:SetVelocity(Vector(0,0,500)) + if SERVER then + user:TakeDamage(30) end - else - if(SERVER) then - user:TakeDamage(40) + else + if SERVER then + user:TakeDamage(40) end - end - if(CLIENT) then return end - user:RemoveItem(self.Name,1) - local exp = ents.Create("env_explosion") - exp:SetPos(user:GetPos()) - exp:Fire("Explode","",0) - exp:Spawn() + end + if CLIENT then return end + user:RemoveItem(self.Name,1) + local exp = ents.Create("env_explosion") + exp:SetPos(user:GetPos()) + exp:Fire("Explode","",0) + exp:Spawn() end diff --git a/gamemode/itemsystem/items/runefeatherfall.lua b/gamemode/itemsystem/items/runefeatherfall.lua index 2ce71fd..c42b120 100644 --- a/gamemode/itemsystem/items/runefeatherfall.lua +++ b/gamemode/itemsystem/items/runefeatherfall.lua @@ -2,7 +2,7 @@ ITEM.Name = "Feather-fall Rune" ITEM.Class = "resource" ITEM.Desc = "A rune that's lighter than air.\nCancels fall dammage" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runefeatherfall.png") ITEM.Structure = { @@ -30,5 +30,5 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnCraft(ply) - ply:AddFatigue(25) + ply:AddFatigue(25) end diff --git a/gamemode/itemsystem/items/runefire.lua b/gamemode/itemsystem/items/runefire.lua index d91e7a5..b71e7cc 100644 --- a/gamemode/itemsystem/items/runefire.lua +++ b/gamemode/itemsystem/items/runefire.lua @@ -2,7 +2,7 @@ ITEM.Name = "Fire Rune" ITEM.Class = "resource" ITEM.Desc = "A perpetually warm stone" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runefire.png") game.AddParticles("particles/particletest.pcf") @@ -31,18 +31,18 @@ ITEM.Range = 500 ITEM.CD = 1 function ITEM:OnUse(user) - if(CLIENT) then return end + if CLIENT then return end user:Ignite(1) - user:SetHeat(0) + user:SetHeat(0) user:RemoveItem(self.Name,1) end function ITEM:OnPrimary(ply,tr) ParticleEffect("firetest",ply:GetPos()+Vector(0,0,72),ply:GetAngles(),ply) - if(CLIENT) then - + if CLIENT then + --Do a cool fire breathing animation else - if(tr.Hit && tr.Entity && tr.Entity:IsPlayer()) then + if(tr.Hit && tr.Entity && tr.Entity:IsPlayer()) then tr.Entity:Ignite(5) user.RemoveItem(self.Name,1) end diff --git a/gamemode/itemsystem/items/runemagic.lua b/gamemode/itemsystem/items/runemagic.lua index e999299..ed86e26 100644 --- a/gamemode/itemsystem/items/runemagic.lua +++ b/gamemode/itemsystem/items/runemagic.lua @@ -2,7 +2,7 @@ ITEM.Name = "Magic Rune" ITEM.Class = "resource" ITEM.Desc = "A stone infused with magic" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runemagic.png") ITEM.Structure = { diff --git a/gamemode/itemsystem/items/runenature.lua b/gamemode/itemsystem/items/runenature.lua index 2ebbff6..c528fc0 100644 --- a/gamemode/itemsystem/items/runenature.lua +++ b/gamemode/itemsystem/items/runenature.lua @@ -2,7 +2,7 @@ ITEM.Name = "Nature Rune" ITEM.Class = "resource" ITEM.Desc = "A blank peice of stone" -ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Model = "models/props_junk/Rock001a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_runenature.png") ITEM.Structure = { @@ -32,9 +32,9 @@ ITEM.Range = 64 ITEM.CD = 1 function ITEM:OnUse(user) - if(CLIENT) then return end + if CLIENT then return end if not user then return end - user:SetHealth(math.min(100,user:Health()+25)) + user:SetHealth(math.min(100,user:Health() + 25)) user:AddFatigue(10) user:RemoveItem(self.Name,1) end diff --git a/gamemode/itemsystem/items/spell_fireball.lua b/gamemode/itemsystem/items/spell_fireball.lua index f5de38d..51f835f 100644 --- a/gamemode/itemsystem/items/spell_fireball.lua +++ b/gamemode/itemsystem/items/spell_fireball.lua @@ -22,6 +22,10 @@ ITEM.Recipe = { ITEM.CD = 0.25 +--[[ + The number of fireballs a player has is held in a global table where each entry is + [player] = # of fireballs +]] ITEM.NumFireballs = {} ITEM.MaxFireballs = 3 @@ -31,37 +35,38 @@ fireball["speed"] = 700 fireball["drop"] = 50 fireball["init"] = function(fb) fb:Ignite(10) end fireball["onhit"] = function (self,data,phys) - print("Explode called") local exp = ents.Create("env_explosion") exp:SetPos(self:GetPos()) exp:Fire("Explode","",0) exp:Spawn() for k,v in pairs(ents.FindInSphere(self:GetPos(),200)) do - if(v.TakeDamage) then - local dmg = ( 200 - v:GetPos():Distance( self:GetPos() ) )/2 + if v.TakeDamage then + local dmg = (200 - v:GetPos():Distance(self:GetPos())) / 2 v:TakeDamage(dmg,nil,self) - print("Takeing " .. dmg .. " dammage") end end self:Remove() end +local fireballfields = { + "speed", + "model", + "drop", + "init", + "onhit", +} function ITEM:DoFireball(pl) - print("Fully successfull fireball callback:") + print("Fully successfull fireball callback:") print(pl) local aim = pl:GetAimVector() local D = ents.Create("ws_projectile") - if(fireball.speed) then D.speed = fireball.speed end - if(fireball.model) then D.model = fireball.model end - if(fireball.drop) then D.drop = fireball.drop end - if(fireball.init) then D.init = fireball.init end - if(fireball.onhit) then D.onhit = fireball.onhit end - - print("D's speed:" .. D.speed) + for k,v in pairs(fireballfields) do + if fireball[k] then D[k] = fireball[k] end + end - D:SetPos(pl:GetShootPos()+aim*50) + D:SetPos(pl:GetShootPos() + aim * 50) D:SetOwner(pl) D:SetAngles(aim:Angle()) D:Spawn() @@ -70,31 +75,31 @@ end function ITEM:OnSecondary(pl,tr) ParticleEffect("firetest",pl:GetPos(),pl:GetAngles(),pl) - if(self.NumFireballs[pl] ~= nil and self.NumFireballs[pl] > 0) then + if self.NumFireballs[pl] ~= nil and self.NumFireballs[pl] > 0 then self:DoFireball(pl) self.NumFireballs = self.NumFireballs-1 end end hook.Add("PlayerDeath","remove_fireball_count",function(victim,inflictor,attacker) - self.NumFireballs[victim] = 0 + ITEM.NumFireballs[victim] = 0 end) hook.Add("PlayerDisconnected","clean_fireball_count",function(ply) - self.NumFireballs[ply] = nil + ITEM.NumFireballs[ply] = nil end) local fireballfunc = function(num,pl,self) - if(num == 0) then return end - if self.NumFireballs[ply] == nil then - self.NumFireballs[ply] = 1 - elseif self.NumFireballs[ply] < self.MaxFireballs then - self.NumFireballs[ply] = self.NumFireballs[ply] + 1 - end + if num == 0 then return end + if ITEM.NumFireballs[ply] == nil then + ITEM.NumFireballs[ply] = 1 + elseif ITEM.NumFireballs[ply] < ITEM.MaxFireballs then + ITEM.NumFireballs[ply] = ITEM.NumFireballs[ply] + 1 + end end function ITEM:OnPrimary(pl,tr) - if(CLIENT) then return end + if CLIENT then return end print("Attempting to cast...") pl:Cast("Fireball",fireballfunc,self) end diff --git a/gamemode/itemsystem/items/spell_teleport.lua b/gamemode/itemsystem/items/spell_teleport.lua index 4faed17..686d5d1 100644 --- a/gamemode/itemsystem/items/spell_teleport.lua +++ b/gamemode/itemsystem/items/spell_teleport.lua @@ -6,7 +6,7 @@ ITEM.Model = "models/props_debris/wood_board02a.mdl" ITEM.Icon = Material("wintersurvival2/hud/ws2_icons/icon_spellteleport.png") ITEM.HoldType = "magic" -//Load some nessessary stuff +--Load some nessessary stuff game.AddParticles("particles/particletest.pcf") PrecacheParticleSystem("firetest") @@ -22,33 +22,37 @@ ITEM.Recipe = { ITEM.CD = 0.25 -ITEM.savedpoint = nil +--[[ + All saved points are stored in a global table where + ITEM.savedpoint[player] = +]] +ITEM.savedpoint = {} function ITEM:DoTeleport(score,pl,self) print("DoTeleport called!") - if(self.savedpoint == nil) then return end - print("Fully successfull teleport callback:") + if ITEM.savedpoint[pl] == nil then return end + print("Fully successfull teleport callback:") print(pl) local aim = pl:GetAimVector() local D = ents.Create("ws_teleporter") - D:SetPos(pl:GetShootPos()+aim*200) + D:SetPos(pl:GetShootPos() + aim * 200) D:SetOwner(pl) D:SetAngles(aim:Angle()) - D.endpoint = self.savedpoint + D.endpoint = ITEM.savedpoint[pl] D:Spawn() D:Activate() pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110)) end - + --[[ local teleportfunc = function(score, pl, self) print("teleportfunc called!") - if(self.savedpoint == nil) then return end - if(score != 100) then return end - print("Fully successfull teleport callback:") + if ITEM.savedpoint[ == nil then return end + if score != 100 then return end + print("Fully successfull teleport callback:") print(pl) pl:SetPos(self.savedpoint) - --[[ + local aim = pl:GetAimVector() local D = ents.Create("ws_teleporter") @@ -59,18 +63,19 @@ local teleportfunc = function(score, pl, self) D:SetAngles(aim:Angle()) D:Spawn() D.endpoint = self.savedpoint - ]]-- + pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110)) end +]]-- function ITEM:OnSecondary(pl,tr) print("Endpoint set?") ParticleEffect("firetest",pl:GetPos(),pl:GetAngles(),pl) - self.savedpoint = pl:GetPos() + ITEM.savedpoint[pl] = pl:GetPos() end function ITEM:OnPrimary(pl,tr) - if(CLIENT) then return end + if CLIENT then return end print("Attempting to cast...") pl:Cast("Gateway",teleportfunc,self) end -- cgit v1.2.3-70-g09d2