Jump to content

Recommended Posts

So I am trying to make it so that hallucinations corrupt flowers around them, making them evil flowers.

 

The (not working) code I currently have is:

local function AuraCorruptFlowers(inst, range)    local hitcount = 0	local pt = Vector3(inst.Transform:GetWorldPosition() )	local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)	for i,ent in ipairs(ents) do		if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then			BecomeCorruptFlower(ent)		end	end    return hitcountend--[[other stuff]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers)

 

I don't understand where to go from here...

Didn't someone write a mod doing something similar?

 

 

This is for a custom character, and to be quite honest Simplex... I looked at and didn't quite understand how pieces fit together in Blackhouse.

Edited by TheHockeyGods

I wrote a pair of components, "corruptible" and "corruptionaura". They'd do exactly what you're looking for, but aaaanyway. Surrounding the body of AuraCorruptFlowers with an inst:DoPeriodicTask() should work.

Edited by simplex

Let me be more clear, I understand how the files worked together... it was the separate functions inside those components that didn't fit together for me.

 

I have:

local function AuraCorruptFlowers(inst, range)	local hitcount = 0	local pt = Vector3(inst.Transform:GetWorldPosition() )	local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)		inst:DoPeriodicTask() for i,ent in ipairs(ents) do			if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then				BecomeCorruptFlower(ent)			end		end	return hitcountend--[[x]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers)

Still not working.

 

Thanks for taking a look.

local function AuraCorruptFlowers(inst, range)	local hitcount = 0	local pt = Vector3(inst.Transform:GetWorldPosition() )	local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)		inst:DoPeriodicTask() for i,ent in ipairs(ents) do			if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then				BecomeCorruptFlower(ent)			end		end	return hitcountend--[[x]]--AddPrefabPostInit("nightmarecreature", AuraCorruptFlowers)
Still not working.

 

Thanks for taking a look.

The DoPeriodicTask should be surrounding the whole function, not just that part. And you're not really passing anything to it!

 

local function AuraCorruptFlowers(inst, range)	inst:DoPeriodicTask(1, function(inst)		local pt = Vector3(inst.Transform:GetWorldPosition() )		local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)		for i,ent in ipairs(ents) do			if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then				BecomeCorruptFlower(ent)			end		end	end)end
Edited by simplex

The DoPeriodicTask should be surrounding the whole function, not just that part. And you're not really passing anything to it!

 

local function AuraCorruptFlowers(inst, range)	inst:DoPeriodicTask(1, function(inst)		local pt = Vector3(inst.Transform:GetWorldPosition() )		local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)		for i,ent in ipairs(ents) do			if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then				BecomeCorruptFlower(ent)			end		end	end)end

 

/facepalm on my side...

 

Its still not working, but I now believe its because of my BecomeCorruptFlower function which I previously thought was okay...

local function BecomeCorruptFlower(ent)	if not ent:HasTag("corruptflower") then		 SpawnPrefab( "flower_evil" )	endend

@TheHockeyGods

 

local function BecomeCorruptFlower(inst)    if not inst:HasTag("corruptflower") and inst.prefab ~= "flower_evil" then        local evil = SpawnPrefab("flower_evil")        evil:AddTag("corruptflower")        evil.Transform:SetPosition( inst:GetPosition():Get() )        inst:Remove()    endend
But I'm not quite sure what you're aiming with the "corruptflower" tag. Is it supposed to mark just the "new" evil flowers? Edited by simplex

@TheHockeyGods

 

local function BecomeCorruptFlower(inst)     if not inst:HasTag("corruptflower") and inst.prefab ~= "flower_evil" then          local evil = SpawnPrefab("flower_evil")          evil:AddTag("corruptflower")          evil.Transform:SetPosition( inst:GetPosition():Get() )          inst:Remove()     endend

 

But I'm not quite sure what you're aiming with the "corruptflower" tag. Is it supposed to mark just the "new" evil flowers?

 

 

My goal here is that I want nightmares to have an aura that turns regular flowers into evil flowers and adds the tag "corruptflower" so that I can add effects to only evil flowers with the tag. I don't want all evil flowers to have these effects, only ones turned evil this way.

 

@TheHockeyGods

Oh yes, you need to change you AddPrefabPostInit call as well. nightmarecreature is the name of the file that defines them, but the actual prefab names are "crawlingnightmare" and "nightmarebeak".

Sorry for the delay @ simplex

Thanks for the information on the hallucinations.

 

Currently this is the code that I have regarding making nightmares corrupt flowers. All in modmain.lua

local evilAuraMaxRange = 20local function CorruptFlowers(prefab)    prefab:AddTag("corruptflower")end-- Nightmares corrupt flowerslocal function updateAura(inst, dt)    auraRange = evilAuraMaxRange    inst.updateTask = inst:DoPeriodicTask(1, updateAura, nil, 1)endlocal function BecomeCorruptFlower(inst)    if not inst:HasTag("corruptflower") and inst.prefab ~= "flower" then        local evil = SpawnPrefab("flower_evil")        evil:AddTag("corruptflower")        evil.Transform:SetPosition( inst:GetPosition():Get() )        inst:Remove()    endendlocal function AuraCorruptFlowers(inst, range)    inst:DoPeriodicTask(1, function(inst)        local pt = Vector3(inst.Transform:GetWorldPosition() )        local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)        for i,ent in ipairs(ents) do            if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then                BecomeCorruptFlower(ent)            end        end    end)endAddPrefabPostInit("evil_flower", CorruptFlowers)AddPrefabPostInit("crawlingnightmare", "nightmarebeak", AuraCorruptFlowers)

 

Can't seem to get the nightmares to transform the flowers yet.

I changed AuraCorruptFlowers to

local function AuraCorruptFlowers(inst, range)	inst:DoPeriodicTask(1, function(inst)		local pt = Vector3(inst.Transform:GetWorldPosition() )		local evilAuraMaxRange = 20		auraRange = evilAuraMaxRange		local ents = TheSim:FindEntities(pt.x, pt.y, pt.z, range)		for i,ent in ipairs(ents) do			if (ent:HasTag("flower") and not ent:HasTag("corruptflower")) then				BecomeCorruptFlower(ent)			end		end	end)end

I wrote the range for AuraCorruptFlowers the same way I wrote it in updateAura, but to no avail.

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
×
  • Create New...