Jump to content

Can you toggle the Quest Item box through script?


Recommended Posts

I'd like to use this on an NPC, if it is possible.

 

I read this from the OBSE list of function commands. I'd like to try to use it on an NPC. But of course, I can't figure out how. How to change an NPC to NOT a quest item, that is. I am using Construction Set Extender.

 

IsQuestItem - returns whether the type is a quest item
(isQuestItem:bool) reference.IsQuestItem objectID:ref

SetQuestItem - sets whether the type is a quest item
(nothing) reference.SetQuestItem isQuestItem:bool objectID:ref

Edited by unknownhero2827
Link to comment
Share on other sites

Save the NPC FormID when you spawn it:

 

ref MyNPC

. . .

Let MyNPC := PlayerRef.PlaceAtMe BanditHighwayman01, 1, 200, 0

 

To set it as quest item: MyNPC.SetQuestItem 1

To return it as non-quest item: MyNPC.SetQuestItem 0

Alternatively (and simpler), you can just set the Base Object as a quest item: SetQuestItem 1 BanditHighwayman01
Since the quest item flag in on the Base Object, in both cases, regardless of the method used, all BanditHighwayman01 in the game will be affected.
(if you are not sure about what i meant in this last statement, read Base Objects vs References )

 

Link to comment
Share on other sites

You just saved me days of work. A royal wig for you.

 

What I'm doing is trying to delete a quest item NPC spawned with PlaceAtMe. I was successful, I think, on my first test. Success being that it was deleted when I used interiorreset after sending it to a custom cell.

 

However...

 

On my consecutive tests, when I wrote interiorreset in the console on the cell, it couldn't find the cell! Yet, I could coc and take myself to the cell just fine. I have no idea what happened. I think I wrote it right...

 

resetinterior merctrashcan00 ; not successful

 

also

 

coc merctrashcan00 ; successful

 

But, I can work around that I suppose. All interior cells should reset after 3 days on their own, as I've read. But is the automatic reset the same as using resetinterior?

 

(I need the cell to reset, so that I can go there and clear the dumped/dead NPCs)

 

EDIT: Tested again. It works the 1st time, but if I reload a save, I can no longer use resetinterior. On that cell, at least.

Edited by unknownhero2827
Link to comment
Share on other sites

adding these lines to previous script (other post)seems to work

 

deadactor.Resurrect ;from here
if deadactor.IsQuestItem == 1
deadactor.SetQuestItem 0
EndIf

set deadtwice to 1
kill
ResetInterior merctrashcan00

EndIf
;else
;deadactor.evp

 

 

but function scripts seems to work better as Qquix suggested

they dont run all the time untill the moment you call them (less cpu demand,less lag)

Edited by kastano
Link to comment
Share on other sites

"but function scripts seems to work better as Qquix suggested

 

they dont run all the time untill the moment you call them (less cpu demand,less lag)"

 

But doesn't it only run ResetInterior if the NPC is dead? So you'd only have the cpu working harder once the NPC is dead, right?

 

I should mention, this script is being used for multiple NPCs. Based off your scripts I've gotten everything to work the way I want. But this won't mess up the other NPCs that use the script will it? I.e. it affects each NPC individually.

 

EDIT: Upon testing. I'm pretty sure it doesn't. The only problem could be is if the player resurrects the NPC. I'm not sure what would happen then. I think the NPC would probably get deleted in the trashcan cell. Unless I wrote something to prevent that.

Edited by unknownhero2827
Link to comment
Share on other sites

I was speeking generally about optimising a mod and giving it potential for future development

your scripts may become bigger in a future time and may have more cpu intensive loops inside them(AI packages etc)

 

-But doesn't it only run ResetInterior if the NPC is dead? So you'd only have the cpu working harder once the NPC is dead, right?

yes the script runs every five seconds on every npc affected and checks if the npc is dead the doonce condition and then continues

i ve seen scripts that under the if conditions put (return - else) so it doesnt even completes an if - endif loop!

 

-But this won't mess up the other NPCs that use the script will it?

no if you mean that the variables(refs) may conflict- in that case deadactor of one npc to deadactor of another

 

in your edit you already discovered a bug - so your script now will become longer and so on (that checks though dont affect performance much)

Link to comment
Share on other sites

Oh man scripting lemme tell ya.

 

Yeah I've decided there's a bit more I want to do with my mod (then there'll be a bit more, and a bit more, and just a little tiny bit more.). So I'll definitely be writing more script. I'll probably post my script later on to have someone proofread it. But I think I've made some major headway so far; or maybe you have (I'll credit you in the mod so you can share some of the fame).

 

The forums will be seeing a lot more of me. Unless I overwhelm myself.

 

Thanks for the help so far.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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