Welcome, Guest. Please login or register.
Did you miss your activation email?
September 19, 2024, 09:05:46 PM
Home Help Login Register
News: Trouble in Terrorist Town? Site here, forum here.

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Adding Grenades
Pages: [1]
Author Topic: Adding Grenades  (Read 3930 times)
TheDmac
Poster

Posts: 50


« on: February 13, 2011, 06:41:12 AM »

I've had no problems with adding guns at all to TTT, but Grenades are being a bitch to add. No matter what type of nade i add, i get

ERROR Translation of ammo grenade not found

I also noticed i can't throw any custom nades, I've tried a few and they normally return that same error. I'm also talking about normal HE grenades, not smokes or flash bangs. I know nothing about lua, at all, but i assume it has to do with this? They simple make the click noise (No ammo sound) and give me the above error error.

This the ammo type thingo i had added
SWEP.Primary.Ammo        = "item_ammo_grenade"

That's probably completely wrong, and i think by the looks of it that's the problem? I'm completely hopeless at LUA, so don't laugh :P

« Last Edit: February 13, 2011, 06:44:12 AM by TheDmac »

www.VersonoGaming.net
Australia TTT Server - Custom Content.
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #1 on: February 13, 2011, 09:17:55 AM »

Post the code.

The translation error is because your grenades use ammo (unlike TTT's grenades), so when you pick them up TTT tries to show the name of the ammo by looking it up in the language file, but it can't find it (because it's not there). This is fairly harmless, not a Lua error, and it is not why your grenades don't work.
TheDmac
Poster

Posts: 50


« Reply #2 on: February 13, 2011, 09:57:53 AM »

How would i go about making it like a normal grenade, and not use ammo of any sort? Or do they use some sort of ammo that i don't know about. Do the default ttt weapons have shared.lua files i can learn from? I couldn't see any (For the ones i looked at anyway).  I basically just want it like a normal nade, that goes away from inventory once thrown.

If the above 2 questions go un-answered i'll go ahead and post the code for you to look at. If the default ttt grenades had shared.lua files i could learn easily, though.
« Last Edit: February 13, 2011, 11:10:42 AM by TheDmac »

www.VersonoGaming.net
Australia TTT Server - Custom Content.
phoenixf129
Poster

Posts: 476


I Rise from the Ashes.


« Reply #3 on: February 13, 2011, 11:28:48 AM »

All TTT weapons have shared.lua files -> gamemodes/terrortown/entities/weapons/weapon_ttt_<name>/shared.lua


Software Upgrade Paradox - If you improve a piece of software enough times, you eventually ruin it.
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #4 on: February 13, 2011, 11:42:18 AM »

TTT grenades consist of two parts: a SWEP and a projectile.

For example, the incendiary grenade SWEP is in:
/terrortown/entities/weapons/weapon_zm_molotov/shared.lua

It uses weapon_tttbasegrenade as its SWEP.Base, and that base does most of the work. The incendiary weapon really just sets its model and stuff, as well as SWEP:GetGrenadeName(), which specifies what projectile the SWEP should throw.

When a grenade SWEP is "fired", it creates the SENT named by GetGrenadeName and propels it forward. All grenades do this, so if you look at the SWEPs for the discomb or smoke grenade, they only differ in the model stuff and which SENT they throw. The grenade base takes care of all the throwing and stuff.

If you checked the incendiary SWEP, you will have noted its projectile is set as "ttt_firegrenade_proj", which is here:
/terrortown/entities/entities/ttt_firegrenade_proj/shared.lua

Again, most of the work is done in the entity's base class, in this case ttt_basegrenade_proj. All a grenade projectile SENT does is specify how it looks and how it should explode. The explosion is created in ENT:Explode(tr), where "tr" is a trace towards the ground that the grenade is lying on (for effects). The incendiary projectile checks some things, creates some effects, and creates fire entities.

So, to create or port a new grenade, you can copy one of the existing grenade SWEPs and just change the name/model/etc. Then you put the name of the grenade projectile entity you're about to make in the GetGrenadeName function. That's it for the SWEP. You then copy one of the existing grenade projectile SENTs and again change name, model, the works. Lastly, you change ENT:Explode to create the explosion you want. If you're porting a grenade, this will hopefully just be a copy/paste job.

That should be it. It should be as easy as creating bog standard TTT guns, only the explosion part requires some Lua work.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Adding Grenades « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.009 seconds with 17 queries.