myav Posted April 12, 2020 Share Posted April 12, 2020 (edited) I have tried the next: Potion property DamageHealth01 auto Event OnCombatStateChanged(Actor akTarget, int aeCombatState) if (aeCombatState == 1) Utility.Wait(1.5) if (selfactor.GetEquippedItemType(1) < 7 && selfactor.GetEquippedItemType(1) != 0) debug.notification("try to apply poison") form MyPoison = DamageHealth01 as Form selfactor.EquipItem(MyPoison, false, true) endif endif EndEventand i get: 1. the message "try to apply poison" ==> so, NPC hold correct weapon in the hand otherwise the message would not appear.2. potion "damage 15 health" in the NPC inventory ==> game add correct potion to invetory of the npc But NPC don't use it on his dagger. Who can to help, where is my logical error ? and how to force NPC to use potion on weapon? Edited April 12, 2020 by myav Link to comment Share on other sites More sharing options...
myav Posted April 13, 2020 Author Share Posted April 13, 2020 So.... for 7 years of skyrim' life, nobody don't try to use poisons for AI ? that all are silent and no ideas (( Link to comment Share on other sites More sharing options...
sabrio204 Posted April 15, 2020 Share Posted April 15, 2020 You'll have to use https://www.nexusmods.com/skyrimspecialedition/mods/13366 afaik Link to comment Share on other sites More sharing options...
ReDragon2013 Posted April 15, 2020 Share Posted April 15, 2020 myav wrote: "So.. nobody don't try to use poisons for AI?" By using vanilla Skyrim (32bit) or SkyrimSE (64bit) without SKSE it is impossible to do that!Because you do not have the objectReference of the weapon that you want to make poisoned. By using link from above, you'll find these SKSE functions. ; this is already done by SKSE, so just forward on to that version Potion Function WornObjectGetPoison(Actor akActor, int aiHandSlot, int aiSlotMask) int Function WornObjectSetPoison(Actor akActor, int aiHandSlot, int aiSlotMask, Potion akPoison, int aiCharges = 1) { Applies akPoison to weapon in aiHandSlot. Note the item MUST be a weapon, or the function will fail and return -1 Returns: The number of poison charges the weapon now has (which should be the same as aiCharges) or -1 if unsuccessful}The following is an approach (based on PlayerAlias script) without SKSE, but not working.myavPlayerAliasPWScript Scriptname myavPlayerAliasPWScript extends ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/8589303-how-to-add-poison-to-already-equipped-weapon-for-npc-not-player/ Potion PROPERTY myPoison auto ; test: potion that is poisoned Spell PROPERTY mySpell auto ; test: spell that has the magicEffect from potion above ObjectReference lastRef Weapon lastWeapon Bool bWaiting ;----------------------- FUNCTION myF_Init(Int i) ;----------------------- IF (i == 0) Debug.Trace(" OnInit() - for " +self) ELSE Debug.Trace(" OnPlayerLoadGame() - for " +self) ENDIF ;;; IF (SKSE.GetVersion() > 0) gotoState("Waiting") ; ### STATE ### ;;; ELSE ;;; gotoState("Failure") ; ### STATE ### ;;; ENDIF ENDFUNCTION ; -- EVENTs -- EVENT OnInit() myF_Init(0) ENDEVENT EVENT OnPlayerLoadGame() myF_Init(1) ENDEVENT ;================================= state Failure ; do not call events in other states, except state "" ;============ endState ;================================= state Waiting ;============ EVENT OnCombatStateChanged(Actor akTarget, Int aeCombatState) IF (bWaiting) || (aeCombatState != 1) RETURN ; - STOP - ENDIF ;--------------------- bWaiting = TRUE ; *T* threadlock on Utility.Wait(1.5) actor aRef = self.GetActorReference() IF aRef.IsInCombat() && (myPoison) IF (aRef.GetEquippedItemType(1) < 7) && (aRef.GetEquippedItemType(1) != 0) Debug.notification("try to apply poison " + myF_Dec2Hex( myPoison.GetFormID() )) aRef.EquipItem(myPoison as Form, False, TRUE) ;;; mySpell.Cast(lastWeapon as ObjectReference) ; it does not work !!! ;;; aRef.RemoveItem(myPoison as Form) ENDIF ENDIF bWaiting = False ; *** threadlock off ENDEVENT EVENT OnObjectEquipped(Form akBaseObject, ObjectReference akReference) ; akReference may be None if object is not persistent (only if this alias points at an actor) ; received when this actor equips something - IF (akBaseObject as Weapon) IF ( lastWeapon ) Debug.Trace(" equipped with " +akBaseObject as Weapon+ ", lastWeapon = " +lastWeapon+ ", lastRef = " +lastRef) ; akBaseObject should be the poisoned weapon, lastWeapon is the unpoisoned weapon lastWeapon = None lastRef = None ELSE Debug.Trace(" equipped with " +akBaseObject as Weapon) ENDIF ;------------------------------ ELSEIF (akBaseObject as Poison) IF ( lastWeapon ) ELSE Debug.Trace(" equipped with " +akBaseOject as Poison) ENDIF ENDIF ENDEVENT EVENT OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) ; akReference may be None if object is not persistent (only if this alias points at an actor) ; received when this actor unequips something - IF (akBaseObject as Weapon) lastWeapon = akBaseObject ; store last unequipped weapon lastRef = akReference ; mostly this is none !!! ENDIF ENDEVENT ;======= endState ; -- FUNCTIONs -- (1) + 1 ;--------------------------------- String FUNCTION myF_Dec2Hex(Int n) ;--------------------------------- ; 842 = 8*10² + 4*10 + 2*1 ; base 10 ; 34Ah = 3*16² + 4*16 + A*1 ; base 16 ; convert a signed integer (longint32) into unsigned doubleword as hexstring ; positive: 0x0 .. 0x7fffffff ; negative: 0x80000000 .. 0xffffffff string[] a = new String[6] a[0] = "a" a[1] = "b" a[2] = "c" a[3] = "d" a[4] = "e" a[5] = "f" int T ; Zero by default IF (n < 0) n = 0x7FFFFFFF + n + 1 ; transform negative to positive (2147483647 == 0x7FFFFFFF) T = 8 ENDIF T = (n / 0x10000000) + T ; store leading halfbyte string s ; "" by default int j int i = 8 ; minimum length of string (that will be the return value) WHILE (i) ; (i > 0) i = i - 1 IF (i) j = n % 16 ; n iMODULO 16 == (n AND 15) n = n / 16 ; n iDIV 16 == (n SHR 4) ELSE j = T ; get stored halfbyte ENDIF IF (j < 10) s = (j as String) + s ; "0" .. "9" ELSE j = j - 10 s = a[j] + s ; "a" .. "f" ENDIF ENDWHILE RETURN s ENDFUNCTION ; ************************************************************** ;/ *** TES5Edit -> Skyrim.esm Leveled Item LItemPoison* LItemPoisonDamageHealth [LVLI:00065A80] Ingestible (VendorItemPoison [KYWD:0008CDED]) Reference DamageHealth01 "Weak Poison" [ALCH:0003A5A4] .. Reference DamageHealth05 "Deadly Poison" [ALCH:00073F34] Magic Effect AlchDamageHealth "Damage Health" [MGEF:0003EB42] Spell crSpider01PoisonBite "Frostbite Poison" [SPEL:000638B2] Poison Fire and Forget Touch ----------------------- Object Effect - EnchWeapon*** EnchWeaponAbsorbHealthBase "Absorb Health" [ENCH:0010FB91] Magic Effect EnchAbsorbHealthFFContact "Absorb Health" [MGEF:000AA155] Scriptname magicAbsorbFXScript extend ActiveMagicEffect FrostbiteVenomFFSelf "Frostbite Venom" [MGEF:000EA65A] Scriptname MagicImodOnPlayerHitScript extend ActiveMagicEffect Spell Frostbite "Frostbite" [SPEL:0002B96B] *** /; Link to comment Share on other sites More sharing options...
Recommended Posts