Benvenuto!

Registrati per poter accedere a tutte le funzioni del forum. Una volta iscritto ed effettuato il login, potrai aprire nuove discussioni, rispondere a discussioni già create, inserire aggiornamenti di status, seguire amici, inviare messaggi privati e molto altro ancora.

Chiudi
RPG Italia è sbarcata su LiberaPay!

Ospite, se vuoi sostenerci donando anche 1€ al mese, questa è l'occasione giusta! RPG Italia non ha pubblicità e l'unica fonte di finanziamento deriva dalle donazioni.
Siate generosi!

Per aderire, diventa un donatore su LiberaPay! È una piattaforma italiana che consente grande flessibilità di pagamento!

mod teletrasporto per NPC

Discussione in 'Skyrim: Mod & Tweaks' iniziata da mORISmark, 4 Gennaio 2021.

Condividi questa Pagina

  1. mORISmark

    mORISmark Livello 1

    Messaggi:
    4
    Mi piace:
    1
    Sto creando un nuovo boss al quale aggiungere l'abilità di teletrasporto, in base al tempo trascorso, colpi ricevuti e altre variabili. Ho trovato ciò che fa al caso mio Sky Ai Teleporting NPCs at Skyrim Nexus - Mods and Community che ha pubblicamente rilasciato il permesso di poter utilizzare il suo script.psc

    Il problema e che dopo pochi minuti di combattimento puntualmente il gioco va in crash.
    Per cui, vorrei un vostro parere.
    Sostanzialmente lo script auto crea dei marker localmente ai quali, il boss NPC si autoteletrasporta in funzione delle variabili come da script sotto:

    Scriptname SkyAiTeleportAbilityScript extends activeMagicEffect

    import Game
    Import Utility

    ;=========================================================================================
    ; PROPERTIES
    ;============================

    Activator property teleportActivator Auto
    {The activator that will be placed and teleported to}
    Activator property TeleportFXStart Auto
    {The Fx that will be placed before teleporting}
    Activator property TeleportFXFinish Auto
    {The Fx that will be placed after teleporting}

    Int Property TeleportChance = 20 Auto
    {The Chance that an NPC will be able to use this ability (Default 20) + 2/3's of the NPC's Level}
    Int Property TeleportChanceHit = 60 Auto
    {If allowed to teleport at all, this is the chance to be allowed to teleport by being hit (Default 60)}
    Int Property TeleportChanceTimed = 60 Auto
    {If allowed to teleport at all, this is the chance to be allowed to teleport on a timer (Default 60)}

    Int Property CountMin = 3 Auto
    {Minimum number of times the script updates before teleporting (Default 3)}
    Int Property CountMax = 7 Auto
    {Maximum number of times the script updates before teleporting (Default 7)}

    Int Property HitCountMin = 2 Auto
    {Minimum number of hits until teleport (Default 3)}
    Int Property HitCountMax = 7 Auto
    {Maximum number of hits until teleport (Default 7)}
    Float Property UpdateTime = 2.5 Auto
    {How often the script updates (Default 2.5 seconds)}
    Float Property fRadius = 2048.0 Auto
    {Radius to search for a teleport point (2048.0 Auto)}

    Bool Property bTimebased = True Auto
    {Allows user to teleport after the script updates a certain number of times. (Default True)}
    Bool Property bHitbased = True Auto
    {Allows user to teleport after being hit a certain number of times. (Default True)}

    ;=========================================================================================
    ; VARIABLES
    ;============================

    ObjectReference ActivatorRef
    ObjectReference casterRef
    ObjectReference FXStartLoc
    ObjectReference FXFinishLoc
    ObjectReference targetLoc
    actor caster

    int RandTeleport
    int RandTeleportHit
    int RandTeleportTimed
    int hitCount
    int updateCounter
    int teleportTimed
    int teleportHit
    int level

    ;=========================================================================================
    ; EVENTS
    ;============================

    Event OnEffectStart(Actor akTarget, Actor akCaster)
    caster = akCaster
    casterRef = (caster as ObjectReference)
    level = (caster.getLevel() * 2/3)
    RandTeleport = Utility.RandomInt(0,100)
    if RandTeleport <=(TeleportChance + (level as Int))
    ActivatorRef = casterRef.placeAtMe(teleportActivator)
    RandTeleportHit = Utility.RandomInt(0,100)
    RandTeleportTimed = Utility.RandomInt(0,100)

    if RandTeleportHit <= TeleportChanceHit
    bHitBased = true
    elseIf RandTeleportHit > TeleportChanceHit
    bHitBased = false
    endIf

    if RandTeleportTimed <= TeleportChanceTimed
    bTimeBased = true
    elseIf RandTeleportTimed > TeleportChanceTimed
    bTimeBased = false
    endIf

    if bTimeBased == true
    updateCounter = 0
    teleportTimed = Utility.RandomInt(CountMin, CountMax)
    endIf
    if bHitBased == true
    hitCount = 0
    teleportHit = Utility.RandomInt(HitCountMin, HitCountMax)
    endIf
    if bHitBased == True || bTimeBased == True
    registerForSingleUpdate(0.5)
    endIf
    endIf
    EndEvent

    Event OnUpdate()
    ActivatorRef = casterRef.placeAtMe(teleportActivator)
    if caster.isInCombat() && caster.isDead() == false
    if bTimeBased == True
    updateCounter+= 1
    If updateCounter >= teleportTimed
    Teleport()
    updateCounter = 0
    teleportTimed = Utility.RandomInt(CountMin, CountMax)
    endif
    endIf
    ActivatorRef
    registerForSingleUpdate(UpdateTime)
    endIf
    EndEvent

    Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    if bHitbased == True
    HitCount += 1
    if HitCount >= TeleportHit
    Teleport()
    HitCount = 0
    if updateCounter != 0
    updateCounter -= 1
    endIf
    teleportHit = Utility.RandomInt(HitCountMin, HitCountMax)
    endIf
    endIf
    EndEvent

    Function Teleport()
    targetLoc = Game. FindRandomReferenceOfTypeFromRef(TeleportActivator, casterRef, fRadius)
    FXStartLoc = casterRef.placeAtMe(TeleportFXStart)
    FXFinishLoc = targetLoc.placeAtMe(TeleportFXFinish)
    FXStartLoc
    targetLoc
    FXFinishLoc
    casterRef.moveTo(targetLoc)
    EndFunction[/SPOILER]

    C'è qualcosa che non va nello script, oppure è il motore del gioco che non sa gestire frequenti teletrasporti?




    p.s. tentativi da escludere:
    l'NPC è stato già spostato anche in altre location, stesso risultato
    l'NPC non ha altri script associati
    l'NPC è nuovo non ha un ID del vanilla.
    l'hardware del mio PC supporta abbondantemente il teletrasporto dell'NPC:
    1660 Ti con 6 GB di Ram
    1 tb SSD
    16 GB di Ram
    Ryzen 3500 H


    informazioni che potrebbero essere utili:
    l'NPC ha l'outfit di Miraak
    Combat style l'ho creato da zero quindi non ha riferimenti del vanilla
    ha la voce di Miraak
     
  2. Vitbull88

    Vitbull88 Scienziato pazzo

    Messaggi:
    1.003
    Mi piace:
    959
    Sembra fatta bene. Hai controllato come va l'utilizzo di memoria mentre giochi? Sale col tempo? Se ti crasha sempre dopo la stessa quantitá di tempo potrebbe essere un problema di quel tipo (anche se a leggere il codice non mi sembra).

    L'altro dubbio che ho é che, non sapendo bene cosa fa teleport(), in teoria potrebbe esserci un conflitto tra le due possibilitá di teleport (hit based o time based): in teoria, se ho letto bene, puoi fare due teletrasporti nello stesso update (nel caso si verifichino in contemporanea le condizioni di hit e time), e magari il secondo tentativo di teleport non trova l'oggetto da teletrasportare. Nel dubbio, io aggiungerei una bool isTeleporting, che é false di base, diventa true quando un teleport va a buon fine, e si resetta a false dopo il teleport, e metterei questa bool come condizione per la funzione teleport().

    Premetto che non ho mai lavorato su mod di skyrim, programmo per tutt'altro, prendi le mie parole come consiglio spassionato :p