htv1lla1n

  • Content count

    37
  • Joined

  • Last visited

 Content Type 

Profiles

Forums

Downloads

Klei Bug Tracker

Game Updates

Hot Lava Bug Reporter

Posts posted by htv1lla1n


  1. On 17.09.2019 at 8:44 PM, Ultroman said:

    Changing what loot drops from certain mobs/entities is a subjective matter, as the lootdropper-component can be set up in various ways. Some entities have random drops, some have weighted drops, some have static drops, some have state-based drops etc.. Look at the lootdropper-component. Read the code there. Go to the prefab you want to change, and see how it sets up its lootdropper-component.

    An alternative route, is to instead simply listen to the event "killed" on your character, because anything you kill that has a combat component on will push this event, with its data parameter containing data.victim, so you can manually drop things using the entity's own lootdropper component like this. If you want to know more, study the lootdropper component and how it is used in the game code.

    Make Mobs Drop Certain Extra Loot Only When My Character Kills Them

    
    inst:ListenForEvent("killed", function(inst, data)
    	local victim = data.victim
    	if not victim then
    		return
    	end
    	
    	if not victim.components.lootdropper then
    		victim:AddComponent("lootdropper")
    	end
    
    	local lootdropper = victim.components.lootdropper
    	
    	if lootdropper then
    		local victimpos = victim:GetPosition()
    		lootdropper:SpawnLootPrefab("SOME_ITEM_PREFAB_NAME", victimpos)
    		lootdropper:SpawnLootPrefab("SOME_OTHER_ITEM_PREFAB_NAME", victimpos)
    	end
    end)

    You can then expand the code to give different drops depending on the prefab name of the victim or the components they have or whatever you want. Now, this only works for victims with a combat component on it. Prey like rabbits and birds do not have a combat component, so you'll have to do something different for those. Let me know if you want that.

    This post shows how you can remove slipperiness entirely from your character. Note that this approach ONLY works in DS and not DST.

    Thanks yet again, mah dude. 

    Quote

    Removing the sanity loss from rain is difficult, but if you want to remove all these wetness things anyway, why not just make your character entirely unwettable?

    
    inst.component.moisture.maxMoistureRate = 0
    inst.component.moisture.baseDryingRate = 100

    The first line should do it, but in case you can get wet from other things, setting the base drying rate to a ridiculous amount will take care of it.

    The reason why I don't make him completely unwettable is because he gets bonuses when reaching certain moisture levels (really just stat bonuses), which I already implemented. I just needed to remove the sanity penalty. 

     

    Btw character still loses sanity when holding a wet tools/weapon/whatever. How do I remove this?


  2. Can't turn off the moisture sanity penalty (SW). 

    I put the code under the local(fn) = function(inst), and copypasted the code there. So the code's 

    Quote

        inst:DoTaskInTime( 0.1, function(inst) 
            if inst.components.moisture then
                local m = inst.components.moisture
                if m:GetMoisture() then
                    TUNING.MOISTURE_SANITY_PENALTY_MAX = 0
                end
            end
        end)

    But the game ignores it completely. No crash, nothing - I just get the sanity drain. 
     

    I'm figuring I need a different code for SW? 

     

    EDIT: Items. Ok, I need a code to remove the sanity penalty from wet items. can't figure it out. 


  3. I'm so close to adding all main mechanics to my character, the only thing I need to add but don't know how to do that, is how do I make enemies drop additional items (FYI that already exist in the game) after they're killed? Basically I want them to drop dubloons (2 on regular, 10 for bosses etc) (and oinks if Hamlet is enabled, if its possible. could also add another "money" item, maybe i'll even do but that doesn't matter rn) once slain. I can't even start figuring it out and I don't know on what mod's code to look on, nothing comes to mind. Pls help and thank you.

     

     

    Oh, and while I'm at it, how do I remove all the downsides of moisture (sanity penalty and (maybe) slippery tools)? 


  4. 1 hour ago, Ultroman said:

    The whole code snippet has to go inside your fn function.

    Like this: pyke.lua

    If it complains about the defaultDamageSettings or damageSettings missing, use this instead: pyke2.lua 

    funny thing is, i tried to put it in but it still gave me the same error..

    ...or i WANTED to try it out, but I got distracted. anyways IT FINALLY DIDN'T CRASH WOOHOOOOOOOOOO ty again bro

    • Like 1

  5. 13 hours ago, Ultroman said:

    Where did you put the code? Show me your character prefam lua file. Attach it to a reply here.

    Ok, I played with it a bit and now it crashes with a different error: "variable 'inst' is not declared"

    i feel ashamed for showing my code because i'm super inexperienced and i suck but oh well gotta learn it seems

     

    there. i probably screwed up somewhere didn't i?

    pyke.lua


  6. 17 hours ago, Ultroman said:

    That's actually an easy one. The CalcDamage function of the combat component has everything you need for this; target, weapon and current multiplier.

    
    local defaultDamageSettings = { executeThreshold = 0.30, executeDamage = 99999 }
    
    local damageSettings = {
    	spider = defaultDamageSettings,
    	spider_warrior = { executeThreshold = 0.20, executeDamage = 99999 },
    	bearger = { executeThreshold = 0.05, executeDamage = 9999 },
    }
    
    local oldCalcDamage = inst.components.combat.CalcDamage
    inst.components.combat.CalcDamage = function(self, target, weapon, multiplier, ...)
    	local result = oldCalcDamage(self, target, weapon, multiplier, ...)
    	if result ~= 0 and weapon ~= nil and weapon.prefab == "someprefabname"
    	and target ~= nil and target:IsValid() and target.components.health then
    		local targetDamageSettings = damageSettings[target.prefab] or defaultDamageSettings
    		if target.components.health:GetPercent() <= targetDamageSettings.executeThreshold then
    			return targetDamageSettings.executeDamage
    		else
    			return result
    		end
    	else
    		return result
    	end
    end

    You can play around with that. You can do a bunch of different things with that as your base template. You can even put in specific damage numbers for specific weapons like this:

    
    local defaultDamageSettings = { executeThreshold = 0.30, executeDamage = 5000, myWeaponExecuteDamage = 99999 }
    
    local damageSettings = {
    	spider = defaultDamageSettings,
    	spider_warrior = { executeThreshold = 0.20, executeDamage = 99999, myWeaponExecuteDamage = 99999 },
    	bearger = { executeThreshold = 0.05, executeDamage = 9999, myWeaponExecuteDamage = 99999 },
    }

    And then move the weapon-part of the if-statement inside the if-statement as its own check.

    Thank you so much! I knew it was something easy but I couldn't exactly figure out how to get the actual health of the enemy. 
    You're my savior xd

    • Like 1

  7. Want to create a character who will execute the enemy under certain threshold of health. Basically, he deals 99999 damage to targets, who're under, let's say, 30% of max health. How do I do that, and is there a way to make him execute certain enemies only under certain thresholds (for example, he'll execute a Spider when the Spider/any other low-health mob (<200hp max) is under 50%; but will execute a Tiger Shark/any other boss only if she's under 10% et cetera.)

    I have general ideas about it, but the most important part is how do I get the game to check for the current health of the enemy and see if it's under a 30% threshold with a certain weapon (that doesn't deal DoT if it's important)?