toasterbathbomb Posted August 1, 2018 Share Posted August 1, 2018 I want to give my character a special perk, where when the character is in a fight, he gets a small sanity boost. How would I go about doing this? Link to comment Share on other sites More sharing options...
Lumina Posted August 1, 2018 Share Posted August 1, 2018 One option is to give them a small boost each time they attack an enemy (similar to wigfrid but smaller, and only for sanity). I'm not sure there are other ways to be sure a character is "active" in a fight. Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 1, 2018 Author Share Posted August 1, 2018 6 minutes ago, Lumina said: One option is to give them a small boost each time they attack an enemy (similar to wigfrid but smaller, and only for sanity). I'm not sure there are other ways to be sure a character is "active" in a fight. How would I do this? Link to comment Share on other sites More sharing options...
Lumina Posted August 1, 2018 Share Posted August 1, 2018 I'm not sure exactly, i'll check tomorrow. You probably want to look at wathgrith.lua code. Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 3, 2018 Author Share Posted August 3, 2018 On 8/1/2018 at 6:04 PM, Lumina said: I'm not sure exactly, i'll check tomorrow. You probably want to look at wathgrith.lua code. Any luck finding anything? I'm not sure how i can look at Wigfrids code, i'm not good at that stuff Link to comment Share on other sites More sharing options...
Lumina Posted August 3, 2018 Share Posted August 3, 2018 (edited) 7 hours ago, toasterbathbomb said: Any luck finding anything? I'm not sure how i can look at Wigfrids code, i'm not good at that stuff Go in the folder of the game, then in data, then in databundle. There, you have a scripts.zip : open the archive somewhere. In scripts/prefabs search for the wathgrith.lua file (you can open it with any text editor, but i suggest notepad++). About your perk i would try something like this : local function IsValidVictim(victim) return victim ~= nil and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end local function OnAttackOther(inst, data) local victim = data.victim if IsValidVictim(victim) then inst.components.sanity:DoDelta(-TUNING.SANITY_SMALL) end end inst:ListenForEvent("onattackother", OnAttackOther) You probably want to adjust the list of valid victim (it's here so you don't gain sanity when attacking walls, for example). The second line goes in the master_postinit function. Code is untested, so there could be errors. Edited August 3, 2018 by Lumina Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 3, 2018 Author Share Posted August 3, 2018 4 hours ago, Lumina said: master_postinit Where can I find this? where do i put this code? Link to comment Share on other sites More sharing options...
Lumina Posted August 3, 2018 Share Posted August 3, 2018 Search in your character.lua file. Then if you still don't know how to put it, look at other character files to have some idea (or other creatures). Don't hesitate to search, a lot. The option "search in all files" is very useful. If you still don't find or are unsure, then ask again Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 3, 2018 Author Share Posted August 3, 2018 4 hours ago, Lumina said: Search in your character.lua file. Then if you still don't know how to put it, look at other character files to have some idea (or other creatures). Don't hesitate to search, a lot. The option "search in all files" is very useful. If you still don't find or are unsure, then ask again Alright, i checked out wathgrithr.lua and looked at the code, then put the code you sent into my prefab file like so The game didnt have any problems, no crashes or errors, but after i killed a couple birds and rabbits with a boomerang, i had no sanity boost. Did I put the code in the wrong place? Link to comment Share on other sites More sharing options...
Lumina Posted August 3, 2018 Share Posted August 3, 2018 Try to kill a spider. The code used, at the moment, will not consider birds and rabbits as valid victim, because of this line : and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or (Rabbits and birds are prey and not hostile). This could be changed, i'm just unsure about how exactly (Yeah, i'm not good with logic and stuff like this). Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 3, 2018 Author Share Posted August 3, 2018 1 hour ago, Lumina said: Try to kill a spider. The code used, at the moment, will not consider birds and rabbits as valid victim, because of this line : and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or (Rabbits and birds are prey and not hostile). This could be changed, i'm just unsure about how exactly (Yeah, i'm not good with logic and stuff like this). my sanity... dropped? how do i make it increase? Link to comment Share on other sites More sharing options...
Lumina Posted August 3, 2018 Share Posted August 3, 2018 16 minutes ago, toasterbathbomb said: my sanity... dropped? how do i make it increase? Oops I took a code i use for sanity loss. Just change : inst.components.sanity:DoDelta(-TUNING.SANITY_SMALL) Into : inst.components.sanity:DoDelta(TUNING.SANITY_SMALL) local function IsValidVictim(victim) return victim ~= nil and not victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end If you want to include bird, rabbit, and all the prey in the code, try this version of the "isvalidvictim" function. Not tested, tell me if you encounter problems. Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 7, 2018 Author Share Posted August 7, 2018 On 8/3/2018 at 5:09 PM, Lumina said: Not tested, Link to comment Share on other sites More sharing options...
Lumina Posted August 7, 2018 Share Posted August 7, 2018 Zip your mod and attach it here if you want me to help. Link to comment Share on other sites More sharing options...
toasterbathbomb Posted August 7, 2018 Author Share Posted August 7, 2018 11 minutes ago, Lumina said: Zip your mod and attach it here if you want me to help. aeiou.zip Link to comment Share on other sites More sharing options...
Lumina Posted August 7, 2018 Share Posted August 7, 2018 13 minutes ago, toasterbathbomb said: aeiou.zip Let me know if this works better with this : local function IsValidVictim(victim) return victim ~= nil and not (victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end Also, don't use twice the "isValidVictim" function, replace one by the other, or comment the unused one, or you risk to cause crashs. For example : --New code, delete it if the game crashes -- local function IsValidVictim(victim) -- return victim ~= nil -- and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or -- victim:HasTag("veggie") or -- victim:HasTag("structure") or -- victim:HasTag("wall") or -- victim:HasTag("companion")) -- and victim.components.health ~= nil -- and victim.components.combat ~= nil -- end --More new code local function IsValidVictim(victim) return victim ~= nil and not (victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end If you really want to keep the old function somewhere for the time of test. But i suggest to remove it after. 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