Jump to content

Someone mind checking over my scripts?


Pumpkinbot

Recommended Posts

So, I'm making a mod to change the birthsigns, and I'm brand-spanking-new to scripting. Someone mind checking these over and see if I didn't suck at it? c:

 

First one is pretty simple, and I'm pretty sure I got it right. Upon choosing the Serpent Stone, the player gets a "The Serpent" spell that gives them one of ten different spells, depending on their race. (Since the Serpent's kind of a strange sign in TES, and everyone under it's sign don't show anything in common, I thought it fit.)

So, the player casts the "The Serpent" spell on themselves, and it runs this script, which goes through each playable race, and then gives them the appropriate lesser power. If they're none of those, then they're probably a custom race, in which case, give them this fallback spell, and then removes the "The Serpent" spell.

ScriptName PBOTSerpentWhatRace

Begin ScriptEffectStart

If GetIsRace Imperial
	Player.AddSpell PBOTSerpentLesserImperial
ElseIf GetIsRace Nord
	Player.AddSpell PBOTSerpentLesserNord
ElseIf GetIsRace Redguard
	Player.AddSpell PBOTSerpentLesserRedguard
ElseIf GetIsRace Breton
	Player.AddSpell PBOTSerpentLesserBreton
Elseif GetIsRace HighElf
	Player.AddSpell PBOTSerpentLesserAltmer
Elseif GetIsRace DarkElf
	Player.AddSpell PBOTSerpentLesserDunmer
Elseif GetIsRace WoodElf
	Player.AddSpell PBOTSerpentLesserBosmer
Elseif GetIsRace Orc
	Player.AddSpell PBOTSerpentLesserOrc
Elseif GetIsRace Khajiit
	Player.AddSpell PBOTSerpentLesserKhajiit
Elseif GetIsRace Argonian
	Player.AddSpell PBOTSerpentLesserArgonian
Else
	Player.AddSpell PBOTSerpentLesserCustom
EndIf

Player.RemoveSpell PBOTSerpentLesser

End

My second one, I'm much less confident in. It's for the Tower birthsign, which adds a "Detect Valuables" spell, like the "Beggar's Nose" spell in Morrowind. More or less, I want it to give a Detect Life-esque shading effect to anything expensive that can fit in pockets. Also added an "If IsActor - Return" just to quickly stop it from running on actors. No need to bog down peoples' computers by having this run unnecessarily on things that aren't items. :tongue:

ScriptName PBOTTowerDetectValuables

Begin ScriptEffectStart

If IsActor
	Return
EndIf

If IsSoulGem || IsSigilStone || GetIsID Gold001
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem6DiamondFlawless || GetIsID Gem6DiamondFlawed || GetIsID Gem6Diamond
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem5EmeraldFlawless || GetIsID Gem5EmeraldFlawed || GetIsID Gem5Emerald
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem4SapphireFlawless || GetIsID Gem4SapphireFlawed || GetIsID Gem4Sapphire
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem3RubyFlawlss || GetIsID Gem3RubyFlawed || GetIsID Gem3Ruby
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem2TopazFlawless || GetIsID Gem2TopazFlawed || GetIsID Gem2Topaz
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem1PearlFlawless || Gem1PearlFlawed || Gem1Pearl
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID Gem0GoldNugget || Gem0SilverNugget
	PlayMagicShaderVisuals PBOTEffectDetectValuables
ElseIf GetIsID VarlaStone || WelkyndStone
	PlayMagicShaderVisuals PBOTEffectDetectValuables
EndIf

End

Begin ScriptEffectFinish
	StopMagicShaderVisuals PBOTEffectDetectValuables
End

EDIT: I've run into a bit of a problem. When compiling the Detect Valuables script, I get an error saying "IsSoulGem" and "IsSigilStone" are unknown commands, so it's not letting me compile. :T They're both OBSE commands, and I have OBSE installed. What's screwing up, here?

 

EDIT2: Nevermind, after a quick bit of Googling, I found out I had to run the Construction Set through OBSE. Done! But now, I've got another script-related question.

I want a touch spell (Weakness to Magicka 50% for 30sec, to be exact) to explode on touch without having to actually need a target. The CS wiki skimps a bit on details, but the SetSpellExplodesWithNoTarget seems to be what I'm looking for. Two questions. 1) Does it only affect the spell that has this attached via script, and 2) Does it apply the effect to the player, as well?

Edited by Pumpkinbot
Link to comment
Share on other sites

For the detect valuable spell, you can simply get their gold value with "GetFullGoldValue" and check it's above... 25?

 

As for the touch spell, you don't have to attach the script to the spell:

If the spell has a script in his effects, that script will only run if the spell hit, but since the spell has still the flag disabled it won't hit anything (unless you "touch" a target).

You need to either open the spell manually and directly check the flag, or you can use SetSpellExplodesWithNoTarget inside a script which only execute when the game load.

 

And... no, a touch/target spell can't hit the caster (even if it's an atomic explosion!), so you need to add a separated "self" effect on the spell, which will only and always hit the caster when you use it, even if the target/touch effect doesn't hit a single target.

Link to comment
Share on other sites

For the detect valuable spell, you can simply get their gold value with "GetFullGoldValue" and check it's above... 25?

 

As for the touch spell, you don't have to attach the script to the spell:

If the spell has a script in his effects, that script will only run if the spell hit, but since the spell has still the flag disabled it won't hit anything (unless you "touch" a target).

You need to either open the spell manually and directly check the flag, or you can use SetSpellExplodesWithNoTarget inside a script which only execute when the game load.

 

And... no, a touch/target spell can't hit the caster (even if it's an atomic explosion!), so you need to add a separated "self" effect on the spell, which will only and always hit the caster when you use it, even if the target/touch effect doesn't hit a single target.

Oh, that GetFullGoldValue thing makes it much easier! Thanks!

 

And as for the SetSpellExplodes thing, I made a script that simply set all my spells that needed it to explode without a target (the Detect Valuables spell being one of them, more on that later), and attached it to a script that runs when the game starts. Skyrim does something similar, yeah? Either way, it seemed to work.

 

But the Detect Valuables spell...I have it as a script effect within 30ft for 45 seconds. But that just applies the script to everything within 30 yards at the time of casting, right? And does it add scripts to only actors, or does it do it on items, too? I'm sure there's some way to attach the script to the player, and have some sort of "IsInSightline" command, or something, I dunno.

Link to comment
Share on other sites

Yes, 30ft is the area of effect of the spell. Every "interactive" object (mainly: actors, items, containers, harvestable flora, ... everything you can "activate" or "use") in that area will be hit by the spell.

 

And sorry, but there's no such command. There's a command called GetLOS which require you give it an object and it return true if the player can see it (or better, if the object is within the camera, so it return true even for items right behind you, :confused:).

Also it's bugged: it only works fine for the player, and it stop working after 10-15 calls within the same frame, but it will work again in the next frame.

But there's no command which return a list of all items within sight range.

Link to comment
Share on other sites

Yes, 30ft is the area of effect of the spell. Every "interactive" object (mainly: actors, items, containers, harvestable flora, ... everything you can "activate" or "use") in that area will be hit by the spell.

 

And sorry, but there's no such command. There's a command called GetLOS which require you give it an object and it return true if the player can see it (or better, if the object is within the camera, so it return true even for items right behind you, :confused:).

Also it's bugged: it only works fine for the player, and it stop working after 10-15 calls within the same frame, but it will work again in the next frame.

But there's no command which return a list of all items within sight range.

Well, what I meant is, it only goes off at the time of casting, meaning if I move around, only the items that were within range when I cast it will have the glow, whereas Detect Life shows everything within so many feet of you, because it's cast on the player.

 

EDIT: Here's my new Detect Valuables script. 30 ft area for 15 seconds on touch. Except it's...not working. :T I do the animation like I casted a thing, and...nothing. Que pasa?

ScriptName PBOTTowerDetectValuables

Ref PBOTThisContainer

Begin ScriptEffectStart
Set PBOTThisContainer to GetSelf
If PBOTThisContainer.GetFullGoldValue == 25
	PlayMagicShaderVisuals PBOTEffectDetectValuables
EndIf
End

Begin ScriptEffectFinish
	StopMagicShaderVisuals PBOTEffectDetectValuables
End
Edited by Pumpkinbot
Link to comment
Share on other sites

Maybe because there's no item with EXACTLY 25 gold value. Try >= 25 instead.

You could add a little condition, so the script only check for interactive object, but not actors.

Also, you don't need to store GetSelf in a variable in this case. A magic script run on the target of the spell, so you can call commands and functions directly:

 

ScriptName PBOTTowerDetectValuables

Begin ScriptEffectStart
   If Eval IsActivatable && !IsActor    ;Only check for interactive objects, except actors
      If GetFullGoldValue >= 25
         PlayMagicShaderVisuals PBOTEffectDetectValuables
      EndIf
   EndIf
End

Begin ScriptEffectFinish
   StopMagicShaderVisuals PBOTEffectDetectValuables
End
Link to comment
Share on other sites

Maybe because there's no item with EXACTLY 25 gold value. Try >= 25 instead.

You could add a little condition, so the script only check for interactive object, but not actors.

Also, you don't need to store GetSelf in a variable in this case. A magic script run on the target of the spell, so you can call commands and functions directly:

Oh, whoops. It's always one tiny mistake that messes a script up, isn't it?

 

Also, you don't need to store GetSelf in a variable in this case. A magic script run on the target of the spell, so you can call commands and functions directly

Really? Coulda sworn GetFullGoldValue had to have a reference stated beforehand. Welp, that makes things simpler! CS wiki's always been a bit wonky.

 

EDIT: Formatting. Nexus' post system has always bugged me. >.< Just give me some bbcode and I'll be happy.

Edited by Pumpkinbot
Link to comment
Share on other sites

GetFullGoldValue require a reference, like many other functions, but in Magic and Object script it can use an implicit reference:

  • For Object scripts: the implicit reference is the item/actor which has the script (and, for inventory items only, you can use GetContainer to obtain the reference of the actor/container who has this item in his inventory)
  • For Function scripts: the implicit reference is the actor/item on which you called the function (example: actor.Call functABC)
  • For Magic scripts, the implicit reference is the actor/item hit by the spell, on which the spell script is running.
  • Quest scripts are global scripts, so they don't have an implicit reference and you must always specify one.

So when you use "GetFullActorValue" in the spell, it automatically do: "spellTarget.GetFullActorValue"

You can always do "someRef.GetFullActorValue", if you don't want to run the command on the implicit reference, but on another one.

Edited by forli
Link to comment
Share on other sites

GetFullGoldValue require a reference, like many other functions, but in Magic and Object script it can use an implicit reference:

  • For Object scripts: the implicit reference is the item/actor which has the script (and, for inventory items only, you can use GetContainer to obtain the reference of the actor/container who has this item in his inventory)
  • For Function scripts: the implicit reference is the actor/item on which you called the function (example: actor.Call functABC)
  • For Magic scripts, the implicit reference is the actor/item hit by the spell, on which the spell script is running.
  • Quest scripts are global scripts, so they don't have an implicit reference and you must always specify one.

So when you use "GetFullActorValue" in the spell, it automatically do: "spellTarget.GetFullActorValue"

You can always do "someRef.GetFullActorValue", if you don't want to run the command on the implicit reference, but on another one.

Ohh, I see. Thanks, I'll test that out the next time I open up the Construction Set!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...