Shaidoc Posted April 7, 2015 Share Posted April 7, 2015 Is there a script I can write for a character that would give the infinite blowdarts, and if not, how can I increase the amount of blowdarts started with? Link to comment Share on other sites More sharing options...
DarkXero Posted April 7, 2015 Share Posted April 7, 2015 (edited) 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)endAnd 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 April 7, 2015 by DarkXero Link to comment Share on other sites More sharing options...
Shaidoc Posted April 7, 2015 Author Share Posted April 7, 2015 Thanks, but it's for a friends character. Link to comment Share on other sites More sharing options...
DarkXero Posted April 7, 2015 Share Posted April 7, 2015 You just have to replace shaidoc in the modmain code for your friend's character name.Then make him add or edit the start_inv thing, if necessary or wanted. Minor changes. Link to comment Share on other sites More sharing options...
Shaidoc Posted April 7, 2015 Author Share Posted April 7, 2015 Can you explain how that code makes the darts infinite? So I can use it if I make a custom weapon. Link to comment Share on other sites More sharing options...
DarkXero Posted April 7, 2015 Share Posted April 7, 2015 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 More sharing options...
Shaidoc Posted April 7, 2015 Author Share Posted April 7, 2015 (edited) 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 April 7, 2015 by Shaidoc Link to comment Share on other sites More sharing options...
DarkXero Posted April 7, 2015 Share Posted April 7, 2015 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 More sharing options...
Shaidoc Posted April 8, 2015 Author Share Posted April 8, 2015 OK, how could i make an item within the game into an infinite weapon? Link to comment Share on other sites More sharing options...
DarkXero Posted April 8, 2015 Share Posted April 8, 2015 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 More sharing options...
Shaidoc Posted April 8, 2015 Author Share Posted April 8, 2015 (edited) 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 April 8, 2015 by Shaidoc Link to comment Share on other sites More sharing options...
Kzisor Posted April 8, 2015 Share Posted April 8, 2015 @Shaidoc, if you do that, it will make it unlimited for every character after you've enabled your mod. Link to comment Share on other sites More sharing options...
Shaidoc Posted April 8, 2015 Author Share Posted April 8, 2015 Yeah I see this now lol, didn't think it through XD. Link to comment Share on other sites More sharing options...
Shaidoc Posted April 8, 2015 Author Share Posted April 8, 2015 Anyway to nerf the damage of blow darts on a character? Link to comment Share on other sites More sharing options...
Shaidoc Posted April 8, 2015 Author Share Posted April 8, 2015 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 More sharing options...
DarkXero Posted April 9, 2015 Share Posted April 9, 2015 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-2has 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 More sharing options...
Shaidoc Posted April 9, 2015 Author Share Posted April 9, 2015 I tried to replace the spear with the pan flute for a friends character, but it broke meh game. said there was an error in proclaiming. Link to comment Share on other sites More sharing options...
DarkXero Posted April 9, 2015 Share Posted April 9, 2015 (edited) 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 April 9, 2015 by DarkXero Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now