Jump to content

[Answered] Help with Begin GameMode vs OnTriggerEnter


Recommended Posts

So I am having this problem where my character is entering the cell where the trigger is. My character ends up equipping and unequipping slave collars, I think the problem is that the script just continues to run over and over again (in the console it keeps repeating "enslaved finished").

 

I've tried using a "Begin OnTriggerEnter Player" but the script does not go off. This is also the first mod I'm working on so bare with me  :D .

 

 

 

 

scn testscript

float timer

begin GameMode
if( playerRef.isSpellTarget SexoutSlaveryFreePlayer )
if(timer < 1)
set timer to timer + getSecondsPassed
return
endif

set SexoutSlaveryPlayerQ.SlaveryID to 128
set SexoutSlaveryPlayerQ.master to testnpcREF
set SexoutSlaveryPlayerQ.slaveryType to 4
set SexoutSlaveryPlayerQ.punishmentType to 2
set SexoutSlaveryPlayerQ.takeItems to 1
set SexoutSlaveryPlayerQ.workType to 1
set SexoutSlaveryPlayerQ.stolenItemsContainer to testBoxREF
set SexoutSlaveryPlayerQ.Collar to SexoutSKSTCollar02
;set SexoutSlaveryPlayerQ.canSubmit to 1
set SexoutSlaveryPlayerQ.noWeapons to 1
set SexoutSlaveryPlayerQ.noClothes to 1
set SexoutSlaveryPlayerQ.dismissCompanions to 1

AddFormToFormList SexoutSlaverySafeCells testcell
AddFormToFormList SexoutSlaveryEquipmentAllowed SexoutSlaverySlaveCollar
AddFormToFormList SexoutSlaveryEquipmentAllowed SexoutSKSTCollar02

playerRef.CIOS SexoutSlaveryEnslavePlayer
RemoveMe
elseif( playerRef.isSpellTarget SexoutSlaveryEnslavePlayer == 0)
playerRef.CIOS SexoutSlaveryFreePlayer
endif
end

 

 

EDIT: The issue was the first if statement, will look more into it later but I'm changing it to something simpler. 

Link to comment

if you need to do a single execution, you can set a variable


scn testscript
float timer

INT BDOONCE

begin GameMode
if( playerRef.isSpellTarget SexoutSlaveryFreePlayer )
if(timer < 1)
set timer to timer + getSecondsPassed
return
endif

IF BDOONCE == 0
SET BDOONCE TO 1
; AND NOW EVERYTHING ELSE
set SexoutSlaveryPlayerQ.SlaveryID to 128
set SexoutSlaveryPlayerQ.master to testnpcREF
set SexoutSlaveryPlayerQ.slaveryType to 4
set SexoutSlaveryPlayerQ.punishmentType to 2
set SexoutSlaveryPlayerQ.takeItems to 1
set SexoutSlaveryPlayerQ.workType to 1
set SexoutSlaveryPlayerQ.stolenItemsContainer to testBoxREF
set SexoutSlaveryPlayerQ.Collar to SexoutSKSTCollar02
;set SexoutSlaveryPlayerQ.canSubmit to 1
set SexoutSlaveryPlayerQ.noWeapons to 1
set SexoutSlaveryPlayerQ.noClothes to 1
set SexoutSlaveryPlayerQ.dismissCompanions to 1

AddFormToFormList SexoutSlaverySafeCells testcell
AddFormToFormList SexoutSlaveryEquipmentAllowed SexoutSlaverySlaveCollar
AddFormToFormList SexoutSlaveryEquipmentAllowed SexoutSKSTCollar02

playerRef.CIOS SexoutSlaveryEnslavePlayer
RemoveMe
elseif( playerRef.isSpellTarget SexoutSlaveryEnslavePlayer == 0)
playerRef.CIOS SexoutSlaveryFreePlayer
endif
ENDIF
end

The OnTriggerEnter Player will work for a single frame, so the timer won't work as you expect. If you need that a code is executed during a certain amount of time, you can use the OnTriggerEnter to define the begin, and the you use a GameMode to handle the rest of the code, in this way:

scn MyScript

int bActivated

Begin OnTriggerEnter Player

   if bActivated == 0
      Let bActivated := 1
   endif

End


Begin GameMode

  If bActivated == 1
      Let bActivated := 2
      ; do the rest of the code
  else
     Return
  endif

End

When you go in the trigger, you set the variable bActivated to 1, at that point the GameMode block will execute the code. Since bActivated is setted to 2 as first thing, it means ";do the rest of the code" will only have a single execution.

Link to comment

The first script where we added BDOONCE didn't work, in my head it seemed like it would. 

Will try the other script.

EDIT: goofed on something, testing again.

EDIT2: No luck Still, will try the other script now.

 

 

Also does it matter that the script is in a trigger object?

Link to comment

I don't know what the script is supposed to do and I only wrote you how to make a single execution of it.

At this point, you should debug your script. For example, are you sure that the player is target of that spell? that's the culprit of all the script: if it won't happen, nothing else will be executed.

To debug, I strongly suggest to run GECK with NVSE... it will allow you to use some functions that are very useful to debug. Look at this for example:

 

 

...
begin GameMode
if( playerRef.isSpellTarget SexoutSlaveryFreePlayer )
if(timer < 1)
set timer to timer + getSecondsPassed
return
endif

IF bDoOnce == 0
Set bDoOnce to 1

PRINTC "THE SCRIPT HAS EXECUTED"

set SexoutSlaveryPlayerQ.SlaveryID to 128
...

 

 

If the player is spell target, after 1 second you must see on console the sentence "THE SCRIPT HAS EXECUTED" - if you don't see it, then you know there's a problem in the block before.

 

 


Also does it matter that the script is in a trigger object?

Yes. If it's simply a gamemode, it would be good to use a quest script. If you use OnTriggerEnter, then of course you will use a trigger :P

Link to comment

You have to really have a great deal of patience with scripts and scripting vane000, it's a very long and painful road, some folks just are not good at wrapping their head around it, it's like "seeing" a 2D texture and knowing how it will look on a 3D mesh, that one still drives me insane. You will get it, one time it will just go off like a light bulb and things will become clear. Your fortunate to have A.J. to help , I can recall when she was still learning it.

Link to comment

scn MyScript

int bActivated

Begin OnTriggerEnter Player

   if bActivated == 0
      Let bActivated := 1
   endif

End


Begin GameMode

  If bActivated == 1
      Let bActivated := 2
      ; do the rest of the code
  else
     Return
  endif

End

 

I've repeated the same error twice

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use