Jump to content

Recommended Posts

So I'm working on various coding things for a character and I've been wondering for a long time, where are the codes for the character tags? I'm talking about the vanilla ones, I understand you make a new file for the modded ones and link it up but something say like, Woodie's 'woodcutter' tag or Webber's 'monster' tag.

I've searched in the character files and never found where these were actually specified and laid out to work the way they do. Such as the fact that I've found the tags in the character files but NOT where they are specified and created.(at least i think) So something like the 'woodcutter' tag I know where it is but I want to know where the coding is actually laid out and made so I can have an understanding of what makes it work and how.

I'm not sure if this has ever been asked before but if anyone could tell me the files I should look in and perhaps missed while searching it would be cool. :D

Thanks!

Link to comment
https://forums.kleientertainment.com/forums/topic/66465-character-tag-coding/
Share on other sites

8 minutes ago, osmRhodey said:

So I'm working on various coding things for a character and I've been wondering for a long time, where are the codes for the character tags? I'm talking about the vanilla ones, I understand you make a new file for the modded ones and link it up but something say like, Woodie's 'woodcutter' tag or Webber's 'monster' tag.

I've searched in the character files and never found where these were actually specified and laid out to work the way they do. Such as the fact that I've found the tags in the character files but NOT where they are specified and created.(at least i think) So something like the 'woodcutter' tag I know where it is but I want to know where the coding is actually laid out and made so I can have an understanding of what makes it work and how.

I'm not sure if this has ever been asked before but if anyone could tell me the files I should look in and perhaps missed while searching it would be cool. :D

Thanks!

Tags are exactly what they're called, just tags, you're probably looking for components. Some components check for tags to add code to prefabs, for example, the "woodcutter" tag is used by possessedaxe component I believe as well as stategraph, as for "monster" tag I'm not sure where its used, but it might be just grouping.

 

Atleast this is what I understood from it.

Edited by Aquaterion
2 hours ago, Aquaterion said:

Tags are exactly what they're called, just tags, you're probably looking for components. Some components check for tags to add code to prefabs, for example, the "woodcutter" tag is used by possessedaxe component I believe as well as stategraph, as for "monster" tag I'm not sure where its used, but it might be just grouping.

That's what I was saying yes. I've been looking for the coding that completely encompasses the coding that links to the tags.

Sadly that component(possessedaxe) seems to be the only one I can find with any character tag in the components. I'm still wondering where the other bits are but I can continue looking. As for that component it only seems to encompass everything for Lucy and not the quick chopping aspect.

:'D
I'll continue my own search but if anyone else has any other files or locations to look through that'd be neato!

Well you didn't specify what you wanted, but maybe you're looking in the wrong place? I've never played woodie, but are you sure it's actually him that's faster at woodcutting, and not lucy the axe itself? because I looked into it and it does seem that lucy is twice as fast as normal axes.

Just now, Aquaterion said:

Well you didn't specify what you wanted, but maybe you're looking in the wrong place? I've never played woodie, but are you sure it's actually him that's faster at woodcutting, and not lucy the axe itself? because I looked into it and it does seem that lucy is twice as fast as normal axes.

I did explain what I was looking for, the general coding going into the tags. I'm searching through prefabs and finding different information so I'll continue searching.

And no, Lucy cuts down quicker but she is not what causes Woodie to chop at a faster pace. There is something in his coding that uses a faster variant of the chopping animation, whether using Lucy or a normal axe. Lucy is only a better, more efficient axe, but the speed is derived from Woodie himself.(I'm looking for that part in the code, for one character, but also looking for the vanilla characters codes so I can understand and build my own)

wilson-choppingaxe.gifwoodie-choppingaxe.gif

My recorder was messing up...So ignore the horrible quality XD

3 minutes ago, osmRhodey said:

I did explain what I was looking for, the general coding going into the tags. I'm searching through prefabs and finding different information so I'll continue searching.

And no, Lucy cuts down quicker but she is not what causes Woodie to chop at a faster pace. There is something in his coding that uses a faster variant of the chopping animation, whether using Lucy or a normal axe. Lucy is only a better, more efficient axe, but the speed is derived from Woodie himself.(I'm looking for that part in the code, for one character, but also looking for the vanilla characters codes so I can understand and build my own)

wilson-choppingaxe.gifwoodie-choppingaxe.gif

My recorder was messing up...So ignore the horrible quality XD

So you want to know what exactly gives Woodie faster chopping speed?

It's coded in the stategraph (SGwilson.lua). Stategraph checks if the player has "woodcutter" tag and plays different animation because of that.

You add tags just so you can check them later in your functions and whatnot, instead of checking prefab for example.

Ffffffffrig

Well that's a lot of things I never would have guessed. xD
Thanks!!!

Next part will be looking into how I can give vanilla tools a sanity drain to the mod character. That and how to get the morphing which I see in the prefab for Wolfgang. So yay, progress!

But yeah thanks!! I never would have thought of the SG. :'D

2 minutes ago, osmRhodey said:

Ffffffffrig

Well that's a lot of things I never would have guessed. xD
Thanks!!!

Next part will be looking into how I can give vanilla tools a sanity drain to the mod character. That and how to get the morphing which I see in the prefab for Wolfgang. So yay, progress!

But yeah thanks!! I never would have thought of the SG. :'D

do you mean when holding them, or when using them?

for holding you could probably ListenForEvent "equip" and then check if the equipped item has the tool component

Edited by Aquaterion
Just now, Aquaterion said:

do you mean when holding them, or when using them?

Holding it. For one of my mod characters I'm trying to have it that if they're holding an item that functions as an axe they have a small sanity drain. I figured to add the tag 'ax' in there but the coding always crashed my game when it came to the sanity drain itself. I've been trying to figure out that and how to make it so they wouldn't be able to hold Lucy.

I'll be going back to that mod later though as I have a different one I'm trying to do for now.

Just now, osmRhodey said:

Holding it. For one of my mod characters I'm trying to have it that if they're holding an item that functions as an axe they have a small sanity drain. I figured to add the tag 'ax' in there but the coding always crashed my game when it came to the sanity drain itself. I've been trying to figure out that and how to make it so they wouldn't be able to hold Lucy.

I'll be going back to that mod later though as I have a different one I'm trying to do for now.

you can do use :HasTag("CHOP_tool") to check if the tool you're holding can chop trees, as for holding Lucy, I think it is the possessedaxe component that I mentioned earlier but you can easily add a onpickup on the "character-specific-item" to check who picked it up

Just now, Aquaterion said:

you can do use :HasTag("CHOP_tool") to check if the tool you're holding can chop trees, as for holding Lucy, I think it is the possessedaxe component that I mentioned earlier but you can easily add a onpickup on the "character-specific-item" to check who picked it up

Ah, I just need to figure out the sanity drain because no matter what I was doing it said something wasn't defined.
And yeah I know. I'm taking the woodcutter tag off and using my own and going to mimic the code for the quicker tree chopping as that's all i am looking for lol

21 minutes ago, osmRhodey said:

Ah, I just need to figure out the sanity drain because no matter what I was doing it said something wasn't defined.
And yeah I know. I'm taking the woodcutter tag off and using my own and going to mimic the code for the quicker tree chopping as that's all i am looking for lol

local function onequip(inst, data)
	if data.eslots == EQUIPSLOTS.HANDS and data.item:HasTag("CHOP_tool") and inst.sanitydrain == nil then
		inst.sanitydrain = inst:DoPeriodicTask(1, function() inst.components.sanity:DoDelta(-5) end)
	end
	--im not sure if this would override the old equip function, but if it does then just add the only thing that it adds:
	--TheFocalPoint.SoundEmitter:PlaySound("dontstarve/wilson/equip_item")
end

local function onunequip(inst, data)
	if data.eslots == EQUIPSLOTS.HANDS and inst.sanitydrain ~= nil then
		inst.sanitydrain:Cancel()
		inst.sanitydrain = nil
	end
end

1 is the time it takes to repeat the task, so -5 sanity per 1 second

put listeners in the master_postinit and it should work if i didn't miss anything

inst:ListenForEvent("equip", onequip)
inst:ListenForEvent("unequip", onunequip)

 

Edited by Aquaterion
29 minutes ago, osmRhodey said:

Ah, I just need to figure out the sanity drain because no matter what I was doing it said something wasn't defined.
And yeah I know. I'm taking the woodcutter tag off and using my own and going to mimic the code for the quicker tree chopping as that's all i am looking for lol

About sanity drain you can do:

inst.components.sanity.dapperness = -TUNING.DAPPERNESS_TINY

This gives reverted Garland sanity effect.

 

About transformation, you have to make multiple builds and change them (depending what conditions have to be met to trigger transformation).

And about stategraph you could just copy-paste the entire State dedicated to chopping, alter it and add it through a Postinit in your modmain.

Edited by PanAzej
Just now, PanAzej said:

About sanity drain you can do:


inst.components.sanity.dapperness = -TUNING.DAPPERNESS_TINY

This gives reverted Garland sanity effect.

 

About transformation, you have to make multiple builds and change them (depending what conditions have to be met to trigger transformation).

And about stategraph you could just copy-paste the entire State dedicated to chopping, alter it and add it through a Postinit in your modmain.

I'll be testing out all of this code in a little. :0

 

Yeah I'm working on the main build right now to get it to work at least.

Yeah that's what I was thinking. Could I not just make a separate file to keep it organized(to me) from the general mass of the modmain? Or does that require other code? :p

Just now, osmRhodey said:

I'll be testing out all of this code in a little. :0

 

Yeah I'm working on the main build right now to get it to work at least.

Yeah that's what I was thinking. Could I not just make a separate file to keep it organized(to me) from the general mass of the modmain? Or does that require other code? :p

if ur using his sanity thing i believe its

inst.components.equippable.dapperness

not

inst.components.sanity.dapperness

for items

Just now, osmRhodey said:

I'll be testing out all of this code in a little. :0

 

Yeah I'm working on the main build right now to get it to work at least.

Yeah that's what I was thinking. Could I not just make a separate file to keep it organized(to me) from the general mass of the modmain? Or does that require other code? :p

Oh, now that I'm reading you didn't want your character to have a permament sanity drain, you want an item to cause it.

Put this in your item's prefab then:

inst.components.equippable.dapperness = -TUNING.DAPPERNESS_TINY

Yes, you can make a part of code a separate file and import it by modimport.

It sounds like you got this mostly figured out, but tags are one of the main areas where if you really want to understand all of their functionality, you just have to use find-in-files. Most coding text editors have a way to search all files in a folder and its subfolders, you can just target the data/scripts folder and search for all occurrences of "woodcutter". In some cases it might be a bit ambiguous, so you can look for HasTag.*woodcutter or AddTag.*woodcutter -- make sure for those ones you put the search in "regular expression" mode, which will make it consider ".*" to be any sequence of characters within a line.

17 minutes ago, rezecib said:

It sounds like you got this mostly figured out, but tags are one of the main areas where if you really want to understand all of their functionality, you just have to use find-in-files. Most coding text editors have a way to search all files in a folder and its subfolders, you can just target the data/scripts folder and search for all occurrences of "woodcutter". In some cases it might be a bit ambiguous, so you can look for HasTag.*woodcutter or AddTag.*woodcutter -- make sure for those ones you put the search in "regular expression" mode, which will make it consider ".*" to be any sequence of characters within a line.

Wait you what...that's a function????

...

Well crap. I feel stupid. Are you using Notepad++ or something else for that searching function? :'D

11 hours ago, rezecib said:

I used Notepad++, yeah. It's one of the tabs of the Find popup for that, and regular expressions are a checkbox at the bottom. But pretty much any text editor that's oriented at coding should have it.

I'm screaming. How did I not see this before??!?! Dangit! XD

Thank you! This will make so many things easier!

On 4/20/2016 at 8:02 PM, Aquaterion said:

local function onequip(inst, data)
	if data.eslots == EQUIPSLOTS.HANDS and data.item:HasTag("CHOP_tool") and inst.sanitydrain == nil then
		inst.sanitydrain = inst:DoPeriodicTask(1, function() inst.components.sanity:DoDelta(-5) end)
	end
	--im not sure if this would override the old equip function, but if it does then just add the only thing that it adds:
	--TheFocalPoint.SoundEmitter:PlaySound("dontstarve/wilson/equip_item")
end

local function onunequip(inst, data)
	if data.eslots == EQUIPSLOTS.HANDS and inst.sanitydrain ~= nil then
		inst.sanitydrain:Cancel()
		inst.sanitydrain = nil
	end
end

1 is the time it takes to repeat the task, so -5 sanity per 1 second

put listeners in the master_postinit and it should work if i didn't miss anything


inst:ListenForEvent("equip", onequip)
inst:ListenForEvent("unequip", onunequip)

 

All right I'm late but I've been messing around with it and it's not working.

Where would the focalpoint one go anyways? I've tried it around but yeah.

Overall isn't working right now. <lD

On 4/20/2016 at 8:32 PM, PanAzej said:

Oh, now that I'm reading you didn't want your character to have a permament sanity drain, you want an item to cause it.

Put this in your item's prefab then:


inst.components.equippable.dapperness = -TUNING.DAPPERNESS_TINY

Yes, you can make a part of code a separate file and import it by modimport.

It's for the axe and pick-axe already in the files. This wasn't for any kind of character made item. I've been trying to get it where a vanilla item like those would cause sanity drain for the character.

6 hours ago, osmRhodey said:

All right I'm late but I've been messing around with it and it's not working.

Where would the focalpoint one go anyways? I've tried it around but yeah.

Overall isn't working right now. <lD

It's for the axe and pick-axe already in the files. This wasn't for any kind of character made item. I've been trying to get it where a vanilla item like those would cause sanity drain for the character.

Then do it through AddPrefabPostInit (in your modmain)

function AxepickaxeDrainPostInit(inst)
    if GLOBAL.TheWorld.ismastersim then
        inst.components.equippable.dapperness = -TUNING.DAPPERNESS_TINY
    end
end
local drainingitems = {"axe", "pickaxe"}
for k,v in pairs(drainingitems) do AddPrefabPostInit(v, AxepickaxeDrainPostInit) end

This will affect all characters though when items are equipped. You'll have to override onequip function to check prefab/character's tag and then cause sanity drain and remove the drain on unequip.

Edited by PanAzej

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