Deleted5420501User Posted March 20, 2016 Share Posted March 20, 2016 (edited) EDIT: I managed to fix this, but I have another problem.I want to heal only attackers, which attack in close combat (no any projectiles including spells), but this not work - when I cast fireball, I get healed.Can anyone help me please? Here is my script: Scriptname CH_LifeLeechScript extends ActiveMagicEffect Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) Actor Attacker = (akAggressor As Actor) Float RP = Game.GetPlayer().GetLevel() ;restore health based on player level if (akSource as Spell) == None && akProjectile == None Attacker.RestoreAV("Health", RP+15) endif EndEvent Edited March 25, 2016 by Guest Link to comment Share on other sites More sharing options...
Deleted5420501User Posted March 27, 2016 Author Share Posted March 27, 2016 Anyone please? Link to comment Share on other sites More sharing options...
Ryagard Posted March 27, 2016 Share Posted March 27, 2016 I am no script wizard but i think you are missing a Property for the spell itself? Link to comment Share on other sites More sharing options...
Deleted5420501User Posted March 28, 2016 Author Share Posted March 28, 2016 This doesn't help but thanks for answer. Link to comment Share on other sites More sharing options...
FrankFamily Posted March 29, 2016 Share Posted March 29, 2016 (edited) Editing, wait a moment... This script is from thw wiki, havent tested it myself but they say it works: Event OnHit(ObjectReference Attacker, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) PlayerRef = Game.GetPlayer() Bool boHitByMagic = FALSE ; True if likely hit by Magic attack. Bool boHitByMelee = FALSE ; True if likely hit by Melee attack. Bool boHitByRanged = FALSE ; True if likely his by Ranged attack. IF akAggressor != PlayerRef && PlayerRef.IsInCombat() && akAggressor.IsHostileToActor(PlayerRef) ; The above is really to rule out run of the mill physical traps. IF ((akAggressor .GetEquippedItemType(0) == 8) || (akAggressor .GetEquippedItemType(1) == 8) \ || (akAggressor .GetEquippedItemType(0) == 9) || (akAggressor .GetEquippedItemType(1) == 9)) && akProjectile != None boHitByMagic = TRUE ELSEIF (akAggressor .GetEquippedItemType(0) != 7) && akProjectile == None boHitByMelee = TRUE ELSEIF (akAggressor .GetEquippedItemType(0) == 7) boHitByRanged = TRUE ENDIF ENDIFApplied to your script: Scriptname CH_LifeLeechScript extends ActiveMagicEffect Actor User ; could be the player or not, i dont know who you are applying this effect to Event OnEffectStart(Actor akTarget, Actor akCaster) User = akTarget EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) IF akAggressor != User && User.IsInCombat() && akAggressor.IsHostileToActor(User) If (akAggressor.GetEquippedItemType(0) != 7) && (akAggressor.GetEquippedItemType(0) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akAggressor.GetEquippedItemType(1) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akProjectile == None) Debug.Notification("user was hit by a melee attack") Float RP = Game.GetPlayer().GetLevel() ;restore health based on player level Attacker.RestoreAV("Health", RP+15) endif Endif EndEventworth giving it a try I guess. Edited March 29, 2016 by FrankFamily Link to comment Share on other sites More sharing options...
Deleted5420501User Posted March 29, 2016 Author Share Posted March 29, 2016 (edited) This doesn't help me :( Edited March 29, 2016 by Guest Link to comment Share on other sites More sharing options...
Deleted5420501User Posted March 29, 2016 Author Share Posted March 29, 2016 (edited) Actor User ; could be the player or not, i dont know who you are applying this effect to Read my first post. Scriptname CH_LifeLeechScript extends ActiveMagicEffect Actor User ; could be the player or not, i dont know who you are applying this effect to Event OnEffectStart(Actor akTarget, Actor akCaster) User = akTarget EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) IF akAggressor != User && User.IsInCombat() && akAggressor.IsHostileToActor(User) If (akAggressor.GetEquippedItemType(0) != 7) && (akAggressor.GetEquippedItemType(0) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akAggressor.GetEquippedItemType(1) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akProjectile == None) Debug.Notification("user was hit by a melee attack") Float RP = Game.GetPlayer().GetLevel() ;restore health based on player level Attacker.RestoreAV("Health", RP+15) endif Endif EndEvent I can't even compile this, throws errors. EDIT: Sorry for post under post I choosed wrong post window. Edited March 29, 2016 by Guest Link to comment Share on other sites More sharing options...
FrankFamily Posted March 29, 2016 Share Posted March 29, 2016 (edited) Just noticed i forgot to change the last attacker to aggressor wich is the variable that comes with the event and removes the need to define a new one. Also removed the RP float, can be put directly into the restoreav function. try this one: Scriptname CH_LifeLeechScript extends ActiveMagicEffect Actor User Event OnEffectStart(Actor akTarget, Actor akCaster) User = akTarget EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) IF 8akAggressor != User) && (User.IsInCombat()) && (akAggressor.IsHostileToActor(User)) If (akAggressor.GetEquippedItemType(0) != 7) && (akAggressor.GetEquippedItemType(0) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akAggressor.GetEquippedItemType(1) != 8) && (akAggressor.GetEquippedItemType(0) != 9) && (akProjectile == None) Debug.Notification("user was hit by a melee attack") akAggressor.RestoreAV("Health", (Game.GetPlayer().GetLevel() + 15.0)) endif Endif EndEvent Edited March 29, 2016 by FrankFamily Link to comment Share on other sites More sharing options...
Deleted5420501User Posted March 29, 2016 Author Share Posted March 29, 2016 Again I getting errors... Starting 1 compile threads for 1 files...Compiling "CH_LifeLeechScript"...steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(11,65): IsHostileToActor is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,18): GetEquippedItemType is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,41): cannot compare a none to a int (cast missing or types unrelated)steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,63): GetEquippedItemType is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,86): cannot compare a none to a int (cast missing or types unrelated)steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,108): GetEquippedItemType is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,131): cannot compare a none to a int (cast missing or types unrelated)steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,153): GetEquippedItemType is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,176): cannot compare a none to a int (cast missing or types unrelated)steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,198): GetEquippedItemType is not a function or does not existsteamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(13,221): cannot compare a none to a int (cast missing or types unrelated)steamapps\common\skyrim\Data\Scripts\Source\temp\CH_LifeLeechScript.psc(16,15): RestoreAV is not a function or does not existNo output generated for CH_LifeLeechScript, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on CH_LifeLeechScript Link to comment Share on other sites More sharing options...
FrankFamily Posted March 30, 2016 Share Posted March 30, 2016 Yeah, silly me, those functions run on actor not object reference... And i even wrote an "8" instead of "("...I have weird relationship with typos... Anyway, this compiles fine, fixed that stuff, added a variable since i think it's better than a bunch of "as actor" casting, and added "IF (akAggressor)" to avoid script errors if there is no agressor. Scriptname CH_LifeLeechScript extends ActiveMagicEffect Actor User Event OnEffectStart(Actor akTarget, Actor akCaster) User = akTarget EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) IF (akAggressor) && (akAggressor != User) && (akProjectile == None) Actor Aggressor = akAggressor as Actor If(User.IsInCombat()) && (Aggressor.IsHostileToActor(User)) && (Aggressor.GetEquippedItemType(0) != 7) && (Aggressor.GetEquippedItemType(0) != 8) && (Aggressor.GetEquippedItemType(0) != 9) && (Aggressor.GetEquippedItemType(1) != 8) && (Aggressor.GetEquippedItemType(0) != 9) Aggressor.RestoreAV("Health", (Game.GetPlayer().GetLevel() + 15.0)) Endif Endif EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts