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 #2


WillieSea
 Share

Recommended Posts

Did you ask the AN guys about setweather? I would think setweather would be the way to go, realizing that there will be a transition time. You might even need to detect if the player is using AN, and if so, you select one of their weathers. Now the detection of AN being present makes your mod dependent on OBSE, but that's the way I would be inclined to go.

I would just use SetWeather and accept the transition time in any event. It would be less jarring. I'd also have a look at vanilla scripts and see what they do when a gate is closed because really, that's what you're doing. Sorry I haven't read the previous posts, so I don't know what you've done so far.

Edit: I just took a quick look at the vanilla scripts and I don't understand why you are messing with the weather at all... :shrug:

Edited by AndalayBay
Link to comment
Share on other sites

Did you ask the AN guys about setweather? I would think setweather would be the way to go, realizing that there will be a transition time. You might even need to detect if the player is using AN, and if so, you select one of their weathers. Now the detection of AN being present makes your mod dependent on OBSE, but that's the way I would be inclined to go.

I sent WrinklyNinja a PM and he's looking into it. I'd really like to avoid making this dependent on OBSE if possible, mainly because some people don't use it and I want this to have as wide an appeal as possible. Look at Midas Magic: 300+ spell that do unique and interesting things with no OBSE requirements.

I would just use SetWeather and accept the transition time in any event. It would be less jarring. I'd also have a look at vanilla scripts and see what they do when a gate is closed because really, that's what you're doing. Sorry I haven't read the previous posts, so I don't know what you've done so far.

I've tried using SetWeather, but it has absolutely no effect. Once I close a gate with the spell, the Oblivion weather keeps playing until I restart my game. ForceWeather is the only weather command that works. As for looking at the vanilla scripts

Edit: I just took a quick look at the vanilla scripts and I don't understand why you are messing with the weather at all... :shrug:

Because when I close an Oblivion Gate with this spell, the Tamriel weather gets stuck on OblivionStormTamriel until I restart the game. SetWeather has absolutely no effect: I've tried standing there for ten minutes (real time), I've tried using the wait function, fast traveling, etc. but the weather refuses to change until I restart the game. ForceWeather is the only thing that seems to cause it to change.

I've been looking through the vanilla scripts myself and I think this spell may be interfering with the part of the gate script that deals with the weather. I'm going to try using ReleaseWeatherOverride followed by SetWeather and see what happens.

Edit: Yes! Finally, it works! :woohoo: Thanks for all your help guys!

Edited by The Vyper
Link to comment
Share on other sites

  • 2 months later...

Hmmmaar.... this is probably one of those "your forgetting THIS, silly" moments, but I am pretty stuck on this.

I've created a few training packages for an NPC including melee, hand to hand and magic all against a target. I've made them all useitemat packages with a directional xmarker facing a target, all with an item in their possesion (or there lack of for handtohand) and mostly its fine. They find the xmarker and stand in the right place at the right time, but in the magic package, he just stands there. I've told him to cast a particular spell in his inventory and to cast general target spells. I've set the count to 0, 1, and 100. Made the location the target dummy and the xmarker. But still he just stands there. What am I doing wrong? The location is a room with one other NPC in but this hasn't disrupted other packages.

Any help would be great guys! Thanks,

Mysterious Mr. Bear :D :D

Link to comment
Share on other sites

Hey, Mysterious Mr. Bear. Isn't that package already used in Vanilla? The mages in the Arcane University and various others already shoot magic at targets; have you tried looking at how they did it?

Anyway, I have a question about whether something is possible or not. I thought it'd be kinda neat to add these staves that you stick in the ground, pour poison into, and then have the staves explode, spewing the poison as an area effect bomb. I've nowhere near the expertise to actually build the things at the moment. I'd just like to know if it's possible. I'm pretty sure that most of it is, but how can I get the staff to recognize the poison's effects?

As a work around, I suppose I could use individual items so I can control what effects go into it ("spirits of napalm" will do fire damage, or whatever), but it'd be even cooler if I could get them to recognize any poison.

Link to comment
Share on other sites

Hmmmaar.... this is probably one of those "your forgetting THIS, silly" moments, but I am pretty stuck on this.

I've created a few training packages for an NPC including melee, hand to hand and magic all against a target. I've made them all useitemat packages with a directional xmarker facing a target, all with an item in their possesion (or there lack of for handtohand) and mostly its fine. They find the xmarker and stand in the right place at the right time, but in the magic package, he just stands there. I've told him to cast a particular spell in his inventory and to cast general target spells. I've set the count to 0, 1, and 100. Made the location the target dummy and the xmarker. But still he just stands there. What am I doing wrong? The location is a room with one other NPC in but this hasn't disrupted other packages.

Any help would be great guys! Thanks,

Mysterious Mr. Bear :D :D

Did you get this sorted? If not, I can tell you how to set up the package. Ironically the count is not the number of times they will cast the spell, it's the maximum level of the spell. So it's usually set to 100. They will keep casting for the duration of the package.

Link to comment
Share on other sites

hey guys, thanks for replying,

Yeah I forgot to mention, I tried copying it piece by peice from the uinivercity mages... and it didn't work with any count :S I guess I'll try removing all NPCs from the room, and trying it with count 100 (Thanks Andaley, thats pretty weird... should have figured it wasn't what it said it was, this IS the cs we're talking about :P) but with a clean save....

One of those weird things I guess!

UmtheMuse, what about relaying it through a weapon? I.E, you poison a dummy weapon given to you, then when you activate the stave it adds the poison from the weapon to the stave. This requires some functions that I don't know if they exist or not (like getting the poison in a Array and then adding the poison via another function) and furthermore, the only way I can see you adding AOE damage is through casting a range spell with an activator from above (though I dont know if you have another way) and it sounds hard to convert poison effects to AOE spells.... maybe instead, use enchantments? It sounds like a really awsome idea :) Im sure you could pull off your Plan B idea no sweat, but it would indeed be awsome to let the player choose the enchantments :P Good luck!

Link to comment
Share on other sites

You also need to link the heading marker to the target. That tells the NPC exactly what you want him to fire the spell at. Same for archery practice, or your NPC might face the wrong direction and fire an arrow right in the back of another NPC's head. Yes, I have had that happen - it was hilarious!

So the X Target Data on the heading marker needs to refer to the practice dummy. Then the Location of the AI package is the heading marker. And the Target can be an Object ID for a specific spell or Object Type can be Spells: Range Target. You could also use Spells: School Destruction, but the NPC may select a touch spell, which looks pretty weird :D

Edited by AndalayBay
Link to comment
Share on other sites

Ooh, I didn't even think of having them wack the staff--I was thinking of it like a container. Alright, so does that help us retrieve the effect? That sounds like it would make a cleaner transition somehow, though I can't guess how.

Wait, I guess I could control the magnitude of the spell by just saying that it's limited by the staff's power (and value). IIrc, it should be easy to just look up the Nth spell effect.

Link to comment
Share on other sites

Blah, yet another problem!!!

I think I'm scripting too much...

I have a spell script that is now around 300 lines long... anybody know if theres a point where scripts just break? Because now after a few uses the spell stops working entirely on all saves until I shut down and reload...

EDIT:

Problem resloved by causing a second spell to be cast, continuing the script, but I would still be interested to know! :D

Edity edit:

It WASN'T script length! Silly me, it was a syntax error undetected by the scriptchecker that caused the script to fail (Im guessing). Fixed now, a very silly mistake :P

Mysterious Mr. Bear :D :D

Edited by Mysterious Mr. Bear
Link to comment
Share on other sites

  • 2 weeks later...

First time on these forums, so here's a big "Hey Everybody!" to (you guessed it!) EVERYBODY. It's great to be joining the Oblivion modding scene! :jellytime:

I've gone through some of the scripting classes, and so far so good. I'm picking up on a lot of caveats to using TES script though. Add to that the fact that I'm coming over from working with real programming languages. Compared to those (C++ and VB.NET) TES script appears to have some really odd conventions. Has anyone put together any refences or started any discussions that would help experienced coders transition over? Well, moderately experienced programmers anyway :D I know how to write code, and I can pick up a new syntax easily enough, but I have a feeling the "gotchas" are gonna be a nightmare!

Thanks in advance, and happy coding!

Edited by DeadHerring
Link to comment
Share on other sites

I am a programmer by trade as well. I learned how to use the script by looking at existing scripts in the game, or seeing something in the game I liked and back-engineered it to figure out how it was done.

I also use the wiki that lists all the commands and functions and just peruse through them to see what 'can' be done with the limited language (thats why its called script and not coding :rofl: )

Link to comment
Share on other sites

I am a programmer by trade as well. I learned how to use the script by looking at existing scripts in the game, or seeing something in the game I liked and back-engineered it to figure out how it was done.

I also use the wiki that lists all the commands and functions and just peruse through them to see what 'can' be done with the limited language (thats why its called script and not coding :rofl: )

I was hoping there was a less frustration-prone way to get a leg up on TES scripting, but fair enough. I would have had to do what you're talking about sooner or later anyway :). Just to clarify, I'm not a programmer by trade...yet. Still need a couple of years before I can claim that. I've just been programming for a long time. :D

Edited by DeadHerring
Link to comment
Share on other sites

  • 4 weeks later...

I'm trying to re-script the AREnclosedCircle activator used in the Ayleid ruin of Vahtacen. What I want to do is place one of these in a cell that can be alternately opened & closed when a linked switch is pressed. The default script is:


scriptName MG10GiantColumnSCRIPT


short trigger

short opened

ref switch

ref myself


;Section for each spell effect

;Proper spell updates the Opened var and plays the appropriate animation

;improper spell updates trigger var - handled below in gamemode section


begin onMagicEffectHit FIDG


	if ( GetStage MG10Vahtacen >= 40 )

		return

	endif



	if ( opened == 0 )

		switch.playgroup forward 1

		set opened to 1

		return

	else

		switch.playgroup fastforward 20

		set trigger to 1

	endif

End


begin OnMagicEffectHit FRDG


	if ( GetStage MG10Vahtacen >= 40 )

		return

	endif


	if ( opened == 1 )

		switch.playgroup backward 1

		set opened to 2

		return

	else

		switch.playgroup fastforward 20

		set trigger to 1

	endif

End



Begin OnMagicEffectHit DGSP


	if ( GetStage MG10Vahtacen >= 40 )

		return

	endif


	if ( opened == 2 )

		switch.playgroup left 1

		set opened to 3

		return	

	else

		switch.playgroup fastforward 20

		set trigger to 1

	endif

End


Begin OnMagicEffectHit FOSP


	if ( GetStage MG10Vahtacen >= 40 )

		return

	endif


	if ( opened == 3 )

		switch.playgroup right 1

		set opened to 4

		SetStage MG10Vahtacen 40

		MG10PillarJumpProofingRef.Disable

		return

	else

		switch.playgroup fastforward 20

		set trigger to 1

	endif

end


Begin OnMagicEffectHit


	if ( GetStage MG10Vahtacen >= 40 )

		return

	endif


	if ( opened < 4 )

	switch.playgroup fastforward 20

	set trigger to 1

endif


End


;If improper spell is casted above, trigger var is set to 1

;this section activates the four "Evil Stones" every time trigger == 1


Begin Gamemode


if ( trigger == 1 )

	set myself to GetSelf

	MG10EvilStone01Ref.Activate myself 1

	MG10EvilStone02Ref.Activate myself 1

	MG10EvilStone03Ref.Activate myself 1

	MG10EvilStone04Ref.Activate myself 1

	set opened to 0

	set trigger to 0

endif


End


What changes do I need to make to achieve the desired result?

Link to comment
Share on other sites

Offt thats a complicated script vyper :S

Tried to look through it but I don't have much time atm... if you could set a "hasopened" variable to 1 when the activator is opened, and then find where the activator closes and move it into a new block that runs in the same way as the open block, but when "has opened == 1", that should work. Just finding out which piece is which, I guess :)

A very basic question I have myself for anyone with a bit of experience- if I attach a script to a container to reduce a variable by 2 every hour, will that script run even when I am not in the same area? Or do I need to handle this with quests?

Thanks,

Mysterious Mr. Bear :D :D

Link to comment
Share on other sites

Offt thats a complicated script vyper :S

A complicated script for a complicated .nif. :lol: That thing has five sets of animations attached to it.

Tried to look through it but I don't have much time atm... if you could set a "hasopened" variable to 1 when the activator is opened, and then find where the activator closes and move it into a new block that runs in the same way as the open block, but when "hasopened == 1", that should work. Just finding out which piece is which, I guess :)

I was sort of thinking along those lines. I could set HasOpened as a short and set it to 1 once the fourth opening animation has played, then set the closing animation to play if HasOpened == 1. Thanks.

I like to have extra sets of eyes when trying to script something complicated. :D

A very basic question I have myself for anyone with a bit of experience- if I attach a script to a container to reduce a variable by 2 every hour, will that script run even when I am not in the same area? Or do I need to handle this with quests?

Thanks,

Mysterious Mr. Bear :D :D

Could you use an OnActivate block that checks the time of day (GameHour) when the chest is activated, multiplies that by 2, then reduces the variable by the result?

Link to comment
Share on other sites

  • 2 weeks later...

I'm having a bit of trouble with a triggerzone. I've set up five spell firing activators and five spell targets. What I want to happen is:

1. Player enters triggerzone.

2. Triggerzone immediately causes all activators to fire at their respective targets.

3. One second later, the triggerzone resets.

4. Repeat 1-3 for as long as the Player remains within the triggerzone.

The first script I tried was:


scn APSBalaseli02TrigZoneScript


short triggered

Short SpellRank

Short Shoosting

float timer



begin onTrigger player


	if triggered == 0

		set triggered to 1

          Set Shoosting to 1

		set timer to 1

	endif


end


begin gameMode


     if player.GetLevel <= 5

		set SpellRank to 1

	elseif ( player.GetLevel >= 6 ) && ( player.GetLevel <= 10 )

		set SpellRank to 2

	elseif ( player.GetLevel >= 11 ) && ( player.GetLevel <= 15 )

		set SpellRank to 3

	elseif ( player.GetLevel >= 16 ) && (player.GetLevel <= 20)

		set SpellRank to 4

	elseif ( player.GetLevel >= 21 )

		set SpellRank to 5

	endif


     if timer <= 1 && Shoosting == 1 && SpellRank > 0

       If SpellRank == 1          

        APSB02Y01.Cast StandardShockDamageTarget1Novice APSB02Y01Target

        APSB02Y02.Cast StandardShockDamageTarget1Novice APSB02Y02Target

        APSB02Y03.Cast StandardShockDamageTarget1Novice APSB02Y03Target

        APSB02X01.Cast StandardShockDamageTarget1Novice APSB02X01Target

        APSB02X02.Cast StandardShockDamageTarget1Novice APSB02Y02Target

       ElseIf Spellrank == 2          

        APSB02Y01.Cast StandardShockDamageTarget2Apprentice APSB02Y01Target

        APSB02Y02.Cast StandardShockDamageTarget2Apprentice APSB02Y02Target

        APSB02Y03.Cast StandardShockDamageTarget2Apprentice APSB02Y03Target

        APSB02X01.Cast StandardShockDamageTarget2Apprentice APSB02X01Target

        APSB02X02.Cast StandardShockDamageTarget2Apprentice APSB02Y02Target

       ElseIf Spellrank == 3          

        APSB02Y01.Cast StandardShockDamageTarget3Journeyman APSB02Y01Target

        APSB02Y02.Cast StandardShockDamageTarget3Journeyman APSB02Y02Target

        APSB02Y03.Cast StandardShockDamageTarget3Journeyman APSB02Y03Target

        APSB02X01.Cast StandardShockDamageTarget3Journeyman APSB02X01Target

        APSB02X02.Cast StandardShockDamageTarget3Journeyman APSB02Y02Target

       ElseIf Spellrank == 4          

        APSB02Y01.Cast StandardShockDamageTarget4Expert APSB02Y01Target

        APSB02Y02.Cast StandardShockDamageTarget4Expert APSB02Y02Target

        APSB02Y03.Cast StandardShockDamageTarget4Expert APSB02Y03Target

        APSB02X01.Cast StandardShockDamageTarget4Expert APSB02X01Target

        APSB02X02.Cast StandardShockDamageTarget4Expert APSB02Y02Target 

       ElseIf Spellrank == 5          

        APSB02Y01.Cast StandardShockDamageTarget5Master APSB02Y01Target

        APSB02Y02.Cast StandardShockDamageTarget5Master APSB02Y02Target

        APSB02Y03.Cast StandardShockDamageTarget5Master APSB02Y03Target

        APSB02X01.Cast StandardShockDamageTarget5Master APSB02X01Target

        APSB02X02.Cast StandardShockDamageTarget5Master APSB02Y02Target 

        Endif

     Endif


	if triggered == 1 && timer <= 0

		set triggered to 0

          Set Shoosting to 0

	endif


	if timer >= 0

		set timer to timer - getSecondsPassed

	endif


end

^That made the activators fire once per frame instead of once per second.
:blink: Not quite what I'm looking for since that makes it virtually impossible to cross the room. The second script I tried was:

^That made them fire once per second forever. Also not quite what I'm after. I need them to fire once per second only while the Player is within the triggerzone. I should be able to accomplish this with a single script, but I can't seem to nail it down. Any ideas?


scn APSBalaseli02TrigZoneScript


Int bTriggered

Int iSpellRank

Float fTimer


Begin OnLoad ; Reset


        Set bTriggered to 0

        Set iSpellRank to 0

        Set fTimer to 0


End


Begin OnTrigger Player


        If bTriggered

        Else

                Set bTriggered to 1

                Set fTimer to 1

                If (Player.GetLevel > 20)

                        Set iSpellRank to 5

                ElseIf (Player.GetLevel > 15)

                        Set iSpellRank to 4

                ElseIf (Player.GetLevel > 10)

                        Set iSpellRank to 3

                ElseIf (Player.GetLevel > 5)

                        Set iSpellRank to 2

                Else

                        Set iSpellRank to 1

                EndIf

        EndIf


End


Begin GameMode


        If bTriggered

        Else

                Return

        EndIf


        If (fTimer <= 0)

                Set fTimer to 1

                If (iSpellRank == 1)    

                        APSB02Y01.Cast StandardShockDamageTarget1Novice APSB02Y01Target

                        APSB02Y02.Cast StandardShockDamageTarget1Novice APSB02Y02Target

                        APSB02Y03.Cast StandardShockDamageTarget1Novice APSB02Y03Target

                        APSB02X01.Cast StandardShockDamageTarget1Novice APSB02X01Target

                        APSB02X02.Cast StandardShockDamageTarget1Novice APSB02Y02Target

                ElseIf (iSpellRank == 2)

                        APSB02Y01.Cast StandardShockDamageTarget2Apprentice APSB02Y01Target

                        APSB02Y02.Cast StandardShockDamageTarget2Apprentice APSB02Y02Target

                        APSB02Y03.Cast StandardShockDamageTarget2Apprentice APSB02Y03Target

                        APSB02X01.Cast StandardShockDamageTarget2Apprentice APSB02X01Target

                        APSB02X02.Cast StandardShockDamageTarget2Apprentice APSB02Y02Target

                ElseIf (iSpellRank == 3)

                        APSB02Y01.Cast StandardShockDamageTarget3Journeyman APSB02Y01Target

                        APSB02Y02.Cast StandardShockDamageTarget3Journeyman APSB02Y02Target

                        APSB02Y03.Cast StandardShockDamageTarget3Journeyman APSB02Y03Target

                        APSB02X01.Cast StandardShockDamageTarget3Journeyman APSB02X01Target

                        APSB02X02.Cast StandardShockDamageTarget3Journeyman APSB02Y02Target

                ElseIf (iSpellRank == 4)

                        APSB02Y01.Cast StandardShockDamageTarget4Expert APSB02Y01Target

                        APSB02Y02.Cast StandardShockDamageTarget4Expert APSB02Y02Target

                        APSB02Y03.Cast StandardShockDamageTarget4Expert APSB02Y03Target

                        APSB02X01.Cast StandardShockDamageTarget4Expert APSB02X01Target

                        APSB02X02.Cast StandardShockDamageTarget4Expert APSB02Y02Target 

                ElseIf (iSpellRank == 5)

                        APSB02Y01.Cast StandardShockDamageTarget5Master APSB02Y01Target

                        APSB02Y02.Cast StandardShockDamageTarget5Master APSB02Y02Target

                        APSB02Y03.Cast StandardShockDamageTarget5Master APSB02Y03Target

                        APSB02X01.Cast StandardShockDamageTarget5Master APSB02X01Target

                        APSB02X02.Cast StandardShockDamageTarget5Master APSB02Y02Target 

                EndIf

        Else

                Set fTimer to (fTimer - GetSecondsPassed)

        EndIf


End

Link to comment
Share on other sites

Okay, this is a bit weird. I have several scripts attached to different creatures. The idea behind these scripts is to give the creatures a self removing ability spell that fully heals them if they are hit by a specific magic effect. One example is:


scn CreatureShockHealScript


Begin GameMode


  If HasMagicEffect SHDG == 1 && IsSpellTarget CreatureHealSpell == 0

    AddSpell CreatureHealSpell

  Endif


End

^That is supposed give CreatureHealSpell to the scripted creature when it takes shock damage. This script works perfectly, as does the self removing script on the spell. I have similar scripts for several other magic effects as well. Most of them work fine, but for some reason, this one doesn't:

scn CreatureFireHealScript


Begin GameMode


  If HasMagicEffect FIDG == 1 && IsSpellTarget CreatureHealSpell == 0

    AddSpell CreatureHealSpell

  Endif


End

^That should add CreatureHealSpell whenever the creature takes fire damage, but it doesn't do anything for some reason. Any idea why this isn't working?

Note 1: CreatureFireHealScript is an Object script, as are the scripts that work correctly.

Note 2: The fire damage spell used for testing this was the default Flare spell you start the game with.

Link to comment
Share on other sites

I'm wondering if the fire damage doesn't last long enough. Looking up HasMagicEffect in the wiki says that it returns 1 as long as the object has that effect.

That's what has me so confused. I have some other scripts that check for SHDG (shock damage), FRDG (frost damage) and DGHE (damage health). Each of those works perfectly, so why doesn't the one with FIDG? I just don't get it. I also tried a second script which was an equally dismal failure:


scn CreatureFireHeal02Script


Begin GameMode


  If HasMagicEffect FIDG == 1 && IsSpellTarget CreatureHealSpell02 == 0

    AddSpell CreatureHealSpell02

  ElseIf HasMagicEffect FIDG == 0 && IsSpellTarget CreatureHealSpell02 == 1

    RemoveSpell CreatureHealSpell02

  Endif


End

CreatureHealSpell02 does not have the self removing script, but shouldn't need it with this setup.

I'm wondering if the fire damage doesn't last long enough. Looking up HasMagicEffect in the wiki says that it returns 1 as long as the object has that effect. Perhaps OnMagicEffectHit would work better.

OnMagicEffectHit would only work on the initial hit. If the spell/enchantment does damage over time, the healing spell would not be added/removed the way I want. I want to make sure the creatures will continue to be healed for as long as they are under the effect of their respective elements. Example scenario:

Frosty the Frightful is just hangin' out in an old fort ruin. Suddenly, Magnus the Malevolent hits Frosty with a spell that does frost damage 10 points for 8 seconds on target.

With the second version of my script, CreatureHealSpell02 would be added to Frosty when he got hit and would be removed only when the 8 second duration was up. That's what I want to do with this script. To my knowledge, HasMagicEffect is the only scripting function that allows this. FIDG seems to be the only magic effect (so far) that doesn't work with this setup.

Edited by The Vyper
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...