Jump to content

[LE] Get Level script help from Xbox One


Ortorin

Recommended Posts

I figure that it wouldn't be too hard to script a notification to popup with the level of the actor that the player is in combat with. However, I am not a programmer. All I know is scripting from Morrowind. Can anyone work with this basic code idea and turn it into an actual mod? I don't even need credit, I just need to be able to see the level of the mobs I'm fighting. I would throw in a check for combat before the main script for getting the reference and level.



String TargetRef
String LastTargetRef
Int TargetLevel

Actor TargetRef = Game.GetPlayer().GetCombatTarget()

If(TargetRef = LastTargetRef)
Return
Endif

TargetLevel = TargetRef.GetLevel()

Debug.Notification("Level is" + TargetLevel)

LastTargetRef = TargetRef

End

Edited by Ortorin
Link to comment
Share on other sites

One way off the top of my head is extremely inconvenient and time consuiming, as it would require a script to be attached to every actor. Alternatively, you could try to use an alias quest ref with PlayerRef. I can't guarantee you it would work, just something you could try.

 

 

 

Scriptname TargetLevel Extends ReferenceAlias (Or AliasReference? IDR.)

Actor Property PlayerRef Auto

String TargetRef

Int DoOnce = 0
Int TargetLevel

Event OnInit()
  RegisterForActorAction(0) ;Melee swing, add on to code for other forms
EndEvent

Event OnActorAction(Int Type, Actor akActor, Form Source, Int Slot)
  TargetRef = PlayerRef.GetTarget()
  TargetLevel = TargetRef.GetBaseActor().GetLevel()

  If akActor == PlayerRef
    If PlayerRef.IsInCombat()
      If DoOnce == 0
        Debug.Notification("Target Level: " + TargetLevel)
        DoOnce == 1
      EndIf
    EndIf
  EndIf

  If TargetRef.IsDead()
    DoOnce == 0
  EndIf

EndEvent

 

 

 

Haven't test compiled it myself, so don't let me tell you it'll work, let alone compile. Just a thought, can expand from there.

Link to comment
Share on other sites

Ortorion wrote: "Can anyone work with this basic code idea and turn it into an actual mod?"

 

This is sub forum CK not request for mods !!!

 

The idea is to make a quest, build an alias with unique name "player" and attach a script like follow to created alias.

Make sure the quest has checked 'start game enabled'!

 

xyzGetTargetLevelScript

 

Scriptname xyzGetTargetLevelScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/8334983-get-level-script-help-from-xbox-one/

  Actor target


; -- EVENTs --

EVENT OnInit()
    Debug.Trace(" OnInit() - for " +self)                ; for debugging
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT


EVENT OnPlayerLoadGame()
    Debug.Trace(" OnPlayerLoadGame() - for " +self)        ; for debugging
    UnRegisterForUpdateGameTime()
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT


EVENT OnUpdateGameTime()
    Utility.Wait(0.25)
    actor player = Game.GetPlayer()

    IF player.IsInCombat()
        actor aRef = player.GetCombatTarget()
        IF (aRef) && (aRef != target)
            target = aRef
            Debug.Notification("Target is level " +aRef.GetLevel())
        ENDIF
    ENDIF

    Utility.Wait(1.75)

    IF self.GetOwningQuest()
        RegisterForSingleUpdateGameTime(0.0)
    ENDIF
ENDEVENT


;EVENT OnCombatStateChanged(Actor akTarget, Int aeCombatState)
;; https://www.creationkit.com/index.php?title=OnCombatStateChanged_-_Actor
;ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...