Jump to content

Spawning a dragon by reading a journal


sgf1974

Recommended Posts

I've searched and searched and I've yet to find a way to spawn a dragon by reading a journal. Below, you'll find what is supposed to happen and then the script I'm using. Hopefully, someone can point me in the right direction so I can get this to work.

 

Here is the goal

- Read a journal left by a previous traveler

- Upon reading it, a dragon is spawned which has a specific key needed to open a specific door

- I created a new dragon by copying an existing one and giving it a new ID (RazortoothHallRazortoothDragon)

- I simply added the necessary key to this dragon's inventory

 

Here is what I have verified to work

- I placed the new dragon at a certain location (it shows up just fine)

- I fought and killed the dragon and obtained the key

- The key allows me to open the door

 

Further steps

At this point, I removed the dragon and added the script below to the journal. I also added an Xmarker intended as the spawn point for the dragon (RazortoothHallRazortoothSpawn).

 

Script used

Scriptname RazortoothHallSpawnRazortooth extends Book
{Reading Katt's Journal will spawn Razortooth}
ActorBase property RazortoothHallRazortoothDragon auto
ObjectReference property RazortoothHallRazortoothSpawn auto
int doOnce
Event OnRead()
if doOnce == 0
RazortoothHallRazortoothSpawn.PlaceActorAtMe(RazortoothHallRazortoothDragon).StartCombat(Game.GetPlayer())
doOnce = 1
endif
endEvent
What I got
The script compiles just fine but when playing the game, I can read the book but the dragon does not spawn.
Edited by sgf1974
Link to comment
Share on other sites

I can try that but I included the "if" statement to prevent the dragon from spawning every time the player reads the book. It should only happen once.

 

EDIT: I removed the "if" statement and added the Debug.MessageBox("Test") but it looks like it didn't fire. Back to the drawing board, I guess. Thanks for the suggestion though.

Edited by sgf1974
Link to comment
Share on other sites

This is by far the best part about learning to script in Papyrus (or learning any scripting/coding language for that matter): learning a whole lot more than I would have otherwise, just by trying to fix one small problem. I'm loving it!!! From what I just read, I think I need to try the following (when I get home from work tonight).

 

 

Scriptname RazortoothHallSpawnRazortooth extends Book
{Reading Katt's Journal will spawn Razortooth}
Actor property RazortoothHallRazortoothDragon auto
ActorBase RazortoothHallRazortoothDragonBase
ObjectReference property RazortoothHallRazortoothSpawn auto
int doOnce
Event OnInit()
RazortoothHallRasortoothDragonBase = RazortoothHallRazortoothDragon.GetBaseObject() as ActorBase
EndEvent
Event OnRead()
if doOnce == 0
RazortoothHallRazortoothSpawn.PlaceActorAtMe(RazortoothHallRazortoothDragonBase).StartCombat(Game.GetPlayer())
doOnce = 1
endif
endEvent
Edited by sgf1974
Link to comment
Share on other sites

I can help! Watch this tutorial by the very respectable darkfox127. What you'll do is use his script which will enable an x-marker. You'll create your dragon, then make the x-marker the dragon's enable parent. So when you read the journal, the x-marker is enabled and thus so too the dragon. The tutorial goes over furtinture, but it could be used on anything really including actors as my own Grayhill Keep mod demonstrates.

 

https://www.youtube.com/watch?v=JWvPaUt8f8s&list=FLykrxnY2sp6lsbZxdxQaKpA&index=5

 

 

Feel free to PM me if you need any more help!

Edited by Kraeten
Link to comment
Share on other sites

None of the above has worked. I'm trying a different angle now...

Anyways I can think of 2 possible reasons why your code isn't working.

First of all, when you didn't initialize doOnce, when you don't doOnce = None, not doOnce = 0

int doOnce = 0

 

The other is that you try to spawn the dragon and start combat with it in the same line of code.

You need to do one then the other.

Actually you probably don't even need the start combat code, if the dragon's faction is supposed to be aggressive with the player, it will start combat with the player automatically.

 

Also, don't use the doOnce thing at all.

doOnce variable is instanced for each book.

 

So if you spawn 2 books, you read one, it spawns a dragon, then it won't spawn anymore dragons.

but if you read the other, it will spawn another dragon.

 

Instead use the "IsRead" function, that way if you spawn 2 books, you will only spawn 1 dragon ever.

Scriptname RazortoothHallSpawnRazortooth extends Book 
 
Actor property RazortoothHallRazortoothDragon auto
ObjectReference property RazortoothHallRazortoothSpawn auto

Event OnRead()
    if !Self.IsRead()
        RazortoothHallRazortoothSpawn.PlaceActorAtMe(RazortoothHallRazortoothDragon)
    endif
endEvent

Edited by GrimyBunyip
Link to comment
Share on other sites

Kraeten - That was the "new angle" I was trying although I hadn't read anything about it and was trying it on my own. It's good to know I was on the right track. Thank you for your suggestion! Also, watching that tutorial video made me a new fan of darkfox127. Ultimately, this is the method I used and it works perfectly... so well that I used it to create the next step for obtaining access to Razortooth Hall.

 

GrimyBunyip - Thank you for your suggestion. Even though I ended up using Kraeten's suggestion (just ended up more suitable for the situation), yours will come in very handy when I get further along in my mod.

 

I really appreciate the help you guys have provided. Thanks again!

Edited by sgf1974
Link to comment
Share on other sites

  • Recently Browsing   0 members

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