Jump to content

Set Abigail flower cooldown to 0 when Abigail killed by you


Recommended Posts

I'm looking to create a mod that sets the `inst.components.cooldown.cooldown_duration` to 0 in abigail_flower.lua when Abigail has been killed by you (or by any other player, if that's easier to write). I would still like for the cooldown to be 3~4 days if Abigail is killed by anyone/anything else. The idea behind this would be if I'm going to fight a boss or something that will kill Abigail immediately, I would prefer to "store" her before the fight and have her available right afterward.

I'm not sure if all of this could be done inside of abigail_flower.lua or if I would need to edit abigail.lua or even other files. Any help with which other variables would be involved or even help writing the if then statement would be greatly appreciated.

Thanks a bunch!

 

P.S. Closed original post as it wasn't very clear and I hadn't done my research beforehand.

Link to comment
Share on other sites

im not too experienced myself but i would try something like

local function OnAttacked(inst, data)
    if data.attacker == nil then
        inst.components.combat:SetTarget(nil)
    elseif data.attacker == inst._playerlink then
	local x, y, z = inst.Transform:GetWorldPosition()
	local flower = inst.components.lootdropper:SpawnLootPrefab("abigail_flower", Vector3(x, y, z))
	flower.components.cooldown.cooldown_duration = 0
        inst.components.health:SetVal(0)
    elseif not data.attacker:HasTag("noauradamage") then
        inst.components.combat:SetTarget(data.attacker)
    end
end

I have no idea if this code would work.  You would probably need to remove abigal_flower from the loot table, add it to the prefabs table and manually spawn it again in the OnDeath function with a condition if you killed it yourself or not. Maybe giving it a variable like "local playerkilled = false" and adding "playerkilled = true" after the "elseif data.attacker == inst._playerlink then" in the OnAttacked function.  So OnDeath do something like

local function OnDeath(inst)

	inst.components.aura:Enable(false)
	if playerkilled == false then
		local x, y, z = inst.Transform:GetWorldPosition()
		local flower = inst.components.lootdropper:SpawnLootPrefab("abigail_flower", Vector3(x, y, z))
		flower.components.cooldown.cooldown_duration = TUNING.TOTAL_DAY_TIME * (1 + math.random() * 2)
	end
end

Again i never used "SpawnLootPrefab" so not really sure how this works

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...