Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

Rosten

Could you do this?

Recommended Posts

Rosten    627

[Wip] - Wilson's Friendship Staff

This mod will add 1 new item, the friendship staff!

what this item does is whenever you fire it, it turns whatever you shot in the face, into your friend (kind of ironic, isn't it) So, here's the current information

 

Item - Friendship Staff

Recipe - 1 Blue gem, 1 Yellow gem, 3 Living logs, 6 Nightmare fuel

Crafting tab - Shadow Manipulator, Magic tab

Durability - 20 uses

Damage - None (you wouldn't want to hurt you're friends would you?)

 

Progress - 100%

Left to do

Upload!

 

Credits

Main Coder Cannibalizer - @Blazingice26

Artist - @MilleniumCount

Quotes - @Ortorin

--------------------------------------

Special Thanks 

@Malacath - For the tons and tons of help he gave me he pretty much coded most of it  :razz:

@Cheerio - For making the followtheleader script from which this mod is based off of, and helping me                                                       edit it to what i needed it to do  :-)

 

Known Bugs -

Game crashes whenever attacking bee's nest with a follower staff (seriously, why would you even do that?)

 

Original Post

 

So, i've got this idea for a mod to do, but one thing i'd like to know is, could you make it where, when a monster is hit by a projectile fired from a staff it automatically becomes a follower, like pigs do whenever you give them meat, except getting hit by a projectile?

 

Here's the idea for the mod

 

Name - Wilson's Friendship staff

Purpose - Adds a new staff that, whenever it strikes an enemy, converts them into a follower until the end of the day

 

Durability - 25 uses

Crafting Recipes -

Tab Magic Shadow Manipulator - Friendship Wand - 1 blue gem 1 yellow gem 3 living logs 6 nightmare fuel

What it does - Turns target into a follower for life.

 

 

Edit - Updated the OP to make it look more like a WIP thread, left the other post in a spoiler if anyone would like to view it, now i just need a moderator to change the title, and credited a few other people

Share this post


Link to post
Share on other sites
Malacath    121

So, i've got this idea for a mod to do, but one thing i'd like to know is, could you make it where, when a monster is hit by a projectile fired from a staff it automatically becomes a follower, like pigs do whenever you give them meat, except getting hit by a projectile?

[...] the answer to "Can we do X in a mod?" is almost always "Yes, but it might not be easy." ;P

And in this case it's probably not even that difficult.

*rough outline*

I don't have any scripts at hand so I can only guess that there is a way to listen to the event that a projectile hits something thus being able to check that something for a follower component and add loyalty.

*rough outline end*

Share this post


Link to post
Share on other sites
Rosten    627

 

So, i've got this idea for a mod to do, but one thing i'd like to know is, could you make it where, when a monster is hit by a projectile fired from a staff it automatically becomes a follower, like pigs do whenever you give them meat, except getting hit by a projectile?

[...] the answer to "Can we do X in a mod?" is almost always "Yes, but it might not be easy." ;P

 

Fair enough, maybe i should change the title to, "Any idea how you would go about doing this" :p

Share this post


Link to post
Share on other sites
Malacath    121

Fair enough, maybe i should change the title to, "Any idea how you would go about doing this" :razz:

I added a very rough outline to my previous post  ; )

Share this post


Link to post
Share on other sites
Rosten    627

I added a very rough outline to my previous post  ; )

Thanks, i'll look into the game files (and you're mods files, the waverly's familiar looks like it might be a bit helpful)

and see what i can come up with

now, im not very proficient in LUA but i might as well take a wild guess as to what it might be along the lines of

something like :

listen for event("projectileHit") then inst:AddComponent("follower")

Well, thats my wild guess

 

P.s - I added a bit of the idea to the OP

Share this post


Link to post
Share on other sites
Malacath    121

I actually think that looking at the fire_projectile.lua file would be more helpful, also the projectile.lua component might give a few hints. And if you are especially unlucky both of those files don't even exist because I just pulled them from my memory and that part of me is a known evil.

But I know for sure that staffs.lua exists and the firestaff (or redstaff) in there might be a good startingpoint as well.

 

Good luck ^^

Share this post


Link to post
Share on other sites
Rosten    627

I actually think that looking at the fire_projectile.lua file would be more helpful, also the projectile.lua component might give a few hints. And if you are especially unlucky both of those files don't even exist because I just pulled them from my memory and that part of me is a known evil.

But I know for sure that staffs.lua exists and the firestaff (or redstaff) in there might be a good startingpoint as well.

 

Good luck ^^

Thanks for all the help, i'll try my best to make this mod a reality

i'll probably be using your guide for making the hand-held objects, so, thanks x2 

Happy Slurper Approves - post-287842-0-51302400-1384173296.png

 

P.s. - It seems you've been getting pretty popular around here, what with your involvement in the waverly project, and all the help you've been giving out on the forums :)

Share this post


Link to post
Share on other sites
Rosten    627

I actually think that looking at the fire_projectile.lua file would be more helpful, also the projectile.lua component might give a few hints. And if you are especially unlucky both of those files don't even exist because I just pulled them from my memory and that part of me is a known evil.

But I know for sure that staffs.lua exists and the firestaff (or redstaff) in there might be a good startingpoint as well.

 

Good luck ^^

Hey, quick question about your guide, i was following it exactly up to the point to see if i can debugspawn the item in, whenever i try to run it on don't starve then it crashes saying it can't find friendstaff.xml or friendstaff.tex, anyway to fix this?

 

Edit - im gonna try using the tex converter to create both files, and see if it works then

Edit2- It seems the tex worked, not sure how to make a xml file for it though

Share this post


Link to post
Share on other sites
seronis    130

Look at the code for the boomerang to see an example projectile that perform an action on contact (specifically it rethrows itself back at its owner).

Share this post


Link to post
Share on other sites
Rosten    627

Look at the code for the boomerang to see an example projectile that perform an action on contact (specifically it rethrows itself back at its owner).

Wow, thats actually a really good idea, something as seemingly insignificant as the return to you when you throw a boomerang could be exactly what we need

Share this post


Link to post
Share on other sites
Rosten    627

So, i took a quick look through the boomerang script, and it looks like the relevant code is this -

local function OnHit(inst, owner, target)
    if owner == target then
        OnDropped(inst)
    else
        ReturnToOwner(inst, owner)
    end
    local impactfx = SpawnPrefab("impact")
    if impactfx then
   local follower = impactfx.entity:AddFollower()
   follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )
        impactfx:FacePoint(inst.Transform:GetWorldPosition())
    end
end
 
Im thinking maybe something along the lines of ;
local function OnHit(target)
        then inst:AddComponent("follower")
-- although im not exactly sure how i would make it apply "follower" to the target, instead of the projectile, like the boomerang does

Share this post


Link to post
Share on other sites
Rosten    627

I actually think that looking at the fire_projectile.lua file would be more helpful, also the projectile.lua component might give a few hints. And if you are especially unlucky both of those files don't even exist because I just pulled them from my memory and that part of me is a known evil.

But I know for sure that staffs.lua exists and the firestaff (or redstaff) in there might be a good startingpoint as well.

 

Good luck ^^

So, i followed all the steps and substituted all the stuff and made the xml and tex files, but whenever  i try to run the mod don't starve just crashes, can someone look at this for me and make sure everythings in order?

(note "friendstaff" is the prefab name) WilsonsFriendWand(Mediafire) (are we allowed to use mediafire links here? it won't let me attach the .rar file to the attachments) I need this fixed as soon as possible because its a bit hard to make a mod without being able to test whether it works or not :/

Share this post


Link to post
Share on other sites
Malacath    121

I'll take a look when I get home, so you need to be just a bit more patient. Unless of course someone else comes along ; )

Also, you'll usually find a log.txt in your documents folder which contains information about the crash even if the game didn't show a crash screen.

Share this post


Link to post
Share on other sites
Heavenfall    184

This is not possible to do currently without editing the "brain" individually for each creature that you want the staff to work on.

Share this post


Link to post
Share on other sites
Rosten    627

This is not possible to do currently without editing the "brain" individually for each creature that you want the staff to work on.

Really? I Guess i could limit it to only a few monsters (probably would've had to anyways, having the ancient guardian as your personal destroyer-of-everything would be a bit OP eh?) could you give me a bit of insight unto how i would do this, i don't know how the brains work very well

Share this post


Link to post
Share on other sites
Rosten    627

Take a look at the pig and its brain, if you follow the code it is quite easy to understand.

I'm gonna experiment with this a while, firstly i'd like to try and set a different mob as always being a follower when you meet it, e.g rabbit, or something like that, then try and find out how i can apply that effect to certain mobs via a projectile

 

--Edit: Messing with brains is really difficult, whenever i was looking at the prefabs for items and scripts and such i could tell what was going on, what was making what happen etc. but these brains are way more complicated..

Share this post


Link to post
Share on other sites
Malacath    121

I'm gonna experiment with this a while, firstly i'd like to try and set a different mob as always being a follower when you meet it, e.g rabbit, or something like that, then try and find out how i can apply that effect to certain mobs via a projectile

 

--Edit: Messing with brains is really difficult, whenever i was looking at the prefabs for items and scripts and such i could tell what was going on, what was making what happen etc. but these brains are way more complicated..

Yes, I would suggest not messing with brains unless you feel super confident about coding. The code for different behaviours is actually not very complex on its own but the overall thing confused me back when I started using brains.

So I'd say try to stick with all the creatures that already have a follower component. Because those should also have the necessary brain to follow. Since it's your first mod that should be a good starting point.

Share this post


Link to post
Share on other sites
Rosten    627

Yes, I would suggest not messing with brains unless you feel super confident about coding. The code for different behaviours is actually not very complex on its own but the overall thing confused me back when I started using brains.

So I'd say try to stick with all the creatures that already have a follower component. Because those should also have the necessary brain to follow. Since it's your first mod that should be a good starting point.

Hmmm... I'm pretty sure the only mobs with a follower component are pigmen, abigail, chester, and beefalo, right?

On second thought, isnt abigail basically a re-skinned ghost with a follower component? interesting,

Controller of the dead anyone?

Share this post


Link to post
Share on other sites
Malacath    121

Hmmm... I'm pretty sure the only mobs with a follower component are pigmen, abigail, chester, and beefalo, right?

Let me do a quick search.

abigail

babybeefalo

beefalo

bishop

bunnyman

cavespiders

chester

hound

knight

mandrake

pigman

rocky

rook

shadowmaxwell

smallbird

spider

walrus

Some of those might not be of interest.

 

And of course you don't need to copy this list, you can check for the components existence by doing for example this

local function OnHit(target)    if target.components.follower then        --Do something here    endend

Share this post


Link to post
Share on other sites
Rosten    627

Let me do a quick search.

abigail

babybeefalo

beefalo

bishop

bunnyman

cavespiders

chester

hound

knight

mandrake

pigman

rocky

rook

shadowmaxwell

smallbird

spider

walrus

 

Some of those might not be of interest.

Hmm, lets pick a few out of there that seem promising

Abigail

Knight 

Bishop ( I imagine that these two are from the damaged clockworks when you repair them?)

Spider/Cavespider

Hound (Didn't know they had a follower component)

----------------------------------------------------------------------------------

That seems like a pretty good list of candidates

Share this post


Link to post
Share on other sites
Rosten    627
local function OnHit(target)    if target.components.follower then        -    endend

So, quick question about the baby beefalo, since, by default they follow normal beefalo, and overwriting that with a component to follow me would probably mess up its behaviors, is there anyway to keep both leaders but make one have higher priority then the other?

Share this post


Link to post
Share on other sites
seronis    130

I dont know the specifics but thats what the brain does. Its a graph of 'needs' that each creature processes in order. If a need isnt met it does that action. If its met it check the next Need in the list.  Pigs for example have a 'run around like headles chicken when on fire' need that is really high priority. It is a higher priority than the 'chase nearby spider' need.  This means if a pig is on fire it will be worried about itself and less about nearby enemies which is a logical reaction.

 

Basically if you insert the  'desire to follow player' at a higher priority than the 'desire to follow mother' then the player is the one who will be followed.

Share this post


Link to post
Share on other sites
Malacath    121

Hmm, lets pick a few out of there that seem promising

Abigail

Knight

Bishop

Spider/Cavespider

Hound (Didn't know they had a follower component)

----------------------------------------------------------------------------------

That seems like a pretty good list of candidates

Hounds follow McTusk. Well at least blue hounds, but all hounds share the part of following you. Also, see my previous post updated , I'm sorry that I always update posts five seconds after posting them.

 

It could also happen, that just making a certain prefab a follower won't work. I remember making hounds a follower was quite a hassle because they still target you in that case so it basically needed a rework of the KeepTarget function in hounds.lua

So you should try out for which mobs it works good.

 

 

So, quick question about the baby beefalo, since, by default they follow normal beefalo, and overwriting that with a component to follow me would probably mess up its behaviors, is there anyway to keep both leaders but make one have higher priority then the other?

Uhhmmm I have no clue how the interactions would be. And I'm quite sure you cannot have more than one leader.

Share this post


Link to post
Share on other sites
Rosten    627

Hounds follow McTusk. Well at least blue hounds, but all hounds share the part of following you. Also, see my previous post updated , I'm sorry that I always update posts five seconds after posting them.

 

It could also happen, that just making a certain prefab a follower won't work. I remember making hounds a follower was quite a hassle because they still target you in that case so it basically needed a rework of the KeepTarget function in hounds.lua

So you should try out for which mobs it works good.

 

 

Uhhmmm I have no clue how the interactions would be. And I'm quite sure you cannot have more than one leader.

Ill try and keep that in mind when im selecting the candidates for followers,

 

Also, i think i remember seeing one mod where you could have a hound friend, but whenever a pack of hounds came it would become hostile towards you again and when you killed off the rest of the pack it would become friendly again, i forgot what it was, might have been Wulfe, That sounds pretty similar to what im talking about

Share this post


Link to post
Share on other sites