aboutsummaryrefslogtreecommitdiff
path: root/gamemode/itemsystem
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/itemsystem')
-rw-r--r--gamemode/itemsystem/items/spell_fireball.lua18
-rw-r--r--gamemode/itemsystem/loaditems.lua17
2 files changed, 32 insertions, 3 deletions
diff --git a/gamemode/itemsystem/items/spell_fireball.lua b/gamemode/itemsystem/items/spell_fireball.lua
index 14bca66..dc7d7e0 100644
--- a/gamemode/itemsystem/items/spell_fireball.lua
+++ b/gamemode/itemsystem/items/spell_fireball.lua
@@ -10,6 +10,15 @@ ITEM.HoldType = "magic"
game.AddParticles("particles/particletest.pcf")
PrecacheParticleSystem("firetest")
+ITEM.Structure = {
+ {
+ Bone = "ValveBiped.Bip01_R_Hand",
+ Model = "models/props_junk/Rock001a.mdl",
+ Size = Vector(1,1,1),
+ Pos = Vector(0,0,0),
+ Ang = Angle(0,0,0),
+ },
+}
ITEM.Recipe = {
Resources = {
@@ -21,6 +30,7 @@ ITEM.Recipe = {
}
ITEM.CD = 0.25
+ITEM.Range = 9999
--[[
The number of fireballs a player has is held in a global table where each entry is
@@ -46,7 +56,7 @@ fireball["onhit"] = function (self,data,phys)
end
end
- self:Remove()
+ self.Remove(self)
end
function ITEM:DoFireball(pl)
@@ -100,6 +110,10 @@ end
function ITEM:OnPrimary(pl,tr)
if CLIENT then return end
print("Attempting to cast...")
- pl:Cast("Fireball",fireballfunc,self)
+ if NumFireballs[pl] == nil or NumFireballs[pl] < 3 then
+ pl:Cast("Fireball",fireballfunc,self)
+ else
+ pl:ChatPrint("You can't summon any more fireballs")
+ end
end
RegisterItem(ITEM)
diff --git a/gamemode/itemsystem/loaditems.lua b/gamemode/itemsystem/loaditems.lua
index 374fd18..2e5be4e 100644
--- a/gamemode/itemsystem/loaditems.lua
+++ b/gamemode/itemsystem/loaditems.lua
@@ -8,9 +8,12 @@ GM.Recipes = GM.Items or {}
--This is so that the client can store info about items/recepies too.
local gmitems = (GAMEMODE or GM).Items
local gmrecepies = (GAMEMODE or GM).Recipes
-
+local itemfiles = {}
function RegisterItem(tbl)
assert(gmitems[tbl] == nil, "Cannot register 2 items with the same name!")
+ tb = debug.getinfo(2)
+ src = string.sub(tb.source,2)
+ itemfiles[#itemfiles + 1] = src
insert(gmitems,tbl)
if tbl.Recipe then
insert(gmrecepies,tbl)
@@ -18,6 +21,18 @@ function RegisterItem(tbl)
print("Registered item:", tbl.Name)
end
+(GAMEMODE or GM).LoadItems = function()
+ allfiles = table.Copy(itemfiles)
+ for _,itemfile in pairs(allfiles) do
+ f = file.Read(itemfile,"GAME")
+ c = CompileString(f,itemfile)
+ print("executing",c)
+ if c ~= nil then
+ c()
+ end
+ end
+end
+
function GetItemByName(name)
for k,v in pairs( gmitems ) do
if (v.Name == name) then return v end