Jump to content

[Answered] Help with Begin GameMode vs OnTriggerEnter


Recommended Posts

Posted

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. 

Posted

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.

Posted

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?

Posted

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

Posted

How do I run GECK with NVSE? 

 

Geck isnt letting the 2nd script you gave me work :/ I've spend almost two hours trying to figure this out, I want it done!

Posted

 

Geck isnt letting the 2nd script you gave me work :/

 

     Let bActivated := 2

 

This line uses NVSE 4+

 

You can replace it with:

 

Set bActivated to 2

Posted

To start GECK with NVSE, create a shortcut of nvse_loader and then add the -editor parameter at the end, like this:

"c:\SteamApps\common\fallout new vegas\nvse_loader.exe" -editor

Posted

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.

Posted

both the first and the second "if" script blocks are using Let

Posted

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

Archived

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

  • Recently Browsing   0 members

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