KingWyrm Posted December 29, 2014 Share Posted December 29, 2014 I need assistance. Im trying to make a berserker type character that basically gains sanity and health when attacking/murdering things. I wanted to make it that whenever she hit something(anything combat related) she gains about 5 health and 3 sanity. but it only works on axes. how would I code that? Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/ Share on other sites More sharing options...
KingWyrm Posted December 29, 2014 Author Share Posted December 29, 2014 Actually, I need help with the whole coding thing. I Kind of get the gist of lua but when Im trying to code for night vision when a certain health, attack bonuses for specifc weapons. I try to test it out but DS keep crashing. someone please show me what I'm doing wrong. I've attach the file as a whole if needed but i think im worried thatI maybe using the wrong function. like here. for toggling night vision.local function health(inst, data) if inst.components.health.current <= 100 then inst.light:Enable(false) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.8) inst.components.locomotor.runspeed = (TUNING.WILSON_WALK_SPEED * 1.0) if inst.components.health.current > 100 then inst.light:Enable(true) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_WALK_SPEED * 2.0) end --night vision local light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(6) inst.Light:SetFalloff(0.50) inst.Light:SetIntensity(.6) inst.Light:SetColour(235/255,12/255,12/255) inst:ListenForEvent( "dusktime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld()) updatestats(inst) Kite-the Berserker.zip Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/#findComment-594048 Share on other sites More sharing options...
Mobbstar Posted December 29, 2014 Share Posted December 29, 2014 There, I restructured it. You need to call the function tryVision at some point, for example in a ListenForEvent. local function tryVision(inst, data) if inst.components.health.current <= 100 then inst.light:Enable(false) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.8) inst.components.locomotor.runspeed = (TUNING.WILSON_WALK_SPEED * 1.0) elseif inst.components.health.current > 100 then if not inst.Light then inst.entity:AddLight() end inst.Light:SetRadius(6) inst.Light:SetFalloff(0.50) inst.Light:SetIntensity(.6) inst.Light:SetColour(235/255,12/255,12/255) inst.light:Enable(true) inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_WALK_SPEED * 2.0) endend --these do not belong here, put them in the characters main 'fn' inst:ListenForEvent( "dusktime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld()) updatestats(inst) Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/#findComment-594064 Share on other sites More sharing options...
KingWyrm Posted December 29, 2014 Author Share Posted December 29, 2014 thanks alot. I thought you have to call in for a global light or something to that effect. then again im looking at different character mods that are probably out dated.the tutorials here are really nice but I feel like I can do better with them if I actually know what im looking for as far a code is concern. Hopefully, the classes I take will help. Also, would you be so kind as to head me in the right direction for the on hit healing effects. I Think it should be code to look for the axe and apply. the Onequip maybe, or should I use something from the combat component. I honestly dont know where to start. Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/#findComment-594209 Share on other sites More sharing options...
KingWyrm Posted December 30, 2014 Author Share Posted December 30, 2014 (edited) --these do not belong here, put them in the characters main 'fn' inst:ListenForEvent( "dusktime", function() updatestats(inst) end , GetWorld())inst:ListenForEvent( "daytime", function() updatestats(inst) end , GetWorld()) inst:ListenForEvent( "nighttime", function() updatestats(inst) end , GetWorld()) updatestats(inst) where exactly does this go? In another file or as i seen in other files in the master_postinit Edited December 30, 2014 by KingWyrm Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/#findComment-594378 Share on other sites More sharing options...
Mobbstar Posted December 30, 2014 Share Posted December 30, 2014 where exactly does this go? In another file or as i seen in other files in the master_postinit master postinit? That's faaar more advanced. I am talking about the function mentioned in MakePlayerCharacter(), which usually is called fn(). Link to comment https://forums.kleientertainment.com/forums/topic/47798-character-modding-onattack-effects/#findComment-594463 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