DamageType plugin

Introduction:

This plugins allow GameLogger to recognize damagetype that come with mods, bonuspacks etc. When heavydamage event happens or a someone dies, these events trigger HDamageEvent function or KillEvent function in EGameStats, passing damagetype, so logger class can see what caused that damage and write an appropriate string into log. If it was some damagetype GameLogger can't recognize, it looks for match in damagetype plugins. If it is found there he takes the appropriate action string from that plugin. In brief, damagetype plugin is a library of damage types, allowing gamelogger to recognize more damage types than it can by default.

Making damagetype plugin.
I made this one as simple as it is possible and that you can make it using UnrealEd, if you're quite new to Unreal editing. If that's about you, you may go right to "UnrealEd way" chapter and skip the first one

Common way (for experienced scripters).

Most of "how-to" instruction are in GameLoggerWeaponDamagePlugin comments. If you're looking for an example look at ECEDamageTypes.uc there. Here's just a brief overview of a subclass options and how it works.

The plugin should be a subclass of GameLoggerWeaponDamagePlugin in order to be loaded. The available plugins are added to MutGameLogger properties and it assigns them to EGameStats. GameLogger's main module - EGameStats loads them in it's PreBeginPlay event. Then in the HDamageEvent or KillEvent if none of the hardcoded damagetypes match the given one, it checks the plugins in the order they were added. In case of HDamage event it also checks if this damagetype should be logged. If match is not found in any plugin both functions return " unknown weapon " .

The plugin holds an array of structs containing three variables:

bDontLogHD    if this damage type should be ignored by HDamage Event. Set it to true if it's a damagetype that always kills the player or kills it in 99% of times.
thisAction enter the name of the weapon. The string must have a space in the beginning and in the end.
thisDamagetype    damagetype that will be written as the string above.


UnrealEd way (for beginners).

Start Unreal Ed and go to the Actor Browser. Deselect "Placeable classes only?", make sure you have the package containing new damagetypes you want to add is loaded and open GameLogger.u package. Make sure Then select Actor -> Info -> GameLoggerPlugin -> GameLoggerWeaponDamagePlugin. Right click on it and select "New..." option.



Enter your package name and classname and click "OK".



Close the opened script editor and again find damagetype plugin and and select your plugin that is under it. Right click your plugin and select "Default properties..." Open section GameLoggerPlugin and spend some time naming your plugin (FriendlyName) and writing a brief description for it (Description), as these fileds will be used in the future versions of GameLogger.



Now select the next section - GameLoggerWeaponDamagePlugin and select the only option there - "ExtraDamageType". You'll see that two buttons will appear on the right - "Empty" and "Add". Click add and you'll see that the "[0]" record appeared. Now there's three options.

bDontLogHD    if this damage type should be ignored by HDamage Event. Set it to true if it's a damagetype that always kills the player or kills it in 99% of times.
thisAction enter the name of the weapon. Note that it will be a part of the following sentences "Killer killed victim with our weapon at location" and "Instigator damaged victim with our weapon at location". The string must have a space in the end and the beginning.
thisDamagetype    damagetype that will be written as the string above. Select the field and select the required damagetype class from the drop-down list.




For each new damagetype click "Add" (if you'll again select the "ExtraDamageType") or "Insert" (if you'll select the "[0]"). Note if you want to remove the record, just select it and click the "remove" button.

Now, go back to the Actor Browser, right-click your class and select "Edit Script..." option. In the Script Editor go to Tools Menu and select Compile Changed. After script has compiled return to the Actor Browser and in the View Menu select the "Show Packages" option. In the bottom of the Actor Browser will apear the section with the checkboxes with package names. Find your package name there and select checkbox left to it. Now click the save button in the toolbar.



Congratulations! You've done! But you'll have to do a little more. Now unselect "Show Packages", as when the next time you'll run the editor, the packages will be shown, but "Placeable classes only?" checkbox will dissappear. Though it is fixed simply by uncheckling "Show Packages", it's the most annoying bug of UnrealEd for me, as I don't work with it much.