diff options
Diffstat (limited to 'gamemode/itemsystem/items')
| -rw-r--r-- | gamemode/itemsystem/items/spell_fireball.lua | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/gamemode/itemsystem/items/spell_fireball.lua b/gamemode/itemsystem/items/spell_fireball.lua index 51f835f..481fd2f 100644 --- a/gamemode/itemsystem/items/spell_fireball.lua +++ b/gamemode/itemsystem/items/spell_fireball.lua @@ -26,8 +26,8 @@ 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 +local NumFireballs = {} +local MaxFireballs = 3 local fireball = {} fireball["model"] = "models/hunter/blocks/cube025x025x025.mdl" @@ -49,21 +49,14 @@ fireball["onhit"] = function (self,data,phys) self:Remove() end -local fireballfields = { - "speed", - "model", - "drop", - "init", - "onhit", -} function ITEM:DoFireball(pl) print("Fully successfull fireball callback:") print(pl) local aim = pl:GetAimVector() local D = ents.Create("ws_projectile") - for k,v in pairs(fireballfields) do - if fireball[k] then D[k] = fireball[k] end + for k,v in pairs(fireball) do + D[k] = v end D:SetPos(pl:GetShootPos() + aim * 50) @@ -75,26 +68,32 @@ 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 NumFireballs[pl] ~= nil and NumFireballs[pl] > 0 then self:DoFireball(pl) - self.NumFireballs = self.NumFireballs-1 + NumFireballs[pl] = NumFireballs[pl]-1 end end hook.Add("PlayerDeath","remove_fireball_count",function(victim,inflictor,attacker) - ITEM.NumFireballs[victim] = 0 + if NumFireballs ~= nil then + NumFireballs[victim] = 0 + else + error("Tried to remove fireball count from non-existant table!") + end end) hook.Add("PlayerDisconnected","clean_fireball_count",function(ply) - ITEM.NumFireballs[ply] = nil + NumFireballs[ply] = nil end) local fireballfunc = function(num,pl,self) + print("Fireball func called with ",num,pl,self) + print("NumFireballs was",NumFireballs) 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 + if NumFireballs[pl] == nil then + NumFireballs[pl] = 1 + elseif NumFireballs[pl] < MaxFireballs then + NumFireballs[pl] = NumFireballs[pl] + 1 end end |
