Jump to content

[LE] Experienced modder TIP required, Script or other creation way.


Recommended Posts

In both scripts recently posted there is a bool variable isTriggered. This variable is set but is never checked. It either is not needed or needs to be checked for proper value within an IF statement.

I also found an error after testing. I added the "Actor damage" after closing CK without testing, went to take a shower and then i tested it and found the error.
IsharaMeradin how should this be correctly written, with the variable checked ?.
This is the script now working :

Scriptname aXMDparaplanisiSkullKeySCRIPT01 extends ObjectReference  
{Set stage on Quest - Adds Skull Key to inventory - Disables STATIC Key - Self disable Trigger Box Activator}
 
 
Quest Property myQuest auto
{The quest we will be setting stages on}
 
Int Property stageSetOnTriggered auto
{The stage that will be set when the player Triggered this}
 
MiscObject Property Key01 Auto
{assign key or item to add to inventory}
 
ObjectReference Property StaticKey Auto
{object - item to disable}
 
ObjectReference Property SoundFX Auto
{soundFX to enable}
 
Message PROPERTY Message01 auto
{Message to show after Activated}
 
Actor Property PlayerREF Auto
{to applay damage on self - Actor}
 
bool Property isTriggered = false auto hidden
 
 
Event OnActivate(ObjectReference akActionRef)
          if (myQuest.GetStageDone(stageSetOnTriggered) == FALSE)
              myQuest.SetStage(stageSetOnTriggered)
              akactionref.additem(Key01, 1)
              isTriggered = true
              StaticKey.disable()
              SoundFX.enable()
              self.Disable()
              Utility.wait(2.5)
              Message01.Show()
              Utility.wait(1.5)
              PlayerREF.DamageActorValue("Health", 100.0)
              Game.TriggerScreenBlood(6)
              GoToState("Done")
      endif
EndEvent

Many thanks in advance !!.
* Sorry Toby, you might want to check this script version.
Edited by maxarturo
Link to comment
Share on other sites


;Actor Property PlayerREF Auto ; UnUSED by now, {to apply damage on self - Actor}

EVENT OnActivate(ObjectReference akActionRef)
IF ( isTriggered )
RETURN ; - STOP - /1 quest already triggered
ENDIF
;---------------------
IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
RETURN ; - STOP - /2 not the player
ENDIF
;---------------------
IF myQuest.IsStageDone(stageSetOnTriggered)
RETURN ; - STOP - /3 quest stage was already set
ENDIF
;---------------------
isTriggered = TRUE

myQuest.setStage(stageSetOnTriggered)
akActionRef.AddItem(Key01 as Form, 1) ; give player the key

StaticKey.Disable()

SoundFX.Enable()
self.Disable()
Utility.Wait(2.5)

Message01.show() ; show message
Utility.wait(1.5)

(akActionRef as Actor).DamageActorValue("Health", 100.0) ; damage player by 100 points
Game.TriggerScreenBlood(6)

;;; GoToState("Done") ; not seen in your script
ENDEVENT

 

Edited by ReDragon2013
Link to comment
Share on other sites

I don't know if ReDragon version is better and in what way, but i for sure would appreciate some advice or shed some light to it.


Nevertheless thank you very much ReDragon for your trouble !!


* GoToState("Done")

i've seen it been used in so many vanilla scripts like this, that i figure there must be a reason behind it.

Edited by maxarturo
Link to comment
Share on other sites

What is the key behind GoToState("Done")?

 

Script should look as follow, variant A:

 

 ;Actor Property PlayerREF Auto                      ; UnUSED by now, {to apply damage on self - Actor}
 ;bool Property isTriggered = false auto hidden      ; UnUSED by now

EVENT OnActivate(ObjectReference akActionRef)
;;;IF ( isTriggered )
;;;    RETURN    ; - STOP - /1    quest already triggered
;;;ENDIF
;---------------------
IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN    ; - STOP - /2    not the player
ENDIF
;---------------------
IF myQuest.IsStageDone(stageSetOnTriggered)
    gotoState("Done")                ; ### STATE ###  just in case, as failsafe
    RETURN    ; - STOP - /3    quest stage was already set
ENDIF
;---------------------
    gotoState("Done")                ; ### STATE ###
;;; isTriggered = TRUE

    myQuest.setStage(stageSetOnTriggered)
    akActionRef.AddItem(Key01 as Form, 1)            ; give player the key

    StaticKey.Disable()

    SoundFX.Enable()
    self.Disable()
    Utility.Wait(2.5)

    Message01.show()                                ; show message
    Utility.wait(1.5)

    (akActionRef as Actor).DamageActorValue("Health", 100.0)    ; damage player by 100 points
    Game.TriggerScreenBlood(6)
ENDEVENT


;=====================
state Done
;=========
EVENT OnActivate(ObjectReference akActionRef)
    ; do not allow to trigger this event again, we have to use the same event (as empty code event) here
ENDEVENT
;=======
endState

 

 

or like this, Variant B

 

 ;Actor Property PlayerREF Auto                    ; UnUSED by now, {to apply damage on self - Actor}
 ;bool Property isTriggered = false auto hidden    ; UnUSED by now

;=====================
state Waiting
;============
EVENT OnActivate(ObjectReference akActionRef)
;;;IF ( isTriggered )
;;;    RETURN    ; - STOP - /1    quest already triggered
;;;ENDIF
;---------------------
IF (akActionRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN    ; - STOP - /2    not the player
ENDIF
;---------------------
IF myQuest.IsStageDone(stageSetOnTriggered)
    gotoState("Done")                ; ### STATE ###  just in case, as failsafe
    RETURN    ; - STOP - /3    quest stage was already set
ENDIF
;---------------------
    gotoState("Done")                ; ### STATE ###
;;; isTriggered = TRUE

    myQuest.setStage(stageSetOnTriggered)
    akActionRef.AddItem(Key01 as Form, 1)            ; give player the key

    StaticKey.Disable()

    SoundFX.Enable()
    self.Disable()
    Utility.Wait(2.5)

    Message01.show()                                ; show message
    Utility.wait(1.5)

    (akActionRef as Actor).DamageActorValue("Health", 100.0)    ; damage player by 100 points
    Game.TriggerScreenBlood(6)
ENDEVENT
;========
endState


;=====================
state Done
;=========
;EVENT OnActivate(ObjectReference akActionRef)
  ; this event is not needed here, because it does not exist in no state
;ENDEVENT
;========
endState

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

After seeing the four versions of the same script, i've come to understand the logic, and each coding style.

 

Thanks ReDragon !.

Edited by maxarturo
Link to comment
Share on other sites

I'm just posting this because i see that this topic has a lot of views & someone might be interested.


After a lot of testing with all four Scripts, i did found some difference mainly on how the game engine executes (timing in miliseconds) the script.

The main is that removing the "Actor Property PlayerREF Auto" and replacing it with " (akActionRef as Actor).DamageActorValue" like ReDragon made it, will make the action fire 0.5seconds faster or the " Message01.show()" 0.5seconds later (i don't know why this is happening).


And why is this important ?, in my case is CRITICAL that everything happens in a linear and synchronize timing, the player is alredy in a bad place constantly taking damage and when the Script fires everything needs to be clear to the player:

1) Activate - activator (take key)

then

2) See quest updating

then

3) See boss appearing

then

4) Read message (curse)

then

5) Take damage (from script)


And all of the above needs to be completely synchronized and not overlapping each other.


Every script might need some different tweaking so that everything works synchronize, but they all work fine.

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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