PCSkipEquip & OnPCEquip

Post » Tue Dec 29, 2009 3:57 pm

Yeah, so I have such a difficult task to overcome. I read Morrowind Scripting for Dummies either Sealed Treasure Script but I cannot figure out how to write something similar. I am trying to make two scripts:
Spoiler
begin dragonstaffscript

short PCSkipEquip
short OnPCEquip
short scrollState
short button
short wasActivated

if ( GetDisabled == 1 )
Return
endif

if ( scrollState == 0 )
;set up PCSkipEquip for first use
Set PCSkipEquip to 1
Set scrollState to 1
endif

if ( OnActivate == 1 )
Set wasActivated to 1
;handle activate method of reading books
endif

if ( wasActivated == 1 )

if ( scrollState == 1 )
Player->AddItem testowalaska 1
Set scrollState to 0
Set wasActivated to 0
Disable
Return
endif

;if ( scrollState == SOMETHING ELSE )
Activate

endif


if ( OnPCEquip == 0 )
Set button to -1
Return
endif

if ( scrollState == 1 )
MessageBox "DRAGONS STAFF" "EQUIP" "DESCRIPTION"
Set scrollState to 2
endif

if ( scrollState == 2 )
set button to GetButtonPressed
if ( button == 0 )
Set scrollState to 3
Set OnPCEquip to 0
Set PCSkipEquip to 0
player->Equip, dragonstaff
;unseal it and set global
elseif ( button == 1 )
Set scrollState to 1
Set PCSkipEquip to 1
Set OnPCEquip to 0
MessageBox "A long long time ago a mysterious red dragon burned in flames blah blah blah" "OK"
endif
Return
endif

if ( scrollState == 3 )
Set scrollState to 1
Set PCSkipEquip to 1
Return
endif

end


The second script is very similar (I also used Treasure Script as a example). I managed to prepare book relevant to Oghma Infinitum. Player will pick up the book and while being in MenuMode 'equpping' the book will show MessageBox with options [READ] [DON'T READ]. Don't read won't do anything. Read option should execute dialogue window after exiting the MenuMode. I stuck :(

Spoiler
begin Oghmascript

short PCSkipEquip
short OnPCEquip
short scrollState
short button
short wasActivated

if ( GetDisabled == 1 )
Return
endif

if ( scrollState == 0 )
;set up PCSkipEquip for first use
Set PCSkipEquip to 1
Set scrollState to 1
endif

if ( OnActivate == 1 )
Set wasActivated to 1
;handle activate method of reading books
endif

if ( wasActivated == 1 )

if ( scrollState == 1 )
Player->AddItem ohgmabook 1
Set scrollState to 0
Set wasActivated to 0
Disable
Return
endif

;if ( scrollState == SOMETHING ELSE )
Activate

endif


if ( OnPCEquip == 0 )
Set button to -1
Return
endif

if ( scrollState == 1 )
MessageBox "What do you want to do? "Read Oghma Infinitum" "Leave it alone"
Set scrollState to 2
endif

if ( scrollState == 2 )
set button to GetButtonPressed
if ( button == 0 )
; I DONT HAVE ANY IDEA WHAT SHOULD BE IN THIS PLACE TO EXECUTE DIALOGUE BOX AFTER LEAVING MENU
elseif ( button == 1 )
Set scrollState to 1
Set PCSkipEquip to 1
Set OnPCEquip to 0
endif
Return
endif

; REST OF CODE INCOMPLETED BECOUSE I GOT MAD

end

User avatar
rheanna bruining
 
Posts: 3415
Joined: Fri Dec 22, 2006 11:00 am

Post » Tue Dec 29, 2009 5:37 pm

Here's my take on it:

Begin somescriptshort OnPCEquipshort PCSkipEquipshort doonceshort buttonif ( doonce == 0 )	set PCSkipEquip to 1	set doonce to 1endifif ( OnPCEquip == 1 )	if ( doonce < 2 )		MessageBox, "Would you like to equip this item?", "Equip", "Info"		set button to -1		set OnPCEquip to 0		Return	endifelseif ( doonce == 2 )	set PCSkipEquip to 1	set doonce to 1endifif ( button == 0 )	Returnendifset button to GetButtonPressedif ( button == -1 )	Returnendifif ( button == 0 )	set doonce to 2	set PCSkipEquip to 0	"player"->Equip, "someitem"elseif ( button == 1 )	MessageBox, "Item info goes here.", "OK"endifset button to 0End


You're better off not calling GetDisabled on an inventory item, because in my experience Morrowind can get confused about the disabled status of objects that do not have a world reference (e.g. they are in inventory). If possible, use a different method.
User avatar
Connor Wing
 
Posts: 3465
Joined: Wed Jun 20, 2007 1:22 am

Post » Tue Dec 29, 2009 7:23 pm

It works correctly. I added short part responsible for picking up and everything seems to be well prepared.
User avatar
Jack Bryan
 
Posts: 3449
Joined: Wed May 16, 2007 2:31 am


Return to III - Morrowind