Jump to content

Infinite Blowdarts?


Recommended Posts

This gives you a blowdart, when you use a blowdart.

 

Put this in modmain.lua:

local blowdarts = {	"blowdart_sleep",	"blowdart_fire",	"blowdart_pipe"}for k, v in pairs(blowdarts) do	AddPrefabPostInit(v, function(inst)		if inst.components.projectile then			local old = inst.components.projectile.onhit			function inst.components.projectile.onhit(inst, attacker, target)				if attacker.prefab == "shaidoc" and attacker.components.inventory then					local item = GLOBAL.SpawnPrefab(v)					attacker.components.inventory:GiveItem(item)				end				return old(inst, attacker, target)			end		end	end)end

And considering that you have:

return MakePlayerCharacter("shaidoc", prefabs, assets, common_postinit, master_postinit, start_inv)

in shaidoc's prefab file, you put:

local start_inv = {    "scythe",    "blowdart_sleep",    "blowdart_fire",    "blowdart_pipe"}

unless you want to have to craft a blowdart in order to make it infinite.

Edited by DarkXero
Link to comment
Share on other sites

To make your own infinite custom weapon, the only thing you have to do is NOT to put the finite uses component.

This way, when you attack with it, no uses will be consumed, and the weapon will not break.

 

Blowdarts are a bit different because they are projectiles by themselves.

 

Each blowdart prefab has a projectile component. So you attack with them using them as projectiles.

I know that when a projectile hits a target, it has been used, and I can hook a function to run when the projectile hits a target.

The function I execute checks if the attacker is a special character.

If it is, then it generates a new blowdart, identical to the one consumed, and gives it to the character's inventory.

 

Basically, when you use a blowdart, another blowdart appears in your inventory.

Link to comment
Share on other sites

Just tested the character and found that every time he uses the dart you have to manually equip.

 

*EDIT* I just did this:

local start_inv = {	"blowdart_pipe",	"blowdart_pipe",}
Edited by Shaidoc
Link to comment
Share on other sites

If you have a single dart, and you use it, it gets consumed, and when you receive the new dart, it won't go to your equipped slot.

Using two darts, you will fire one, keep one in the equipped slot, and gain one there.

 

So yeah, use two darts to not have to manually equip them again and again.

Link to comment
Share on other sites

Remove the finiteuses component from the weapon.

Or make a new weapon without the finiteuses component.

 

Or use something like this:

AddPrefabPostInit("spear", function(inst)	if inst.components.finiteuses and inst.components.inventoryitem then		local durab = inst.components.finiteuses		local old = durab.Use		function durab:Use(num)			local owner = inst.components.inventoryitem.owner			if owner.prefab == "wilson" then				old(durab, 0)			else				old(durab, num)			end		end	endend)

So the durability of a spear goes down with anybody that isn't Wilson.

 

What do you want?

A current weapon in the game to be infinite for everybody?

Make all weapons in the game have no durability?

Make a new weapon infinite to everybody?

Make a weapon only usable by a certain character?

Link to comment
Share on other sites

Thx, I kinda just add the weapons prefab to the mods folder and removed the finite from there.

 

I'm wanting to make that an item will never break if a player is using it and make it so that an item doesn't use up fuel if a player is using it.

Edited by Shaidoc
Link to comment
Share on other sites

OK, here are my need to knows:

 

Is there a way to set up a local function to make a certain player's damage increase vs. animals, but base vs. monsters? I.E. for a hunter type character.

 

A way to make you give less light the less sanity you have? My character, Shaidoc, controls shadows and pushes them back for his friends and himself, but the lower his sanity is the harder it is for him to.

 

A way to make the onemanband use no fuel for only one character?

Link to comment
Share on other sites

1)

local animalmult = {	beefalo = 4,	rabbit = 2,	perd = 3,	koalefant_summer = 5,	koalefant_winter = 5,	penguin = 10}AddComponentPostInit("combat", function(self)	local old = self.CalcDamage	function self:CalcDamage(target, weapon, multiplier)		if self.inst.prefab == "shaidoc" and animalmult[target.prefab] then			return old(self, target, weapon, animalmult[target.prefab])		else			return old(self, target, weapon, multiplier)		end	endend)

2)

http://forums.kleientertainment.com/topic/52637-game-crashes-on-enabling-of-mod/page-2

has an example of modifying a light radius based on sanity.

 

3)

This one is ugly. It's either modifying the builder component to make an exception, or (easier) making a onemanbandspecial (this is, cloning the onemanband prefab into your mod to make a "new" prefab (only different in name)), then doing:

-- in shaidoc.lua's master_postinitinst:AddTag("shadowbonger")-- in modmain.luaGLOBAL.Recipe("onemanbandspecial", {GLOBAL.Ingredient("goldnugget", 2), GLOBAL.Ingredient("pigskin", 2)}, GLOBAL.RECIPETABS.MAGIC, GLOBAL.TECH.MAGIC_TWO, nil, nil, nil, nil, "shadowbonger")

Else, you will overwrite the onemanband recipe and other people won't be able to have it.

Link to comment
Share on other sites

I used:

AddPrefabPostInit("panflute", function(inst)    if inst.components.finiteuses and inst.components.inventoryitem then        local durab = inst.components.finiteuses        local old = durab.Use        function durab:Use(num)            local owner = inst.components.inventoryitem.owner            if owner.prefab == "wilson" then                old(durab, 0)            else                old(durab, num)            end        end    endend)

just fine for Wilson. No uses consumed. Are you in the RoG testing branch?

 

And it is a good idea to always post logs.

Zip them and attach them or put them in spoilers, like:

[­spoiler] Hello World [/­spoiler]

Edited by DarkXero
Link to comment
Share on other sites

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
 Share

×
  • Create New...