Jump to content

Recommended Posts

So I'm trying to make a werewolf character using the werebeaver code. The main reason I'm writing this topic is because I cannot fix an error I get after transforming into a werebeaver: "variable 'BeaverBadge' is not declared". I've tried fixing this myself, but I can't seem to get it. I just keep getting the same error over and over, telling me 'BeaverBadge' is not declared, no matter what I try. I've attached my prefab and log.

Spoiler

ebbj0z.jpg

The other reason I'm writing this is I want to know if it is possible to change the circumstances under which the werebeaver (in this case, werewolf) transforms. Like by eating too much raw meat (say, 4 pieces) at once... And eats only meat items. I'm assuming it has to do with this section of code, since I played around with the ACTIONS.CHOP bit earlier.

Spoiler

local function onworked(inst, data)
	if not inst.components.beaverness:IsBeaver() and data.target and data.target.components.workable and data.target.components.workable.action == ACTIONS.CHOP then
		inst.components.beaverness:DoDelta(3)
		--local dist = easing.linear(inst.components.beaverness:GetPercent(), 0, .1, 1)
		--TheCamera:Shake("SIDE", .15, .05, dist*.66)
	--else
		--TheCamera:Shake("SIDE", .15, .05, .1)
	end
end

 

 

phoenix (2).lua

log.txt

Edited by Whitefang45
Link to comment
https://forums.kleientertainment.com/forums/topic/68718-werebeaver-code-help/
Share on other sites

Woodie's BeaverBadge is the wood-meter in the top-right corner.

The function SetHUDState tries to add said wood-meter, but you haven't imported it at the top of the file using
local BeaverBadge = require "widgets/beaverbadge"
Either import it or change the function to use your custom badge.

About food, use something like this line:
    inst:ListenForEvent("oneatsomething", onbeavereat)
but instead of normal "onbeavereat", you want to raise the beaverness

Thank you, @Mobbstar, you were right about the badge thing. I actually feel kinda dumb for not realizing that. My character transforms properly now, thanks to you, sans one itty bitty problem.

24bss5d.jpg

I haven't done the textures yet, but I find myself wondering if Phoenix (Woodie?) is okay. I'd imagine it's hard to be a proper werebeaver with such small arms.

But anyway, thank you! Could I possibly be so rude as to ask what you mean by raise the beaverness? I've seen people say this before, but I don't quite remember what it means.

1 hour ago, Whitefang45 said:

But anyway, thank you! Could I possibly be so rude as to ask what you mean by raise the beaverness? I've seen people say this before, but I don't quite remember what it means.

It's called "DoDelta" in code, but it just means "add or subtract this value"

inst.components.beaverness:DoDelta(3)

This changes (raises) the "beaverness" value by 3.

inst.components.hunger:DoDelta(-20)

This changes the "hunger" value by -20, so it lowers it by 20. This is just as an example, mind you.

Thank you again, @Mobbstar. I honestly can't thank you enough for the help you've given me. I've modified the code to my liking regarding food, making the werebeast carnivorous.

However, now I'd like to ask if it is possible to change the circumstances under which the werebeaver transforms. Woodie transforms into the werebeaver after chopping too many trees. Is there a way to make this so my custom werecreature transforms after eating raw meat? Kind of like how pigs transform into werepigs after eating four pieces of monster meat.

Just now, Whitefang45 said:

However, now I'd like to ask if it is possible to change the circumstances under which the werebeaver transforms. Woodie transforms into the werebeaver after chopping too many trees. Is there a way to make this so my custom werecreature transforms after eating raw meat? Kind of like how pigs transform into werepigs after eating four pieces of monster meat.

...isnt that what the "oneat" stuff is about? Or do you mean the function itself, which would probably look somewhat like this:

local function oneat(inst,data)
    if data.food and data.food.prefab == "meat" then
        inst.components.beaverness:DoDelta(100) --test value
    end
end

@Mobbstar I'm... not sure. I'm sorry, I must sound like a real idiot right now, but I just can't get it. I've tried playing with the code, and I've used the function you gave me, but my character still doesn't transform after eating raw meat. He just goes nuts after chowing down a whole stack of raw meat.

local function onworked(inst, data)
	if not inst.components.beaverness:IsBeaver() and data.target and data.target.components.workable and data.target.components.workable.action == ACTIONS.CHOP then
		inst.components.beaverness:DoDelta(3)
		--local dist = easing.linear(inst.components.beaverness:GetPercent(), 0, .1, 1)
		--TheCamera:Shake("SIDE", .15, .05, dist*.66)
	--else
		--TheCamera:Shake("SIDE", .15, .05, .1)
	end
end

I'm pretty sure I should be doing something with this function. But I've played around with it for at least two hours now, but nothing seems to quite do it.

6 hours ago, Whitefang45 said:

I'm pretty sure I should be doing something with this function. But I've played around with it for at least two hours now, but nothing seems to quite do it.

 

The function you are trying to use only fired when "working" something, the "if" part then further limits to "chopping".

 

Did you place inst:ListenForEvent("oneatsomething", oneat)

@Mobbstar, thank you! I can't thank you enough for all the help you've given me with this, nor can I thank you enough for being so patient with a dummy like me. Everything's working perfectly now! Now all that's left is for me to figure out why the werebeast's arms are so stubby like they are, and how to fix it.

Edited by Whitefang45

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