Noober1 Posted June 12, 2021 Share Posted June 12, 2021 Hello! I'm working on a modded weapon that levels with the player in sense that it grows stronger the more you use it. For example, Im trying to see if there is a way that if this weapon is equipped, a script can track its kill counts and unlock perks when X amount of kills have been recorded. The particular weapon is a staff so I cannot add these perks to a perk tree and select them like you would any other weapon perk when you level up. Instead, the perks have been integrated into the staff's enchantment and parts of the enchantment kick into effect when certain perks have been unlocked. I know you can script counters with Int but have not seen any useful examples on how to implement it. Any advice would be greatly appreciated! Link to comment Share on other sites More sharing options...
maxarturo Posted June 12, 2021 Share Posted June 12, 2021 Read this relevant post, i'm too lazy right now to write..., but do read it till the end. https://forums.nexusmods.com/index.php?/topic/10096263-need-help-with-adding-ability-on-onkill-events/ Link to comment Share on other sites More sharing options...
Noober1 Posted June 12, 2021 Author Share Posted June 12, 2021 Ok thanks man! I'll give it a check! Link to comment Share on other sites More sharing options...
ReDragon2013 Posted June 12, 2021 Share Posted June 12, 2021 (edited) No idea, if next is working for your purpose. The approach is a script attached to your special staff. It adds the perk to player depends on kills. The kills are checked every 2 seconds with QueryStat() function.Cloak spell and story manager as well is not needed. But keep in mind its theory, not tested for working as intended. nooberStaffEquippedScript Scriptname nooberStaffEquippedScript extends ObjectReference Hidden ; https://forums.nexusmods.com/index.php?/topic/10133833-kill-count-with-weapon-unlocks-perk/ GlobalVariable PROPERTY globalStaffKillCounter auto ; new created by CK, and assigned to this property Perk PROPERTY SpecialPerk auto ; perk in staff enchantment, to unlock Int PROPERTY iCounter auto ; [default=0] ; Noober1 wrote: "perks have been integrated into the staffs enchantment and parts of the enchantment ; kick into effect when certain perks have been unlocked." ; -- EVENTs -- 4 EVENT OnInit() Debug.Trace(" OnInit() - has been reached for " +self) ENDEVENT EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) actor player = Game.GetPlayer() IF (akNewContainer as Actor == player) gotoState("Waiting") ; ### STATE ### player got the stuff ELSEIF (akOldContainer as Actor == player) UnRegisterForUpdate() gotoState("") ; ### STATE ### player lost the staff ENDIF ;IF ( akOldContainer ) ; IF ( akNewContainer ) ; Debug.Trace("We have switched containers!") ; ELSE ; Debug.Trace("We have been dropped!") ; ENDIF ;ELSE ; IF ( akNewContainer ) ; Debug.Trace("We have been picked up!") ; ENDIF ;ENDIF ENDEVENT ;========================== state Waiting ;============ EVENT OnEquipped(Actor akActor) Debug.Trace("Staff is equipped by player! " +self) iCounter = 0 RegisterForSingleUpdate(0.0) ; weapon equipped ENDEVENT EVENT OnUnequipped(Actor akActor) UnRegisterForUpdate() Game.GetPlayer().RemovePerk( SpecialPerk ) ENDEVENT EVENT OnUpdate() myF_Check() ENDEVENT ;======= endState ; -- FUNCTIONs -- ; https://www.creationkit.com/index.php?title=RemovePerk_-_Actor ; https://www.creationkit.com/index.php?title=QueryStat_-_Game ; int Function QueryStat(string asStat) native global ; People Killed ; 1 ; Undead Killed ; 2 ; Animals Killed ; 2 ; Creatures Killed ; 3 ; Daedra Killed ; 4 ; Automatons Killed ; 5 ;------------------- FUNCTION myF_Check() ;------------------- IF ( globalStaffKillCounter ) ELSE ; edit: added this line RETURN ; - STOP - mod uninstalled! ENDIF ;--------------------- int i = Game.QueryStat("People Killed") + Game.QueryStat("Undead Killed") + \ Game.QueryStat("Animals Killed") + Game.QueryStat("Creatures Killed") + \ Game.QueryStat("Daedra Killed") + Game.QueryStat("Automatons Killed") IF (iCounter == 0) iCounter = i ; init this counter with value, since staff is equipped! ELSE i = i - iCounter globalStaffKillCounter.Mod(i as Float) ENDIF IF (globalStaffKillCounter.GetValue() > 15) ; more than 15 kills with this staff equipped ; unlock perk player.AddPerk( SpecialPerk ) ENDIF RegisterForSingleUpdate(2.5) ; check again in 2.5 sec ENDFUNCTION Edited June 16, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
maxarturo Posted June 12, 2021 Share Posted June 12, 2021 @ ReDragon2013. Instead of pulling every 2.5 seconds and having continuously active a script in the background, it's better to use the 'Story Manager' that fire ONLY on the actor's death, it's a thousands times better in terms of system performance, and especially if you have a large number of kills to make. Have a nice weekend. Link to comment Share on other sites More sharing options...
Deleted19761User Posted June 15, 2021 Share Posted June 15, 2021 (edited) You might be able to accomplish this by invoking the Soul Trap Function perhaps, creating a integer value that ticks up to keep track of how many kills have been made when the soul-trap function fires off instead of looking for the death event of the last target. (Checking for Soul Trap event instead might be simpler.) Tying kills to a perk through a specific weapon does not sound very efficient, maybe with a specific enchant instead. You could instigate an item level up by creating a leveled list for the weapon in question (or any weapon that you can enchant with this effect) and every time a kill tier is met the weapon upgrades to the next level. Edited June 15, 2021 by Guest Link to comment Share on other sites More sharing options...
Noober1 Posted June 16, 2021 Author Share Posted June 16, 2021 Thanks for the tips guys! MUCH Appreciated Link to comment Share on other sites More sharing options...
Recommended Posts