Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting for Silgrad Tower.
10-11-2006, 03:51 PM,
#1
Scripting for Silgrad Tower.
Scripting for Silgrad Tower.

ABLE OF CONTENTS



  1. A buyable house including all the necessary scripts
  2. A small quest. The PC has to retrieve 1 or more objects for the quest giver
  3. How to create a "room for rent"?
  4. Scripted conversation.

Questions.
Technical info concerning interiors.
Dum loquor, hora fugit  - While I speak the time flies



Ovid 43 BC - 17 AD
10-11-2006, 06:46 PM,
#2
RE: Scripting and quests for Reich Parkeep and Steadhelm.
Second topic.

A small quest. The PC has to retrieve 1 or more objects for the quest giver. In return the PC will be rewarded.

I assume you know how to create a quest and add dialogue.
Dialogue.


----[/HR]
QuestName == StSrBooktoFindQuest
IDBook == The object name of the book, this has to be retrieved.
NPC "x" == Quest giver, your NPC

----------------------------

Scriptname StSrBooktoFindScript
short BookToFind


; Runs on the Quest
; Script type == Quest
; Add the script to the quest (screenshots)
; If the PC has to find one book, this script can be skipped
----------------------------

Go to the quest stage tab (in your quest window). Go to the index field and right-click. Create a new stage. Go to the log entry(top one) and right-click and select new. Add the text in the log entry (left of the result script listing). Look at the screenshot.


Quest stages.

10
I found a special book (or two special books) and I should talk to NPC "X" or whatever hint.

20
I spoke to NPC "X". If I find the book (or books), I'll receive a reward or whatever you like.

30
I brought the book (or books) to NPC "X" and received a nice reward.
Add in the Result Script listing: StopQuest StSrBooktoFindQuest.


100 NPC "X" is dead, I can't complete the quest
Add in the Result Script listing: StopQuest StSrBooktoFindQuest.


---------------------


Scriptname StSrBookScript

begin OnAdd Player

if ( StSrBooktoFindQuest.BookToFind < 1 )
set StSrBooktoFindQuest.BookToFind to (StSrBooktoFindQuest.BookToFind + 1 )
endif

if ( GetStage StSrBooktoFindQuest < 10 ) && ( StSrBooktoFindQuest.BookToFind == 2 )
setstage StSrBooktoFindQuest 10
endif

end


; Script type == Object
; Attached to the book
; For two books

or >>>>>>>>>>>>>>>>>>>For 1 item!

Scriptname StSrBookScript

begin OnAdd Player

if ( GetStage StSrBooktoFindQuest < 10 )
setstage StSrBooktoFindQuest 10
endif

end



; Script type == Object
; Attached to the book

---------------------



begin OnDeath


if ( GetStage StSrBooktoFindQuest >= 10 ) && ( GetStage StSrBooktoFindQuest < 30 )
setstage StSrBooktoFindQuest 100
endif

end


; Attached to the NPC "X"
; Script type == Object
---------------------

Go to the topics tab in your quest window.

In editor ID listing, add a greeting.

Add the topic (for example book) to the greeting.

Topic Book.

Add the info.
"Can you find my IDBook?"

In the result script listing add (below the response details):
setstage StSrBooktoFindQuest 20

In the conditions listing add:
GetIsID for NPC "X"
GetStage StSrBooktoFindQuest < 10
---------------------

Add another info.
"Great, you have the book (or books)!"

In the result listing script add:
setstage StSrBooktoFindQuest 30
player.removeitem IDBook 1 or 2
player.additem Gold001 50


In the conditions listing add:
GetIsID for NPC "X"
GetStage StSrBooktoFindQuest >= 10
GetItemCount IDBook == 1 (Run on target selected) or == 2 for two books!!

----[/HR]


Poster has attached these images (downsized versions):
[Image: tn_attachment-5418.jpg] [Image: tn_attachment-5419.jpg] [Image: tn_attachment-5420.jpg]


Quest script___________ Quest script added_________ Quest stages
Dum loquor, hora fugit  - While I speak the time flies



Ovid 43 BC - 17 AD
06-16-2007, 11:15 AM,
#3
RE: Scripting and quests for Reich Parkeep and Steadhelm.
Third topic.

Room rental script, how to create a "room for rent"?

I'll use Steadhelm08 as an example.


blue[/HR]

You have to change the red and blue parts in the script.
Blue == reference editor ID i.e. StSrShc08StenRef (S).
S == Screenshot.

Order.

1 First you have to assign a reference editor ID to the door and the bed including ownership (S).
2 Then start with the script and attach it to the NPC.
3 Finally the dialogue ("rent" is defined in the script).

Concerning 3.

You have to add dialogue.
Alter the dialogue via the quest window.

You need a Greeting, a Bed Rental topic with two info's one for when the room is free and the other for when the room is rented. Further you need a Yes and No topic (the latter two are choices).

The two choices will be added to the info (Bed Rental topic) that will be displayed when the room isn't rented.

The Yes choice removes the gold and sets the room to rented via the result script when the player has enough gold.
The second info (Yes choice) will be displayed when the PC doesn't have enough gold.


The "GetScriptVariable" function through the function info [Reference: "StSrShc08StenRef", rent] determines if the room is free or rented (S).
Rent == 0 ---> free.
Rent == 1 ---> rented.


Room topic.

Look at the screenshot and you'll see the StSrShc08Bed topic.
Add this topic to the GREETING.

Add the Yes and No topic as a choice, to the info that will be displayed when the room isn't rented (S).


No topic. (Standard for a merch publican, you don't have to create this topic)

If you want to have a custom made answer create a new topic and always start with your modding ID.


Yes topic.

One info will be displayed when the player has enough gold.
Through the "GetItemCount" function it's checked if there's enough gold. Select "run on target" (S).

In the result script listing (S),
player.removeitem Gold001 25
set StSrShc08StenRef.rent to 1


The second info will be displayed when the player doesn't have enough gold (S). Through the "GetItemCount" function it's checked if there's not enough gold. Select "run on target" (S).


The bed and yes topic have to start with your modding ID.



blue[/HR]

This script works for a room that isn't in the same cell as well.
The script (object type) is attached to the NPC (Inn owner).
The rentdoor and bed are owned by the NPC, make sure persistent reference is selected. Make sure the NPC uses a different bed (assign one) if he/she has to sleep in the same cell otherwise the NPC could use the "rent" bed.


To copy the script: Select it and select copy.
Go to the script editor (CS) and select new. Press CTRL and V together.


Green[/HR]

Scriptname StSrShc08TheRustyGuarRoomRental

short rent
short rentday
short rentmonth
short cleanupRR
short setup

begin gamemode


if ( rent == 1 )

if ( setup == 0 )
set rentday to GameDay
set rentmonth to GameMonth
set setup to 1
StSrShc08RentDoor.unlock
StSrShc08RentBed.SetOwnership

else

if ( GameDay != rentday )
set cleanupRR to 1
elseif ( GameMonth != rentmonth )
set cleanupRR to 1
endif
endif

if ( Player.GetinCell Steadhelm08Basement == 0 )
if ( CleanupRR == 1 )
set CleanupRR to 2
endif
endif


if ( CleanupRR == 2 )

set rent to 0
set setup to 0
set rentday to 0
set cleanupRR to 0
set rentmonth to 0
StSrShc08RentDoor.SetOpenState 0
StSrShc08RentDoor.lock 30
StSrShc08RentBed.SetOwnership StSrShc08Sten

endif
endif

end


Poster has attached these images (downsized versions):
[Image: tn_attachment-8909.jpg] [Image: tn_attachment-10599.jpg] [Image: tn_attachment-10600.jpg] [Image: tn_attachment-10601.jpg] [Image: tn_attachment-10602.jpg]
Dum loquor, hora fugit  - While I speak the time flies



Ovid 43 BC - 17 AD
11-22-2007, 03:29 PM,
#4
RE: Scripting and quests for Reich Parkeep and Steadhelm.
Fourth topic.

Scripted Conversation.


Use the ST esm v2.78 or higher.
I refer to the "StSrTheaterQ" quest and the "StSrTheater2" cell.

How to proceed.

  1. Create the quest.
  2. Create a topic in this case the "StSTheaterSpeech" for the "Conversation tab".
  3. Add the info's (max 1 response per info) including the applicable functions (in the correct order).
  4. Create the quest script.
  5. Add the result script (counter, target, speaker update) and the counter condition to the conditions listing for every info.
  6. Add the "talk when time" script to the NPC's.
    [/list=1]

    Concerning 2.

    Because we're using a script you don't need to select "run immediately" and you don't need to use the "link from/ to" listing.


    Concerning 3.

    The correct order: Add the info's from the top to the bottom.
    The first info has to be spoken first (top of the list), the second info as second etc.


    Concerning 4.

    Code:
    Scriptname StSrTheaterQuest

    ;Tracking which info has to be spoken
    short STconvCount

    ; used by conversation scripts to tell whose turn to speak
    short STTspeaker
    short STTtarget

    ; 1 = Clavidis
    ; 2 = Anara
    ; 3 = Ullis
    ; 4 = Zolassa
    ; 5 = Ulfgard

    ; used to time space between conversation items
    float convTimer


    ;Tracking if the play started
    short PlayStart


    begin gamemode

    ; count down timer
        if convTimer > 0
            set convTimer to convTimer - getSecondsPassed
        endif


        If gamehour >= 10 && gamehour <= 11 && playstart == 0
                setstage StSrTheaterQ 10
                set playstart to 1
        endif

        If gamehour >= 14 && gamehour <= 15 && playstart == 1
                set playstart to 0
        endif

    end
    The "STconvCount" defines the order of the spoken info's.
    Meaning: "0" is the first info, "1" is the second info etc.
    This counter is updated in the "result script" of the info.

    The "convTimer" is set to the duration of the info spoken by the NPC in question. This is set in the "talk when time" script ("SayTo" function) attached to the NPC that said the last info.

    The quest script decreases the "convTimer" through the "- getSecondsPassed" function.

    As long as the "convTimer" is greater than zero the next speaker can't say the next info. This is defined in the "talk when time" script attached to the NPC's.

    STTspeaker defines the next speaker and STTtarget the target (the speaker will look at the target, as defined in the "SayTo" function).


    Quote:From the CS Wiki

    SayTo TargetActor, TopicID, ForceSubtitleFlag (optional)

    Example:

    SayTo Joe SecretTopic
    SayTo player SecretTopic 1

    Use the function to have an NPC speak a single dialogue item to the player or another NPC. The speaking NPC will head track or turn towards the target, if his current package allows it, but will not wait to close the distance (so you will want to make sure to call this at an appropriate speaking distance).


    Returns the time in seconds that the NPC will take to finish speaking, which can be useful for timing followups in scripts.


    If ForceSubtitleFlag = 1, the subtitles will be displayed regardless of distance between the speaker and the player.
    Conversation topics don't have subtitles (exception rumors; INFOGENERAL topic).


    Quote:From the CS Wiki

    Syntax:

    Say TopicID [ForceSubtitleFlag] [SpeakerID] [UnknownFlag]

    Use the function to have an NPC speak a single dialogue item on the specified topic.


    Examples:

    Say SecretTopic

    Say DAMolagBalSpeech 1 DAMolagBalVoice 1


    Notes:

    * The NPC will lip-synch but will not otherwise interrupt his current package.

    * "Say" returns the time in seconds that the NPC will take to finish speaking, which can be useful for timing followups in scripts.

    * If ForceSubtitleFlag = 1, the subtitles will be displayed regardless of distance between the speaker and the player.

    * With the optional "SpeakerID" it's possible to make a creature, an activator or another Object say something. The ID needs to be a NPC which will be used to determine race and gender of the voice-file to be used. For this, the NPC doesn't need to be placed in the world.

    * "UnknownFlag" is set to 1 in all daedra-shrine scripts, it is recommended to set it to 1 whenever you use the SpeakerID.

    * Calling this function on a Creature, or anything other than an NPC, may crash the game unless a SpeakerID is provided.


    Concerning 5.

    Look at the screenshots.

    The first info has a condition that requires the "STconvCount" to be "0" hence it's the first info that will be spoken.
    The second info has a condition that requires the "STconvCount" to be "1" hence it's the second info that will be spoken.

    The info will be spoken ("talk when time" script) when the "STconvCount" has the correct value.

    In the result script of the info the next target and speaker are defined.
    The counter is incremented by "1" as well --> Allowing the next info to be spoken as long as the "convTimer" is zero ("talk when time" script).


    Concerning 6.

    Code:
    scn StSrTheaterUlfgardScript

    short STTtarget                

    begin gamemode

    ; talk when it is time

    if StSrTheaterQ.STTspeaker == 1 && StSrTheaterQ.convTimer <= 0
        set STTtarget to StSrTheaterQ.STTtarget; As long as the timer is greater than zero the NPC can't speak.

        if STTtarget == 0
            set StSrTheaterQ.convTimer to Say StSrTheaterSpeech 1
        elseif STTtarget == 1
            set StSrTheaterQ.convTimer to SayTo StSrTheaterClavidesRef, StSrTheaterSpeech 1
        elseif STTtarget == 2
            set StSrTheaterQ.convTimer to SayTo StSrTheaterAnaraRef, StSrTheaterSpeech 1
        elseif STTtarget == 3
            set StSrTheaterQ.convTimer to SayTo StSrTheaterUllisRef, StSrTheaterSpeech 1
        elseif STTtarget == 4
            set StSrTheaterQ.convTimer to SayTo StSrTheaterZolassaRef, StSrTheaterSpeech 1
        elseif STTtarget == 5
            set StSrTheaterQ.convTimer to SayTo StSrTheaterUlfgardRef, StSrTheaterSpeech 1
        endif    
    endif


    end
    Make sure the NPC has the correct reference editor ID in this case "StSrTheaterUlfgardRef" (screenshot).

    We defined "5" to be Ulfgard (StSrTheaterQuest script).

    The script checks the target and speaker and when these have the correct value, the NPC will speak to the correct target ("SayTo/ Say" function). The NPC will say the info when the "STconvCount" has the correct value (see above).

    The script sets the "convTimer" to the length of the spoken info.
    The next speaker (defined in the result script of the spoken info) has to wait until the "convTimer" is zero (StSrTheaterQuest script).


    Remarks.

    Because Ulfgard says the first info, the "STTtarget" in the result script of the quest stage 10 has to be set to "5".

    Because Ulfgard says the second info as well, the "STTtarget" in the result cript of the first info has to be set to "0".

    Poster has attached these images (downsized versions):
    [Image: tn_attachment-10587.jpg] [Image: tn_attachment-10588.jpg] [Image: tn_attachment-10589.jpg] [Image: tn_attachment-10590.jpg] [Image: tn_attachment-10598.jpg]
Dum loquor, hora fugit  - While I speak the time flies



Ovid 43 BC - 17 AD


Forum Jump:


Users browsing this thread: 1 Guest(s)