Jump to content

Recommended Posts

Hello,

I want to add news hound to hound wawe, one for each season, but i'm still confused when it comes to component change.

Should i replace the "local function SummonSpawn(pt)" and add a new table to define which hound is related to which season ?

Also, is there a way to start an hound attack to test the mod ?

Thanks a lot :)

Edited by Lumina

I think this mod might be perfect:

http://steamcommunity.com/sharedfiles/filedetails/?id=544126369

hmm.. I just saw this mod replaces the old hounded component, which is not a good idea...but the rest looks professional.

if it is not possible to change stuff with normal modding functions, maybe try this:

 


and also this mod adds new hounds to attack:
http://steamcommunity.com/sharedfiles/filedetails/?id=591576144

Edited by Serpens

the stuff DarkXero posted there is a way to edit local game functions without the need to completely overwrite the scripts, like the mods above do.

In case of teleportato I finally used another function where I was able to just use normal AddPrefabPostInit. So I did not test the code from DarkXero more than you can read in the thread.
Maybe try reading some of the posts above to understand it better.

Edited by Serpens

I also don't understand what it does exactly (the "debug" stuff)
But the only thing you need to know is how to use it :D And now we have ~ 4 examples on different things, so I think with some trial and error it should work :D

Edited by Serpens

Well, I assumed it would have been overkill to spawn extra stuff along with the hounds, so I did this

local function GetUpvalue(func, name)
	local debug = GLOBAL.debug
	local i = 1
	while true do
		local n, v = debug.getupvalue(func, i)
		if not n then
			return nil, nil
		end
		if n == name then
			return v, i
		end
		i = i + 1
	end
end

local function SetUpvalue(func, ind, value)
	local debug = GLOBAL.debug
	debug.setupvalue(func, ind, value)
end

local function HackHounded(self)
	local summon_fn = self.SummonSpawn

	local SummonSpawn, SummonSpawn_index = GetUpvalue(summon_fn, "SummonSpawn")
	local GetSpawnPoint, GetSpawnPoint_index = GetUpvalue(SummonSpawn, "GetSpawnPoint")

	local old_SummonSpawn = SummonSpawn
	local new_SummonSpawn = function(pt)
		-- Chance for our prefab to replace a hound of the wave
		if pt and math.random() < 0.5 then
			local spawn_pt = GetSpawnPoint(pt)

			if spawn_pt then

				local prefab = "spider_warrior"

				-- Chance to get a special prefab of ours (like ice hound instead of hound)
				if math.random() < 0.33 then
					if GLOBAL.TheWorld.state.iswinter or GLOBAL.TheWorld.state.isspring then
						prefab = "krampus"
					else
						prefab = "warg"
					end
				end

				local spawn = GLOBAL.SpawnPrefab(prefab)
				if spawn then
					spawn.Physics:Teleport(spawn_pt:Get())
					spawn:FacePoint(pt)
					if spawn.FadeIn ~= nil then
						spawn:FadeIn()
					end

					return spawn
				end
			end
		else
			return old_SummonSpawn(pt)
		end
	end

	SetUpvalue(summon_fn, SummonSpawn_index, new_SummonSpawn)
end

AddComponentPostInit("hounded", HackHounded)

Now you can get normal hounds, season hounds, your stuff, and also your season stuff.

 

To test hound waves, you can host a server WITHOUT caves, then input

c_select(TheWorld)

then press backspace to show debug info.

Then on the items on the left, look for the hounded component.

The string will say how much time is left until the next attack.

Then you do

LongUpdate(400)

or whatever number in seconds is needed to reach the wave.

If it says 500 until next attack, put 450 so you can hear the warning sounds before the wave spawns.

  • Like 1

Thanks a lot.

All seems to work perfectly fine so far, the old classic hound spawn with the new prefab without any problem. Thanks also for the command, it's very useful to have access of this kind of debug info when trying some mods :)

I'm grateful for the help.

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