Jump to content

[LE] How can I put a new script in a quest?


Recommended Posts

Hi everyone.

 

I want to put a new script in the quest PlayerVampireQuest I do this:

 

1) I make the new script an put it in the quest PlayerVampireQuest the event OnUpdateGameTime to add a new aptitd to the player but it but it doesn't work

 

2) To see if the problem was my code I copy all the script of PlayerVampireQuestScript an paste in my new script and add the new aptitud for the player but it doesn't work too

 

3) I add the new aptitud in PlayerVampireQuestScript and if it worked

 

So I don´t kno wwhy the new script in the quest doesn´t work Can someone can help me?

Link to comment
Share on other sites

Are you testing on a new game? Or at least on a game where the PlayerVampireQuest has not already been started?

 

Once a quest has started all attached scripts are "baked in", some minor changes can be done to the existing scripts but no new scripts will be recognized until the quest has been stopped and restarted. Given that not all quests can safely be stopped and restarted without causing other issues, it is always best to test on a new game or at the very least a save that does not have any of the associated things already active.

Link to comment
Share on other sites

Why don't you explain with simple words and in order what you want to achieve, maybe someone could provide assistance easily if she / he knows the objective, and the solution could have a different approach or application.

Link to comment
Share on other sites

I want to add a new vampire aptitud using a spell but I don´t want to edit the original script PlayerVampireQuestScript in the quest PlayerVampireQuest (Although I have already done it like that and works perfect but I don't want to do it like this) so I want to add a new script in in the quest PlayerVampireQuest to add the aptitud that I make.

Link to comment
Share on other sites

maxarturo wrote: "Why don't you explain with simple words and in order what you want to achieve"

That's the point.

 

Usually you have to create a new quest with CK and there add a new alias filled with unique player as reference. That means you should have after that an own "<modname>.esp" file in data folder.

Because of your "aptitud" spell this should be already done.

 

Now add next script to this alias (name it as you like, but unique as possible)

Shadow9605PlayerAliasAptitudScript

 

Scriptname Shadow9605PlayerAliasAptitudScript extend ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/10204073-how-can-i-put-a-new-script-in-a-quest/

  Keyword PROPERTY isVampire auto    ; vanilla keyword

  Spell PROPERTY myAptitud auto      ; the spell you have created for player as vampire

  Bool PROPERTY bSpellDone auto       ; [default=False]

; Shadow9605 wrote: "new vampire aptitud using a spell"


; -- EVENTs --

EVENT OnInit()
    myF_Debug(0, "OnInit")            ; it should be impossible that player starts as a vamipre
ENDEVENT


EVENT OnPlayerLoadGame()
    myF_Debug(1, "OnPlayerLoadGame")

    IF ( bSpellDone )
        RETURN ; - STOP - spell already given
    ENDIF

    IF IsPlayerVampire()
        CastAptitud()
        bSpellDone = TRUE
    ENDIF
ENDEVENT


; Event received when this actor finishes changing its race
EVENT OnRaceSwitchComplete()
    myF_Debug(2, "OnRaceSwitchComplete")
    
    IF IsPlayerVampire()
        CastAptitud()
    ELSE
        AptitudSpell(False)
    ENDIF
ENDEVENT

; ### next events are alternativ entry points ### 

;; Event received when a magic affect is being applied to this object
;Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)
;    myF_Debug(3, "OnMagicEffectApply")
;EndEvent
;
;; Event received when a spell is cast by this object
;Event OnSpellCast(Form akSpell)
;    myF_Debug(4, "OnSpellCast")
;EndEvent
;
;
;; Event received when this actor starts a new package (only if this alias points at an actor)
;Event OnPackageStart(Package akNewPackage)
;    myF_Debug(5, akNewPackage as String)
;EndEvent
;
;; Event received when this actors package changes (only if this alias points at an actor)
;Event OnPackageChange(Package akOldPackage)
;    myF_Debug(6, akOldPackage as String)
;EndEvent
;
;; Event received when this actors package ends (only if this alias points at an actor)
;Event OnPackageEnd(Package akOldPackage)
;    myF_Debug(7, akOldPackage as String)
;EndEvent


; -- FUNCTIONs --

;----------------------------------
FUNCTION myF_Debug(Int i, String s)
;----------------------------------
    Debug.Trace(" " +s+ "(" +i+ ") has been received.. " +self)
ENDFUNCTION


;------------------------------
Bool FUNCTION IsPlayerVampire()
;------------------------------
    race r = self.GetActorReference().GetRace()
    RETURN r.HasKeyword(isVampire)
ENDFUNCTION


;---------------------
FUNCTION CastAptitud()
;---------------------
    myAptitud.Cast( self.GetReference() )
    bSpellDone = TRUE
ENDFUNCTION


;------------------------------
FUNCTION AptitudSpell(Bool bOK)
;------------------------------
    actor player = Game.GetPlayer()
    IF ( bOK )
        player.AddSpell(myAptitud, TRUE)
        bSpellDone = TRUE
    ELSE
        player.RemoveSpell(myAptitud)
        bSpellDone = False
    ENDIF
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

I know all that you telling me but the didn't work but now I now what is my problem the problem is that I was using the event OnUpdateGameTime and I find out because I tried again to make my script work by executing the quest and then I teleported with the map to hibernalia and from that it worked and now i use the event onInit a work when the quest PlayerVampireQuest run.

 

Thank you for try to help me ReDragon2013, maxarturo and IsharaMeradin.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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