[Modding Question] How do I add new items?


Recommended Posts

So, I'm trying to mod in some new weapons, or at least one new weapon for my Violence is Bad mod. I was wondering how would that work? I'm trying to add new descriptions, an entirely new weapon, make it unique to a single character, so having it restricted to one character. I'm trying to figure it out but the last time I tried it caused the game to not boot up.

 

Any one here got a tutorial they can give me so I can better understand how to do this?

Link to comment
Share on other sites

This is a pre-update 11 guide as I am having issues with getting the items I was working on to work again (worked pre-update), seems to be something with the Strings.lua causing issues when it is modified as giving them items already in game through the method provided works. I'll leave this here in case someone finds a solution to use this method. I will update this post if something changes or a solution to the black startup screen in found.

 

Make sure you use commas after each line break, otherwise there is a good chance the game will outright break.

 

This is a small sample from an older mod I was working on that has been on hold for a bit, the same concept should apply to ranged weapons as well. anything beginning with -- is either not code or implemented.

 

    item_nika_knife = util.extend(melee_template)
    {
        name = STRINGS.ITEMS.NIKA_KNIFE,
        desc = STRINGS.ITEMS.NIKA_KNIFE_TOOLTIP,
        flavor = STRINGS.ITEMS.NIKA_KNIFE_FLAVOR,
        --The 3 items above draw from the Strings.lua file
        icon = "itemrigs/FloorProp_AmmoClip.png",
        profile_icon = "gui/icons/item_icons/items_icon_small/icon-item_tazer_small.png",
        profile_icon_100 = "gui/icons/item_icons/icon-item_tazer.png",        
        --profile_icon = "gui/items/icon-tazer-ftm.png",
        requirements = {  },
        traits = { damage = 2, lethalMelee = true},
        value = 500,
        --there is a way to make items not spawn in the game world, reference other exclusive agent items for the value needed.
        floorWeight = 1,
    },      

 

 

This will allow the weapon to exist, but it won't have any unique text if any. The next thing you need to edit is the Strings.lua

 

Following the format of other items, you should arrange the text to look something this. Make sure that the names it is trying to draw from are the same as they are listed in the Strings.Lua

 

        --Stringname = Ingame text
        NIKA_KNIFE = "NIKA PLACEHOLDER KNIFE",
        NIKA_KNIFE_TOOLTIP = "Fatal melee damage.",
        NIKA_KNIFE_FLAVOR = "PLACEHOLDER",

 

 

This should let you generate an item with a designated name and description.

 

To add on to an agent for their starting items, navigate to their location in the agentdefs.lua and find the line Upgrades

 

 

        kanim = "kanim_female_sharpshooter_2",
        hireText = STRINGS.AGENTS.NIKA.RESCUED,
        centralHireSpeech = SCRIPTS.INGAME.CENTRAL_AGENT_ESCAPE_NIKA,
        traits = util.extend( DEFAULT_TRAITS ) { shields = 0, shieldsMax = 0, mp=8, mpMax = 8 },
        skills = util.extend( DEFAULT_SKILLS ) {},
        startingSkills = { },
        abilities = util.tconcat( {  "sprint" }, DEFAULT_ABILITIES ),
        children = {}, -- Dont add items here, add them to te upgrades table in createDefaultAgency()
        sounds = NIKA_SOUNDS,
        speech = speechdefs.sharpshooter_2,
        blurb = STRINGS.AGENTS.NIKA.ALT_1.BIO,
        upgrades = { "augment_nika", "item_nika_pistol", "item_nika_knife" },  

        --this line adds them to their starting loadout, in this case I am editing Nika to give a unique pistol and knife.

 

You can test giving them new items by just their "upgrades" selection with items already in game, it seems that the Strings.lua is causing the issue.

 

It appears that some things have changed with the way that the agents work in terms of compatibility, most of this tutorial still applies though you might want to check with the Dev mode that Cyberboy2000 suggested since there are some strange things that can happen involving commondefs.lua.

Link to comment
Share on other sites

Well, it depends on what type of weapon you want to make. The best thing you can do is to look at the existing items and try to understand what does what. Puritifyer already gave you an example, here's another one.

item_nika_pistol = util.extend( commondefs.weapon_reloadable_template )    --name and type of item
 {
      name = "NIKA'S HAND CANNON",    --You can use raw strings instead of modifying strings.lua
      desc = "Ranged targets. Lethal damage.",
      flavor = "Nika's personal plasma cannon.",   
      icon = "itemrigs/FloorProp_Pistol.png",   --The graphics used. Pretty obvious 
      profile_icon = "gui/icons/item_icons/items_icon_small/icon-item_gun_pistol_small.png", 
      profile_icon_100 = "gui/icons/item_icons/icon-item_gun_pistol.png",   
      equipped_icon = "gui/items/equipped_pistol.png",
      traits = { weaponType="pistol", baseDamage = 1, ammo = 2, maxAmmo = 2, armorPiercing = 1, pwrCost = 1 },   -- The traits of the gun.
      sounds = {shoot="SpySociety/Weapons/LowBore/shoot_handgun_silenced", reload="SpySociety/Weapons/LowBore/reload_handgun", use="SpySociety/Actions/item_pickup",shell="SpySociety/Weapons/Shells/shell_handgun_wood"},  --Obvious
      weapon_anim = "kanim_light_revolver",
       agent_anim = "anims_1h",
      value = 600,   --cost at a store (also determines sell price)
      soldAfter = NEVER_SOLD,   --Makes it not appear in store
 }

Also, if you are having problems with crashes, go to Main.lua and set DEV to true. That will give you some direction when an error occurs.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.