Jump to content

Make creatures attack shadows


Recommended Posts

Hi there :D

Is there a way to allow creatures (of a new mod, not from vanilla) to attack shadow creatures (helping the player)? :)

 

Edit: Also, on a completely unrelated note (but I didn't want to make multiple topics, spamming the forum), how can you make your followers continue to follow you after logging in and out (I don't have a problem with having them just stay somewhere, waiting for the player to return) :)

Edited by Thibooms
Link to comment
Share on other sites

Replicas are components that are present on the client and contain information that is a subset of their server-side part.
According to entityreplica.lua following components are replicable: builder, combat, container, equippable, fishingrod, follower, health, hunger, inventory, inventoryitem, moisture, named, rider, sanity, sheltered, stackable, writeable.

Edited by Muche
Link to comment
Share on other sites

1 minute ago, Muche said:

Replicas are components that are present on the client and contain information that is a subset of their server-side part.
According to entityreplica.lua[/u] following components are replicable: builder, combat, container, equippable, fishingrod, follower, health, hunger, inventory, inventoryitem, moisture, named, rider, sanity, sheltered, stackable, writeable

Ok I'll look into it, thanks :). Do you happen to know anything about the other question too? :) (in the edit)

Link to comment
Share on other sites

I usually post a link to this guide:

 

 

I guess they will have to remember who they followed previously and follow again when the player joins; attunable and possessedaxe components do some reestablishing upon ms_playerjoined event.

Edited by Muche
Link to comment
Share on other sites

You could probably have a save and load function on your character, to store how many you had, so when you log back in, it spawns that amount back.
 

--character.lua
local function onsave(inst, data)
	data.followercount = inst.components.leader:CountFollowers("wurm") -- this checks for tags, not prefabs
end

local function onload(inst, data)
	if data.followercount ~= nil and data.followercount > 0 then
		local x,y,z = inst.Transform:GetWorldPosition()
		for i=1, data.followercount do
			local wurm = SpawnPrefab("wurm") -- if i remember correctly ur creatures are called wurms right?
			wurm.Transform:SetPosition(x + math.random(-2,2), y, z + math.random(-2,2))
			wurm.components.follower:SetLeader(inst)
		end
	end
end
-- master_postinit
inst.OnSave = onsave
inst.OnLoad = onload

I haven't tried it but yea should work other than some small issues I didn't notice.

Edited by Aquaterion
Link to comment
Share on other sites

35 minutes ago, Aquaterion said:

You could probably have a save and load function on your character, to store how many you had, so when you log back in, it spawns that amount back.
 


--character.lua
local function onsave(inst, data)
	data.followercount = inst.components.leader:CountFollowers("wurm") -- this checks for tags, not prefabs
end

local function onload(inst, data)
	if data.followercount ~= nil and data.followercount > 0 then
		local x,y,z = inst.Transform:GetWorldPosition()
		for i=1, data.followercount do
			local wurm = SpawnPrefab("wurm") -- if i remember correctly ur creatures are called wurms right?
			wurm.Transform:SetPosition(x + math.random(-2,2), y, z + math.random(-2,2))
			wurm.components.follower:SetLeader(inst)
		end
	end
end
-- master_postinit
inst.OnSave = onsave
inst.OnLoad = onload

I haven't tried it but yea should work other than some small issues I didn't notice.

Thank you very much Aquaterion, this will be very helpful. I don't have much time on my hands now but when I do have time I'll make sure to try it. I just wanted to ask ahead so I can get stuff done next time :).

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