luvadea Posted October 11, 2019 Share Posted October 11, 2019 Here is the thing I need:Player finds an unconscious NPC and1 Player casts healing spell (any)2 Laying (by AI package) NPC "wakes up"How do I connect casting the healing spell (any healing spell-not one particular) by player with the package change? Sorry guys if I'm asking daft questions..just give me a clue please.. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 12, 2019 Share Posted October 12, 2019 Most healing spells are cast on self. This is why stock NPCs that want healed ask for a potion. At any rate, here is a probable possible method. If you put all the spells you want to be recognized in a single formlist you could use the OnSpellCast event, get the spell that was cast and see if the formlist has that spell. If you get a matching spell, update a global variable that you use as a condition on the NPC's AI package and then force their AI package to re-evaluate. Script running the OnSpellCast event would need to know the NPC to be "healed". Probably best to use a quest alias and assign the desired NPC to the alias and then have the AI package stuff on the quest alias rather than on the NPC directly. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 12, 2019 Share Posted October 12, 2019 (edited) A script could be as follow like IsharaMeradin has written. Make sure your script has a unique name! luvaPlayerAliasScript Scriptname luvaPlayerAliasScript extends ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/8054773-player-heals-an-npc-script/ GlobalVariable PROPERTY myGlobalAI auto Conditional ; "use as a condition on the NPCs AI package" ReferenceAlias PROPERTY myNPC auto ; "use a quest alias and assign the desired NPC to the alias" FormList PROPERTY myList auto ; "put all the healing spells you want to be recognized in a single formlist" ; steps ; ----- ; (0) create a globalVar and the formlist ; (1) create a quest ; (2) create two aliases (for the player and desired NPC) ; (3a) attach this script to the player alias ; read this topic: https://forums.nexusmods.com/index.php?/topic/8049858-question-regarding-player-alias/ ; (3b) fill properties by using Creation Kit ; (3c) compile this script ; (4) make a condition on NPC AI package (How to?) ; -- EVENTs -- EVENT OnInit() ; native Debug.Trace(" OnInit() - has been reached.. " +self) ; debugging only ENDEVENT EVENT OnPlayerLoadGame() ; native Debug.Trace(" OnPlayerLoadGame() - has been reached.. " +self) ; debugging only ENDEVENT EVENT OnSpellCast(Form akSpell) ; native ; https://www.creationkit.com/index.php?title=OnSpellCast_-_ObjectReference ; akSpell can be Spell, Enchantment, Potion or Ingredient (see WIKI above, your browser needs cookies enabled!) IF (akSpell as Spell) ELSE RETURN ; - STOP - not a spell ENDIF ;--------------------- int i = myList.Find(akSpell) IF (i >= 0) myF_Action() ; player is healing someone, spell was found in list ENDIF ENDEVENT ; -- FUNCTION -- ;-------------------- FUNCTION myF_Action() ;-------------------- myGlobalAI.Mod(1) ; == myGlobalAI.setValue( myGlobalAI.GetValue() + 1.0 ) ;;; myGlobalAI.Mod(-1) ; == myGlobalAI.setValue( myGlobalAI.GetValue() - 1.0 ) actor aRef IF ( myNPC ) aRef = myNPC.GetActorReference() ; get NPC ENDIF IF ( aRef ) aRef.EvaluatePackage() ; refresh the current AI package ENDIF ENDFUNCTION Edited October 12, 2019 by ReDragon2013 Link to comment Share on other sites More sharing options...
luvadea Posted October 18, 2019 Author Share Posted October 18, 2019 Thank you both for answering!This is the solution if anybody is looking for it Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)if(akSource.hasKeyword(MagicRestoreHealth))Actor Youractor = getReference() as ActorgetOwningQuest().setStage(20) Link to comment Share on other sites More sharing options...
TobiaszPL Posted October 19, 2019 Share Posted October 19, 2019 (edited) Thats what i wanted to suggest You :x... But how about little upgrade?... Event OnInit() GoToState( "Wait" ) EndEvent State Wait Event OnHit( ObjectReference QArg, Form QSrc, Projectile QPrc, bool A, bool B, bool C, bool D) If( QSrc.hasKeyword( MagicRestoreHealth )) GoToState( "Done" ) Else EndEvent EndState State Done ; Empty State EndState ; The EndWithout States you will SET STAGE every time player cast Healing Spell on Your NPC :x...You could also add another IF to check if stage is for example 10 - otherwise player can jump from stage 0 to 20 skiping everything before //Edit:and ofc.getOwningQuest().setStage(20) xDDDD Edited October 19, 2019 by TobiaszPL Link to comment Share on other sites More sharing options...
Recommended Posts