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

  • 3 weeks later...

I'm having a bit of difficulty with a script I've attached to a weapon. The way it's supposed to work is like this:

Player has the weapon equipped. As long as the Player's Infamy is 0, the weapon will work. As soon as the Player's infamy rises above 0, four things are summosed to happen:

1. a messagebox displays, telling the Player they are no longer worthy of the weapon.

2. the weapon is unequipped.

3. the weapon removed from the Player's inventory.

4. a currently disabled activator is re-enabled.

The problem: CTD as soon as the weapon is removed from inventory. Every time.

The script is:


scn DivineBladeObjectScript


Short evil


Begin GameMode


set evil to getPCInfamy

 if player.GetItemCount DivineBlade >= 1

  If evil > 0

   If player.getequipped DivineBlade == 1 

     Messagebox "You are no longer worthy of wielding this blade." ;this part works

     Player.UnequipItem DivineBlade ;this part works too

   ElseIf Player.GetEquipped DivineBlade == 0

     Player.RemoveItem DivineBlade 1 ;this is where I get the CTD

     DivBladeActRef.enable

   Endif

  Endif

 Endif

End

What do I need to change to get this working right?

Link to comment
Share on other sites

Its probably CTD'ing because you are removing the item with the script running on it one frame after unequipping it. I would install a timer or counter and wait 10 frames or more before removing it.

And I would use RemoveMe instead of RemoveItem. And you will also want to enable DivBladeActRef BEFORE you remove the item from the players inventory.

Link to comment
Share on other sites

try this one:

scn SwordScript


ref MySelf


Begin GameMode


set MySelf to DivineBlade


If player.GetItemCount MySelf > 0

	If getPCInfamy > 0

		If player.GetEquipped MySelf == 0

			Messagebox "You are no longer worthy of wielding this blade."

	 		DivBladeActRef.enable

	 		RemoveMe

		Endif

		If player.GetEquipped MySelf

			player.UnequipItem MySelf

		Endif

	Endif

Endif


End

Link to comment
Share on other sites

  • 2 weeks later...

Okay, now I've run into another problem with the Divine Blade: the scripted enchantment isn't quite working properly. The script (with explanation below) for it is:


scn MCDivBladeEnchScript


Ref Target


Begin ScriptEffectStart


Set Target to GetSelf


If Player.Getlevel <= 2

 If Target.GetAv Health < 20 

  Player.PushActorAway Target 10

  Target.kill Player

 ElseIf target.GetAv Health > 20

  Player.PushActorAway Target 10

  Target.AddSpell MCMShockAb10p ; ShockAB refers to the Ability spell and XXp refers to how much damage it causes

 Endif

ElseIf Player.GetLevel <= 5

 If Target.GetAv Health < 25

  Player.PushActorAway Target 10

  Target.kill Player

 ElseIf target.GetAv Health > 25

  Player.PushActorAway Target 10

  Target.AddSpell MCMShockAb15p

 Endif

ElseIf Player.GetLevel <= 6

 If Target.GetAv Health < 30

  Player.PushActorAway Target 10

  Target.kill Player

 ElseIf target.GetAv Health > 30

  Player.PushActorAway Target 10

  Target.AddSpell MCMShockAb20p

 Endif

ElseIf Player.GetLevel <= 10

 If Target.GetAv Health < 35

  Player.PushActorAway Target 10

  Target.kill Player

 ElseIf target.GetAv Health > 35

  Player.PushActorAway Target 10

  Target.AddSpell MCMShockAb25p

  Endif

ElseIf Player.GetLevel <= 11

 If Target.GetAv Health < 40

  Player.PushActorAway Target 15

  Target.kill Player

 ElseIf target.GetAv Health > 40 

  Player.PushActorAway Target 15

  Target.AddSpell MCMShockAb30p

 Endif

ElseIf Player.GetLevel <= 15

 If Target.GetAv Health < 50

  Player.PushActorAway Target 15

  Target.kill Player

 ElseIf target.GetAv Health > 50

  Player.PushActorAway Target 15

  Target.AddSpell MCMShockAb40p

 Endif

ElseIf Player.GetLevel <= 16

 If Target.GetAv Health < 60

  Player.PushActorAway Target 15

  Target.kill Player

 ElseIf target.GetAv Health > 60

  Player.PushActorAway Target 15

  Target.AddSpell MCMShockAb50p

 Endif

ElseIf Player.GetLevel <= 20

 If Target.GetAv Health < 70

  Player.PushActorAway Target 20

  Target.kill Player

 ElseIf target.GetAv Health > 70

  Player.PushActorAway Target 20

  Target.AddSpell MCMShockAb60p

 Endif

ElseIf Player.GetLevel <= 21

 If Target.GetAv Health < 85

  Player.PushActorAway Target 20

  Target.kill Player

 ElseIf target.GetAv Health > 85

  Player.PushActorAway Target 20

  Target.AddSpell MCMShockAb75p

 Endif

ElseIf Player.GetLevel <= 25

 If Target.GetAv Health < 95

  Player.PushActorAway Target 25

  Target.kill Player

 ElseIf target.GetAv Health > 95

  Player.PushActorAway Target 25

  Target.AddSpell MCMShockAb85p

 Endif

ElseIf Player.GetLevel <= 26

 If Target.GetAv Health < 100

  Player.PushActorAway Target 25

  Target.kill Player

 ElseIf target.GetAv Health > 100

  Player.PushActorAway Target 25

  Target.AddSpell MCMShockAb90p

 Endif

ElseIf Player.GetLevel <= 30

 If Target.GetAv Health < 110

  Player.PushActorAway Target 30

  Target.kill Player

 ElseIf target.GetAv Health > 110

  Player.PushActorAway Target 30

  Target.AddSpell MCMShockAb100p

 Endif

ElseIf Player.GetLevel >= 33

 If Target.GetAv Health < 120

  Player.PushActorAway Target 35

  Target.kill Player

 ElseIf target.GetAv Health > 120

  Player.PushActorAway Target 35

  Target.AddSpell MCMShockAb110p

 Endif

Endif

Basically, this sword is supposed to do more magical damage as the Player levels up. In order for this to work, the weapon adds damaging ability spells to the target that remove themselves after one second. The first problem I ran into with this was that the ability spells sometimes killed the target without crediting the kill to the Player. This, in turn, could break the intention of the object script running on the sword (see my previous help request in this thread). If the ability spell killed a guard, it would not count as murder and the sword would remain in the Player's possession.

My solution was to check the target's health on each strike and see if it was greater or less than the damage of the sword (which is 10) + the damage of the ability spell that would be added at that level. If the target's health is less than those two, the script calls for Target.Kill Player, which should give the kill credit to the Player. For some reason, these parts don't seem to be working. So how can I ensure that the Player gets credit for the kills?

Link to comment
Share on other sites

Would it not be easier to have multiple 'power levels' of the sword? And it could then add the correct one when the player levels up.

The 'script' route your taking may or may not work.

As for the script:

1. If the health is '==' to the amount its checking for < or >, it will not work.

2. Using the 'kill' command has its own issues. For example, death items can get readded to corpses if you call the kill command on it again from a hit.

3. Weapon damage 'can' be more than 10 if the player is skilled or uses sneak or special attacks. So the calculations may not work as you expect.

Link to comment
Share on other sites

Would it not be easier to have multiple 'power levels' of the sword?

Not for the purposes of the sword. PushActorAway doesn't seem to work in a scripted enchantment if other effects are part of it, which is why I'm using ability spells to simulate other effects. Given that, it seemed a bit pointless to constantly exchange the sword for a more powerful version when I could just add increasingly powerful ability spells.

As for the script:

1. If the health is '==' to the amount its checking for < or >, it will not work.

2. Using the 'kill' command has its own issues. For example, death items can get re-added to corpses if you call the kill command on it again from a hit.

3. Weapon damage 'can' be more than 10 if the player is skilled or uses sneak or special attacks. So the calculations may not work as you expect.

1. Good point. I should have set it to '<=' to begin with.

2. I didn't know that. Interesting. I can add a check like If Target.GetAv Health <= XX && Target.GetDead == 0 before calling the 'Kill' command.

3. Maybe I should eliminate the weapon's base damage entirely and rely on the enchantment for the damage. It sort of makes sense for a divine weapon to only do magical damage, anyway. And it would be a different setup from anything else I've seen.

Link to comment
Share on other sites

Hey, I'm obviously very new to Oblivion modding and have a few questions concerning scripts for combat. I kind of want to find out if what I'm thinking is possible.

There are many animation replacing programs that one can even specify different styles for certain weapon types. The problem with them is that they do not work in first person. I love playing the game in first person, only rarely going to third for a look at my character and whatnot. Anyway, I figured there was no way around this until I saw the "Spears of Cyrodiil" mod by Skycaptain. You can hit the specified key and with any weapon that you're holding, you change stance and get (only 1) basic attack. All normal power attacks are possible to do to.

That mod gave me the idea to do perhaps multiple styles with the press of a button, doing it in the same way Skycaptain did. There would be a button (or multiple buttons) to select, which will change you to that stance/style no matter what the weapon. This would make dual wielding, spears, and other custom weapon styles possible. So, finally, here are my questions:

1. Would it be possible to make multiple attacks from the stance? Spears of Cyrodiil only has one attack, no combos or anything. This question kinda leads to others like:

A. If so, would attack combos be possible?

B. Or atleast a different attack for the direction the player is moving?

2. Would it be possible to specify a custom animation file in another folder (or the First Person Folder)? This way, it would be easy to customize (for anyone who can mess around with Nifscope a little) to make the styles whatever they want. They can throw together their favorite stance and moves for it however they want this way.

I'd like to find out if any of this is possible, because if it is I'll definitely set about learning everything I can of scripting and the like. Thanks for reading this post.

Link to comment
Share on other sites

I'm trying to modify a script to (among other things) rapidly change weather between two types for 5 seconds before settling on one type. The problem is that, no matter how I try to set it up, the changes never occur. This is not entirely unexpected since I'm not very good with timers, but it is driving me nuts. The current script is:


scn GCGateCloserSpellScript


Float Timer

Short GateTimer

Short Change

Ref Gate


begin ScriptEffectStart


 If Player.GetInWorldspace Tamriel == 1

  Set Gate to GetSelf

   If GetDestroyed == 0 && Gate.IsActor == 0

     Set Timer to 0

     Set GateTimer to 1

     Set Change to 0

     CloseOblivionGate	

     ModpcFame 1

     ModPCMiscStat 13 1

	Player.additem GCSSLL06Master 1

	PlaySound NPCAtronachStormEnrage	

	PlaySound3D SPLDestructionHit

   else

	PlaySound SPLShockFail

	PlaySound3D SPLDestructionFail

  Endif

 Endif

End


Begin GameMode


If GateTimer == 1

  If Timer >= 0 && Change == 0

   Set Timer to Timer + GetSecondsPassed

   Set Change to 1

  ElseIf  Timer >= 0 && Change == 1

      If Timer >= 0.5

         ForceWeather Clear

       ElseIf Timer >= 1

         ForceWeather OblivionStormTamriel

       ElseIf Timer >= 1.5

         ForceWeather Clear

       ElseIf Timer >= 2

         ForceWeather OblivionStormTamriel

       ElseIf Timer >= 2.5

         ForceWeather Clear

       ElseIf Timer >= 3

         ForceWeather OblivionStormTamriel

       ElseIf Timer >= 3.5

         ForceWeather Clear

       ElseIf Timer >= 4

         ForceWeather OblivionStormTamriel

       ElseIf Timer >= 4.5

         ForceWeather Clear

       ElseIf Timer >= 5

         SetWeather Clear

       Endif

  Endif

Endif

End

This is intended to be an update for the Oblivion Gate Closer Spell mod.

Link to comment
Share on other sites

You only update the timer in the first frame, so it NEVER does anything.

Your Timer will only equal 0.0005 or something like that and never get incremented again since you set 'change' to 1 in that block of code. Chamge must equal 0 for it to continue incrementing.

Link to comment
Share on other sites

You only update the timer in the first frame, so it NEVER does anything.

Your Timer will only equal 0.0005 or something like that and never get incremented again since you set 'change' to 1 in that block of code. Chamge must equal 0 for it to continue incrementing.

I've tried changing it around a bit, but it still does nothing to the weather. My most recent attempt at a working script is:


scn GCGateCloserSpellScript


Float Timer

Short GateTimer

Short Change

Ref Gate


begin ScriptEffectStart


 If Player.GetInWorldspace Tamriel == 1

  Set Gate to GetSelf

   If GetDestroyed == 0 && Gate.IsActor == 0

     Set Timer to 0

     Set GateTimer to 1

     CloseOblivionGate	

     ModpcFame 1

     ModPCMiscStat 13 1

	Player.additem GCSSLL06Master 1

	PlaySound NPCAtronachStormEnrage	

	PlaySound3D SPLDestructionHit

   else

	PlaySound SPLShockFail

	PlaySound3D SPLDestructionFail

  Endif

 Endif

End


Begin GameMode


If GateTimer == 1

   Set Timer to Timer + GetSecondsPassed

   Set Change to 1

Endif

If Timer >= 0.5 && Change == 1

  ForceWeather Clear

  Set Change to 2

ElseIf Timer >= 1 && Change == 2

  ForceWeather OblivionStormTamriel

  Set Change to 3

ElseIf Timer >= 1.5 && Change == 3

  ForceWeather Clear

  Set Change to 4

ElseIf Timer >= 2 && Change == 4

  ForceWeather OblivionStormTamriel

  Set Change to 5

ElseIf Timer >= 2.5 && Change == 5

  ForceWeather Clear

  Set Change to 6

ElseIf Timer >= 3 && Change == 6

  ForceWeather OblivionStormTamriel

  Set Change to 7

ElseIf Timer >= 3.5 && Change == 7

  ForceWeather Clear

  Set Change to 8

ElseIf Timer >= 4 && Change == 8

  ForceWeather OblivionStormTamriel

  Set Change to 9

ElseIf Timer >= 4.5 && Change == 9

  ForceWeather Clear

  Set Change to 10

ElseIf Timer >= 5 && Change == 10

  SetWeather Clear

  Set Change to 11

Endif

End

:grr: Why isn't this working? :wallbash: :wallbash: :wallbash:

Link to comment
Share on other sites

Are you sure its 'starting' the gamemode block? Put a message box in there.

There are eaiser ways to do your game mode block where you do not need the 'Change' switch at all.

Start from the highest number and work your way down instead of the lowest number and working your way up.

The reason you can do it this way is the very first condition that is TRUE is the only one that will be executed. So when Timer == 1, it will only execute the LAST Elseif statement.

If Timer >= 5
ForceWeather Clear
ElseIf Timer >= 4.5
ForceWeather OblivionStormTamriel
ElseIf Timer >= 4
ForceWeather Clear
ElseIf Timer >= 3.5
ForceWeather OblivionStormTamriel
ElseIf Timer >= 3
ForceWeather Clear
ElseIf Timer >= 2.5
ForceWeather OblivionStormTamriel
ElseIf Timer >= 2
ForceWeather Clear
ElseIf Timer >= 1.5
ForceWeather OblivionStormTamriel
ElseIf Timer >= 1
ForceWeather Clear
Endif[/code]

I am also not sure if the game engine can 'force' weather changes that fast. Your only giving it half a second between each change.

Link to comment
Share on other sites

Did you put a message box in there to verify that your script is even running?

Yep, I put a message box after every Set Change to X command and the only one that ever displayed was the first one. It made no difference if I set the timer to count up or down.

Then I tried removing the Change variable entirely and just using the timer. Same result.

Then I tried moving the Set Timer to Timer - GetSecondsPassed command into the ScriptEffectStart block. Result: The GameMode block didn't even run.

I figured it was time to stop trying when I started thinking about using my game disc as a clay pigeon. :lol:

Link to comment
Share on other sites

You cannot use 'GameMode' in a spell script. Period.

:doh: I wish I'd known that. It would have saved some time, at least.

You need to change that to ScriptEffectUpdate

And the spell duration must be long enough to accomplish the entirety of what you want that script to do. Once the spell ends, all stored variables are gone forever.

Okay, I changed the block to ScriptEffectUpdate and set the spell duration to 6 seconds, but I still can't get it to work. The first script I tried was:


scn GCGateCloserSpellScript


Float Timer

Short GateTimer

Ref Gate


begin ScriptEffectStart


 If Player.GetInWorldspace Tamriel == 1

  Set Gate to GetSelf

   If GetDestroyed == 0 && Gate.IsActor == 0

     Set Timer to 0

     Set GateTimer to 1

     CloseOblivionGate  

     ModpcFame 1

     ModPCMiscStat 13 1

        Player.additem GCSSLL06Master 1

        PlaySound NPCAtronachStormEnrage        

        PlaySound3D SPLDestructionHit

        set Timer to timer - GetSecondsPassed

   else

        PlaySound SPLShockFail

        PlaySound3D SPLDestructionFail

  Endif

 Endif

End


Begin ScriptEffectUpdate


If Timer >= 5

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer >= 4

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 3

  ForceWeather Clear

  MessageBox "Weather Clear"

ElseIf Timer >= 2

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 1

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer < 1

  SetWeather Clear

  MessageBox  "Weather set to clear"

Endif

End

The only part of the ScriptEffectUpdate block that ran was the very last ElseIf. So I changed the Timer variables around like this:

Begin ScriptEffectUpdate


If Timer >= 1

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer >= 2

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 3

  ForceWeather Clear

  MessageBox "Weather Clear"

ElseIf Timer >= 4

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 5

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer > 5

  SetWeather Clear

  MessageBox  "Weather set to clear"

Endif

End

Now the ScriptEffectUpdate block doesn't run at all.

And before you ask, I did remember to change the earlier part to Set Timer to Timer + GetSecondsPassed. :P

Link to comment
Share on other sites

Vyper, you've got those condition blocks backwards. You've got >= 1, which will always be true. If you timer is 5, for example, then it's greater than 1, isn't it? So the first block will always be true.

ScripteffectStart only runs once. You need to update your timer in ScriptEffectUpdate. EDIT: Also, as Willie points out, you need to use ScriptEffectElapsedSeconds, so you'll have to change your ScriptEffectStart block too.

So your ScriptEffectUpdate block would be:


Begin ScriptEffectUpdate


set Timer to Timer - ScriptEffectElapsedSeconds


If Timer >= 5

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer >= 4

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 3

  ForceWeather Clear

  MessageBox "Weather Clear"

ElseIf Timer >= 2

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 1

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer < 1

  SetWeather Clear

  MessageBox  "Weather set to clear"

Endif

End

Edited by AndalayBay
Link to comment
Share on other sites

Yeah, I normally use ScriptEffectElapsedSeconds, but I wasn't sure if he had a magic effect or not. I admit I didn't look up to see if ScriptEffect could be used for non-magic effects. I've only used it for magic effects, so I use ScriptEffectElapsedSeconds.

Link to comment
Share on other sites

Vyper, you've got those condition blocks backwards. You've got >= 1, which will always be true. If you timer is 5, for example, then it's greater than 1, isn't it? So the first block will always be true.

ScripteffectStart only runs once. You need to update your timer in ScriptEffectUpdate. EDIT: Also, as Willie points out, you need to use ScriptEffectElapsedSeconds, so you'll have to change your ScriptEffectStart block too.

So your ScriptEffectUpdate block would be:


Begin ScriptEffectUpdate


set Timer to Timer - ScriptEffectElapsedSeconds


If Timer >= 5

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer >= 4

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 3

  ForceWeather Clear

  MessageBox "Weather Clear"

ElseIf Timer >= 2

  ForceWeather OblivionStormTamriel

  MessageBox  "Weather Oblivion"

ElseIf Timer >= 1

  ForceWeather Clear

  MessageBox  "Weather Clear"

ElseIf Timer < 1

  SetWeather Clear

  MessageBox  "Weather set to clear"

Endif

End

Even with that ^ arrangement, the only part of the ScriptEffectUpdate block that runs is the last ElseIf statement (and that doesn't change the weather at all).

Th reason I wanted to use a timer to switch the weather back and forth was because SetWeather will not do anything for some reason. And without something to change the weather, the Tamriel Oblivion sky will continue to play once a gate is shut with this spell. Using ForceWeather works, but the change is instant and jarring. It would be less jarring if the weather kept switching back and force for a few seconds, as if two weather systems were at war with each other.

Would adding a Float variable help in any way?

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...