Jump to content

Wes Balloon damage modifier


Recommended Posts

Hello Guys, I'm new to Lua Coding, and I'm trying to create a mod for change the damage of the Wes's balloon on explode, and have damage configuration at the mod menu.

I've tried to copy the original Balloon.lua from the game and paste with the damage value changed in my MOD folder /script/balloon.lua
Also made a copy of the animations to de directory /anim/balloon.zip (balloon_shapes and balloons_empty too)

I need help because my mod doesn't change the damage of balloon on explode, no matter the value.

Can someone give a hand?

 

I'll drop the code bellow.

Thanks in advance!

 

My modmain.lua is

PrefabFiles =
{
    "balloon"
}

local SetDefaultDamage = GetModConfigData("balloon_combat")

 

And my modinfo.lua

name = "Ballon dmg modifier"
description = "Makes Wes ballons explode 200 damage points."
author = "Muted"
version = "1"

forumthread = ""

-- This lets other players know if your mod is out of date, update it to match the current version in the game
api_version = 10

-- Can specify a custom icon for this mod! (atlas for xml - icon for tex)
icon_atlas = ""
icon = ""


-- Specify compatibility with the game!
dst_compatible = true
all_clients_require_mod = true

configuration_options =
{
    {
        name = "balloon_combat",
        label = "Damage",
        options =    {
                        {description = "50", data = 50},
                        {description = "100", data = 99},
                        {description = "200", data = 200},
                        {description = "250", data = 250},
                        {description = "500", data = 500},
                        {description = "1000", data = 1000},
                    },

        default = 200,
    },
}

 

Link to comment
Share on other sites

In balloon.lua

change this

    inst.components.combat:SetDefaultDamage(5)

for his

    inst.components.combat:SetDefaultDamage(TUNING.BALLOONDAMAGE)

on modmain.

TUNING.BALLOONDAMAGE = GetModConfigData("balloon_combat")

 

Also, Rae is the best 'Naut

Link to comment
Share on other sites

In modinfo.lua:

all_clients_require_mod = false

because people don't need to download your mod because they don't need to know the balloon damage.

This also makes your mod a server side only mod, because that is what it is.

{description = "100", data = 100},

because using 99 triggers me.

 

In modmain.lua:

-- Get balloon damage from mod configuration
local balloon_damage = GetModConfigData("balloon_combat")

-- Function that applies the new damage to the combat component of the balloon
local function ChangeDamage(inst)
	inst.components.combat:SetDefaultDamage(balloon_damage)
end

-- Function that runs the function ChangeDamage on the prefab named "balloon"
-- which are Wes' balloons when they spawn
AddPrefabPostInit("balloon", ChangeDamage)

 

This way you don't have to copy-paste balloon.lua and load it with PrefabFiles.

Link to comment
Share on other sites

Modmain.lua:

local newDamage = GetModConfigData("balloon_combat")
AddPrefabPostInit("balloon",
    function(inst)
        if(inst.components~=nil and inst.components.combat~=nil)
        then
            inst.components.combat:SetDefaultDamage(newDamage)
        end
    end
)

No need for having a custom balloon.lua or the animations if all you want is to change the damage output.

Link to comment
Share on other sites

Thank you guys it's working now!

You all are awesome!

 

Is there any kind of reputation in this forum i can help you? (inside the forum rules)

 

Also, Rae is the best 'Naut.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...