Jump to content

Script - Only spawn if custom quest is active


ZunaSW

Recommended Posts

^^ Wrong approach.

 

You can't use the NPC as its own spawner. The script would have to be placed on a hidden object in-game, on a trigger for example.

 

To test if a quest is running, use "myquestname.IsRunning()" like acidzebra suggested. You also need to declare the Quest Property "myquestname" near the top of your script:

 

Quest Property muquestname Auto

Edited by steve40
Link to comment
Share on other sites

I made this event:

 

Event OnCellLoad()

if CWE02.IsRunning()

self.enable()

endIf

EndEvent

 

But it doesn't work. In the compiler output appears this:

 

e:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CWE02.psc(3,15): cannot name a variable or property the same as a known type or script

e:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CWE02.psc(6,10): IsRunning is not a function or does not exist

e:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CWE02.psc(6,10): cannot call the member function IsRunning alone or on a type, must call it on a variable

 

:wallbash:

Then, I can't put the IsRunning function in a event or can I put it?

 

I put this script to a reference in the world editor. in the tab scripts, I put it in a spawn point of an NPC.

 

 

EDIT: I make a new script, and then I wrote this:

 

Scriptname CWEProperty02 extends ObjectReference

 

State Departing

Event OnCellLoad()

if CWE02.IsRunning()

self.enable()

endIf

EndEvent

EndState

 

But it doesn't works :wallbash:

Edited by ZunaSW
Link to comment
Share on other sites

You're running wild, trying things without really knowing what you are doing. You need to run through the basic tutorials so you get a grasp of how papyrus handles things, even (and maybe especially) if you have experience with other scripting languages. Like Steve said, you need to declare properties in your script (notably for the quest), then link that script quest property to your actual quest.

 

About properties specifically

http://www.creationk...s_%28Papyrus%29

The basic introduction

http://www.creationk...us_Introduction

Step-by-step tutorials

http://www.creationk...rus_Hello_World

A lot of example scripts

http://www.creationk...egory:Solutions

 

You're trying to run before you can walk. I can just about crawl right now. Steve is a marathon championship title holder ;)

 

For completeness' sake

 

script SOMESCRIPTNAME extends ObjectReference
;declaring the properties
quest property CWE02 auto
ObjectReference property THEGUYYOUWANTENABLEDREF auto
;event block
Event OnCellLoad()
	if CWE02.IsRunning()
	THEGUYYOUWANTENABLEDREF.enable()
	endIf
EndEvent

 

And as Steve pointed out, this should be put on a hidden object or trigger, not on the NPC.Then you should open the properties for the script and link the quest property to the actual quest and the objectreference property to the NPC reference in your scene.

 

BUT please go through the tutorials.

Edited by acidzebra
Link to comment
Share on other sites

Yes, I'm following the tutorials, but it is not easy. I'm learning about properties now. Thanks, I will see what can I make :D. Thanks to both :)

 

EDIT: Hummm.... Now I learned more, but I have a question, Can functions, events and properties are in a same script?

Edited by ZunaSW
Link to comment
Share on other sites

Yes. Multiple of each and any combination. Think of properties as a way of tying your script to world objects, events, and quests (and even sharing data between scripts). Functions are like in any scripting language, a block of code you can call on from somewhere else within the same script for more efficient coding. Events are what the script uses to check for certain conditions in the game world to act on. Edited by acidzebra
Link to comment
Share on other sites

Ok, thanks. Now I made a different script with a event and a function, but I get errors.

Script:

 

Scriptname CWE02ScriptSpawn extends ObjectReference  

quest property CWE02 auto
ObjectReference property CWFortSoldierImperialCWE auto
bool property Locked
function set(int value)
              Event OnLoad()
               Debug.Trace("Every object in this cell has loaded its 3d")
               if CWE02.IsRunning()
               CWFortSoldierImperialCWE.enable()
               endIf
EndEvent
EndFunction

 

 

Errors:

 

Starting 1 compile threads for 1 files...

Compiling "CWE02ScriptSpawn"...

e:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CWE02ScriptSpawn.psc(7,15): no viable alternative at input 'Event'

e:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CWE02ScriptSpawn.psc(13,0): missing EOF at 'EndFunction'

No output generated for CWE02ScriptSpawn, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on CWE02ScriptSpawn

 

 

I understanding the EOF as a problem when I write the function, but I don't see the problem.

And "no viable alternative at input event"... I dont understand this...

There aren't more errors. I think the script will work if I solve the errors, but I'm not sure.

Edited by ZunaSW
Link to comment
Share on other sites

You can call functions from inside of event blocks, but you don't need a function block here. Events and functions are separate building blocks.

 

So

 

event someevent()

somefunction()

endevent

 

function somefunction

[some stuff]

endfunction

 

Now the event will call on the function.

Edited by acidzebra
Link to comment
Share on other sites

Scriptname testquestscript extends ObjectReference   

quest property CWE02 auto
ObjectReference property CWFortSoldierImperialCWE auto


  			Event OnLoad()
           	Debug.Trace("Every object in this cell has loaded its 3d")
           	if CWE02.IsRunning()
           	CWFortSoldierImperialCWE.enable()
           	endIf
EndEvent

 

compiles just fine for me (if it'll do what you want is another matter). Like I said, you don't appear to need a function.

Edited by acidzebra
Link to comment
Share on other sites

Yes, I tried yesterday with some like you put, but I have a lot of errors. For example "IsRunning is not a function or does not exist". Now I'm trying to make other script, like the other, but with some things changed. I used the tutorial of Creation Kit official site (Hello World tutorial), and I have errors when I want to put "ifCWE02.IsRunning()". The error says "IsRunning is not a function or does not exist".

The script:

 

Scriptname CWE02newscript extends ObjectReference  

Event OnCellLoad()
int count
if CWE02.IsRunning()
CWFortSoldierImperialCWE.enable()
endIf
Debug.MessageBox("¡Los Imperiales han llegado! Matémoslos a todos")
count = count + 1
endEvent

 

Like I said, the problem is in IsRunning. When the script haven't "IsRunning", it works perfectly.

Edited by ZunaSW
Link to comment
Share on other sites

  • Recently Browsing   0 members

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