• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Medic M79 Grenade Launcher?

Hi. I'm new to UnrealScript modding. I have known a bit about C++. I decided to begin my modding by editing the existed M79 from Demolitionist to the Medic Grenade Launcher (which shoots out medic grenade, if you have not known), to work with Marco's Serverext. I digged into "KFWeap_GrenadeLauncher_M79.uc" and found this piece of code:
Code:
// DEFAULT_FIREMODE
    FireModeIconPaths(DEFAULT_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_Grenade'
    FiringStatesArray(DEFAULT_FIREMODE)=WeaponSingleFireAndReload
    WeaponFireTypes(DEFAULT_FIREMODE)=EWFT_Projectile
[COLOR=#FFFF00]WeaponProjectiles(DEFAULT_FIREMODE)[/COLOR]=class'[COLOR=#FF0000]KFProj_HighExplosive_M79[/COLOR]'
    FireInterval(DEFAULT_FIREMODE)=+0.25
    InstantHitDamage(DEFAULT_FIREMODE)=150.0
    InstantHitDamageTypes(DEFAULT_FIREMODE)=class'KFDT_Ballistic_M79Impact'
    Spread(DEFAULT_FIREMODE)=0.015
    FireOffset=(X=23,Y=4.0,Z=-3)
So, all I need to do is replace "KFProj_HighExplosive_M79" with "KFProj_MedicGrenade", then compile it? (assuming textures and animations don't change)
 
You'll probably also want to change the InstantHitDamageTypes(DEFAULT_FIREMODE), unless you want it to do impact damage. However, you don't want to merely replace these lines of code in KFWeap_GrenadeLauncher_M79.uc, instead you'll need to make your own class that extends KFWeap_GrenadeLauncher_M79. If you're not aware of what I'm talking about, I'll explain it further.
 
  • Like
Reactions: linkedparadise
Upvote 0
Pharrahnox;n2285988 said:
You'll probably also want to change the InstantHitDamageTypes(DEFAULT_FIREMODE), unless you want it to do impact damage. However, you don't want to merely replace these lines of code in KFWeap_GrenadeLauncher_M79.uc, instead you'll need to make your own class that extends KFWeap_GrenadeLauncher_M79. If you're not aware of what I'm talking about, I'll explain it further.

Thanks for reply. I disabled the InstantHitDamageTypes. You mean I should make a copy of this and rename it as "KFWeap_GrenadeLauncher_M79Med" or something like that, right? Also, do I need any more files to be added into compile with, or just this one is enough?
 
Upvote 0
What do you mean you disabled InstantHitDamageTypes? If you just removed the line that set the value for it in KFWeap_GrenadeLauncher_M79, then it will actually still be set, but it will default to the value set by the parent class.

I'm not sure what sort of programming you've done before, but hopefully you're comfortable with Object Oriented Programming (OOP). What we do when we're modding a game using Unreal Engine is we extend classes already defined in the engine, or in the game we're working on (KF2 in this case), and we override any functionality that we want to change. We can also add extra things. So we have our custom class(es), but we need the game to actually use our custom class(es). Luckily, since you're going to be using ServerExt to handle your custom weapon, you simply need to compile your package that contains your custom weapon, and add it to the custom weapons list for ServerExt. If you're not sure about the compilation process or how to structure your package see here for details.

I don't know how much you know about OOP or modding - in general or with Unreal Engine - so if what I've said isn't enough, just tell me what you do know and I'll attempt to fill in any gaps in your understanding, or teach you the process.

I should note that I think you are able to alter the files in the KFGameContent package and not need to compile them, and your changes will be in effect, but this really isn't the way you're meant to do it. It's fine for small things that only you need access to, but if you plan on allowing others to use your mod, it should be done by extending the game's classes. Also it might cause compatibility issues if you try to play online, I don't know.
 
  • Like
Reactions: JackSheepson
Upvote 0
Pharrahnox;n2285995 said:
What do you mean you disabled InstantHitDamageTypes? If you just removed the line that set the value for it in KFWeap_GrenadeLauncher_M79, then it will actually still be set, but it will default to the value set by the parent class.

I'm not sure what sort of programming you've done before, but hopefully you're comfortable with Object Oriented Programming (OOP). What we do when we're modding a game using Unreal Engine is we extend classes already defined in the engine, or in the game we're working on (KF2 in this case), and we override any functionality that we want to change. We can also add extra things. So we have our custom class(es), but we need the game to actually use our custom class(es). Luckily, since you're going to be using ServerExt to handle your custom weapon, you simply need to compile your package that contains your custom weapon, and add it to the custom weapons list for ServerExt. If you're not sure about the compilation process or how to structure your package see here for details.

I don't know how much you know about OOP or modding - in general or with Unreal Engine - so if what I've said isn't enough, just tell me what you do know and I'll attempt to fill in any gaps in your understanding, or teach you the process.

I should note that I think you are able to alter the files in the KFGameContent package and not need to compile them, and your changes will be in effect, but this really isn't the way you're meant to do it. It's fine for small things that only you need access to, but if you plan on allowing others to use your mod, it should be done by extending the game's classes. Also it might cause compatibility issues if you try to play online, I don't know.

Thanks. I put double slashes before the line and thought It would work haha. Well, apparently It worked, as I uploaded a test here:
https://www.youtube.com/watch?v=brLKqeswjNs

So, It is nearly finished. But there are 2 things that struggle me:

1) If you look closely in the video at 0:06, the M79Med weapon slot's name was displayed simply as "Weapon". How can I change that string?

2) Since Serverext hasn't supported custom trader list, I had a look in this thread: http://forums.tripwireinteractive.co...gameinfo-class in order to find a way to push it into trader list. It said:
Now you'll need a class that extends KFGameReplicationInfo, and in the default properties, add the line TraderItems=KFGFxObject_TraderItems'MySdkPackage.DefaultTraderItems'

Now add the line GameReplicationInfoClass=class'Mypackage.MyKFGameReplicationInfo' to the default properties in your gameinfo class.
W̶h̶e̶r̶e̶ ̶c̶a̶n̶ ̶I̶ ̶f̶i̶n̶d̶ ̶t̶h̶o̶s̶e̶ ̶5̶ ̶p̶r̶o̶p̶e̶r̶t̶i̶e̶s̶?̶
OK, I found the first 3, but I don't know what is MyKFGameReplicationInfo and "your gameinfo class"
 
Last edited:
Upvote 0
I wasn't aware of that method of adding the weapon to the trader list. I might check it out at some point. The biggest issue with that is that you have to make a separate game mode just to use your custom weapon. It is better to use only a mutator if you can get away with it, because you can only use one game mode mod at once, but you can use many mutators at the same time.

1) The reason why it shows up as "Weapon" is because you haven't created the localisation file (the .int file). Weapons, as well as some other objects, use strings that are localised, which means that the value of the string variable is dependent on which language you have selected. It is mentioned (but not really explained) in the link you provided:
Next go to your steamapps/kf2/kfgame/localization/int folder and create a .int file with a text editor and name the file the same name as your package with your source code. You'll give your weapon a description here. See the KFGameContent.int for what to put in your int file.
.int files are only for the 'international' language for Unreal Engine which is English. Other languages have different extensions, and belong in different folders within the "localization" folder. For example, files that contain localised strings for the Chinese language have the extension .chn and belong in the Localization\CHN folder.

The Inventory class has localised string variables, such as ItemName. All weapons in KF2 extend KFWeapon, which extends Weapon, which extends Inventory. So the custom weapon that you've created has this localised ItemName variable. The value of localised strings are retrieved from the localisation file associated with the package that the class is located in. There should be a separate section in the localisation file for each class that contains localised strings in the package. It looks like your package name is m79med, so your localisation file would be m79med.int (for the English strings). The name of your custom weapon shows up as "Weapon" because that is the default value, and the default value is used because you don't have an entry for ItemName for your custom weapon in your localisation file. Have a look in Steam\steamapps\common\killingfloor2\KFGame\Locali zation\INT\KFGameContent.int for example of the entries you should have for your custom weapon. The entry for the M79 is:
Code:
[KFWeap_GrenadeLauncher_M79]
ItemName="M79 Grenade Launcher"
ItemCategory="Explosives"
ItemDescription="•Fire mode launches a grenade.\n•Grenade explodes on impact.\n•Only arms itself a few meters downrange so you don't blow your own face off."
Use this as a template for what you should have in your own localisation file.

2) MyKFGameReplicationInfo is your custom class that extends KFGameReplicationInfo, and "your game info class" is your class that extends KFGameInfo (maybe even GameInfo). The link you provided says:
Now you'll need a class that extends KFGameReplicationInfo, and in the default properties, add the line TraderItems=KFGFxObject_TraderItems'MySdkPackage.D efaultTraderItems'
So that's why you have your MyKFGameReplicationInfo class. It doesn't have to have this name. Also, don't include any of the oddly placed spaces in the lines of code on that page, they were added in by the forum due to the strings being too long. Using code tags fixes this though. So the code you're meant to have is:
Code:
TraderItems=KFGFxObject_TraderItems'MySdkPackage.DefaultTraderItems'

Finally, ServerExt does actually have a custom trader list that you can use, it's just not immediately obvious how you should go about using it. I haven't actually tried to add weapons in via ServerExt before, but I've recently adpated Marco's custom trader list code to fit my purposes for the mod I'm working on. It does work.

In the Readme for ServerExt, it says:
CustomItems = Custom trader items, you need to input class name for KFWeaponDefinition classes.
So in KFServerExtMut.ini, you would add CustomItems=PackageName.ClassName. I'm pretty sure you're meant to include PackageName, although it doesn't specifically mention it in the .ini. Usually you would need to though. In your case it would be:
Code:
CustomItems=m79med.m79med
If you wanted to add another item to the trader list, you'd just need to add another CustomItems= entry to the .ini.

Edit: I forgot to address your response to the issue with InstantHitDamageTypes. You have commented it out, meaning that your custom weapon won't be overriding the value of InstantHitDamageTypes(DEFAULT_FIREMODE). All this means is that the parent class's value will be used instead, which as it turns out is KFWeap_GrenadeLauncher_M79. I'm actually not sure how you'd go about 'removing' the damage type all together, maybe set it to class'KFDamageType', or simply None (which could be dodgy). But I guess you don't actually have to remove it, if you don't want the impact to do damage, set InstantHitDamage(DEFAULT_FIREMODE)=0.0. But you might want it to do damage, in which case you could leave the damage type as the m79 damage type, or make your own and customise its values.
 
Last edited:
  • Like
Reactions: linkedparadise
Upvote 0
Pharrahnox;n2286004 said:
I wasn't aware of that method of adding the weapon to the trader list. I might check it out at some point. The biggest issue with that is that you have to make a separate game mode just to use your custom weapon. It is better to use only a mutator if you can get away with it, because you can only use one game mode mod at once, but you can use many mutators at the same time.

1) The reason why it shows up as "Weapon" is because you haven't created the localisation file (the .int file). Weapons, as well as some other objects, use strings that are localised, which means that the value of the string variable is dependent on which language you have selected. It is mentioned (but not really explained) in the link you provided:

.int files are only for the 'international' language for Unreal Engine which is English. Other languages have different extensions, and belong in different folders within the "localization" folder. For example, files that contain localised strings for the Chinese language have the extension .chn and belong in the Localization\CHN folder.

The Inventory class has localised string variables, such as ItemName. All weapons in KF2 extend KFWeapon, which extends Weapon, which extends Inventory. So the custom weapon that you've created has this localised ItemName variable. The value of localised strings are retrieved from the localisation file associated with the package that the class is located in. There should be a separate section in the localisation file for each class that contains localised strings in the package. It looks like your package name is m79med, so your localisation file would be m79med.int (for the English strings). The name of your custom weapon shows up as "Weapon" because that is the default value, and the default value is used because you don't have an entry for ItemName for your custom weapon in your localisation file. Have a look in Steam\steamapps\common\killingfloor2\KFGame\Locali zation\INT\KFGameContent.int for example of the entries you should have for your custom weapon. The entry for the M79 is:
Code:
[KFWeap_GrenadeLauncher_M79]
ItemName="M79 Grenade Launcher"
ItemCategory="Explosives"
ItemDescription="•Fire mode launches a grenade.\n•Grenade explodes on impact.\n•Only arms itself a few meters downrange so you don't blow your own face off."
Use this as a template for what you should have in your own localisation file.

2) MyKFGameReplicationInfo is your custom class that extends KFGameReplicationInfo, and "your game info class" is your class that extends KFGameInfo (maybe even GameInfo). The link you provided says:

So that's why you have your MyKFGameReplicationInfo class. It doesn't have to have this name. Also, don't include any of the oddly placed spaces in the lines of code on that page, they were added in by the forum due to the strings being too long. Using code tags fixes this though. So the code you're meant to have is:
Code:
TraderItems=KFGFxObject_TraderItems'MySdkPackage.DefaultTraderItems'

Finally, ServerExt does actually have a custom trader list that you can use, it's just not immediately obvious how you should go about using it. I haven't actually tried to add weapons in via ServerExt before, but I've recently adpated Marco's custom trader list code to fit my purposes for the mod I'm working on. It does work.

In the Readme for ServerExt, it says:

So in KFServerExtMut.ini, you would add CustomItems=PackageName.ClassName. I'm pretty sure you're meant to include PackageName, although it doesn't specifically mention it in the .ini. Usually you would need to though. In your case it would be:
Code:
CustomItems=m79med.m79med
If you wanted to add another item to the trader list, you'd just need to add another CustomItems= entry to the .ini.

Edit: I forgot to address your response to the issue with InstantHitDamageTypes. You have commented it out, meaning that your custom weapon won't be overriding the value of InstantHitDamageTypes(DEFAULT_FIREMODE). All this means is that the parent class's value will be used instead, which as it turns out is KFWeap_GrenadeLauncher_M79. I'm actually not sure how you'd go about 'removing' the damage type all together, maybe set it to class'KFDamageType', or simply None (which could be dodgy). But I guess you don't actually have to remove it, if you don't want the impact to do damage, set InstantHitDamage(DEFAULT_FIREMODE)=0.0. But you might want it to do damage, in which case you could leave the damage type as the m79 damage type, or make your own and customise its values.

Many thanks for your help, although it didn't list out the weapon in trader, again :(
Here's source code if you wanna try: https://openload.co/f/juyooTItl7I/M79Med.rar
 
Upvote 0
Many thanks for your help, but edit serverextmut.ini still can't get it to work either :(
Here's source code if you wanna try:
M79Med.uc (main file)
Spoiler!


KFWeapDef_M79Med.uc
Spoiler!
 
Upvote 0
Hey, sorry I didn't get back to you sooner. I tried it out and it worked for me using ServerExt. It showed up in the Medic tab. Are you sure that your M79Med package was compiled and published correctly? Let me know exactly what you did, and I'll try to track down where the issue might be. If that doesn't work I'll just tell you exactly what I did.

And sorry about that mix up, you're right it's meant to be the WeaponDef class.
 
Upvote 0
Yeah, I compiled and it appeared a single .u file in Documents\My Games\KillingFloor2\KFGame\Unpublished\.
I put it in my KF2 game folder (\KFGame\BrewedPC\).
I also editted KFServerExtMut.ini in KFGame\BrewedPC\Config\.
I launched the game with command line "open kf-outpost?mutator=serverextmut.serverextmut,m79med.m79med"
Therefore I succeeded in calling it out manually in game (giveweapon m79med.m79med), but it didn't appear in trader list (right column), nor the inventory (left column).
 
Upvote 0
Ah ok, I see a few issues there.

1. You've compiled your package, which gave you the .u file in your Unpublished directory. You'll want to brew your package, rather than copy it from Unpublished\BrewedPC\Script to Published\BrewedPC, or to KFGame\BrewedPC. You can actually just compile and then brew your package without ever needing to move things around. If you want to use your package without brewing it, here's what the tutorial has to say:
5. Test your mod (by running as "unpublished")
Run your mod with an additional command-line parameter, "-useunpublished", to test it before brewing. Brewing will "publish" your content and put it in a Published directory, which the game needs when not using -useunpublished.
I don't actually ever use the unpublished version. I don't know if that's normal or not, but I always brew it before testing it. Here is some information on the 'cooking' process for Unreal Engine: link (you don't need to know anything from here). I'm pretty sure that 'cooking' and 'brewing' are almost exactly the same thing for most purposes, with maybe only a few differences. For Unreal Tournament 3, you have a CookedPC folder instead of BrewedPC.

2. You're not meant to create the folder KFGame\BrewedPC\Config. It's meant to be KFGame\Config. This is why your weapon won't be in the trader, because your .ini wouldn't have been found.

3. Your package isn't actually a mutator. I don't think it will cause any issues by having ?mutator=SomePackage.SomeNonMutatorClass, but it's not going to do anything, as far as I'm aware. You can reference your custom weapon via ServerExt without needed to load it in as its own mutator. So your launch command should be:
Code:
open kf-outpost?mutator=serverextmut.serverextmut

Let me know how you go with it.
 
Last edited:
  • Like
Reactions: JackSheepson
Upvote 0
A few more questions:

What's the difference between "unpublished" and "brewed" exactly?

You mean when I brew my package, the game will automatically recognize it, which means I don;'t have to move files between locations? Also, where do I use the command line "-unpublished"? Steam launch option, or creating new game?

Oh, and I just mistyped the address. I editted KFServerExtMut.ini in KFGame\Config\ and it didn't work.

Finally, I loaded the weapon in command line just to prove that I can spawn it in game; it worked with a command but the trader
 
Upvote 0
I'm not sure exactly what brewing does, but according to the link I gave you it can make load times faster (depending on what's in your package) and is what the game recognises by default. I think the -useunpublished is used when compiling:
Code:
kfeditor make -useunpublished
I've never used this before, but I think I really should ;). After doing some reading, it looks like copying files from Unpublished to Published isn't unusual like I thought it was. Yes, brewing it does handle the 'copying' for you, so you don't have to move the files manually. Well, not the .u files anyway. Some files, including localisation files, need to be copied manually. Have a look at the Publishing and Cooking section in the following link for some useful information on using Unpublished and Published mods: link.

Ok, the fact that you can spawn it in shows that your package has been compiled correctly and that your weapon can be successfully referenced and loaded - which I should've realised before.

So it probably has something to do with ServerExt then. This is the exact (copy and paste) entry I have in KFServerExtMut.ini:
Code:
CustomItems=M79Med.KFWeapDef_M79Med
If yours doesn't match that, then that's the problem (or one of the problems). I know that's what you have in one of your above posts, but it's best to confirm it anyway.

Is ServerExt actually working properly? Is it the latest version? Does setting bKillMessages=False or bDamageMessages=False in the .ini actually prevent the kill and damage messages?

Also, does the log file tell you anything useful? If you don't know where to find the log file or what to look for in it let me know.
 
Last edited:
Upvote 0
it worked with a command but the trader

KFServerExtMut.ini
Code:
CustomItems=M79Med.KFWeapDef_M79Med

*I always add a file to the INT directory of my server and push it to my clients.

M79Med.int

Code:
[KFWeap_M79Med]
ItemName="KFWeap_M79Med Grenade Launcher"
ItemCategory="Explosives"
ItemDescription="•Fire mode launches a grenade.\n•Projectile has healing properties with toxic damage to zeds.\n•Blow the sh!t out of them."

DOWNLOAD EXAMPLE

*This file when added to INT directory will enable game to translate info in trader for recognition and should be on both server and client. If using ServerExt you wont have to worry about that as its already built into the mod. If using a mutator it would have to be hardcoded with item description and use localization file info above. This has been an ongoing problem with current setup TW has in place for modders.


MYVERSION

Code:
    // DEFAULT_FIREMODE
    FireModeIconPaths(DEFAULT_FIREMODE)=Texture2D'ui_firemodes_tex.UI_FireModeSelect_Grenade'
    FiringStatesArray(DEFAULT_FIREMODE)=WeaponSingleFireAndReload
    WeaponFireTypes(DEFAULT_FIREMODE)=EWFT_Projectile

    WeaponProjectiles(DEFAULT_FIREMODE)=class'KFProj_MedicGrenade'  //Firemode damage type Switch different types from other weapons
    FireInterval(DEFAULT_FIREMODE)=+0.25
    InstantHitDamage(DEFAULT_FIREMODE)=150.0 //Damage dealt
    InstantHitDamageTypes(DEFAULT_FIREMODE)=class'KFDT_Ballistic_M79Impact'
    InstantHitDamageTypes(BASH_FIREMODE)=class'KFDT_Bludgeon_M79'  //damage type
    Spread(DEFAULT_FIREMODE)=0.015
    FireOffset=(X=23,Y=4.0,Z=-3)

I wish you luck and have fun with it try different things. ;)
 
Last edited:
Upvote 0
Thanks. I'm using the latest version of ServerExt, downloaded yesterday. This is my exact copy of KFServerExtMut.ini located in ...\SteamApps\common\killingfloor2\KFGame\Config.
Spoiler!

Now that you mentioned it, changing "bKillMessages" and "bDamageMessages" both to "False" doesn't disable the damage dealt announcement in the left corner of the screen. This must be something wrong with ServerExt.
 
Upvote 0
Oh well there's you're problem (I think). It's meant to be located in Documents\My Games\KillingFloor2\KFGame\Config. I don't know for sure, maybe you can install it in your steam directory... Anyway, try putting it in the My Games directory instead. Where is ServerExt located?

Since changing those values in the .ini had no effect, it probably means that the .ini is still not being found. I'm hoping that moving it to the My Games directory will fix this.
 
Upvote 0
Are you using a subdir for your configs? If editing the INI does nothing you either have the INI in the wrong folder, or you are not actually running the mod. And I am assuming you are running this offline by the path you are using, not a server? I haven't looked at ServerEXT but perhaps it's a server mod only?

Pharrahnox;n2286111 said:
Oh well there's you're problem (I think). It's meant to be located in Documents\My Games\KillingFloor2\KFGame\Config. I don't know for sure, maybe you can install it in your steam directory...

It really depends on your configs and what you are doing. It can work in either directory. Also, for what it's worth, I've never brewed/cooked/ or used unpublish for any mods i've written and I've never used them in the "my documents" folder. That's just how I had my end setup.
 
Last edited:
Upvote 0
Slie;n2286147 said:
It really depends on your configs and what you are doing. It can work in either directory. Also, for what it's worth, I've never brewed/cooked/ or used unpublish for any mods i've written and I've never used them in the "my documents" folder. That's just how I had my end setup.
Yeah I thought that maybe it could work in either, but it looks like linkedparadise might have had the .u in My Games, and the .ini in Steam. In regards to publishing, it looks like I interpreted the modding tutorial strangely, but hey, it works ;).

linkedparadise;n2286168 said:
Thanks :D You're right. The configs were meant to be extracted to \Documents\My Games\KillingFloor2\KFGame\Config. The first time I got there, I noticed it right away. Now it's working smoothly.
I'm glad you have it working now. I look forward to trying out your weapons some time if you release them to the public.
 
Upvote 0