Jump to content

Recommended Posts

Sure, you just need to have them wear an item with the "regal" tag on it. That can easily be done with any equippable item using AddPrefabPostInit :)

function ThingPostInit(inst)
  inst:AddTag("regal")
end
AddPrefabPostInit("thing", ThingPostInit)

You can refine it a bit more from there if you wanted to, but that's the basic requirement for it.

Hope that helps :)

EDIT: You don't even need to check for "ismastersim" since tags are checked by clients as well

Edited by w00tyd00d
Link to comment
Share on other sites

2 hours ago, w00tyd00d said:

If you wanted it to happen naturally without an equipped item, however, you're gunna have to do some stategraph editing since the code only checks for equipped items. Not impossible, just a bit more work :p 

I had that in mind. I don't mind puttin' in the extra work, I might end up learnin' stuff from that.

Link to comment
Share on other sites

Yes, modifying SGwilson.lua will be a solution, but you need to copy that file to your mod and modify on that file directly.

However, I prefer to a hacking but API way:

local CHARACTER = "wilson"
AddComponentPostInit("inventory",function(cmp)
	OldEquipHasTag=cmp.EquipHasTag
	function cmp:EquipHasTag(tag)
		if self.inst.prefab==CHARACTER and tag=="regal" then
			return true
		else
			return OldEquipHasTag(self,tag)
		end
	end
end)

in modmain.lua and it is server_only.

Link to comment
Share on other sites

4 hours ago, ptr said:

Yes, modifying SGwilson.lua will be a solution, but you need to copy that file to your mod and modify on that file directly.

However, I prefer to a hacking but API way:


local CHARACTER = "wilson"
AddComponentPostInit("inventory",function(cmp)
	OldEquipHasTag=cmp.EquipHasTag
	function cmp:EquipHasTag(tag)
		if self.inst.prefab==CHARACTER and tag=="regal" then
			return true
		else
			return OldEquipHasTag(self,tag)
		end
	end
end)

in modmain.lua and it is server_only.

Works like a charm! I know ya can't see it, but I'm bowin' to ya.

Link to comment
Share on other sites

15 hours ago, ptr said:

Yes, modifying SGwilson.lua will be a solution, but you need to copy that file to your mod and modify on that file directly.

However, I prefer to a hacking but API way:

Well not necessarily, there's API functions that deal with just modifying/appending stategraphs as well so you woudn't need the whole file.
But either way, I like your solution better :)

Link to comment
Share on other sites

47 minutes ago, w00tyd00d said:

Well not necessarily, there's API functions that deal with just modifying/appending stategraphs as well so you woudn't need the whole file

Oh, right, AddStategraphPostInit. There's gonna to be indeed a lot of work though, as many functions are required to be overwritten after some inspection. So I give up.;)

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