• Itemforge - An items system for Garry's Mod
    335 replies, posted
Could you make a weapon with GCombat or what ever the thing is called and hold it as a hand held weapon?
Can you put up a Beta SVN that we could try it on? :33333333
[QUOTE=Daimao;15276770]The item rotation is :( I'd suggest a different background for the item icons and a standard rotation that looks good on every item. [/QUOTE] This is the default inventory window. I'm hoping scripters will make their own inventory windows for their gamemodes if they're not satisfied with mine. And as for the models in the slots, they are actually rotating while you look at them (sort of like something on display at a store). [QUOTE=Daimao;15276770] The Gear Attachment is :) You'll be able to make all sorts of awesome shit like silencers on pistols and all that sort of giggly stuff. One little problem with this, though: If you're going to draw those models on the viewmodels too, you're going to need a dll to set the rendergroup of that entity. If you need one just ring me up.[/QUOTE] I might do that. Originally I wanted a variety of "hands" viewmodels posed in different ways, to attach the world model of an item to; except I can't model and I've never attached anything to the viewmodel. So as it stands the only way to show the player holding an item in first person is to actually make a viewmodel for it... [QUOTE=Barfusman12;15342793]So, you will be able to wear different things? And they will lets say, give boost o your armour or something?[/QUOTE] I'm leaving equipment up to the scripters to decide how they want to do these things. One idea I have had for how this could be done is by giving players an "equipment only" inventory where every slot in it represents a slot to equip something on (head, feet, arms, back, body, etc). So whenever an item is equipped, it's just put in the player's equipment inventory in the right slot, then it's world model is attached to the right body part on the player. Likewise when it leaves that inventory, the equipment model gets removed. [QUOTE=drbugbait;15363152]holy crap its clientside awesome i always wanted a invintory so that a could like carry a ent around all the time or maybe i could spawn a quantum storage device AND carry it around,that would be awesome so good luck and i hope you release it soon :) bye[/QUOTE] [QUOTE=Pontikkapannu;15365133]Like the crate stool, but advanced and with inventory system. Could it be or is it possible to store [u]non player charters[/u] into [i]inventory[/i] [b][i]of hundreds of soldiers[/i][/b], or even just few NPCs? (Presumably it would [u]crash[/u] with hunders of them) *Yes I know you can 'crate' NPC Kleiners into single boxes with that crate stool **And what if you store [u]active grenade[/u] [u]before it explodes[/u]? Or is it possible to do?[/QUOTE] Okay, let me clear this up: Only Itemforge Items can be put inside of inventories. That means if you want something in your inventory, someone has to script it. However, that doesn't necessarily mean "oh fuck I can't put a hunter into a crate"; somebody could make a "Hunter" item; whenever a hunter is put inside of a crate, the hunter NPC gets removed, and a Hunter item gets added to the crate's inventory; likewise when the Hunter item leaves the crate, it gets removed and spawns a hunter; sound like a plan? The same thing can be done for props - someone (maybe me this time) could script a "Prop Item" that gets created when a prop is put in an inventory, and gets removed when it's taken out. Guys, keep in mind if I do too much this system will never get released. I need you scripters to back me up here. And yeah, storing active grenades is possible; In fact in Fallout 1+2 you could have plastic explosives and dynamite with timers in them that you could plant in an unwitting NPC's inventory and then blow him to bits... was pretty funny. [QUOTE=GmanMan;15382872]Is there a "Drop all" button? Because if there is you have created a server crashig device. Heres how it works. -minge gets on server. -slowly acumulates asplosive props and junk in invetories. -when he has 9000 props he dumps them all at once into the server. -server crashes. Pretty cool thing though.[/QUOTE] Once again, may I remind everybody that players do not have inventories by default; I am leaving this up to the scripters to decide how they want to handle player inventories. For instance, in some gamemodes, like Stranded, a player's "inventory" could be an inventory attached to the player himself. However, in other gamemodes, such as RP/RPG, maybe the player's equipment is his inventory (IE, backpack, satchel, etc). Gamemode coders will do inventories differently. And if Itemforge is being used seperately from a gamemode, scripters can create addons that give inventories to players on their first spawn or whatever. As for the drop question, if you look in the screenshots, there is a Drop button in the inventory window that looks like a rock with a red down arrow. But currently it doesn't do anything. You can select several items in the inventory at the same time; if the "drop" button was working, it would drop all the items at the same time like you suggested. This can be done without a drop button, however. The base_container, which is the only item with an inventory right now (it looks like a crate in all the screenshots), can be loaded up with hundreds of "unique" items and then broken; this will cause all of the items to spill out. I've tested it several times; although laggy afterwards it rarely crashes servers. Like Kogitsune suggests, this is why, by default, stacks of similiar items merge when they enter inventories, and also why the inventory limits (max slots, weight caps, and item-size limits) exist. [QUOTE=robowurmz;15376838]I can't wait to have melee battles with a friend by throwing pans and kettles at him.[/QUOTE] It's funny you mentioned that, I had a "Throw" feature built into all items at a certain time, as the default secondary attack. But I took it out because I figured people using the system would want to do throw their own way. I'm thinking of making a "base_thrown" item-type for thrown weapons like hand grenades, or rocks or whatever. [QUOTE=Maxaxle;15390209]Can't wait! But is it togglable?[/QUOTE] What do you mean? Okay, time for a status update... Currently I am redoing the cooldown for the weapons. See, weapons attack on both the server and client. But getting them to attack at the same time is somewhat difficult. The way I was doing it before is having the server and client do cooldown seperately. Theoretically this should have worked; the weapon attacks, then I make it wait for "x" seconds and it can attack again. However, the weapons started to attack out-of-sync (ex: pistol fires on server then 1/4 of a second later it attacks on the client). To fix this problem, whenever the weapon attacks on the server, it syncs the next attack time with the client. This has improved this problem quite a bit, however the server will attack more often than the client, which is something I need to fix. Ranged weapon clips have been changed; Before, all ranged weapons had two clips, one for the primary and another for the secondary. This has been changed; now weapons can have any many clips as you want (or none if you so please) and you can set which clip the primary/secondary draws ammo from. Most weapons will probably only use one clip (like the HL2 Pistol), but the SMG uses two (one for SMG ammo and another for nades). Some weapons have one clip, but the primary and secondary both take ammo from it (like the shotgun). I have been working on new weapons. Last time I updated you, the only two ranged weapons were the SMG and Flechette Gun. I've created two weapons since then. I've made a near-perfect version of the HL2 pistol; it has accuracy penalties identical to the real HL2 pistol. It also kicks the view when you fire it the same way the HL2 pistol does - with one exception: I can't reset the view kick every time the gun is fired like the pistol does because that binding doesn't exist in Garry's Mod. Now I'm working on an imitation HL2 shotgun. I have got the primary and secondary attack of the shotgun working almost flawlessly. It turns out that the "Pump" thing the player does when he attacks isn't part of the attack ani
A beta SVN would be wonderful! Please do!
You're really giving your all for this, and I applaud that.
Wow, huge post, i am loving all this, and please do that beta SVN.
Well, i can't wait, but, i suppose i have to, atleast if it is longer in production, it'd be a better result, right?
Am I correct in assuming that we could get out a gun with 30 bullets in the clip, fire 3, put it back into our inventory, get it out again and it would have 27 bullets in the clip? Could we treat the gun as an inventory? And the clips? Could I 'open' a clip of ammo and put in there 12 incendiary bullets and 18 armor piercing bullets. Then place my clip into my gun, and then get my gun out of my inventory and then it would fire 12 incendiary bullets then 18 armor piercing? With the split and merge functions, could I make it alternate between them? How far can I go with this? Could I potentially open the bullet up and put in different materials, then in the final firing of the gun, it figures out what to do based on the materials in the bullets? With the combinations issue, is there a way to check what was put in or removed from an inventory when it was used? Could I make an 'empty bottle' item that checks if anything has been put in there, if say, water was put in there it would turn into a water bottle item? I know I have to code the items myself, I am happy to, but is the system you have in place suitable for this sort of thing? I can't wait to test this out!
[QUOTE=Kill coDer;15497776]Am I correct in assuming that we could get out a gun with 30 bullets in the clip, fire 3, put it back into our inventory, get it out again and it would have 27 bullets in the clip? [/QUOTE] Yeah; the items aren't remade whenever they change states, so everything will pretty much stay intact. [QUOTE=Kill coDer;15497776] Could I 'open' a clip of ammo and put in there 12 incendiary bullets and 18 armor piercing bullets. Then place my clip into my gun, and then get my gun out of my inventory and then it would fire 12 incendiary bullets then 18 armor piercing? [/QUOTE] The ammo loading is based on Fallout 1/2's guns. One type of ammo per clip (or no ammo) can be loaded at a time. What you're talking about is possible, and I don't see why someone couldn't override my ammo loading system to do that. I could have had it so each clip was an inventory on the gun, but I figured this would unnecessarily complicate the ammo loading. [QUOTE=Kill coDer;15497776] Could we treat the gun as an inventory? And the clips? [/QUOTE] "Gun as an inventory"? I'm not sure what you mean by this. I want to make a weapon like the "Rock-It" launcher in Fallout 3, where you load the gun's inventory with random junk and then fire it off. This is totally possible and I intend to make this; maybe I'll make that today. [QUOTE=Kill coDer;15497776] With the split and merge functions, could I make it alternate between them? How far can I go with this? Could I potentially open the bullet up and put in different materials, then in the final firing of the gun, it figures out what to do based on the materials in the bullets? [/QUOTE] Split and merge work for items of the same type. And yeah, you can rig your gun up so that the bullets get to decide what happen when they're fired instead of the gun. Right now the guns decide what happens when shots are fired from them, but this can be changed so that ammo decides instead. [QUOTE=Kill coDer;15497776] With the combinations issue, is there a way to check what was put in or removed from an inventory when it was used? Could I make an 'empty bottle' item that checks if anything has been put in there, if say, water was put in there it would turn into a water bottle item? [/QUOTE] I have an event called "GetName()"; If you made a bottle item with an inventory, you could have it so the bottle's GetName() looks in the inventory. If there were no items stored, it could return "Empty Bottle"; if there was a "Water" item in there, it could be "Water Bottle". A simple way to do this would be something like: [lua] function ITEM:GetName() --Make sure the inventory has been set and we have at least one item if self.Inventory && !self.Inventory:IsEmpty() then --If the first item was "Water", this would be "Water Bottle"; --If it was "SMG Grenade" it would be "SMG Grenade Bottle", etc return self.Inventory:GetFirst():GetName().." Bottle"; end --Returns "Empty Bottle" by default return "Empty Bottle"; end [/lua] [QUOTE=Kill coDer;15497776] I know I have to code the items myself, I am happy to, but is the system you have in place suitable for this sort of thing? I can't wait to test this out![/QUOTE] Thanks, I created this system with things like this in mind, so yes, it should be possible to do. [b]Status update[/b]: I've re-created the HL2 .357 Revolver. It was actually pretty easy, here's the entire thing: [lua] --[[ weapon_357 SHARED The Itemforge version of the Half-Life 2 .357 revolver. ]]-- if SERVER then AddCSLuaFile("shared.lua") end ITEM.Name=".357 Revolver"; ITEM.Description="This is a .357 revolver.\nThis weapon is designed for use with .357 rounds."; ITEM.Base="base_firearm"; ITEM.Spawnable=true; ITEM.AdminSpawnable=true; ITEM.WorldModel="models/weapons/W_357.mdl"; ITEM.ViewModel="models/weapons/v_357.mdl"; --Overridden Base Weapon stuff ITEM.PrimaryDelay=.75; --Taken directly from the modcode. --Overridden Base Ranged Weapon stuff ITEM.Clips={}; ITEM.Clips[1]={Type="ammo_357",Size=6}; ITEM.PrimaryClip=1; ITEM.PrimaryFiresUnderwater=false; ITEM.PrimaryFireSounds={ --These sound identical to me, but what the hell. Sound("weapons/357/357_fire2.wav"), Sound("weapons/357/357_fire3.wav") }; ITEM.ReloadDelay=3.6666667461395; ITEM.ReloadSounds={ --The viewmodel is responsible for playing the reload sounds } --Overridden Base Firearm stuff ITEM.BulletDamage=75; ITEM.BulletSpread=Vector(0,0,0); --Taken directly from modcode; this is 0 degrees. The .357 is perfectly accurate. ITEM.ViewKickMin=Angle(-8,-2,0); --Taken directly from modcode. The view kicks up. ITEM.ViewKickMax=Angle(-8,2,0); function ITEM:OnPrimaryAttack() if !self["base_firearm"].OnPrimaryAttack(self) then return false end --We need to snap the holding player's eyes on the server; --if we can't do that for some reason just return true to indicate everything else went as planned if CLIENT || !self:IsHeld() then return true end local pl=self:GetWOwner(); ang=pl:GetLocalAngles() ang.p=ang.p+math.random(-1,1); ang.y=ang.y+math.random(-1,1); ang.r=0; pl:SnapEyeAngles(ang); end function ITEM:OnSecondaryAttack() --Secondary attack does NOTHING end [/lua] The weapon cooldowns are still giving me shit. I've done some research into how cooldowns work. Even Garrysmod SWEPs use the Source Engine's SetNextPrimaryAttack/SetNextSecondaryAttack. It appears that both the client and server set cooldown - the client predicts when the next attack is supposed to be, and the server occasionally syncs the "correct" cooldown with the client. However, I'm not sure [u]when[/u] the server syncs with the client; currently the server is syncing the next attack time with the client as soon as it is set on the server; however from the modcode it appears that this is not how it works, so I will be working on a solution to this. Oh, and you can now set whether or not you want a ranged weapon's primary/secondary to work underwater. It's on by default. That's all right now.
[QUOTE=theJ89;15500140] The weapon cooldowns are still giving me shit. I've done some research into how cooldowns work. Even Garrysmod SWEPs use the Source Engine's SetNextPrimaryAttack/SetNextSecondaryAttack. It appears that both the client and server set cooldown - the client predicts when the next attack is supposed to be, and the server occasionally syncs the "correct" cooldown with the client. However, I'm not sure [u]when[/u] the server syncs with the client; currently the server is syncing the next attack time with the client as soon as it is set on the server; however from the modcode it appears that this is not how it works, so I will be working on a solution to this.[/QUOTE] My solution is to just run it on both. The server controls when the next fire can actually happen from what I've saw, and it should block the client from spamming the hell out of the function if you run it clientside for prediction.
[QUOTE=Kogitsune;15500866]My solution is to just run it on both. The server controls when the next fire can actually happen from what I've saw, and it should block the client from spamming the hell out of the function if you run it clientside for prediction.[/QUOTE] This is what I'm doing; the problem is I'm using my own system to do this. I can't use the Weapon:SetNextPrimaryAttack()/Weapon:SetNextSecondaryAttack() because unlike SWEPs, the weapons can be fired in the world; and I can't use Weapon functions on an entity.
[QUOTE=theJ89;15502217]This is what I'm doing; the problem is I'm using my own system to do this. I can't use the Weapon:SetNextPrimaryAttack()/Weapon:SetNextSecondaryAttack() because unlike SWEPs, the weapons can be fired in the world; and I can't use Weapon functions on an entity.[/QUOTE] It would be pretty cool if someone can get models for the super armor from fallout 3 so we can put body part pieces on the player
Okay, Rock-It launcher is pretty much done. I could spice it up with some special effects or something, but it's functional right now. Also, I have added the name of the item at the top of the right click menu: [img]http://img193.imageshack.us/img193/82/rockit.png[/img] Edit: Minor changes - I changed the header text color to something more readable, shifted the heading text a bit, and filled the Rock-It Launcher with some items; notice the Unload thing: [img]http://img241.imageshack.us/img241/2513/rockit2.png[/img]
Looks great! By using the gun as an inventory, I mean't being able to treat it like a bag. For example on my gamemode I would make a GUI that resembles the SMG, then when you opened the smg you could drag your clip of ammo into the primary slot and a grenade into the grenade launcher on the underside of the gun. When you used the weapon it would fire the bullets inside the clip you put into the primary slot, and when you used secondary fire it would fire the grenade in the grenade slot. From what I've read it shouldn't be too difficult to build. Keep going theJ89 your progress is amazing.
This is awesome! I hope you but up a beta!
-snip-
Do want beta.
How long until an SVN will be available? I want to try this thing out..
HOLY COW thats awesome work dude! once there is a release worthy version(be it beta or alpha) i will get one... this is sooo nice!
Beta SVN posted. Check end of first post.
Awesome! Thanks mate.. Man this is amazing...
Current Update: Fixed a few issues with ammo loading and sounds. Drag-drop loading and reloading a gun with ammo from the inventory it was in was broken; this has been fixed. Sounds did not play when reloading the rock-it launcher; this also has been fixed. Beta SVN Updated.
Thanks! I was about to post about that... I love how you can turn on the magnet, stick it in a container and it still works.. Next stop, timed explosives you can stick into peoples backpacks! For creating an inventory for the player I can just do: [lua] local inv=IF.Inv:Create(); if !inv || !inv:IsValid() then return false end inv:ConnectItem(PLAYER); PLAYER.Inventory=inv; [/lua] Follow the examples etc.. The main issue I am concerned about is saving and loading... I only need to save the players inventory, sticking it in a table and GSONing it is what I've been doing with my inventory system. However my inventory system is essentially a spiffy list of items the player has, with a function for when they are used. I keep expecting that using a weapon will hold it.. Also, if you try to hold another weapon while holding one currently, it should probably swap the weapons.
inv:ConnectItem() connects an inventory to an item; inv:ConnectEntity() connects an inventory to an entity (pretty much anything besides an item, including players) You've probably already discovered why ConnectItem/ConnectEntity is necessary. It basically tells Itemforge "this inventory is here"; you can get the position of an inventory, which pretty much returns the position of it's connected object. Also, if all of the inventory's connections disappear then the inventory disappears too. As for saving, I have not yet worked out the save/load process for items. I'm thinking of doing several different interfaces that would let you save items and inventories (databases, text files, etc) but I won't really know until I get there. EDIT: Also sorry about the poor state of the inventory system; I've neglected it for several months so a lot of the features are out of date. Connecting inventories to entities is very basic at the moment; I don't think there's even a way to find out what inventories are on an entity clientside right now.
Heheh, healthpack.. [lua] --[[ item_healthpack SHARED Heals 30 hp ]]-- ITEM.Name="Health Pack"; ITEM.Description="Heals 30 HP."; ITEM.Base="item"; ITEM.WorldModel="models/Items/HealthKit.mdl"; ITEM.MaxHealth=30; ITEM.MaxAmount=10; if SERVER then function ITEM:OnUse(pl) if(pl:Health( ) > 129)then pl:PrintMessage(3, "You cannot be healed any futher!") return false end pl:SetHealth( math.Clamp( pl:Health() + 30, 0, 130 ) ); self:SetAmount(self:GetAmount() - 1) return true end end [/lua] Heheh, health vial.. [lua] --[[ item_healthvial SHARED Heals 10 hp ]]-- ITEM.Name="Health Vial"; ITEM.Description="Heals 10 HP."; ITEM.Base="item"; ITEM.WorldModel="models/healthvial.mdl"; ITEM.MaxHealth=30; ITEM.MaxAmount=10; if SERVER then function ITEM:OnUse(pl) if(pl:Health( ) > 129)then pl:PrintMessage(3, "You cannot be healed any futher!") return false end pl:SetHealth( math.Clamp( pl:Health() + 10, 0, 130 ) ); self:SetAmount(self:GetAmount() - 1) return true end end [/lua] Does split actually work? Or am I just doing it wrong.. Also, decals and traces from the guns rarely appear when firing..
Just tried out the SVN, loving it so far! Quick question, does the GearAttach module work? If so, may I have an example of use? I've had a quick poke about in the code but I can't seem to get the gear to draw. I'm working with a bot in a listen server: [code] ] lua_run_cl ENT = IF.Modules.GearAttach:ToAP( player.GetByID( 2 ), "models/props_junk/watermelon01.mdl", "eyes" )[/code] Unfortunately his head is melon-less so I assume I'm doing it wrong.
[QUOTE=Turd92;15555043]Just tried out the SVN, loving it so far! Quick question, does the GearAttach module work? If so, may I have an example of use? I've had a quick poke about in the code but I can't seem to get the gear to draw. I'm working with a bot in a listen server: [code] ] lua_run_cl ENT = IF.Modules.GearAttach:ToAP( player.GetByID( 2 ), "models/props_junk/watermelon01.mdl", "eyes" )[/code] Unfortunately his head is melon-less so I assume I'm doing it wrong.[/QUOTE] Yes, it works, but the way I have it set up right now, you have to call :Draw() on the thing returned every frame that it needs to be drawn, at the moment. btw you don't need the .Modules, IF.GearAttach is the same thing as IF.Modules.GearAttach Here's what I do to attach a model to the player's right hand. This is more or less simplified code from the Itemforge SWEP. [lua] --To create a model function SWEP:ShowWorldModel() --Stop if we've already got a world model if self.WM then return true end --Create a new world model self.WM=IF.GearAttach:ToAP(self.Owner,"models/props_junk/watermelon01.mdl","eyes"); --Couldn't attach for some reason? if self.WM==false then return false end return true; end --To draw the model: function SWEP:DrawWorldModel() --Instead of drawing the SWEP's real world model, we'll try to make a fake one if self:ShowWorldModel() then --and then draw it self.WM:Draw(); end end [/lua] Making a better interface for this is something I'm working on. At the moment it's kind of a hacky thing that's only used by the Itemforge SWEP. I'm not really sure what kind of Draw hook you'd need to make this work outside of an SWEP.
I'll have a play, thanks for the help ;)
[QUOTE=Kill coDer;15554674] Does split actually work? Or am I just doing it wrong.. [/QUOTE] The item:Split([true/false]SameLocation,howMany) function works. It's arguments are set up in a stupid order at the moment though. I'm gonna see if I can move that SameLocation thing to the end somehow. The right-click menu's "Split" doesn't work yet. I need to make a PlayerSplit command; I'm probably going to do that today... after I wake up 8 hours from now. [QUOTE=Kill coDer;15554674] Also, decals and traces from the guns rarely appear when firing.. [/QUOTE] This is related to the faulty weapon cooldowns. The server attacks first and then tells the client when the next time it can attack is (so the client rarely gets a chance to attack; hence no tracers/bullet effects). I'm working on this. Also shotgun reloads are incomplete; since the shotgun reloads a special way I am having to code something special for it's reloading thing. Dragdropping ammo works for the shotgun, but no other method of reloading the shotgun works at the moment.
To be perfectly honest I don't need, nor want, any of the weapons to be able to be fired while out of the players hand.. I will probably override the cooldown code with the normal GMod stuff.. ... unless you make it perfect :P There is nothing worse than a lack of a gaping hole where you just fired your weapon... Thanks!
Sorry, you need to Log In to post a reply to this thread.