Jump to content

WIP - Better Traps, first MOD seeking help.


Silane

Recommended Posts

So images like this:

 

474659.png474660.png474661.png

Not exactly, the background will be the hud so for the penguin and the slurtle you'll have to have transparency behind the images. The trap image is to big. And also, you don't have a custom trap yet anyways which could use that image.

Link to comment
Share on other sites

The trap image was for the mod icon.    Dunno if that would work though....

 

474662.png474663.png

Ahhh, i see ^^ Yes that would probably work, just try it.

Now name them "penguin.png" and "slurtle.png" and put them in "images/inventoryimages/", you can put the modicon.png in "images/".

Download "Don't Starve Mod Tools" from Steam and start the game.

Done.

Link to comment
Share on other sites

Nevermind.  I was being an idiot again.  XD   

(I can't spell apparently)

 

 

Now for the next goal..... to make them give you loot when you murder them.  >D    Mwahahahaha!

 

 

But for now it works and it does catch them so I am very happy.  :D

 

Thanks again everyone for the help!   And your patience with me.  ;)

Link to comment
Share on other sites

I think to get it to work I will need to use this code:

 inst:AddComponent("lootdropper")

But it will need to be in it's own function.....   Maybe only defined by it's inventory status?  (Dunno)

 

 

Interestingly enough, when a caught Pengull is set back down it does not join its flock.  XD     Other than it being odd it doesn't seem to affect gameplay.

Link to comment
Share on other sites

Interestingly enough slurtles already give you their loot when you murder them but penguins don't... I'll try to find out why.

 

EDIT: I think it's just that penguins don't have a 100% chance to drop something. And I coincidentally always ended up with nothing.

Link to comment
Share on other sites

Get _simplex_testing, it's the fastest thing to use for that. You only need to write gimme("slurtle") in the console. And I don't see a reason not to use it  ; )  And when you don't want anything you hover over the penguin and press "CTRL"+"K" and it dies. Just remember to disable it when you want to play serious.

 

@simplex On that note, someone uploaded _simplex_testing on Steam Workshop, is that fine for you or did he even ask you?

Link to comment
Share on other sites

That's rather awesome and helpful.  Thanks.  :D

 

On discovering that!   It seems the traps do not work on Snurtles.... just the Slurtles and penguins, and when a penguin is caught/murdered no loot item.

 

Would I have to make another function block for the snurtle as well as the inventory image?  (Only reason I ask is because there is no actual prefab for snurtles, only for the slurtles.)

Link to comment
Share on other sites

On discovering that!   It seems the traps do not work on Snurtles.... just the Slurtles and penguins, and when a penguin is caught/murdered no loot item.

I wrote further up that loot for penguins has only a chance of 10% to drop (I might not have mentioned this number). The same goes right now for murdering it in the inventory.

 

 

Would I have to make another function block for the snurtle as well as the inventory image?  (Only reason I ask is because there is no actual prefab for snurtles, only for the slurtles.)

Yes, you'd have to do another function. It's not true that there is no snurtle prefab, there might not be a seperate file for it but there is a prefab. One file can return as many prefabs as you want and slurtle.lua does that

return Prefab("cave/slurtle", makeslurtle, assets, prefabs),       Prefab("cave/snurtle", makesnurtle, assets, prefabs) 

EDIT: You can use the follwinf modmain which is a bit more compact. But it's also more rigid so you need to consider for yourself:

local function ModPrefab(inst)    inst:AddTag("canbetrapped")	inst:AddComponent("inventoryitem")	inst.components.inventoryitem.canbepickup = false    inst.components.inventoryitem.imagename = inst.prefab    inst.components.inventoryitem.atlasname = "images/inventoryimages/"..inst.prefab..".xml"endAddPrefabPostInit("penguin", ModPrefab)AddPrefabPostInit("slurtle", ModPrefab)

This way you can use the same function for all prefabs you want to modify.

Link to comment
Share on other sites

Oh!  I did not know about the loot % on Penguins...    I may have to do something about that later.  ;)

 

But I have added the code for the snurtle file and tested it.  :D     So I will be uploading that post haste.      I'll have to keep that in mind about multiple prefabs in files though.  Yup, yup.

Link to comment
Share on other sites

......................  I just found out.  Now traps are useless as this makes it so you can just pickup the creature?    There is a line that says:  inst.components.inventoryitem.canbepickup = false

Shouldn't that cancel being able to pick them up?

 

Also!  Changed the mod to allow frogs to be trapped/picked up as living inventory items.  :D   But the same does not work for making a spider an inventory item?

 

And then to make the stackable as inventory items I believe I would need to use the: inst:AddComponent("stackable")

 

But would I set them up as separate functions to the traps?  (I believe so, just asking)

 

And than about changing the chance of loot dropped by creatures, is there a way to only set an increase of loot as an inventory item?   

Link to comment
Share on other sites

......................  I just found out.  Now traps are useless as this makes it so you can just pickup the creature?    There is a line that says:  inst.components.inventoryitem.canbepickup = false

Shouldn't that cancel being able to pick them up?

Uhhhh yes, it should  o.0

This is straight copy-paste from "rabbit.lau" so it should definately work. You can also see the typo  xD

inst.components.inventoryitem.canbepickedup = false
Also!  Changed the mod to allow frogs to be trapped/picked up as living inventory items.   :grin:   But the same does not work for making a spider an inventory item?

Sweet  ^^

I think this technique should work for all mobs, no clue why it doesn't for spiders...

And then to make the stackable as inventory items I believe I would need to use the: inst:AddComponent("stackable")

 

But would I set them up as separate functions to the traps?  (I believe so, just asking)

In a single AddPrefabPostInit you can change as many things as you want about the prefab. I.e. change stategraphs or brains, remove components....

So you can use the same function. But when you use one function for multiple prefabs you need to be careful that all changes are valid for all those prefabs. I would for example not use the current function for rabbits to add the stackable component because you would also add things that rabbits already have and change the path to its inventoryimage and so on. So just be careful what you change wiith the functions.

At the same time you can run as many AddPrefabPostInit functions for a single prefab as you want. So you can add an additional on just for the penguin to modify loot.

And than about changing the chance of loot dropped by creatures, is there a way to only set an increase of loot as an inventory item?   

It is definately possible. But it involves a bit more code. I can give you a rough outline of the process though.

Listen for the event "death" on the penguin, check if the penguin iis held via inventoryitem:IsHeld() and in the case it is you can add your custom loot to the killer.

Link to comment
Share on other sites

That fixed the picking up/and trapping issue thanks Malacath.   :grin:    However now when it catches a frog the frog is simply disappearing?  Is this possibly due to the fact that they are already trappable?

 

The full section on the rabbit prefab is this:

inst.components.inventoryitem.nobounce = trueinst.components.inventoryitem.canbepickedup = falseinst.components.inventoryitem:SetOnPickupFn(onpickup)inst.components.inventoryitem:SetOnDroppedFn(ondrop)

Should I make use of the other 3 lines as well?

 

Note that this is only happening when a spider or frog gets trapped with the current coding...

Link to comment
Share on other sites

That fixed the picking up/and trapping issue thanks Malacath.   :grin:    However now when it catches a frog the frog is simply disappearing?  Is this possibly due to the fact that they are already trappable?

 

The full section on the rabbit prefab is this:

inst.components.inventoryitem.nobounce = trueinst.components.inventoryitem.canbepickedup = falseinst.components.inventoryitem:SetOnPickupFn(onpickup)inst.components.inventoryitem:SetOnDroppedFn(ondrop)Should I make use of the other 3 lines as well?

Note that this is only happening when a spider or frog gets trapped with the current coding...

It worked before adding the "canbepickedup" line?

Link to comment
Share on other sites

Yup.  Before I changed the "canbepick/edup" thing the frog was able to be trapped and become a whole inventory item that is murder-able.  ;P   Not the spider though.  

(But you could also just run over and pick the dang frog up.  >.< )

Link to comment
Share on other sites

I have no clue, sorry. I took a quick glance over the prefabs of the spider and the frog but didn't see anything intriguing. Maybe you can find something when you look careful enough.

In the hopes that I don't forget to I will take a closer look at a later point in time.

Link to comment
Share on other sites

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.

×
  • Create New...