Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

General Script Questions #1


WillieSea
 Share

Recommended Posts

You can check the WIKI for any function you like to see how its used.

I always check the WIKI on commands that I use to make sure its being used right. Its a good practice to get into the habit of doing. :question:

For example, most math functions are used with the Set command.

Link to comment
Share on other sites

I'm trying to set up a little quest to get...something. Basically, in order to open the chest containing the item, the Player has to visit one wayshrine of each of the Nine Divines and then get to the chest with all nine spells still active. How might I script the chest to open only if the Player has all nine effects active?

Link to comment
Share on other sites

I don't think there is a command to detect active spell effects.

You would have to do something else, perhaps change the spell that when added, it adds an item to the players inventory that is invisible. Then when the effect ends, you remove the item.

Then you could use GetItemCount to see if the spells are active.

Link to comment
Share on other sites

I don't think there is a command to detect active spell effects.

You would have to do something else, perhaps change the spell that when added, it adds an item to the players inventory that is invisible. Then when the effect ends, you remove the item.

Then you could use GetItemCount to see if the spells are active.

What about IsSpellTarget?

Hmm...I could use a combination of these. I could have the Player pick up a book (Quest Object, so it can't be dropped) describing the item and give it a script that will add tokens to the Player using IsSpellTarget.

Or, could I use IsSpellTarget to check for multiple spells at once, like:


scn DivineChestScript


Begin OnActivate Player


If Player.IsSpellTarget SpellID1 && Player.IsSpellTarget SpellID2 && Player.IsSpellTarget SpellID3 && Player.IsSpellTarget SpellID4 && Player.IsSpellTarget SpellID5 && Player.IsSpellTarget SpellID6 && Player.IsSpellTarget SpellID7 && Player.IsSpellTarget SpellID8 && Player.IsSpellTarget SpellID9

  Activate

Else

  Messagebox "You must have the blessings of the Nine to open this chest."

Endif


End



Link to comment
Share on other sites

IsSpellTarget might work on its own. :trophy:

I never used that function and thought it was more of a 'on the spot' check, not an enchantment check.

On a side note, my in-laws travelled 500 miles to visit us, so I am rather busy with them (for the next week).

Link to comment
Share on other sites

Looking at your setup there, the PC will need to have all spells active at the same time, might be hard unless they have a very long duration.

Maybe if you increment a variable when the player recieves each spell?, You could check the value and if it's nine then open.

The wayshrine blessing do have a long duration, but that's not really an issue. Each Chapel has a large altar to get a blessing from, but also has eight smaller altars that can be used once the related wayshrine has been visited. The scripted chest will be located in the undercroft of just such a chapel, so having them all active once you get to the chest won't be a problem. I probably should have mentioned that earlier. :) In any case, I'll try the IsSpellTarget method when I get home.

Link to comment
Share on other sites

  • 2 weeks later...

I have a problem with a script of simple menu.

How it was intended to work: first, stage of a quest gets updated and if player is sitting, then one of ShowMessageSE03 variables (depending on which message should be shown) gets changed to 1. Menu poofs, player chooses one of two options, and then one of two activators (depending on which button was chosen) gets activated and everything proceeds as it was in default.

But in practice, regardless of which button I'll choose, the menu starts to show constantly, as if no button was chosen. Why? Does it have something to do with keeping both parts in GameMode block? I'll note that I've done similar thing a few times before with keeping the first part in OnActivate block and it was working perfectly.


	if ( ShowMessageSE03A == 1 )

		if ( CheckButtonSE03 == 0 )

			messagebox "Which button would you like to press?", "(Mania) Illusion of Giant Gnarl", "(Dementia) Huge wave of small Gnarls"

			set CheckButtonSE03 to 1

		endif

	elseif ( ShowMessageSE03B == 1 )

		if ( CheckButtonSE03 == 0 )

			messagebox "Which button would you like to press?", "(Mania) Drop huge amount of keys", "(Dementia) Activate fire trap"

			set CheckButtonSE03 to 1

		endif

	elseif ( ShowMessageSE03C == 1 )

		if ( CheckButtonSE03 == 0 )

			messagebox "Which button would you like to press?", "(Mania) Activate ghost illusion", "(Dementia) Raise undead to kill Grommok"

			set CheckButtonSE03 to 1

		endif

	endif


	if ( CheckButtonSE03 == 1 )

		set ButtonSE03 to getbuttonpressed

		if ( ButtonSE03 > -1 )

			if ( ButtonSE03 == 0 )

				if ( ShowMessageSE03A == 1 )

					SE03ManiaButton01ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03A to 2

				elseif ( ShowMessageSE03B == 1 )

					SE03ManiaButton02ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03B to 2

				elseif ( ShowMessageSE03C == 1 )

					SE03ManiaButton03ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03C to 2

				endif

			elseif ( ButtonSE03 == 1 )

				if ( ShowMessageSE03A == 1 )

					SE03DementiaButton01ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03A to 2

				elseif ( ShowMessageSE03B == 1 )

					SE03DementiaButton02ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03B to 2

				elseif ( ShowMessageSE03C == 1 )

					SE03DementiaButton03ActiveREF.activate player 1

					set CheckButtonSE03 to 0

					set ShowMessageSE03C to 2

				endif

			endif

		else

			set CheckButtonSE03 to 0

		endif

	endif

Link to comment
Share on other sites

Its hard to say without seeing more of the script.

One thing I never do in an IF/EndIf is mix variables in the same block. For example, you check:

if ( ShowMessageSE03A == 1 )
elseif ( ShowMessageSE03B == 1 )
elseif ( ShowMessageSE03C == 1 )[/code] It may not cause any problems, but it does make the script confusing. I will use an 'endif' between different variables and start another 'IF' instead of using an 'ElseIf'. When you are checking the button being greater than -1, you have an 'else' condition that instantly resets the variable used to get into the button checking back to 0, which stops it from checking the button press menu.
[code]if ( ButtonSE03 > -1 )
...
else
set CheckButtonSE03 to 0
endif
Since you are setting CheckButtonSE03 back to 0, it displays the message again.
if ( ShowMessageSE03A == 1 )
if ( CheckButtonSE03 == 0 )
messagebox ...[/code]

Link to comment
Share on other sites

Its hard to say without seeing more of the script.

This is the entire part dedicated for this purpose. I've just placed it in general quest script that does various things, and other parts have nothing to do with this one.

When you are checking the button being greater than -1, you have an 'else' condition that instantly resets the variable used to get into the button checking back to 0, which stops it from checking the button press menu.

Well, I've deleted the "Button > -1" thing and script suddenly started to work - thank you very much for help. :) Although I can't understand why it works this way. If Button variable is greater than -1, then "else" thing shouldn't be even executed. And this variable must be greater than -1, as shows the fact that the script works as intended without "Button > -1" thing. Do I'm missing something? :unsure:

Link to comment
Share on other sites

Remember, a GameMode block runs once per FPS cycle. So if you are getting 30 frames per second (FPS) then it runs 30 times in a second.

Remembering that, the value of Button will be -1 every FPS cycle 'until' you press a button. Since you cannot click on the button in the first FPS cycle, the 'else' condition was executed, setting the variable CheckButtonSE03 back to 0.

The solution is not removing the "Button > -1" line of code, its removing the 'else' condition that goes with it where the value is set to 0.

Link to comment
Share on other sites

  • 1 month later...

Hi, it's again me with a new question.

NPC has a script, which causes him to immediately receive specific armor with additional visual effects when starting combat - this is supposed to act like a spell, but isn't a spell at all. Now, I would like to allow player to dispel this "spell", but only if dispelling spell is strong enough. Is there a non-OBSE way to do that?

Link to comment
Share on other sites

Any spell 'cast' on the play can be dispelled by a strong enough dispell spell.

If you have a GameMode block on the armor, you can check if the 'getContainer' reference is currently 'IsInCombat' with anybody. And then play the visual effect of your choice on the container reference.

Link to comment
Share on other sites

  • 1 month later...

Kia Ora

At this point I'm not sure I can script to save myself but I'm having a go and need to ask will this work?



scn KHActivatorClawSwitch01


ref KHLightingEnergy01

ref KHLightingEnergy02

ref KHPortalActivatorRef

ref myParent

ref mySelf

float EffectTime01


short Busy

short DoOnce


begin OnActivate


	if (KHLightingEnergy01.GetDisabled == 0) && (KHLightingEnergy02.GetDisabled == 0)


			set EffectTime01 to 0

			set DoOnce to 0


	if Busy == 0

		playgroup forward 0

		set myParent to GetParentRef

		set mySelf to getSelf

		myparent.activate mySelf 1

		set Busy to 1

	endif


end


begin Gamemode


		 if  ( player.getitemcount KHDragonEgg01 <= 0 )

				messagebox " Seems to be somit missing "

					elseif  player.getitemcount KHDragonEgg01 >= 1

						set EffectTime01 to (EffectTime01 + GetSecondsPassed)

					if EffectTime01 >= 10

						KHLightingEnergy01.enable

							KHLightingEnergy02.enable

					if EffectTime01 >= 200

							KHPortalActivatorRef.enable

						set DoOnce to 1

					endif

				endif

			endif

		endif

	if IsAnimPlaying == 0

		set Busy to 0	

	endif

end


The idea is to check PC has got the item and then enable a power souce effect and slightly after anable an activator

Almost forgot to ask as well if I have some light sources (4 on each Parent Reference) linked to a disabled reference, when I enable

the reference will the 4 light sources enable also?

the code will anable an energy source eg:

KHLightingEnergy03.enable ; and the 4 linked light sources enable too

Thanks in advance

Edited by Kiwi-Hawk
Link to comment
Share on other sites

It will not work 'as-is'.

1. You are using 'reference' names that contain 'no' reference information.

You need to 'set' the reference name 'on' the object in the 'Render Window'. And remove the 'ref' variables from your script.

2. Yes, you can 'parent' child objects 'enable state' to one 'XMarker' object. Set the Xmarker to 'initially disabled' and all its children will also be disabled. Enable that Xmarker (after giving it a reference name and checking its 'Persistant Reference' check box) then all the children will enable with it.

MyXmarkerREF.enable
3. Your IF/ELSEIF/ENDIF structure is not complete. 4. Without knowing what objects you are using, I could not speak about using 'playgroup' or 'isanimPlaying' commands. 5. Your best bet is to try it out and report what does or does not work. Then we can help more. See my comment in the code below.
scn KHActivatorClawSwitch01 
ref myParent
ref mySelf
float EffectTime01

short Busy
short DoOnce

begin OnActivate
if (KHLightingEnergy01.GetDisabled == 0)
set EffectTime01 to 0
set DoOnce to 0
if Busy == 0
playgroup forward 0
set myParent to GetParentRef
set mySelf to getSelf
myparent.activate mySelf 1
set Busy to 1
endif
endif
end

begin Gamemode
;What condition do you want for 'when' the light turns on? Just being in the cell?
if ( player.getitemcount KHDragonEgg01 <= 0 )
messagebox " Seems to be somit missing "
else
set EffectTime01 to (EffectTime01 + GetSecondsPassed)
if EffectTime01 >= 10
KHLightingEnergy01.enable
KHLightingEnergy02.enable
if EffectTime01 >= 200
KHPortalActivatorRef.enable
set DoOnce to 1
endif
endif
endif

if IsAnimPlaying == 0
set Busy to 0
endif
end[/code]

Link to comment
Share on other sites

Kia Ora

First up thanks so much for all your help

if I step back a bit after the boss fight PC walks up some grand stairs and triggers a triggbox which sets of 4 energypower beams each with 5 light souces linked

in this script:



scn KHTriggerShrinePowerScr


short triggered

short next

short busy

short opened

float PowerTrig

ref KHLightingEnergy03Ref  ; KHLightingEnergy03

ref KHLightingEnergy04Ref  ; KHLightingEnergy04     

ref KHLightingEnergy05Ref  ; KHLightingEnergy05

ref KHLightingEnergy06Ref  ; KHLightingEnergy06  

ref target

ref mySelf



begin onTrigger player

       if triggered == 0   && next == 0             

        Messagebox "Ooops,.  I've activated some Power source by the looks"

       set triggered to 1 

    elseif triggered <= 1              

	if PowerTrig > 0

	set PowerTrig to (PowerTrig + getsecondspassed)

			if ( PowerTrig >= 10 ) && next == 1

				KHLightingEnergy05Ref.enable ; pluse light sources

				KHLightingEnergy06Ref.enable ; pluse light sources

			if ( PowerTrig >= 50 )

				KHLightingEnergy03Ref.enable ; pluse light sources

				KHLightingEnergy04Ref.enable ; pluse light sources 

;  Disabling these after time to save on frame hit

			if (KHPortalActivatorRef.enable == 1) && ( PowerTrig >=600 ) :not sure how mauch the time needs to be yet

				KHLightingEnergy03Ref.disable

				KHLightingEnergy04Ref.disable

				KHLightingEnergy05Ref.disable

				KHLightingEnergy06Ref.disable

			set next to 0

			endif

		endif

	endif

endif



	if busy == 1 && isAnimPlaying == 0

		set busy to 0

	endif

endif

end


the idea is when PC walks up the stairs the beams start to light up and after a length of time (or even better when the avctivator is enabled) they fade out then when PC pulls the Claw lever the above script should (edited to hopfuly help)


scn KHActivatorClawSwitch01


ref KHLightingEnergy01Ref   ; KHLightingEnergy01

ref KHLightingEnergy02Ref   ; KHLightingEnergy02

ref KHPortalActivatorRef        ; KHPortalActivator

ref myParent

ref mySelf

float EffectTime01


short Busy

short DoOnce


begin OnActivate


	if (KHLightingEnergy01Ref.GetDisabled == 0) && (KHLightingEnergy02Ref.GetDisabled == 0)


			set EffectTime01 to 0

			set DoOnce to 0


	if Busy == 0

		playgroup forward 0

		set myParent to GetParentRef

		set mySelf to getSelf

		myparent.activate mySelf 1

		set Busy to 1

	endif


end


begin Gamemode


		 if  ( player.getitemcount KHDragonEgg01 <= 0 )

				messagebox " Seems to be somit missing "

					elseif  player.getitemcount KHDragonEgg01 >= 1

						set EffectTime01 to (EffectTime01 + GetSecondsPassed)

					if EffectTime01 >= 10

						KHLightingEnergy01Ref.enable            ; and attached light beam

							KHLightingEnergy02Ref.enable    ; and attached light beam

					if EffectTime01 >= 200

							KHPortalActivatorRef.enable

 ;  I have no idea how to disable LighteningEnergy 1 & 2 and leave the 2 beams working and not sure it to much of a hit Frame wise with just 2 till PC leaves cell

						set DoOnce to 1

					endif

				endif

			endif

		endif

	if IsAnimPlaying == 0

		set Busy to 0	

	endif

end


I put the item name after the comment, I stil have the ref because I couldn't get a save using the real name, I got invalid ref error

the end result needs to be the KHPortalActivator enabled so the when PC activates it theres some portal doors stuff enabled and PC is moved to an xmaker

outside.

theres about 4 scripts in the wee mini end game thing I sort of working backwards cause these seem easyer than the others.

In general the idea is PC kills boss get the head is moved to a point where PC need activate (to enable) 4 shards that enable 4 stones and a staff on activating the staff

it checks PC has the 4 stones then moves PC to another point where PC takes out 2 guards and activates a wall switch that enables a door, opens a secret invisable wall

and another guard after the fight PC can then use the door bringing PC out at lower level giveing entry to an area where PC has the BOSS Boss fight and walks up stairs to

actvate the scripts I'm doing here,.. sorry if I'm long winded but I thought it might help if you had an idea what I'm trying to do

Link to comment
Share on other sites

A 'Reference ID Name' is NOT an 'Editor ID Name'. That is why you are getting an error.

Double-click on the object in the 'Render Window'. Its 'reference properties' window will open. In the 'Reference' text box, type in your reference name. This object and this object alone will now have that reference name. NEVER start a reference name with a numberic character.

Dinner time, I will check back later if you have other issues...

Link to comment
Share on other sites

Kia Ora

this script pulled me up on the message box when I had most of it under ingamemod, seems it was working even tho I had't triggered the

switch,.. I'm gonna try it like this BTW the item name is normaly the same as the reference name without the Ref on end when I make stuff

that way I can remember whats what



scn KHActivatorClawSwitch01


ref myParent

ref mySelf

float EffectTime01


short Busy

short DoOnce


begin OnActivate



	if (KHLightingEnergy01Ref.GetDisabled == 0) && (KHLightingEnergy02Ref.GetDisabled == 0)

		set EffectTime01 to 0

		set DoOnce to 0

		 if  ( player.getitemcount KHDragonEgg01 <= 0 )

			messagebox " Seems to be somit missing "

			elseif  player.getitemcount KHDragonEgg01 >= 1

				set EffectTime01 to (EffectTime01 + GetSecondsPassed)

					if EffectTime01 >= 60

						KHLightingEnergy01Ref.enable

						KHLightingEnergy02Ref.enable

					if EffectTime01 >= 180

						KHPortalActivatorRef.enable

						set DoOnce to 1

					endif

				endif

			endif

		endif

	if Busy == 0

		playgroup forward 0

		set myParent to GetParentRef

		set mySelf to getSelf

		myparent.activate mySelf 1

		set Busy to 1

	endif


end


begin Gamemode



	if IsAnimPlaying == 0

		set Busy to 0	

	endif

end

Link to comment
Share on other sites

Kia Ora

Nothing happens at all with script above and it seems I got this wrong too


Scn KHMovetoMarker


Short DoOnce


Begin OnAdd Player 

    If DoOnce == 1

        Return

    ElseIf Player.GetItemCount LandDreughHeadTrophy > 0

        Player.MoveTo KHRockTopRef

        Set DoOnce to 1

    EndIf

End


I have to drop the head to move

Link to comment
Share on other sites

You should take my scripting classes, they might help you.

For the first script, 'KHActivatorClawSwitch01', I had 're-wrote' it to fix the 'IF/ENDIF' errors you have.

You were getting the message in the GameMode block because you had no condition for it 'not' to display. (see the comment in the script I had rewrote for you)

What is the script 'ON' and what is the script 'PARENTED' to?

The second script, your code:

Set DoOnce to 1

Will never execute. Put it before the 'player.moveTo' command. When you use MoveTo on the player, it exits the script and will not process it any further.

Link to comment
Share on other sites

Kia Ora

Sorry I missed that coment (rushing to much)

I just need the Energy beams on and that Activator to enable and stay on if theres to be a frame hit I could disable the Beams but probley not needed as

the activator will enable stuff and move the player out of that cell

the script is on a Claw switch (OBClawWallSwitch01) and parented to nothing, it's just to enable on activattion a a spellshrine activator, those Lighteningenergy (SE08TowerEnergy01) that are Parent for 2 light beams (FXLightBeam01)

Edited by Kiwi-Hawk
Link to comment
Share on other sites

1. First script: If its not parented to anything, then you don't need the parentage code:

                set myParent to GetParentRef 
set mySelf to getSelf
myparent.activate mySelf 1 [/code]

If its not doing anything when you activate the switch, then check these conditions:

a) KHLightingEnergy01Ref must be ENABLED.

b) KHLightingEnergy02Ref must be ENABLED.

c) If the player has a KHDragonEgg01 then you get a message, otherwise after an hour, the lights should enable. Two hours later the portal should enable. Resting or sleeping will NOT advance time in the script.

I think what you want is the lights to be 'disabled' at start, not 'enabled'. Change the == 0 to == 1.

2. Second script: Make the change I noted in the previous post and see if it works.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...