Jump to content
Sign in to follow this  
DarkKreepe

How to change character health?

Recommended Posts

Hello everyone. I have a problem with changing of character health

I need to change character health to 50% or decrement it on 50%

 

player:getBodyDamage():AddDamage(BodyDamage:ToIndex(BodyPartType.Hand_R), 0.5)

 

This script dont work and print an error in console 

Edited by DarkKreepe

Share this post


Link to post
Share on other sites

Maximum health of a body part would be 100, so you would be decreasing its health by 0.5 to 99.5.

What you'd want to do is:
 

local rightHand = getPlayer():getBodyDamage():getBodyPart(BodyPartType.Hand_R);
rightHand:AddDamage(rightHand:getDamage()-50); // set damage to 50%

 

Share this post


Link to post
Share on other sites
38 minutes ago, blindcoder said:

Maximum health of a body part would be 100, so you would be decreasing its health by 0.5 to 99.5.

What you'd want to do is:
 


local rightHand = getPlayer():getBodyDamage():getBodyPart(BodyPartType.Hand_R);
rightHand:AddDamage(rightHand:getDamage()-50); // set damage to 50%

 

 

Thank you very much, blindcoder, but this script don't work... I don't know why.

Maybe i missed required lua like:

require "ISUI/ISUIElement"
require('NPCs/MainCreationMethods');

 

Share this post


Link to post
Share on other sites
Blood check complete
-----------------------------------------
STACK TRACE
-----------------------------------------
function: OZBloodTypeCheck -- file: OZBGIIN.lua line # 102
java.lang.RuntimeException: Object tried to call nil in OZBloodTypeCheck
    at se.krka.kahlua.vm.KahluaUtil.fail(KahluaUtil.java:91)
    at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:947)
    at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
    at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1727)
    at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1672)
    at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:53)
    at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:81)
    at zombie.Lua.Event.trigger(Event.java:37)
    at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:61)
    at zombie.gameStates.IngameState.enter(IngameState.java:544)
    at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:145)
    at zombie.GameWindow.logic(GameWindow.java:619)
    at zombie.GameWindow.run(GameWindow.java:1173)
    at zombie.GameWindow.maina(GameWindow.java:974)
    at zombie.gameStates.MainScreenState.main(MainScreenState.java:173)
-----------------------------------------
STACK TRACE
-----------------------------------------
function: OZBloodTypeCheck -- file: OZBGIIN.lua line # 102
Adding NecroForge for USMilitaryGear
FirstNAME:Bob
Key Pressed
reanimate: saved 0 zombies
removing all player data

 

Share this post


Link to post
Share on other sites
17 minutes ago, blindcoder said:

I wrote that from memory, it might not be entirely correct...

What's in console.txt?

 

Maybe this?

local rightHand = getPlayer():getBodyDamage():getBodyPart(BodyPartType.ToIndex(BodyPartType.Hand_R));

 

Share this post


Link to post
Share on other sites

Yep, i think i found a mistake...

 

local rightHand = getPlayer():getBodyDamage():getBodyPart(BodyPartType.FromIndex(BodyPartType.ToIndex(BodyPartType.Hand_R)));

 

Now error in 

 

rightHand:AddDamage(rightHand:getDamage()-50.0); --set damage to 50%

 

Edited by DarkKreepe

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...