theJ89, I have a couple of new questions. How can I get items to drop actual entities on break instead of just debris? Also, how can I make grenades under Itemforge?
[QUOTE=Rayne Mercury;29445358]I explained this to someone last night, you must have been there to bring this up, Russian. It's just more like an MMORPG than a round-based zombie DM gamemode.
theJ89, when I get home today, I'm going to finish up the basics of the gamemode, and maybe get my server up. It'll be quite barebones and pointless, but if you dropped in to check it out, that'd be cool.[/QUOTE]
I should have some time to come check out your server today.
[QUOTE=Rayne Mercury;29469577]theJ89, I have a couple of new questions. How can I get items to drop actual entities on break instead of just debris? Also, how can I make grenades under Itemforge?[/QUOTE]
You can write hooks for itemtypes the same way you write hooks for entities.
I think you're looking for the ITEM:OnBreak(howMany,bLastBroke,who) hook. For an example of this hook, check items/base_item/events_server.lua
Grenades are something I've been meaning to do for a while, but basically what I would do, I would create a new item type based off of base_thrown. You can do that by creating a new folder in itemforge/items/ and putting a shared.lua with the following in there:
[lua]
ITEM.Name = "Grenade"
ITEM.Base = "base_thrown"
--Replace these with the world/view models you want to use
ITEM.WorldModel="models/weapons/W_357.mdl";
ITEM.ViewModel="models/weapons/v_357.mdl";
function ITEM:OnThrown()
self:SimpleTimer(5,self.Explode);
end
function ITEM:Explode()
--Write explosion code (involving position of grenade) here
end
[/lua]
Okay, I'll try to explain what's going on here.
ITEM.Base is special; by giving the itemtype a base, we're saying that this type of item is actually a copy of another type of item(it uses all of the code from base_thrown).
Everything else in the file either overrides some underlying property in base_thrown (like ITEM.Name) or adds something unique to the grenade (like ITEM:Explode).
ITEM.Name is an itemtype property that allows you to set the default name of all items of that type.
ITEM.WorldModel and ITEM.ViewModel set the world/viewmodel that the item uses. Pretty straightforward.
ITEM:OnThrow() - this is an event. Apparently, I was stupid and forgot to write this event, so I'll go do that now.
Basically, an event is a function that automatically runs on the item (like a hook) whenever some particular action happens (e.g. the grenade is thrown).
ITEM:Explode() is a function that can be run on any grenade. When you call it (e.g. grenade:Explode() ), it makes the grenade explode.
You'll have to write the code for that.
If you check out base_thrown, you can see more properties you can set to change things like how hard the grenade is thrown, the delay between a click and a throw, etc.
theJ89, you are awesome. Thank you for putting up with me and all my questions! Do you know of anyone else who is or is going to use Itemforge as the basis of their gamemode/server?
Are you planning on doing any work on grenades before the final release? If so, I might wait until you've implemented them yourself.
Yesterday I didn't get anything done. I'm hoping to do all that today.
EDIT: I don't really know how to do this anywhere, but since I'm working with Itemforge, I thought I'd ask here: How can I add ironsights to weapons? I know how to get coordinates and such, just don't know the technical, Lua side. It seems to use the secondary, do I need to put something in that section of the script?
[QUOTE=Rayne Mercury;29472894]theJ89, you are awesome. Thank you for putting up with me and all my questions! Do you know of anyone else who is or is going to use Itemforge as the basis of their gamemode/server?
Are you planning on doing any work on grenades before the final release? If so, I might wait until you've implemented them yourself.
Yesterday I didn't get anything done. I'm hoping to do all that today.
EDIT: I don't really know how to do this anywhere, but since I'm working with Itemforge, I thought I'd ask here: How can I add ironsights to weapons? I know how to get coordinates and such, just don't know the technical, Lua side. It seems to use the secondary, do I need to put something in that section of the script?[/QUOTE]
No problem. I think Kill Coder was doing something with Itemforge a while ago, and a few other people had expressed interest in the system in the past. Just having the time to work on the system is the biggest issue for me.
I'm uploading a new version to the SVN that adds a grenade if you want to take a look at it.
Okay, well, I admit that the grenade was a little more complicated than what I presented above, but I wanted to add my own personal touch to them :P
To add Ironsights to weapons, you need to have an event in your itemtype,
[lua]ITEM:GetSWEPViewModelPosition(oldPos, oldAng)[/lua]
This is basically the same as the SWEP hook. This event gets called every frame you're holding the item as a weapon and you have it out. oldPos and oldAng is the position/angle of the viewmodel if you do nothing to it. If you return a different position, angle pair (return pos,ang) then the SWEP is positioned there instead.
Ironsights work by having a switch that turns the "modified view" on/off. Usually, the secondary fire flips this switch on/off. In Itemforge, you can use networked vars to do this. At the bottom of your itemtype script, you need to have
[lua]IF.Items:CreateNWVar(ITEM,"Ironsights","bool",false);[/lua]
What this does is create a property on all items of this type called "Ironsights". It can be true or false (that's what "bool" indicates). The third param there means if we haven't set it to anything yet, it defaults to false.
So now, basically, what you want to do is have the weapon's secondary attack flip this switch. You can do this with:
[lua]self:SetNWBool("Ironsights", !self:GetNWBool("Ironsights"));[/lua]
What's going on there is that self:GetNWBool("Ironsights") is checking what the current state of the switch is.
Since we want to flip the switch to it's opposite, we use "!" which flips the true/false value we got from GetNWBool (so if it was true, it returns false, or if it was false, it returns true). Then, self:SetNWBool("Ironsights", ...) is changing "Ironsights" to that new value.
[b]Status update:[/b]
Beta SVN Updated.
* Itemforge is version 0.23 now
New stuff:
* Frag Grenade. It's throwable, you can control it with Wiremod, you can use it while it's in an inventory (like a crate or something) / while you're holding it, and it will pull the pin. The grenade burns for about 5 seconds.
* Added ITEM:OnThrow(pl) to base_thrown. This event calls on the thrown item, right after the item is thrown.
Bug fixes:
* Fixed a bug related to Wiremod that was causing Item entities to fail
* Fixed a bug where removing an item during an OnBreak event would cause errors
* Simplified Wiremod detection in item:WireOutput()
Other changes:
* Minor comment changes in base_thrown
Sigh... I used CS:S viewmodels. They're left-handed. I don't know how to change this. Heh.
EDIT: Your grenade is left-handed also.
[QUOTE=theJ89;29477468]No problem. I think Kill Coder was doing something with Itemforge a while ago, and a few other people had expressed interest in the system in the past. Just having the time to work on the system is the biggest issue for me.[/QUOTE]
Yeah I made my RP use this as the inventory solution. I also built my gore mod around it. You could headshot someone then pick up their brain and eat it; you would then gain intelligence stats.
I also learnt how to use metatables from this.
The reason I stopped making stuff with this was the lack of a saving ability. I tried to make one myself but I couldn't figure it out well enough to do so.
[QUOTE=Kill coDer;29480844]Yeah I made my RP use this as the inventory solution. I also built my gore mod around it. You could headshot someone then pick up their brain and eat it; you would then gain intelligence stats.
I also learnt how to use metatables from this.
The reason I stopped making stuff with this was the lack of a saving ability. I tried to make one myself but I couldn't figure it out well enough to do so.[/QUOTE]
Nice post count, Kill coDer. Now you must never post again... Mwah ha ha ha!
EDIT: Sorry, this is off-topic. To be relevant: I'm finished working on this tonight. Any idea what might cause my P90 to show up as Default Item Name and based on base_item instead of base_firearm, and be the button model and all that? I looked through and didn't catch any typos or anything in the script. I could be wrong.
That either means there was an error loading the script (check the console for errors), or that the ITEM.Name, ITEM.Base stuff wasn't in your script.
The reason it's showing up as a copy of base_item is because every item needs to have a base. As long as there's a folder in itemforge/items/, Itemforge will create a new blank item initially based off of base_item. After that, it loads scripts to change that (it tries to load init.lua and cl_init.lua first, but if it can't find those it loads shared.lua). Since it's still a perfect copy of base_item, that means nothing else (like ITEM.Name, etc) was loaded either.
So, if there are no errors, this might mean that it detected the folder in itemforge/items/, but couldn't load the script.
Where are the itemtype scripts located (e.g. shared.lua, init.lua, cl_init.lua), relative to garrysmod/?
The fastest way for me to figure this out would be to see some code, mind posting some? (or if you'd like to keep it private, PMing me )
Well, I made the P90 along with two other weapons and two new ammo items, all the others worked fine. I forgot about checking the console until long after it had gone away (I was playing with the new grenade and stuff, and for some reason all the IN and OUT messages were printing to my console, so it flooded any possible loading errors out).
I need sleep now, but tomorrow when I get home I'll check it out and send you some code if necessary.
EDIT: Oh, I checked if Name and Base were there, they were.
EDIT2: Found the problem, it was a stray "end" at the bottom of the file... Sorry. Now my issue is the left-handedness of all the weapons...
EDIT3: I found SWEP.ViewModelFlip in itemforge_item_held, I just don't know how to change it for individual weapons. Do I have to add something somewhere for ITEM.ViewModelFlip to be usable?
[QUOTE=Rayne Mercury;29482230]
EDIT3: I found SWEP.ViewModelFlip in itemforge_item_held, I just don't know how to change it for individual weapons. Do I have to add something somewhere for ITEM.ViewModelFlip to be usable?[/QUOTE]
Actually, I addressed that problem early this morning. I just need to commit the changes when I get home. I added an itemtype property, ITEM.SWEPViewModelFlip, to control whether all items of that type have a flipped viewmodel.
Also, I have functions that allow you to turn the viewmodel flip of individual items on/off (apparently that DOES work) and detect whether or not an item uses a flipped viewmodel.
Thanks! I'll be glad to have that once it's done. Right now I has more issues...
Well, more like things I want to do that I don't know how.
Anyway, this really isn't the place to ask these questions, I know, these are basic Lua/sandbox questions that I should be posting elsewhere for. So, I'll stop crowding your thread with non-Itemforge related questions.
I'm off to post a new thread with my questions! You're welcome to follow me and answer them, theJ89, I really appreciate all your help!
[b]Status Update[/b]:
Beta SVN updated.
Itemforge is version 0.24 now
New stuff:
View model flipping is supported now. Setting the itemtype property:
[lua]
ITEM.SWEPViewModelFlip = true;
[/lua]
will make all items of that type have a flipped viewmodel.
Additionally, you can make individual items have flipped/unflipped viewmodels with item:SetSWEPViewModelFlip(bShouldFlip).
You can detect whether or not a particular item has a flipped view model with item:GetSWEPViewModelFlip().
ITEM:OnDraw2DBack(width,height) was added. This serves the same as OnDraw2D, except it allows 2D drawing in the background of the slot (behind the model).
The Rock-It Launcher now has the ability to trigger a special effect on launched items (similar to the Scavenger cannon). The Rock-It launcher will look for the "OnRockItLaunch" event on the launched item, and if it finds it, will run the event with two parameters: The Rock-It launcher that the item was launched from, and the player who fired his weapon (which can be nil if the rock-it was fired while not being held by a player). To set up a Rock-It Launcher triggered effect on one of your items, you need the following event defined in the itemtype serverside:
[lua]
function ITEM:OnRockItLaunch(iRockitLauncher,pl)
--Put code here
end
[/lua]
Bug fixes:
The grenade's view model is now flipped.
Active grenades will avoid merging now.
The red flash of an active grenade is in the background of the item slot as previously intended
Other changes:
Grenades in a Rock-It Launcher will become live after being launched
Flechettes can be fired in bulk, shotgun style by loading them into a Rock-It Launcher
Thanks, yay! I think I'm going to be ready to open up an "Alpha" testing server today, if I could get you added on Steam, I'd invite you once it's up, theJ89.
Some random item-related questions coming as soon as I remember what they were....
Here's one, do you know of an easy way to make it easy to tell that an entity is part of Itemforge (that is, holdable)? Like a faint glow or something that shows when you first look at something.
-snip wrong thread-
Sure, it's theJ89 on Steam.
If you hold [c] and mouseover an item in the world, you'll see a glowing outline (that indicates you can do stuff like rightclicking it, drag/dropping it, etc).
I set up the glow effect in the base item's OnDraw3D event (you can check itemforge/items/base_item/events_client.lua for the original). You can extend or override any itemtype (including the base itemtype) by making an extend/ folder in it's folder, and then placing extension folders in there (works similar to placing an addon into garrysmod/addons/).
If you want to extend base_item, for instance, you could make folder(s) itemforge/items/base_item/extend/glowing/. Put a shared.lua or init.lua/cl_init.lua in there (like you were making a new item) and then in that file, put whatever code you want to add to or override in base_item.
For example, I made a shared.lua, and just copy/pasted the default OnDraw3D and took out the "mouse hovering" check, then replaced it with a "dropped in world check" so it glows all the time, as long as it's dropped in the world (if you took that out, it would glow while being held by players, or when showing up in an item slot.)
[lua]
if SERVER then AddCSLuaFile("shared.lua") end
if CLIENT then
local mWhite=Material("white_outline");
local oneVector=Vector(1,1,1);
function ITEM:OnDraw3D(eEntity,bTranslucent)
if self:InWorld() then
--Draw an outline around the entity
render.SuppressEngineLighting(true);
render.SetAmbientLight(1,1,1);
render.SetColorModulation(1,0.7,0);
SetMaterialOverride(mWhite);
local f=1 + math.abs(-1+2*math.fmod(CurTime()*5,1))*0.1;
eEntity:SetModelScale(Vector(f,f,f));
eEntity:DrawModel();
--Reset things we temporarily changed to draw the outline
eEntity:SetModelScale(oneVector);
SetMaterialOverride(nil);
render.SuppressEngineLighting(false);
end
--Draw the model normally (with a different color/material if one has been set)
local c=self:GetColor();
render.SetColorModulation(c.r/255,c.g/255,c.b/255);
render.SetBlend(c.a/255);
SetMaterialOverride(self:GetOverrideMaterialMat());
eEntity:DrawModel();
SetMaterialOverride(nil);
end
end
[/lua]
If you ever want to get rid of an extension, you can just get rid of the extension folder.
Also, worth mentioning, if two extensions have the same thing, then the last extension that loaded gets the final say.
e.g. you have two extensions that override OnDraw3D, then the last extension's OnDraw3D becomes the new OnDraw3D.
Edit:
I just noticed the extensions are broken, I tested the code I gave in the example above and it works, but I'll have to do a commit for the extension to load.
I just added you, my name is currently The Survivor. It's normally Rayne Mercury. I ended up not getting anything done today. I might finish up what needs to be done tonight, but perhaps not. It's hard for me to do stuff like this during the week, due to work, and it gets worse up until Friday. So maybe after a good long sleep tonight I'll be ready to crack down and finish.
Before the end, I have to really sit down and learn Wiremod. I never did before, it was way too complicated for me back when I used to play Garry's Mod sandbox (which I only played offline, singleplayer). It's going to add a lot of functionality to this game.
I was going to ask a question, but I just answered it myself in my head.
I could sit here and come up with every question I need answered before I'm finished with the gamemode, but then I'd probably not learn anything. I'm going to start working things out on my own for a bit and see what I can do.
[b]Status Update:[/b]
Beta SVN updated.
Itemforge is version 0.25 now
Bug fixes:
Grenade viewmodel flip was accidentally turned off (I had the wrong name for the property). Fixed.
Extensions to itemtypes load correctly now (before, the path to the extensions was being built incorrectly).
Other changes:
Sawblades were way too heavy; a single sawblade wasn't fitting into the Rock-It launcher. This was due to an error in computing the weight before. I changed it to 5kg until I get around to calculating an accurate weight for it.
Do you think it's possible to make Itemforge NPCs? Same way we have items, just with NPCs?
Not sure I follow, please elaborate.
Perhaps he means like manhacks and city scanners? I don't know.
Sorry, I had very little time earlier. I don't know how Source or Lua NPCs work yet, so I don't know specifics. What if there was a base_NPC that had all the basic information that all NPCs need in order to function, and then you could have NPC_human based on that, and NPC_soldier based on that. Same system as items, just the entities turn out to be NPCs. Not sure how well the concept of "one NPC becomes all" would work, since that's how items work. Hope this makes some sense.
I would just go with a scripted NPC. Integrating it into itemforge doesn't have a lot of benefit (ex, how often do I need to put a combine soldier into my inventory? or how often do I need to hold DOG as a weapon?)
Although, I do see the benefit of making machines, like manhacks, rollermines, and scanners into items. However, more likely what I would do is just have an item called manhack/rollermine/scanner that when you try to drop it into the world, it creates a manhack/rollermine/scanner NPC and then the item gets removed. You could probably write code that would allow you to press [E] on the rollermine, which would remove it and then create a rollermine item in your inventory, for example. (this gives the illusion that the rollermine NPC and the rollermine item are the same thing). That would probably be close enough.
I do a similar approach with the ropes and the rope item; a rope_end entity (that isn't an item) is created when you cut a rope, and then when you use it, it removes the rope_end (and the rope constraint itself) and then creates a rope item in your inventory. Likewise, holding the rope item, then clicking two points close enough together removes the rope item, and creates the rope constraint (that isn't a part of Itemforge).
I'm just completely lost when it comes to making/using NPCs code-wise, and because I'm familiar with Itemforge, I wondered if it'd be possible to make creation/management as easy as Itemforge is.
Garrysmod already has some scripted NPCs but I don't really know anymore about them than you.
I've made like, one thing that could even be remotely considered a scripted NPC. I made a scripted turret that you could give SWEPs, it would look for targets and then fire at them. If you struck it, it loses health, and if it gets too damaged it 'dies'. But, custom zombies? Custom humans? Nope, never made any. Even if it was pertinant to Itemforge, I wouldn't know where to start or what to include.
Also, feature creep is something I have to be very careful with. One of the reasons Itemforge has been in development so long is because I keep adding things that I didn't originally intend to add.
Some things are small and trivial, and I don't have any trouble adding them if it makes someone's life easier. But, if I have to design a whole new component and/or change the rest of the system to accommodate it, then it comes down to whether all the effort is really worth the pain. If I were making, like, a general purpose gamemode development toolkit, then yeah, I would probably include something to make NPCs easier to create. But, the focus of Itemforge in on the items/inventories, and I need to stay true to that if I ever want to finish.
Yeah, I wasn't suggesting you try to include it, just wondered what you thought of the idea. Maybe I should stop throwing new ideas to distract you, and let you finish the core.
Hi. Not sure if this is still active but anyways...
I was wondering if there is a way to spawn itemforge items via console without using the debug menu. My intention mostly is to make an entity that works as a dispenser, you use it and it spawns X item, like itemforge's smg ammunition or something.
Dont bumb old threads please.
[QUOTE=James xX;31826646]Dont bumb old threads please.[/QUOTE]
It was only three months, it's not like it has been three years.
It's still long enough
Then should I assume that the project is dead and no longer being worked on? Or that I can't ask stuff about it?
Sorry, you need to Log In to post a reply to this thread.