Scripting tutorials?

Post » Sun Jan 24, 2010 7:04 pm

Hello again. :)

Can anyone please link me to some scripting tutorials for Morrowind non GOTY?

I really want to learn how to script more, I finished the tutorial in Morrowind Scripting for Dummies fairly fast, and I liked it!

I really just want to learn more! It would be great if you can post any links you know thank you all in advance!
User avatar
Bones47
 
Posts: 3399
Joined: Fri Nov 09, 2007 11:15 pm

Post » Sun Jan 24, 2010 4:12 pm

http://www.morrowind-mod.com/Modders%20Resources%20Tutorials.htm is a large list of all sorts of tutorial, not just link to scripting.

In my experience, i learnt more about scripting by:

1. writing down what i want to happen, and comparing that to lists of scripting commands available.
2. Thinking about where the thing i want is already ingame, so i can just look at their scripts and copy them or modify as i need [this is a tactic i still use today. I keep a library of scripts, names according to purpose, that i can quickly modify if and when i need it; even though i could write these scripts from scratch, i can still save effort]. This also works for other people's mods. I cant think of any modder who wouldnt be glad that other people are learning off their work and investingating scripts they have written.


I'd like to think i can do pretty much anything these days with scripts (except MWSE stuff which ive never investigated) and i only ever used the in-CS commands list, the Scripting for Dummies (which is great) and months of effort investigating existing scripts and cannabalising them as i need them. Its not really something that can be learnt instantly in one tutorial because you have to learn how to think in script format ^_^ so you outline Cause's and Effects.

Imho, if youve absorbed the basics from Scripting for Dummies, then just jump in and start writing things you need for a mod. If it doesnt work, post it here and one of us can probably help you. Ive noticed that a bunch of new eager-to-learn modders are asking lots of questions which is really great ^_^
User avatar
Jamie Lee
 
Posts: 3415
Joined: Sun Jun 17, 2007 9:15 am

Post » Sun Jan 24, 2010 2:58 pm

Thank you very much I will look into that link right away!

And I do in fact have a dialog scripting question.

I want my companion that I am making to:

  • Set acompanion to 0
  • AiWander 0 0 0 0 0 0 0 0 0 0 0 0
  • teleport to a location (The location I want her to go to is inside Arrile's Tradehouse)


So I have to questions:

  • How do I set where she would teleport to when this dialog comes up?
  • How should I order this to work properly.


As of right now she stops following you and starts wandering.
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Sun Jan 24, 2010 4:57 pm

Alright I don't want to make yet another thread so can someone please help me with this, I have a problem with my script. I have been working on fixing this for about an hour and I found that I really need help with it!


Alright nvm I fixed everything up to this point, and trust me there was a LOT of scripting involved. ;)

I will edit this post if I come across another problem.
User avatar
NAtIVe GOddess
 
Posts: 3348
Joined: Tue Aug 15, 2006 6:46 am

Post » Sun Jan 24, 2010 3:24 pm

New problem!

Alright so I have a problem now.

My companion will do the infinit ForceGreeding thing, even though I set it as a DoOnce. here is the script.


(Script further down.)
User avatar
SEXY QUEEN
 
Posts: 3417
Joined: Mon Aug 13, 2007 7:54 pm

Post » Mon Jan 25, 2010 4:32 am

New problem!

Alright so I have a problem now.

My companion will do the infinit ForceGreeding thing, even though I set it as a DoOnce. here is the script.


Begin Tii_Guar_Companion_Script

short acompanion == 0
short DoOnce;
short doonce == 0
short GettingSupplies == 0
short objectcount
short state == 0
float timer == 0

Set objectcount to ( GetItemCount, "chitin arrow" )

if ( DoOnce == 0 )
AddTopic "Who is Hircine?"
AddTopic "Why are you a hunter?"
AddTopic "That is a very nice amulet."
AddTopic "Shall we hunt?"
set DoOnce to 1
endif

if ( acompanion = 1 )
AddTopic "Supplies"
endif

if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )
if ( objectcount < 25 )
Set GettingSupplies to 1
; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.
endif

if ( GettingSupplies == 1 )
if ( DoOnce == 1 )
if (GetDistance, "player" <= 200 )
forcegreeting
endif
Set DoOnce to 2
endif
Set GettingSupplies to 2
endif

if ( GettingSupplies == 2 )
if ( state == 0 )
AiTravel, -258, -139, 129
Set state to 20
endif

if ( state == 20 )
if ( GetAIPackageDone == 1 )
Set state to 30
endif
endif
;checks to see if Tii Guar has been set to getting supplies mode and if so, she will tell you what she is doing then
;travel up to the counter.

if ( state == 30 )
Set timer to ( timer + GetSecondsPassed )
AIWander, 0, 0, 0
;checks to see if Tii Guar has made it to the counter and if so starts the timer and makes her stand still.
endif
endif

if ( timer >= 15.0 )
Set GettingSupplies to 3
endif

if ( GettingSupplies == 3 )
if ( DoOnce == 2 )
if (GetDistance, "player" <= 200 )
forcegreeting
endif
Set DoOnce to 1
endif
Set acompanion to 1
Set state to 0
Set GettingSupplies to 1
endif

;checks to see if the timer has been running for 15 seconds, and if so will force greet the player with dialog
;"Recieved Supplies" and then begins following the player again. Then resets the script for future use.

endif
;ends checking for the correct cell.
End

When typing long scripts like that you should put them in a code box. In the post box, where the smiley is, there is a button that looks like "<>". Click on it and paste your code in between the words. Very helpful =p
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Sun Jan 24, 2010 4:15 pm

Alright I did that but can anyone help me :( I haven't gotten any help with the scripts I have put up in this thread.

Begin Tii_Guar_Companion_Scriptshort objectcount == 0short DoOnce;short acompanion == 0short GettingSupplies == 0short state == 0float timer == 0		Set objectcount to ( GetItemCount, "chitin arrow" )		if ( DoOnce == 0 )			AddTopic "Who is Hircine?"			AddTopic "Why are you a hunter?"			AddTopic "That is a very nice amulet."			AddTopic "Shall we hunt?"			set DoOnce to 1		endif		if ( acompanion = 1 )			AddTopic "Supplies"		endif		if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )		if ( objectcount < 25 )			Set GettingSupplies to 1		; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.		endif		if ( GettingSupplies == 1 )		if ( DoOnce == 1 )		if (GetDistance, "player" <= 200 )   			forcegreeting		endif			Set DoOnce to 2		endif			Set GettingSupplies to 2		endif		if ( GettingSupplies == 2 )		if ( state == 0 )			AiTravel, -258, -139, 129			Set state to 20		endif		if ( state == 20 )		if ( GetAIPackageDone == 1 )			Set timer to ( timer + GetSecondsPassed )			AIWander, 0, 0, 0			;checks to see if Tii Guar has made it to the counter and if so starts the timer and makes her stand still.		endif		endif		endif		endif			;checks to see if Tii Guar has been set to getting supplies mode and if so, she will tell you what she is doing then			;travel up to the counter.		if ( timer >= 15.0 )			Set GettingSupplies to 3		endif		if ( GettingSupplies == 3 )		if ( DoOnce == 2 )		if (GetDistance, "player" <= 200 )   			forcegreeting		endif			Set DoOnce to 1		endif			Set acompanion to 1			Set state to 0			Set GettingSupplies to 0		endif			;checks to see if the timer has been running for 15 seconds, and if so will force greet the player with dialog			;"Recieved Supplies" and then begins following the player again. Then resets the script for future use.		endif		;ends checking for the correct cell.End

User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Sun Jan 24, 2010 1:25 pm

Alright I did that but can anyone help me :( I haven't gotten any help with the scripts I have put up in this thread.

Begin Tii_Guar_Companion_Scriptdeleted to save roomEnd




First, what is the problem? The infinite forcegreeding thing you mentioned? I don't really know what that means :( is it in MWSFD?
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm

Post » Sun Jan 24, 2010 1:18 pm

No this is my own mod I am not following any tutorials, I am looking up functions as necessary though. :)


Well the problem with ForceGreeting is that you need to make it a DoOnce part of the script otherwise it will come up with a dialog box that just keeps on saying the same greeting over and over, you can't close the dialog box because the command is being continuesly said so it just reopens.

It works perfectly fine with the first ForceGreeting, but the second one doesn't work at all. With the script I posted last a greeting doesn't even come up anymore.

The first ForceGreeting that works:

if ( GettingSupplies == 1 )		if ( DoOnce == 1 )		if (GetDistance, "player" <= 200 )   			forcegreeting		endif			Set DoOnce to 2		endif			Set GettingSupplies to 2		endif


And the second one that doesn't

		if ( GettingSupplies == 3 )		if ( DoOnce == 2 )		if (GetDistance, "player" <= 200 )   			forcegreeting		endif			Set DoOnce to 1		endif			Set acompanion to 1			Set state to 0			Set GettingSupplies to 0		endif

I don't see why the second one wouldn't work :(

PS: there is a function in between these that sets GettingSupplies to 3 so that isn't the problem.
User avatar
Taylah Haines
 
Posts: 3439
Joined: Tue Feb 13, 2007 3:10 am

Post » Sun Jan 24, 2010 5:27 pm

You don't need any other tutorial, plenty of info to digest in MSFD. Start learning how variables are declared, how values to variables are assigned, how control structures work. Use MWEdit to indent your code and to check your syntax error, it catches much more than TESCS.

[EDIT]untested, I'd try reorganizing the script alittle, something like this
Begin Tii_Guar_Companion_Scriptshort objectcount ; == 0short DoOnceshort acompanion ; == 0short state ; == 0float timer ; == 0if ( DoOnce == 0 )	AddTopic "Who is Hircine?"	AddTopic "Why are you a hunter?"	AddTopic "That is a very nice amulet."	AddTopic "Shall we hunt?"	set DoOnce to 1endifif ( acompanion == 1 )	if ( DoOnce == 1 )		AddTopic "Supplies"		set DoOnce to 2	endifendifif ( state == 0 )	if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )		Set objectcount to ( GetItemCount, "chitin arrow" )		if ( objectcount < 25 )			Set state to 1			; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.		endif	endif	returnelseif ( state == 1 )	if ( GetDistance, "player" <= 200 )		Set state to 2		forcegreeting	endif	returnelseif ( state == 2 )	if ( MenuMode )		return   ; wait to be out of dialog	endif			AiTravel, -258, -139, 129	set state to 3	returnelseif ( state == 3 )	if ( GetAIPackageDone == 1 )		AIWander, 0, 0, 0		;checks to see if Tii Guar has made it to the counter and if so starts the timer and makes her stand still.		set state to 4	endif	returnelseif ( state == 4 )	if ( timer < 15 )		Set timer to ( timer + GetSecondsPassed )		return	endif	set timer to 0	Set state to 5	returnelseif ( state == 5 )	if ( GetDistance, "player" <= 200 )		set state to 6		forcegreeting	endifendifEnd

User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am

Post » Sun Jan 24, 2010 7:06 pm

:( I am a bit passed that sorry! I wasn't getting help here with the script so I was getting help VIA PM

I still have some problems though.


My problem is that it looks to me like the timer isn't setting! Here is my script.

Begin Tii_Guar_Companion_Scriptshort "objectcount" == 0short DoOnce;short "acompanion" == 0short "GettingSupplies" == 0short "speed" == 0short "hello" == 0float "timer" == 0		set "speed" to ( Player->GetSpeed + 50 )		Set objectcount to ( GetItemCount, "chitin arrow" )		if ( timer == 15.0 )			Set "acompanion" to 1			Set "GettingSupplies" to 3			Set "timer" to 0		endif		if ( DoOnce == 0 )			AddTopic "Who is Hircine?"			AddTopic "Why are you a hunter?"			AddTopic "That is a very nice amulet."			AddTopic "Shall we hunt?"			set DoOnce to 1		endif		if ( "acompanion" = 1 )			AddTopic "Supplies"			AiFollow Player 0 0 0 0 0		endif		if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )		if ( "objectcount" < 25 )			Set GettingSupplies to 1		; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.		endif		if ( "GettingSupplies" == 1 )		if ( DoOnce == 1 )		if ( GetDistance, "player" <= 200 )   			forcegreeting		endif			Set "DoOnce" to 2		endif			Set "GettingSupplies" to 2		if ( "hello" == 1 )			Set "hello" to 0		endif		endif			; DIALOG RESULTS BOX FOR THE FIRST FORCEGREETING SAYS:			;Set "acompanion" to 0			;"aa shaddow_Tii Guar"-> AiTravel, -324, -64, 387, 0			;if ( GetAIPackageDone == 1 )			;Set "timer" to ( "timer" + GetSecondsPassed )			;endif			;Goodbye		if ( "GettingSupplies" == 3 )		if ( "hello" == 0 )		if ( GetDistance, "player" <= 200 )   			forcegreeting		endif			Set "hello" to 1		endif			Set "DoOnce" to 1			Set "GettingSupplies" to 0		endif			; Resets the script for future use.		endif		;ends checking for the correct cell.End

User avatar
Naomi Lastname
 
Posts: 3390
Joined: Mon Sep 25, 2006 9:21 am

Post » Sun Jan 24, 2010 7:47 pm

Unfortunately, you can't initialize variables in MWScript. In theory, they should all start with the value 0.

You also can't quote variables. I'm not sure how much that will break, but it won't work, at all. They become keywords of a sort once declared (IDs get quoted, variables do not).

Fixing those two will certainly help improve your script. Not sure if it will instafix it, but you may get useful errors afterwards.
User avatar
Ray
 
Posts: 3472
Joined: Tue Aug 07, 2007 10:17 am

Post » Mon Jan 25, 2010 5:26 am

Alright so I changed the scrip[t as you said, but nothing has changed in game.

Begin Tii_Guar_Companion_Scriptshort objectcount == 0short DoOnce == 0short acompanion == 0short GettingSupplies == 0short speed == 0short hello == 0float timer == 0		set speed to ( Player->GetSpeed + 50 )		Set objectcount to ( GetItemCount, "chitin arrow" )		if ( timer == 15.0 )			Set acompanion to 1			Set GettingSupplies to 3			Set timer to 0		endif		if ( DoOnce == 0 )			AddTopic "Who is Hircine?"			AddTopic "Why are you a hunter?"			AddTopic "That is a very nice amulet."			AddTopic "Shall we hunt?"			set DoOnce to 1		endif		if ( acompanion = 1 )			AddTopic "Supplies"			AiFollow Player 0 0 0 0 0		endif		if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )		if ( objectcount < 25 )			Set GettingSupplies to 1		; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.		endif		if ( GettingSupplies == 1 )		if ( DoOnce == 1 )		if ( GetDistance, player <= 200 )   			forcegreeting		endif			Set DoOnce to 2		endif			Set GettingSupplies to 2		if ( hello == 1 )			Set hello to 0		endif		endif			; DIALOG RESULTS BOX FOR THE FIRST FORCEGREETING SAYS:			;Set acompanion to 0			;"aa shaddow_Tii Guar"-> AiTravel, -324, -64, 387, 0			;if ( GetAIPackageDone == 1 )			;Set timer to ( timer + GetSecondsPassed )			;endif			;Goodbye		if ( GettingSupplies == 3 )		if ( hello == 0 )		if ( GetDistance, "player" <= 200 )   			forcegreeting		endif			Set hello to 1		endif			Set DoOnce to 1			Set GettingSupplies to 0		endif			; Resets the script for future use.		endif		;ends checking for the correct cell.End


It still looks like it doesn't set the timer in the Dialog.. Does the script look like it should work?
User avatar
Lilit Ager
 
Posts: 3444
Joined: Thu Nov 23, 2006 9:06 pm

Post » Sun Jan 24, 2010 4:15 pm

Perhaps using GetSecondsPassed in dialogue is problematic?

You could try using this line instead in the dialogue window:

set timerOn to 1


And putting this section at the top of the script:

short timerOnif ( timerOn == 1 )	set timer to ( timer + GetSecondsPassed )endif


You may also need to include the line:

set timerOn to 0


After the line "Set timer to 0".
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Sun Jan 24, 2010 11:30 pm

It sounds like a great idea so I did it and started with a script I had used before, this is what my problem is now :( So many I know...

My NPC Tii Guar will not move!! She is being set to my companion I know that because when I attack her she says "I'm on tyour side" and doesn't fight back, but when I attack her the fith time she makes battle cries and such but just stands there... the other NPCs attack me but she just stands there going "You will die where you stand!" and such.

So because of this I cannot do testing until it is fixed...

Begin Tii_Guar_Companion_Scriptshort objectcount == 0short DoOnce;short acompanion == 0short GettingSupplies == 0short timerOn == 0float timer == 0                Set objectcount to ( GetItemCount, "chitin arrow" )                if ( DoOnce == 0 )                        AddTopic "Who is Hircine?"                        AddTopic "Why are you a hunter?"                        AddTopic "That is a very nice amulet."                        AddTopic "Shall we hunt?"                        set DoOnce to 1                endif                if ( acompanion = 1 )				AddTopic "Supplies"				AiFollow Player 0 0 0 0 0			else				AiWander 0 0 0 0 0 0 0 0 0 0 0 0               endif			if ( timerOn == 1 )				Set timer to ( timer + GetSecondsPassed )				Set acompanion to 0			endif                if ( timer = 15.0 )				Set GettingSupplies to 3				Set timer to 0				Set timerOn to 0                endif                if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )                if ( objectcount < 25 )                        Set GettingSupplies to 1                ; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.                endif                if ( GettingSupplies == 1 )                if ( DoOnce == 1 )                if (GetDistance, "player" <= 200 )                        forcegreeting                endif                        Set DoOnce to 2                endif                        Set GettingSupplies to 2                endif                if ( GettingSupplies == 3 )                if ( DoOnce == 2 )                if (GetDistance, "player" <= 200 )                        forcegreeting                endif                        Set DoOnce to 1                endif                        Set acompanion to 1                        Set GettingSupplies to 0                endif                        ;checks to see if the timer has been running for 15 seconds, and if so will force greet the player with dialog                        ;"Recieved Supplies" and then begins following the player again. Then resets the script for future use.                endif                ;ends checking for the correct cell.End


And the only code that would have been used in dialog is this:

Set acompanion to 1


When she says she will follow me.
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Sun Jan 24, 2010 7:23 pm

You're still initializing the variables, which may be breaking things (why it isn't failing to compile, I'm not sure).

begin "Tii_Guar_Companion_Script"short objectcount ; <- pk - Nothing comes after the name (putting var x = y is initializing, which you cant do in MWScript)short DoOnce;short acompanion ; The special variable for companions is Companion (I think), not sure if you want that oneshort GettingSuppliesshort timerOnfloat timerSet objectcount to ( GetItemCount, "chitin arrow" )if ( DoOnce == 0 )    AddTopic "Who is Hircine?"    AddTopic "Why are you a hunter?"    AddTopic "That is a very nice amulet."    AddTopic "Shall we hunt?"    set DoOnce to 1endifif ( acompanion = 1 )    AddTopic "Supplies"    AiFollow "player" 0 0 0 0 0 ; pk - Quote and proper-case your IDs!else    AiWander 0 0 0 0 0 0 0 0 0 0 0 0endifif ( timerOn == 1 )    Set timer to ( timer + GetSecondsPassed )    Set acompanion to 0endif;if ( timer = 15.0 ) ; <- pk - This will never work. a) = is not the operator you want. B) a float is highly unlikely to ever == something.if ( timer > 15.0 )    Set GettingSupplies to 3    Set timer to 0    Set timerOn to 0endifif ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 ) ; pk - Using a function in an if like this is sketchy. It may work, or it may not.    if ( objectcount < 25 )        Set GettingSupplies to 1        ; sees how many chitin arrows Tii Guar currently has in her inventory and if it is less then 25 starts the GettingSupplies block.    endif    if ( GettingSupplies == 1 )        if ( DoOnce == 1 )            ; pk - Now, Im not sure on this part. How you had it set up, it checks for the distance once, if that fails cancels the whole thing with no greeting. This tweak will make it check until it greets, then stop. This may not be what you want.            if (GetDistance, "player" <= 200 )                Set DoOnce to 2                ForceGreeting            endif        endif        Set GettingSupplies to 2    endif    if ( GettingSupplies == 3 )        if ( DoOnce == 2 )            ; pk - Same change as the previous ForceGreeting            if (GetDistance, "player" <= 200 )                Set DoOnce to 1                ForceGreeting            endif        endif        Set acompanion to 1        Set GettingSupplies to 0    endif    ;checks to see if the timer has been running for 15 seconds, and if so will force greet the player with dialog    ;"Recieved Supplies" and then begins following the player again. Then resets the script for future use.endif;ends checking for the correct cell.end "Tii_Guar_Companion_Script"


That may (or may not) work better, but there were definitely a few bugs in it. I tried to comment what the issue was and fix it in the code. :)

Edit: Frakking single quotes. Removed them from my comments (syntax highlighting in exchange for grammar. meh).
User avatar
Setal Vara
 
Posts: 3390
Joined: Thu Nov 16, 2006 1:24 pm

Post » Sun Jan 24, 2010 1:48 pm

Thank you very much!! It looks a lot cleaner and I am sure it will work better but I still have the same problem. It sets Tii Guar to follow me.. but she doesn't move... what is the problem here do you know?
User avatar
K J S
 
Posts: 3326
Joined: Thu Apr 05, 2007 11:50 am

Post » Mon Jan 25, 2010 12:58 am

timerOn is never set to 1, therefore acompanion remains at 1, therefore the NPC is being set to follow every frame, which may be the problem.

if ( acompanion = 1 )    AddTopic "Supplies"    AiFollow "player" 0 0 0 0 0    set timerOn to 1 ; Im not sure if this is where you want it but I think you need this line somewhereelseif ( GetCurrentAIPackage != 0 ) ; I put this here so the next line isnt executed every frame    AiWander 0 0 0 0 0 0 0 0 0 0 0 0endifif ( timerOn == 1 )    Set timer to ( timer + GetSecondsPassed )    Set acompanion to 0endif

User avatar
Adriana Lenzo
 
Posts: 3446
Joined: Tue Apr 03, 2007 1:32 am

Post » Mon Jan 25, 2010 5:29 am

Actually timerOn is being set to 1 via dialog.

In the first forcegreeting I have this in the results box.

AiTravel, -324, -64, 387, 0Set timerOn to 1Goodbye

User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm

Post » Mon Jan 25, 2010 4:53 am

Actually timerOn is being set to 1 via dialog.

In the first forcegreeting I have this in the results box.

AiTravel, -324, -64, 387, 0Set timerOn to 1Goodbye


I've never tried to do that, but I think that unless it's a global variable that won't work, and i'm not sure if it would even if it was a global variable. If it doesn't work i suggest using a script part in the above script to set it to 1, and see if that works. Because if you just use the dialogue resultbox, i don't think it know's which script to put the timeon to 1 in.
i.e. I have over twenty scritps in my mod using "DoOnce" so it wouldn't make sense to put
Set DoOnce to 1
Goodbye
In the result box, because it could apply to anyone. Just some food for thought, I'm not really sure though.
User avatar
Sudah mati ini Keparat
 
Posts: 3605
Joined: Mon Jul 23, 2007 6:14 pm

Post » Sun Jan 24, 2010 4:25 pm

That makes a lot of sense :) Thank you!

Alright so I basically re wrote the entire script, much cleaner and I think it will work great! But.... well I guess it doesn't work great :) The problem is that setting my NPC to:

AIFollow Player 0, 0, 0, 0

Doesn't work right... I try it on other NPCs and it works fine, they start walking around following me but Tii Guar just doesn't.... I mean she clearly starts following me because she turns toward me wherever I go and I can hit her without causing a fight but she doesn't walk at all. Anybody have a though? Here is my new and improved script.

Spoiler
begin "Tii_Guar_Companion_Script";Variables.short topics ;used to add all necessary topics at the right times to Tii Guar.short acompanion ;used for setting AI to follow player.short timerOn ; used for setting the timer (used in relation to timer).short objectCount ;used for checking how many arrows Tii Guar has.short supplies ;used for the feature of resupplying Tii Guars inventory.short greeting ;used for checking distance for force greet.short repair ;used for reparing Tii Guar's equipment.float timer ;used for timing an event for resupplying.;set variables.set topics to 0;skip acompanion because we don't want it to continuesly be set to 0.set timerOn to 0set timer to 0set objectCount to ( GetItemCount, "chitin arrow" ) ;sets objectCount to the amount of arrows Tii Guar has in her inventory.set supplies to -1set greeting to 0set repair to 0;control all topicsif ( topics == 0 ) ;topics added the moment you talk to Tii Guar	AddTopic "Why are you in Seyda Neen?"	AddTopic "Why do you trade at Arrille's Tradehouse?"	AddTopic "Why are you a hunter?"	AddTopic "That is a very nice amulet."	AddTopic "Who is Hircine?"	AddTopic "Supplies"	set topics to 1endif;controls setting Tii Guar as a companion.if ( acompanion == 1 )	"aa shaddow_Tii Guar"-> AIFollow Player 0, 0, 0, 0 ;sets Tii Guar to Follow player.	set supplies to 0elseif ( acompanion == 0 )	"aa shaddow_Tii Guar"-> AIWander, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0endif;control timerOn settingsif ( timerOn == 1 )	set timer to ( timer + GetSecondsPassed )	"aa shaddow_Tii Guar"-> AIWander, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0endif;control timerif ( timer > 15.0 )	set supplies to 4	set timer to 0	set timerOn to 0endif;control resupplying (for use with objectCount, timer, timerOn, acompanion, and greeting)if ( supplies == 0 )	if ( objectCount < 25 ) ;if Tii Guar has less then 25 chitin arrows.		if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 )			set supplies to 1		endif ;only ends checking cell.	endif ;only ends checking objectCount.elseif ( supplies == 1 )	if ( greeting == 0 )		if ( GetDistance, Player <= 200 )			ForceGreeting			set greeting to 1			set supplies to 2 ;after the greeting is forced moves to the next step. CHECK IF ERROR ACCURS.		endif ;only ends checking distance and setting greeting.	endif ;only ends checking greeting.elseif ( supplies == 2 )	set acompanion to 0	setHello 0 ;makes Tii Guar not initiate voice dialog wile the walking.	"aa shaddow_Tii Guar"-> AITravel, -324, -64, 387 ;makes Tii Guar start heading up stairs.	set supplies to 3elseif ( supplies == 3 )	if ( GetAIPackageDone == 1 ) ;if Tii Guar has made it to her destination.		set timerOn to 1	else		Return	endifelseif ( supplies == 4 )	if ( greeting == 1 )		set acompanion to 1		if ( GetDistance, Player <= 200 )			ForceGreeting			set greeting to 0			set supplies to 5 ;after the greeting is forced moves to the next step. CHECK IF ERROR ACCURS.		endif ;only ends checking distance and setting greeting.	endif ;only ends checking greeting.elseif ( supplies == 5 )	;this is where set repair to 1 will be.	set supplies to 6 ;change to 0 when repair feature is implemented.endifend

User avatar
lydia nekongo
 
Posts: 3403
Joined: Wed Jul 19, 2006 1:04 pm

Post » Mon Jan 25, 2010 2:58 am

I could be totally wrong but I think the problem may be similar to what I described earlier.

"acompanion" remains 1 for some time, so the AIFollow command is executed every frame during that period.

if ( acompanion == 1 )        if ( GetCurrentAIPackage != 3 ) ; Consider something like this                "aa shaddow_Tii Guar"-> AIFollow Player 0, 0, 0, 0 ;sets Tii Guar to Follow player.        endif


GetCurrentAIPackage returns the following:
None -1
Wander 0
Travel 1
Escort 2
Follow 3
Activate 4
Pursue 5
User avatar
Pawel Platek
 
Posts: 3489
Joined: Sat May 26, 2007 2:08 pm

Post » Sun Jan 24, 2010 8:24 pm

Sweet! Thank you she is following me properly now!!

Alright I'll work on my script a bit and post if I have any problems!
User avatar
Zosia Cetnar
 
Posts: 3476
Joined: Thu Aug 03, 2006 6:35 am

Post » Sun Jan 24, 2010 2:58 pm

Glad I could help :)
User avatar
Auguste Bartholdi
 
Posts: 3521
Joined: Tue Jun 13, 2006 11:20 am

Post » Sun Jan 24, 2010 8:35 pm

Alright now :) This looks like the very last bug in the whole script for this feature!! :celebrate:

So the only problem is that ForceGreeting the second time it is being used doesn't work.

Here is the main script:

Spoiler
begin "Tii_Guar_Companion_Script";Variables.short topics ;used to add all necessary topics at the right times to Tii Guar.short acompanion ;used for setting AI to follow player.short objectCount ;used for checking how many arrows Tii Guar has.short supplies ;used for the feature of resupplying Tii Guars inventory.short greeting ;used for checking distance for force greet.short repair ;used for reparing Tii Guar's equipment.'float timer ;used for timing an event for resupplying.;set variables.set objectCount to ( GetItemCount, "chitin arrow" ) ;sets objectCount to the amount of arrows Tii Guar has in her inventory.;control all topicsif ( topics == 0 ) ;topics added the moment you talk to Tii Guar	AddTopic "Why are you in Seyda Neen?"	AddTopic "Why do you trade at Arrille's Tradehouse?"	AddTopic "Why are you a hunter?"	AddTopic "That is a very nice amulet."	AddTopic "Who is Hircine?"	AddTopic "Supplies"	set topics to 1endif;controls setting Tii Guar as a companion.if ( acompanion == 1 )	if ( GetCurrentAIPackage != 3 ) ;if Tii Guar isn't already following the player.		if ( GetCurrentAIPackage != 1 ) ;if Tii Guar isn't already Traveling upstairs.			"aa shaddow_Tii Guar"-> AIFollow Player 0, 0, 0, 0 ;sets Tii Guar to Follow player.		endif	endifelseif ( acompanion == 0 )	if ( GetCurrentAIPackage != 0 ) ;if Tii Guar isn't already Wandering.		if ( GetCurrentAIPackage != 1 ) ;if Tii Guar isn't already Traveling upstairs.			"aa shaddow_Tii Guar"-> AIWander, 0, 0, 0, 0, 30, 0, 40, 40, 30, 10, 0, 0		endif	endifendif;control timerif ( timer >= 15.0 )	if ( GetCurrentAIPackage != 1 ) ;if Tii Guar has made it to her destination.		setHello 30 ;sets Tii Guar back to being able to initiate dialogue		set supplies to 3		set acompanion to 1		set timer to 0	else		set timer to ( timer + GetSecondsPassed )	endifendif;control resupplying (for use with objectCount, timer, timerOn, acompanion, and greeting)if ( GetPCCell "Seyda Neen, Arrille's Tradehouse" == 1 ) ;makes sure Tii Guar and the player are in the right cell.if ( supplies == 0 )	if ( objectCount < 25 ) ;if Tii Guar has less then 25 chitin arrows.		if ( acompanion == 1 )			set supplies to 1		else			Return		endif ;only ends checking if Tii Guar is your companion.	endif ;only ends checking objectCount.elseif ( supplies == 1 )	if ( GetDistance, Player <= 200 )		if ( greeting == 0 )			ForceGreeting			set acompanion to 0			set supplies to 2 ;after the greeting is forced moves to the next step.		endif ;only ends checking distance and setting greeting.	endif ;only ends checking greeting.elseif ( supplies == 2 )	if ( GetCurrentAIPackage != 3 ) ;if Tii Guar isn't already following the player.		if (GetCurrentAIPackage != 1 ) ;if Tii Guar isn't already Traveling upstairs.			setHello 0 ;makes Tii Guar not initiate voice dialogue wile the walking.			"aa shaddow_Tii Guar"-> AITravel, -324, -64, 387 ;makes Tii Guar start heading up stairs.			set timer to ( timer + GetSecondsPassed ) ;sets proper variables and sets supplies to 3.		endif		endif	endifelseif ( supplies == 3 )	if ( GetDistance, Player <= 200 )			if ( greeting == 1 )			ForceGreeting			;this is where set repair to 1 will be.			set supplies to 5 ;change to 0 when repair feature is implemented.		endif	endifendif ;ends the whole block.endif ;ends checking it Tii Guar and the player are in the right cell.end


Here is the code in the Results page for the first ForceGreeting:

Spoiler
"aa shaddow_Tii Guar"-> set greeting to 1Goodbye


And here is the code set in the second ForceDialog:

Spoiler
"aa shaddow_Tii Guar"-> set greeting to 0Player -> AddItem Gold_001, 23


So let me explain my problem in more detail, the second ForceGreeting may not be working, but if I manually talk to the NPC I get the proper dialog then if I close out and open it back up that dialog is gone just as it is supposed to run, the only problem is that when she is set to acompanion and therefor set to follow you, I want her to walk up to you then once she is close enough initiate the second ForceGreet.

Any help on this would be most appreciated! Thank you all so far!

EDIT~~~~~~~~~

Added a second apostrophe so it looks like Tii Guar's equipment.'

:) The whole code was green so I put that in there...
User avatar
Stace
 
Posts: 3455
Joined: Sun Jun 18, 2006 2:52 pm

Next

Return to III - Morrowind