Jump to content

Recommended Posts

I have basicly Maxwell Puppet clones with a custom skin set up. Everything works, it appears visible with the right animations, it has the same brain attached to it and it gets summoned through a crafting recipe. However, I have no idea how to actually make it follow my character after having crafted it. I looked at Maxwell's lua file (and also tried a couple f things) but I didn't find much either. I don't want to attach the creature to a simpler brain because I want to use the chop/mine/dig/attack(kite) behaviours that already coded in. Thanks in advance!

 

Attached files ("thibaud" is the character AKA "waxwell" equivalent, "guardian_thibaud" is the puppet equivalent)

waxwell.lua   thibaud.lua

guardian_thibaud.lua   guardian_thibaudbrain.lua

 

I use this to craft the creature: (in modmain)

Spoiler

-- Make a Paper Guardian: lumber
local Ingredient = GLOBAL.Ingredient
local af_rec = AddRecipe("guardianlumber", 
{Ingredient("papyrus", 4), Ingredient("cutgrass", 4)}, 
GLOBAL.RECIPETABS.DRAWINGS, GLOBAL.TECH.NONE, nil, nil, nil, nil, "paperdrawing_builder","images/inventoryimages/wurm_thibaud.xml", "wurm_thibaud.tex")
GLOBAL.STRINGS.RECIPE_DESC.GUARDIANLUMBER = "Draw a paper lumber guardian!"
af_rec.sortkey = -1

 


 

Edited by Thibooms

Ehh, I'm no expert on this type of thing, although I think I have some sort of idea of what's going on.

What I think is happening is that the code is still looking for Maxwell, and can't find him, so they don't do anything. Figure out a way to craft these guardians as Maxwell, and see if they follow him.

 

Might be something involving the brain value, you did say they share the same brain as the shadow puppets.

again, I'm no expert, so if what I suggested doesn't work, I can't help you out

Edited by StarmanNess
aaa

Thanks, Lumina and StarmanNess for replying. StarmanNess, your reply made me think about the fact that it was the "reader" component you can find in wawell.lua that I was missing (but it clearly wasn't since that only adresses using the codex umbra). It got me thinking about something else. So here's what I did:

 

I put this code (from the guardian_thibaud.lua)

Spoiler

local function onbuilt(inst, builder)
    local theta = math.random() * 2 * PI
    local pt = builder:GetPosition()
    local radius = math.random(3, 6)
    local offset = FindWalkableOffset(pt, theta, radius, 12, true)
    if offset ~= nil then
        pt.x = pt.x + offset.x
        pt.z = pt.z + offset.z
    end
    builder.components.petleash:SpawnPetAt(pt.x, 0, pt.z, inst.pettype)
    inst:Remove()
end

 

higher up. It clearly was not running before because now when I craft the creature it doesn't appear. This is clearly because of the last line of the function that states to remove the entity. Removing that last line gives the same effect as before: the creature appears, but it doesn't follow. I thought that this would work to start the petleash thingy. Does anyone *now* have a clue on how to continue? :)

 

Edit: I also replaced things like "shadowlumber" by "guardianlumber" in the brain now (forgot)

Edited by Thibooms
1 hour ago, StarmanNess said:

Did you do this as Maxwell or your mod character?

As the mod character. I don't really get what you want me to do with Maxwell. I did try to summon the creature with Maxwell if that's what you're asking, it's got the same effect so it is definitely not searching for Maxwell.

17 minutes ago, Thibooms said:

it's got the same effect so it is definitely not searching for Maxwell.

Gotcha. That's all I needed to know.

Unfortunately, I can't tell what other issues there are. If it were the case that they follow Maxwell, that would just be a quick fix. Sorry about that, but I hope I led you in the right direction. :cool2:

3 hours ago, StarmanNess said:

Gotcha. That's all I needed to know.

Unfortunately, I can't tell what other issues there are. If it were the case that they follow Maxwell, that would just be a quick fix. Sorry about that, but I hope I led you in the right direction. :cool2:

Update: got it to follow me. When it comes to recipes, I had to add "_builder" at the end of the prefab name, for it to work with the MakeBuilder thingy. New problem: the creature doesn't just follow me, he will go right next to me. Also, when he is about a meter or two away his animation will go to idle but his body will carry on until he is right next to me. Then, when the leader tries to walk again the creature will be right on the leader's tail. And it's kind of annoying. I think I need someone who knows something about brains for this (setting different minimum follow distance will make the creature run back and forth all the time)

 

guardian_thibaudbrain.lua.

1 minute ago, DarkKingBoo said:

Have you tried using inst.components.leader:AddFollower(x) ?

Where x is the var used to indentify the newly spawned shadowmaxwell.

Where would I use this, given the weird way in which shadowmaxwell works? Also, as stated in previous post, it follows me but it now keeps on "kissing my ass" so to speak.

12 minutes ago, Lumina said:

Maybe it's because of the petleash ? I guess petleash is for pet (like the small hound, for example), not for usual followers ?

But that doesn't explain the weird behaviour upon following. Isn't this a brain issue?

local function onbuilt(inst, builder)
    local theta = math.random() * 2 * PI
    local pt = builder:GetPosition()
    local radius = math.random(3, 6)
    local offset = FindWalkableOffset(pt, theta, radius, 12, true)
    if offset ~= nil then
        pt.x = pt.x + offset.x
        pt.z = pt.z + offset.z
    end
	inst.Transform:SetPosition(pt.x, 0, pt.z)
    builder.components.leader:AddFollower(inst)
end

EDIT: Forgot to add the SetPosition for spawning.

Edited by DarkKingBoo
30 minutes ago, Thibooms said:

But that doesn't explain the weird behaviour upon following. Isn't this a brain issue?

It could, i think. petleash is probably for keeping pet close to you and force them to appears close to you if you are too far of them, and i guess it's not really compatible with the active followers (since pets don't really do anything). I'm not sure, i'm not familiar with petleash function...

Spoiler
44 minutes ago, DarkKingBoo said:


local function onbuilt(inst, builder)
    local theta = math.random() * 2 * PI
    local pt = builder:GetPosition()
    local radius = math.random(3, 6)
    local offset = FindWalkableOffset(pt, theta, radius, 12, true)
    if offset ~= nil then
        pt.x = pt.x + offset.x
        pt.z = pt.z + offset.z
    end
	inst.Transform:SetPosition(pt.x, 0, pt.z)
    builder.components.leader:AddFollower(inst)
end

EDIT: Forgot to add the SetPosition for spawning.

 

Tried it. Apparently this code creates an issue with the MakeBuilder thingy so I had to make sure the recipe was "guardianlumber" and not "guardianlumber_builder" for the creature to appear. The creature does follow but it still shows the same behaviour. I think there has got to be something going on with the brain/stategraph

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