Jump to content

Recommended Posts

So what I have been attempting to do, is change follower options, but only for 1 character ( a mod I'm making). For example, for this particular character, have all of his followers last 50% longer. I'm just really not sure where to start, without editing follower options already within the game. I am completely new to modding, any help would be appreciated.

 

Thanks!

  • Developer

The best place to start is usually by taking someone else's mod and see how they're doing things.  Here are a couple of suggestions:

 

This mod adjusts follower settings.

This mod is a character mod with character specific abilities so you can see how those are hooked up.

 

 

Let me know how it goes :).

The best place to start is usually by taking someone else's mod and see how they're doing things.  Here are a couple of suggestions:

 

This mod adjusts follower settings.

This mod is a character mod with character specific abilities so you can see how those are hooked up.

 

 

Let me know how it goes :-).

Thanks! Will, do, I will update you on this shortly.

The best place to start is usually by taking someone else's mod and see how they're doing things.  Here are a couple of suggestions:

 

This mod adjusts follower settings.

This mod is a character mod with character specific abilities so you can see how those are hooked up.

 

 

Let me know how it goes :-).

 

So I managed to look at a few mods, and got a basic idea of what to do. But right now I am having an issue, this is what I have so far:

 

local function betterfollowers(inst, data)
        local leader = data.leader
        if leader == GLOBAL.GetPlayer() then
                inst.components.locomotor.walkspeed = self.walkspeed * 1.50    
                inst.components.locomotor.runspeed = self.runspeed * 1.50
                inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER * 1.25)
                inst.components.combat.damage = self.damage * 1.25
                inst:AddTag("insomniac")
        else
                inst.components.locomotor.walkspeed = self.inst.components.locomotor    
                inst.components.locomotor.runspeed = self.inst.components.locomotor
        end
 end
 
I am getting an error ( there are probably more to be followed) which states that "variable 'GLOBAL' is not declared," I'm not quite sure how to do this. I saw in another topic on this forum that the person declared GLOBAL at the top, which I guessed at how to do, yet I still came up with the same error (most probably I declared it improperly).

 

So I managed to look at a few mods, and got a basic idea of what to do. But right now I am having an issue, this is what I have so far:

 

local function betterfollowers(inst, data)
        local leader = data.leader
        if leader == GLOBAL.GetPlayer() then
                inst.components.locomotor.walkspeed = self.walkspeed * 1.50    
                inst.components.locomotor.runspeed = self.runspeed * 1.50
                inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER * 1.25)
                inst.components.combat.damage = self.damage * 1.25
                inst:AddTag("insomniac")
        else
                inst.components.locomotor.walkspeed = self.inst.components.locomotor    
                inst.components.locomotor.runspeed = self.inst.components.locomotor
        end
 end
 
I am getting an error ( there are probably more to be followed) which states that "variable 'GLOBAL' is not declared," I'm not quite sure how to do this. I saw in another topic on this forum that the person declared GLOBAL at the top, which I guessed at how to do, yet I still came up with the same error (most probably I declared it improperly).

 

Where are you putting the code? Because GLOBAL is not necessary unless you are currently in momain.lua or modworldgen.lua. In any other file there shouldn't be a need for GLOBAL. Then again, if you are in one of those two files there's no need to declare GLOBAL at all.

Where are you putting the code? Because GLOBAL is not necessary unless you are currently in momain.lua or modworldgen.lua. In any other file there shouldn't be a need for GLOBAL. Then again, if you are in one of those two files there's no need to declare GLOBAL at all.

Oh wait, I was looking at a mod with GLOBAL in modmain. This is in scripts/prefabs/saidcharacter.lua. If I'm not to use GLOBAL, what exactly do I use?

Nothing, just keep that part away.

Write only GetPlayer()

 

Alright, thanks, this works. But now I get this: variable 'self' is not declared. I know where this is coming from,

 

local function betterfollowers(inst, data)  
        local leader = data.leader
        if leader == GLOBAL.GetPlayer() then
                inst.components.locomotor.walkspeed = self.walkspeed * 1.50    
                inst.components.locomotor.runspeed = self.runspeed * 1.50
                inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER * 1.25)
                inst.components.combat.damage = self.damage * 1.25
                inst:AddTag("insomniac")
        else
                inst.components.locomotor.walkspeed = self.inst.components.locomotor    
                inst.components.locomotor.runspeed = self.inst.components.locomotor
        end
 end
 

Do I simply replace self, or just remove it completely again? 

Do I simply replace self, or just remove it completely again? 

There's a bit of cunfusion going on here. You have probably copied some code from different components and others from some prefabs and such. So let me try to brak it down for you:

inst.components.locomotor.walkspeed = self.walkspeed * 1.50    inst.components.locomotor.runspeed = self.runspeed * 1.50

Here you want to set the walk- and runspeed to a multiple of their earlier values. It doesn't work here because this "self" is not referencing anything. You probably copied it from "locomotor.lua" where "self" is used to the locomotor component. So you would need to replace it with

inst.components.locomotor.walkspeed

which is, as you see the same you had before the "=", which hopefully makes sense. Same goes for runspeed of course. In the same fashion you'll have to correct all the other mistakes with "self", find out what component it was initially referencing and replace it accordingly.

Now I don't see what you want to do with these two lines

inst.components.locomotor.walkspeed = self.inst.components.locomotor    inst.components.locomotor.runspeed = self.inst.components.locomotor

so I'll go out on a limb here and say they were an error and are not needed. In any other case just tell me what they should've done.

The corrected code, if you can't do it yourself:

local function betterfollowers(inst, data)          local leader = data.leader        if leader == GLOBAL.GetPlayer() then                inst.components.locomotor.walkspeed = inst.components.locomotor.walkspeed * 1.50                    inst.components.locomotor.runspeed = inst.components.locomotor.runspeed * 1.50                inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER * 1.25)                inst.components.combat.damage = inst.components.combat.damage * 1.25                inst:AddTag("insomniac")        end end

Edited by Malacath

There's a bit of cunfusion going on here. You have probably copied some code from different components and others from some prefabs and such. So let me try to brak it down for you:

 

Yes, I did copy some lines from several different components, that's probably why my coding didn't make too much sense.

 

Basically what I am trying to do is to have this character's followers to move faster, last longer, deal more damage, and not sleep. Yet, even with this code, that doesn't seem to be happening. 

 

Anyways, thanks for the reply, I will continue working on this and hopefully have it finished soon.

 

 

Now I don't see what you want to do with these two lines

inst.components.locomotor.walkspeed = self.inst.components.locomotor    inst.components.locomotor.runspeed = self.inst.components.locomotor

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