MisterRADical Posted April 20, 2019 Share Posted April 20, 2019 (edited) I was trying to make a script that lowers the players health when equipping a piece of armor. Here's what I have so far: Scriptname ArmorDamageHealthScript extends activemagiceffect Keyword Property ArmorEquipped Auto Const Float Property HealthLostAndRestored Auto Const ActorValue Property Health Auto Const Perk Property HealthRestorePerkReq Auto Const Event OnEquipped(Actor akActor) if akActor == Game.GetPlayer() Game.GetPlayer().HasPerk(HealthRestorePerkReq) == true && Game.GetPlayer().IsEquipped(ArmorEquipped) == true Game.GetPlayer().DamageValue(Health, HealthLostAndRestored) endIf endEvent Event OnUnequipped(Actor akActor) if akActor == Game.GetPlayer() Game.GetPlayer().HasPerk(HealthRestorePerkReq) == false && Game.GetPlayer().IsEquipped(ArmorEquipped) == false Game.GetPlayer().RestoreValue(Health, HealthLostAndRestored) endIf endEventI tried using abReduceHealth before but every time I unequip the armor the health goes down, so if you spam equip and unequip it the health gets all messed up. If anyone knows how to fix that instead that would be great, but if not then I would like help with the script. I am still knew to scripting and only have gotten a few to work, I can't get this one to though and I've tried other ways other then using OnEquipped. When I go in-game and equip the armor it does nothing. If anybody can make it work I'd be very grateful. Even more so if you can make the health percentage based rather than a set amount. Edited April 20, 2019 by MisterRADical Link to comment Share on other sites More sharing options...
Evangela Posted April 21, 2019 Share Posted April 21, 2019 The unequipped event is never going to do its thing because the perk is most likely not removed. Link to comment Share on other sites More sharing options...
MisterRADical Posted April 21, 2019 Author Share Posted April 21, 2019 The unequipped event is never going to do its thing because the perk is most likely not removed. I removed it but it still doesn't work :\ Link to comment Share on other sites More sharing options...
SKKmods Posted April 22, 2019 Share Posted April 22, 2019 How is the activemagiceffect associated with the player/armor and how is it going to receive events without remote registering for them ? If the activemagiceffect is attached or associated properly then its needs RegisterForRemoteEvent(pPlayerREF, "OnItemEquipped") with Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference) + the same for OnItemUnEquipped Or, create a start game enabled quest, add a reference alias for unique actor player, attach a script which automatically receives the actor events so no remote registering and nail in Event OnItemEquipped() and Event OnItemUnEquipped() using the fully qualified function. Link to comment Share on other sites More sharing options...
MisterRADical Posted April 22, 2019 Author Share Posted April 22, 2019 How is the activemagiceffect associated with the player/armor and how is it going to receive events without remote registering for them ? If the activemagiceffect is attached or associated properly then its needs RegisterForRemoteEvent(pPlayerREF, "OnItemEquipped") with Event Actor.OnItemEquipped(Actor akSender, Form akBaseObject, ObjectReference akReference) + the same for OnItemUnEquipped Or, create a start game enabled quest, add a reference alias for unique actor player, attach a script which automatically receives the actor events so no remote registering and nail in Event OnItemEquipped() and Event OnItemUnEquipped() using the fully qualified function. I am a little confused. RegisterForRemoteEvent(pPlayerREF, "OnItemEquipped")? Where does that go? I've never seen a line like this so idk. Can you explain what it does exactly too in simple terms. And then just do the Even Actor.OnItemEquipped(blah blah) and then Game.GetPlayer().IsEquipped(ArmorEquipped) == true or do you have to ref the armor a different way. Link to comment Share on other sites More sharing options...
hereami Posted April 23, 2019 Share Posted April 23, 2019 (edited) When I go in-game and equip the armor it does nothing.Naturally, there should be OnEffectStart/Finish events, not OnEquipped. I suppose MGEF is applied by armor enchantment? Or make the script to "extend ObjectReference" and attach to armor item. Do not run IsEquipped condition.Btw, speaking about dynamic health level. When i tried to boost up the health via PeakValuModifier (Recover set!) depending on Adrenaline amount, i have permanent health loss after several up/down cycles. Is this a known bug with PeakValue or what?PS. Or if it's a permanent Actor's effect, then really needs all that remote detection stuff - Register etc. Edited April 23, 2019 by hereami Link to comment Share on other sites More sharing options...
MisterRADical Posted April 26, 2019 Author Share Posted April 26, 2019 When I go in-game and equip the armor it does nothing.Naturally, there should be OnEffectStart/Finish events, not OnEquipped. I suppose MGEF is applied by armor enchantment? Or make the script to "extend ObjectReference" and attach to armor item. Do not run IsEquipped condition.Btw, speaking about dynamic health level. When i tried to boost up the health via PeakValuModifier (Recover set!) depending on Adrenaline amount, i have permanent health loss after several up/down cycles. Is this a known bug with PeakValue or what?PS. Or if it's a permanent Actor's effect, then really needs all that remote detection stuff - Register etc. Sorry I've been busy, can you give me a script that would work? I tried and get "no viable alternative at input '.' " so idk. Link to comment Share on other sites More sharing options...
hereami Posted April 27, 2019 Share Posted April 27, 2019 (edited) Sorry I've been busy, can you give me a script that would work? I tried and get "no viable alternative at input '.' " so idk.Tbh, i didn't know, ActiveMagicEffect does include OnEquipped, so... But also may be a problem with Effect applied before the carrier item gets equipped, i had a trouble when checking GetEquipped condition for an armor's magic effect - it never started. Possibly, may happen the same, though looks strange for OnEquipped event.Also, ArmorEquipped in your script is of type Keyword, not Armor - may be a type mismatch? even if actual value is of type Armor? - never tried to violate, not sure. What i meant is like this (attach to armor piece - simplest. If need armor records untouched - do as SKK50 said, it's better route): Scriptname ArmorDamageHealthScript extends ObjectReference Float Property HealthDmgPct Auto Const ; should be 0.0 - 1.0Perk Property HealthRestorePerkReq Auto ConstFloat HealthDmgAmount Event OnEquipped(Actor akActor) if (akActor == Game.GetPlayer()) if (akActor.HasPerk(HealthRestorePerkReq) == true) HealthDmgAmount = akActor.GetValue(Game.GetHealthAV()) * HealthDmgPct akActor.ModValue(Game.GetHealthAV(), -HealthDmgAmount) endif endIfendEvent Event OnUnEquipped(Actor akActor) if (akActor == Game.GetPlayer()) if ( (akActor.HasPerk(HealthRestorePerkReq) == true) || (HealthDmgAmount > 0) ) akActor.ModValue(Game.GetHealthAV(), HealthDmgAmount) endif endIfendEvent DamageValue doesn't seem fit, it's same as regular hit damage, i suppose, can be healed etc. Replaced by ModValue - should change maximal value. Correct if desired. Edited April 27, 2019 by hereami Link to comment Share on other sites More sharing options...
MisterRADical Posted April 28, 2019 Author Share Posted April 28, 2019 (edited) Sorry I've been busy, can you give me a script that would work? I tried and get "no viable alternative at input '.' " so idk.Tbh, i didn't know, ActiveMagicEffect does include OnEquipped, so... But also may be a problem with Effect applied before the carrier item gets equipped, i had a trouble when checking GetEquipped condition for an armor's magic effect - it never started. Possibly, may happen the same, though looks strange for OnEquipped event.Also, ArmorEquipped in your script is of type Keyword, not Armor - may be a type mismatch? even if actual value is of type Armor? - never tried to violate, not sure. What i meant is like this (attach to armor piece - simplest. If need armor records untouched - do as SKK50 said, it's better route): Scriptname ArmorDamageHealthScript extends ObjectReference Float Property HealthDmgPct Auto Const ; should be 0.0 - 1.0Perk Property HealthRestorePerkReq Auto ConstFloat HealthDmgAmount Event OnEquipped(Actor akActor) if (akActor == Game.GetPlayer()) if (akActor.HasPerk(HealthRestorePerkReq) == true) HealthDmgAmount = akActor.GetValue(Game.GetHealthAV()) * HealthDmgPct akActor.ModValue(Game.GetHealthAV(), -HealthDmgAmount) endif endIfendEvent Event OnUnEquipped(Actor akActor) if (akActor == Game.GetPlayer()) if ( (akActor.HasPerk(HealthRestorePerkReq) == true) || (HealthDmgAmount > 0) ) akActor.ModValue(Game.GetHealthAV(), HealthDmgAmount) endif endIfendEvent DamageValue doesn't seem fit, it's same as regular hit damage, i suppose, can be healed etc. Replaced by ModValue - should change maximal value. Correct if desired. OMG THANK YOU! I thought I was never going to get an effect like that to work which saddened me. Thank you so much man, this should help in the future too as I can just change it up a bit for other stuff. Learning scripting (at least where I am which is at the very beginning, so I'm just a Novice) is very intimidating so thanks everyone for the help. And I didn't even know you could have more than one If too, that's cool. Also, if I wanted to do let's say Action Points, would it just be GetActionPointAV? and how would I do the SPECIAL's? They were also glitching out :\ Edited April 28, 2019 by MisterRADical Link to comment Share on other sites More sharing options...
hereami Posted April 28, 2019 Share Posted April 28, 2019 (edited) Good if worked. I didn't test, thus never can be sure, even for simplest things.Definitely, you can make it more versatile and reusable, just replace all Game.GetHealthAV() with a custom Property variable and assign any existing ActorValue (as you did initially), made so just because it was a narrowed task.Also take care about ModValue(), it fits logic perfectly in this particular case, but still, me too had problem with PeakValueModifier (e.g. abReduce...) and suppose they act very similar. So it may bug out as well, i don't have any experience with using it. PS. For Special etc. it's more reasonable to use fixed whole numbers, not pct, as the range is predictable. Edited April 28, 2019 by hereami Link to comment Share on other sites More sharing options...
Recommended Posts