Jump to content

Scripting question about if


gasti89

Recommended Posts

Hey there! A (hopefully) easy question for proh scripters :)

 

I'm using a default script that does exactly what i need (set a stage when a specific actor (aka player) enters the trigger). The only thing is that i need 2 prereq stages to be set in order to make the trigger work.

 

Do i have to add another "prereq stage" property? If yes, where should i add the line and with wich syntax?

 

Or there's a syntax that allows to have a sort of "OR" (like conditions)?

 

Thanks in advance!

 

Here's the script

 

Scriptname defaultSetStageTRIGSpecificActor extends ObjectReference  
{trigger looking for a particular base actor
to set a quest stage
}

import game
import debug

quest property preQuest auto
{ quest required to go}

quest property myQuest auto	
{ quest to call SetStage on}

int property stage auto
{ stage to set}

int property prereqStageOPT = -1 auto
{ OPTIONAL: stage that must be set for this trigger to fire }

ActorBase property TriggerActor auto
{actor that trigger is looking for}

bool property disableWhenDone = true auto
{ disable myself after I've been triggered. Defaults to true }

bool property onlyOnce = true auto
{ stage will be set only once. Defaults to true }

auto STATE waitingForActor
EVENT onTriggerEnter(objectReference triggerRef)
	; check for correct actor
	actor actorRef = triggerRef as actor
	if actorRef != None && actorRef.GetActorBase() == TriggerActor
		if prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1
			myQuest.setStage(stage)
			if onlyOnce
				gotoState("hasBeenTriggered")
			endif
			if disableWhenDone
				Disable()
			endif
			trace(self+" triggered by "+actorRef)
		endif
	else
		trace(self+" didn't trigger for base actor " + actorRef.GetActorBase() + " <> " + TriggerActor)
	endif
endEVENT
endSTATE

STATE hasBeenTriggered
; this is an empty state.
endSTATE

Link to comment
Share on other sites

1. Add a quest property for your second prerequisite quest (eg preQuest02).

2. Add an int property for the prerequisite stage of preQuest02 (eg prereqStageOPT02) initialized to -1.

3. Edit this line in the script:

 

if prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1

to this:

 

if (prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1) && (prereqStageOPT02 == -1 || preQuest02.getStageDone(prereqStageOpt02) == 1)

Link to comment
Share on other sites

&& means AND, || means OR

 

So in the original script,

 

if prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1

means "if prereqStageOPT is -1 (which means it was left at default, unchanged) or if preQuest has finished prereqStageOPT".

 

In the modified script,

 

if (prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1) && (prereqStageOPT02 == -1 || preQuest02.getStageDone(prereqStageOpt02) == 1)

means "if (the stuff from before) AND (the new stuff)".

 

If both stages are from the same quest, and you only want to use one preQuest property, use this:

 

f (prereqStageOPT == -1 || preQuest.getStageDone(prereqStageOPT) == 1) && (prereqStageOPT02 == -1 || preQuest.getStageDone(prereqStageOpt02) == 1)

Edited by fg109
Link to comment
Share on other sites

  • Recently Browsing   0 members

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