Deleted38846565User Posted March 30, 2018 Share Posted March 30, 2018 The DamageActorValue script is compiling for me, though it seems like it has no effect. I'm attempting to damage the player via script, in a similar way as if they were hit. This is my current script/function, it takes in the actor and the percentage of health that it should be damaged. Scriptname DamagePlayer extends Quest;damages the actor by a percentage Function DamageActorHealthPercent(Actor ActorRef, float Percent)String ActorHealth = ActorRef.GetBaseActorValue("Health");get actor healthint HealthValue = ActorHealth as Int;cast to intfloat Damage = (HealthValue * Percent);get percentage of healthActorRef.DamageActorValue("Health", Damage);damage actors' health based off of percentage EndFunction The function complicates it, but I've also done the DamageActorValue without this function, and there still seemed to be no effect on the health. Link to comment Share on other sites More sharing options...
candlepin Posted March 30, 2018 Share Posted March 30, 2018 You need an event to trigger the function (i.e. call the function within an event). Link to comment Share on other sites More sharing options...
DMan1629 Posted March 30, 2018 Share Posted March 30, 2018 Few things:1st: you need to make sure the script actually runs. I see it extends Quest - make sure that quest is actually running when it's supposed to.2nd: make sure your function is actually called. Call it through an event or manually. You can also change it to an event instead, will make the whole process shorter - if you want.3rd: make sure that the actor's ref is actually passed to the function.4th: notice that you wrote "String ActorHealth" - GetBaseActorValue returns a float.5th: I'm not sure the conversion to int is correct, I myself did a manual conversion. Again, not sure about this so check it out in a different way. Summary:Everything else is OK, so just make sure all I wrote is implemented.I used DamageActorValue myself and it works fine (no sound the actor is being damaged just an FYI)Let me know how it works out. Cheers! Link to comment Share on other sites More sharing options...
Evangela Posted March 30, 2018 Share Posted March 30, 2018 (edited) Casting isn't necessary, but if that's a style you're comfortable with, go for it. GetBaseActorValue doesn't account for buffs(green), while GetActorValue does. Function DamageActorHealthPercent(Actor ActorRef, float Percent) Float ActorHealth = ActorRef.GetActorValue("Health") ;get actor health Float Damage = (ActorHealth * Percent) ;get percentage of health ActorRef.DamageActorValue("Health", Damage) ;damage actors' health based off of percentage EndFunction You can take even more steps out and just put it all into DamageActorValue: ; ActorRef being the actor you call this on ActorRef.DamageActorValue("Health", ActorRef.GetActorValue("Health") * percent) And just to say what this is doing exactly, you're damaging health by a percentage of the current value. 100 * 0.5 = 50, 50 * 0.5 = 25, etc.. Edited March 30, 2018 by Rasikko Link to comment Share on other sites More sharing options...
Deleted38846565User Posted March 30, 2018 Author Share Posted March 30, 2018 Thanks for all the info, I wasn't able to find any tutorials on functions so that's why it's oddly done, kinda was a guessing game XD but a function isn't necessary. I tried this PlayerRef.DamageActorValue("Health", PlayerRef.GetActorValue("Health") * 0.8) It compiles although the Player's health still wasn't damaged, and double checked that PlayerRef is the Player and it was. I used DamageActorValue myself and it works fine (no sound the actor is being damaged just an FYI) Also does that mean just no hit sound? Is there still a cue that you took damage, i.e. blood on the screen, a grunt and/or health bar going down? Link to comment Share on other sites More sharing options...
DMan1629 Posted March 31, 2018 Share Posted March 31, 2018 Also does that mean just no hit sound? Is there still a cue that you took damage, i.e. blood on the screen, a grunt and/or health bar going down?It means you just take damage. No sound, no grunt, no blood. Obviously the health bar goes down. Now for your problem with the script:I'm still not sure you're calling your function properly.Is the quest running?Add this line in the beginning of the function to know if it gets there:Debug.Notification("Damage function on")This will let you know if the function actually runs with a notification on the top left corner, or if you messed up before (my money's on the latter)If it does show the notification, try replacing "ActorRef" inside the function with "Game.GetPlayer()" just to see if it works. I'm pretty sure the problem is with calling the function or even before - the quest not running.Anyway, keep me updated. Link to comment Share on other sites More sharing options...
Deleted38846565User Posted March 31, 2018 Author Share Posted March 31, 2018 I'm still not sure you're calling your function properly.Is the quest running? I ditched the function and used a single line script, also I changed PlayerRef to Game.GetPlayer() but there was no difference. The script now is Game.GetPlayer().DamageActorValue("Health", Game.GetPlayer().GetActorValue("Health") * 0.8) It's being called in the phase of a scene, and it should be called as every other script in that scene is working, plus I have debugs there. Link to comment Share on other sites More sharing options...
Deleted38846565User Posted March 31, 2018 Author Share Posted March 31, 2018 Okay, I see the problem. In the scene the player has their controls disabled which removes the hud entirely, after enabling it mid-scene I seen the health bar much lower. I'm pretty sure I need the controls disabled for the scene which is a problem, but maybe I can try to find the blood ISM and simply use that. I do currently have an ISM, and an animation so the player knows they've been hit, I just wanted the added touch of the health going down, but blood on top of that should be good enough. Thanks for the help! Link to comment Share on other sites More sharing options...
DMan1629 Posted March 31, 2018 Share Posted March 31, 2018 You can also just add the damage sound and animation but without the damage but apply the damage itself after the scene is finished.Just a thought... Link to comment Share on other sites More sharing options...
Deleted38846565User Posted March 31, 2018 Author Share Posted March 31, 2018 The player is "healed" during the cutscene too, thanks for the advice though! Funny enough the player was being healed which is why I didn't catch the health being low before, I didn't think the npc would heal the player so fast. Link to comment Share on other sites More sharing options...
Recommended Posts