I'm Live!
Watch Now

Creating Slayer’s Ban Hammer from scratch – The LUA

<< Creating Slayer’s Ban Hammer from scratch – The TRE

Ok, we need to let the server know about our new binary object in the TREs.
This is simple LUA, it’s purely definition and include files.
So first we need to decide where we’re going to put our weapon object definition file.
This may be different if you work on different servers, but as this is a custom object developed by a member of the team here (Slayer), and as there are already folders for two-handed weapons, it goes something like this:
bin/scripts/objects –> all objects go in here
bin/scripts/objects/custom_content –> this is where we put non-emu objects
bin/scripts/objects /custom_content/weapons/melee/2handed –> the logical place for two handed weapons
bin/scripts/objects /custom_content/weapons/melee/2handed/custom –> where our custom weapon will go.
You’ll probably have to create this folder, and various files in the folders above to point down here. so, it’s time to open your editor and create a blank file called banhammer.lua
we’ll come to the other two files shortly
Here’s the banhammer.lua to cut and paste, let’s break it down
object_weapon_melee_2handed_custom_banhammer = object_weapon_melee_2handed_custom_shared_banhammer:new {

    playerRaces = { "object/creature/player/bothan_male.iff",
                "object/creature/player/smc_female.iff",
                "object/creature/player/smc_male.iff",
                "object/creature/player/talz_male.iff",
                "object/creature/player/talz_female.iff",
                "object/creature/player/togruta_female.iff",
                "object/creature/player/togruta_male.iff",
                "object/creature/player/weequay_male.iff",
                "object/creature/player/weequay_female.iff",
                "object/creature/player/nautolan_male.iff",
                "object/creature/player/nautolan_female.iff",
                "object/creature/player/nightsister_female.iff",
                "object/creature/player/nightsister_male.iff",
                "object/creature/player/nikto_male.iff",
                "object/creature/player/nikto_female.iff",
                "object/creature/player/quarren_male.iff",
                "object/creature/player/quarren_female.iff",
                "object/creature/player/ishi_tib_male.iff",
                "object/creature/player/ishi_tib_female.iff",
                "object/creature/player/hutt_female.iff",
                "object/creature/player/hutt_male.iff",
                "object/creature/player/gran_male.iff",
                "object/creature/player/gran_female.iff",
                "object/creature/player/gotal_male.iff",
                "object/creature/player/gotal_female.iff",
                "object/creature/player/aqualish_female.iff",
                "object/creature/player/aqualish_male.iff",
                "object/creature/player/bith_female.iff",
                "object/creature/player/bith_male.iff",
                "object/creature/player/chiss_female.iff",
                "object/creature/player/chiss_male.iff",
                "object/creature/player/devaronian_female.iff",
                "object/creature/player/devaronian_male.iff",
                "object/creature/player/bothan_female.iff",
                "object/creature/player/bothan_male.iff",
                "object/creature/player/human_male.iff",
                "object/creature/player/human_female.iff",
                "object/creature/player/ithorian_male.iff",
                "object/creature/player/ithorian_female.iff",
                "object/creature/player/moncal_male.iff",
                "object/creature/player/moncal_female.iff",
                "object/creature/player/rodian_male.iff",
                "object/creature/player/rodian_female.iff",
                "object/creature/player/sullustan_male.iff",
                "object/creature/player/sullustan_female.iff",
                "object/creature/player/trandoshan_male.iff",
                "object/creature/player/trandoshan_female.iff",
                "object/creature/player/twilek_male.iff",
                "object/creature/player/twilek_female.iff",
                "object/creature/player/wookiee_male.iff",
                "object/creature/player/wookiee_female.iff",
                "object/creature/player/zabrak_male.iff",
                "object/creature/player/zabrak_female.iff" },

    attackType = MELEEATTACK,
    damageType = LIGHTSABER,
    armorPiercing = HEAVY,
that’s the first two parts of the file, most of it is taken up with specifying the species that can use the weapon. I wish there was an “all_species” option.
    xpType = "combat_meleespecialize_2handed",

    certificationsRequired = { },
    creatureAccuracyModifiers = { "2handed_accuracy" },
    defenderDefenseModifiers = { "melee_defense" },
    defenderSecondaryDefenseModifiers = { "counterattack" },
    defenderToughnessModifiers = { "2handed_toughness" },
    speedModifiers = { "2handed_speed" },
    damageModifiers = { },

    -- The values below are the default values.  To be used for blue frog objects primarily
    healthAttackCost = 1,
    actionAttackCost = 1,
    mindAttackCost = 1,
    forceCost = 0,

    pointBlankRange = 0,
    pointBlankAccuracy = 100,

    idealRange = 5,
    idealAccuracy = 100,

    maxRange = 5,
    maxRangeAccuracy = 100,

    minDamage = 10000,
    maxDamage = 45000,

    attackSpeed = 0.1,

    woundsRatio = 100,
and finally part 4 – I’ll post the entire file so you can just open that
    numberExperimentalProperties = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    experimentalProperties = {"XX", "XX", "SR", "SR", "SR", "SR", "SR", "SR", "SR", "XX", "SR", "XX", "SR", "SR", "SR"},
    experimentalWeights = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    experimentalGroupTitles = {"null", "null", "expDamage", "expDamage", "expDamage", "expDamage", "exp_durability", "expRange", "expRange", "null", "expRange", "null", "expEffeciency", "expEffeciency", "expEffeciency"},
    experimentalSubGroupTitles = {"null", "null", "mindamage", "maxdamage", "attackspeed", "woundchance", "hitpoints", "zerorangemod", "maxrangemod", "midrange", "midrangemod", "maxrange", "attackhealthcost", "attackactioncost", "attackmindcost"},
    experimentalMin = {0, 0, 1000, 10000, 0.1, 10, 10000, 10, 10, 25, 10, 50, 0, 0, 0},
    experimentalMax = {0, 0, 10000, 100000, 1.0, 100, 100000, 100, 100, 45, 100, 100, 0, 0, 0},
    experimentalPrecision = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    experimentalCombineType = {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}

ObjectTemplates:addTemplate(object_weapon_melee_2handed_custom_banhammer, "object/weapon/melee/2handed/custom/banhammer.iff")

The first line :

object_weapon_melee_2handed_custom_banhammer = object_weapon_melee_2handed_custom_shared_banhammer:new {
the left hand side of the alignment specifies the template name, usually broken down into the path for the object (without any custom_content in there) object_weapon_melee_2handed_custom_banhammer the right hand side creates a new array object containing all the values within object_weapon_melee_2handed_custom_shared_banhammer:new : NOTE THE USE of shared_ in this declaration – this is important. In this file, it’s the only place that it’s needed

the next statement defines the player species that can use this weapon. after that we have 3 lines

    attackType = MELEEATTACK,
    damageType = LIGHTSABER,
    armorPiercing = HEAVY,

as this is the admin Banhammer we’ve set them to uber values.

   certificationsRequired = { },
    creatureAccuracyModifiers = { "2handed_accuracy" },
    defenderDefenseModifiers = { "melee_defense" },
    defenderSecondaryDefenseModifiers = { "counterattack" },
    defenderToughnessModifiers = { "2handed_toughness" },
    speedModifiers = { "2handed_speed" },
    damageModifiers = { },
    -- The values below are the default values.  To be used for blue frog objects primarily
    healthAttackCost = 1,
    actionAttackCost = 1,
    mindAttackCost = 1,
    forceCost = 0,
    pointBlankRange = 0,
    pointBlankAccuracy = 100,
    idealRange = 5,
    idealAccuracy = 100,
    maxRange = 5,
    maxRangeAccuracy = 100,
    minDamage = 10000,
    maxDamage = 45000,
    attackSpeed = 0.1,
    woundsRatio = 100,

as it’s admin, again, we’ve removed any requirement to be certified for this weapon. The modifiers are pretty irrelevant here as the weapon’s not going to be used in real combat, but you can examine other weapons’ modifiers and see how they work.

The next part, I’ll freely admit, I’m not sure why it’s here, as the experimental values are usually part of the draft schematic for when the weapon is crafted.

    numberExperimentalProperties = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    experimentalProperties = {"XX", "XX", "SR", "SR", "SR", "SR", "SR", "SR", "SR", "XX", "SR", "XX", "SR", "SR", "SR"},
    experimentalWeights = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    experimentalGroupTitles = {"null", "null", "expDamage", "expDamage", "expDamage", "expDamage", "exp_durability", "expRange", "expRange", "null", "expRange", "null", "expEffeciency", "expEffeciency", "expEffeciency"},
    experimentalSubGroupTitles = {"null", "null", "mindamage", "maxdamage", "attackspeed", "woundchance", "hitpoints", "zerorangemod", "maxrangemod", "midrange", "midrangemod", "maxrange", "attackhealthcost", "attackactioncost", "attackmindcost"},
    experimentalMin = {0, 0, 1000, 10000, 0.1, 10, 10000, 10, 10, 25, 10, 50, 0, 0, 0},
    experimentalMax = {0, 0, 10000, 100000, 1.0, 100, 100000, 100, 100, 45, 100, 100, 0, 0, 0},
    experimentalPrecision = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    experimentalCombineType = {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}

and finally, the bit that adds the weapon template and tells the server what these values apply to

ObjectTemplates:addTemplate(object_weapon_melee_2handed_custom_banhammer, "object/weapon/melee/2handed/custom/banhammer.iff") 
object_weapon_melee_2handed_custom_banhammer is the template name, that could be used by admins using the /create <template> command object/weapon/melee/2handed/custom/banhammer.iff is the path to the IFF in the TRE file that you created.

Ok, so we’ve created a text file on the server.

The server now needs to include it in its system edit a file called serverobjects.lua in the same folder as the file you’ve just created. Add the following line :

includeFile("custom_content/weapon/melee/2handed/custom/banhammer.lua")

this tells the server to include your weapon object.

However, the server doesn’t yet know about the serverobjects.lua file, so in each folder above this one, we need another serverobjects.lua file that points to the one below it.

bin/scripts/objects/custom_content/weapon/melee/2handed/serverobjects.lua needs to contain a line such as

includeFile("custom_content/weapon/melee/2handed/custom/serverobjects.lua")

bin/scripts/objects/custom_content/weapon/melee/serverobjects.lua needs to contain a line such as

includeFile("custom_content/weapon/melee/2handed/serverobjects.lua")

bin/scripts/objects/custom_content/weapon/serverobjects.lua needs to contain a line such as

includeFile("custom_content/weapon/melee/serverobjects.lua")

bin/scripts/objects/custom_content/serverobjects.lua needs to contain a line such as

includeFile("custom_content/weapon/serverobjects.lua")

bin/scripts/objects/serverobjects.lua needs to contain a line such as

includeFile("custom_content/serverobjects.lua")

and so on. Most of these will already be in place in the future.

The next file to create is the objects.lua file, in the same folder as your new weapon object file. If you ware working in a folder which already has objects in it, then this file will most likely already exist. into this file goes the following information:

object_weapon_melee_2handed_custom_shared_banhammer = SharedWeaponObjectTemplate:new {
    clientTemplateFileName = "object/weapon/melee/2handed/custom/shared_banhammer.iff"
}
ObjectTemplates:addClientTemplate(object_weapon_melee_2handed_custom_shared_banhammer, "object/weapon/melee/2handed/custom/shared_banhammer.iff")
This is the shared template, I’m not 100% sure of how or why this exists in this form, but it does, so we need to be aware of it. There should be FOUR occurrences of shared_ in this file, the template name, the clientTemplateFilename, where it adds the client template, and finally the path to the IFF in your TRE file, even though the IFF doesn’t have shared_ in its name.

That’s it for declaring the TANO for the new weapon.

It won’t work though, and it’s something you’ll forget to do frequently.
There’s a file called bin/scripts/objects/allobjects.lua
This file contains a list of all the objects.lua files in the system.
I don’t know why it’s all in one file and not broken down like the serverobjects.lua files have been, but that’s what we’re working with at the moment.
Find a spot in the file that refers to a folder close to the one that you’re working in, so maybe custom_content/weapon/melee/2handed/objects.lua and add a line to the path to your new objects file includeFile(“custom_content/weapon/melee/2handed/custom/objects.lua”)

 

You should now be ready to go.
restart your server, load in your admin toon, then try the following command: /object createitem object/weapon/melee/2handed/custom/banhammer.iff
NOTE : no shared_ in the filename, and it points to the exact path of the IFF in your TRE file.

Creating Slayer’s Ban Hammer from scratch – The Draft Schematic (coming soon) >>

Affiliates