Jump to content

Light emitting shields


MercerMeka

Recommended Posts

Hello,

 

I have an idea for a mod which adds light emitting shields to the game however it only give off light when Blocking. That way you can be a sneaky dungeon delver and still have some light whenever you need it.:)

 

Can someone provide a script for adding and removing an Ability when blocking/not blocking?

 

I would very much appreciate it and I would make the mod available for everyone of course.

 

- Mercer

Link to comment
Share on other sites

  • 2 months later...

With OBSE it's propably no problem, try this:

scn ShieldOfLightScript

ref actoritem 

begin
   set actoritem to GetContainer
   if actoritem == player
      set actoritem to actoritem.GetEquippedObject 13
      if actoritem == ShieldOfLight && player.IsBlocking != 0 && player.HasSpell AbShieldLight == 0
         player.AddSpellNS AbShieldLight
      endif
      if eval (actoritem != ShieldOfLight || player.IsBlocking == 0) && player.HasSpell AbShieldLight != 0
         player.RemoveSpellNS AbShieldLight
      endif
   endif
end

Script is attached to a shield and you can use also IsSpellTarget function. In case of abilities it's enough to add them.

Link to comment
Share on other sites

Thanks heaps, RomanR. It works!!

 

I had to change "begin" to "begin gameMode". Does that sound okay to you? ('m very inexperienced with scripts).

 

I tested it and already have a new request :laugh:

 

Would it be possible to have the light effect keep lighting as long as the block button is held down instead of only shining light when the player is actually blocking. Every time I take a swing with my weapon the lights goes out. Not a big problem but if there a easy solution it would be cool.

Alternatively could the light effect simply last 3 seconds longer after the player has blocked?

 

EDIT:

Could the ability be changed into a spell and the script would still work? If so maybe I could just add a light spell for 3 seconds.

 

EDIT2:

I'm trying to make it so that some shields shine light with different colors but it doesn't seem possible without changing the default Light spell color.

Does anyone have any ideas on how to have multiple colors of light? (I think it might be possible with OBGE but I don't want to make that an requirement)

Edited by MercerMeka
Link to comment
Share on other sites

You can add the Lightning spell or Lightning effect to any ability, as spells do run of for 3s and that is what you wanted right and abilities lasts as long as the item is in use, equipped or activated or whatever? That is the main difference between a spell and ability. The spell has a magic timer set in seconds at the magic effect added to it but if I recall right, it is not possible to set that field with second when added to an ability.

 

The number of seconds that a spell can be activated is extremely high though and then it might feel like an ability, which is only an illusion of course. The highest number I used in game was 6000s at a spell for the player and I decreased it to 600s, a healing spell with some fortify and Light. The limit is most likely thousand and thousand times more of course. :D Maybe even more seconds than a human life span? :wink: Someone will know the limit.

 

The player could cast a lightning at the shield but it would really work much better if the shield hits the player with the spell or any target really, when equipped even. You can combine any effect with any magic object, like spells, powers, enchants, abilities or whatever. Nothing is impossible. Shall I add the code here?

 

That begin GameMode will run 1 time every frame, or 1 time every FPS and it is so small that it will have no impact at all as it will slow the game down by 0.000047% of a second. As it is only needed when the player equips the shield, it would be better to use

 

Begin OnEquip

not

Begin GameMode

 

Begin OnEquip will only run 1 time every time you equip the object that has a script including Begin OnEquip and if the samescript includes both:

Begin OnEquip
<Lots of code>
End

Begin GameMode
<Lots of Code>
End

The GameMode part will run every frame and the OnEquip section will be ignored until you equip the item. The game do check the status of all scripts every frame, trying to figure out if it is a Spell Effect script, ObjectScript, GameMode, MenuMode, a quest script or whatever and it will peek at all variables ad skip the rest in that specific script if there is the conditions are not fullfilled. So a GameMode Script can be made to be as effective as a OnEquip script, if it is exitted at the top row with:

if ( Condition != 0 )
return
endif

The return will tell the script to pause one game frame (1 FPS) and run again and exit until the condition is 0 in this case and then it will peek at the lower rows until another return pops up or the script end. :D Most what I wrote is extremely basic and if you knew it already, then we hope someone else will maybe get some use of it. :ninja: :geek: :tongue:

 

The most useful WIK page in this case is the Begin that explain all Different blocktypes

Edited by Pellape
Link to comment
Share on other sites

You can use also IsControlPressed instead IsBlocking function, but I think the effect will be same. Also delaying the removing the a ability is also possible using extra variable and GetSecondsPassed function.

 

For example:

set timer to 3
...
set timer to timer - GetSecondsPassed
if timer <= 0
   player.RemoveSpellNS ...
endif

Spells are needed to cast actively, so the Ability or Enchanment is better fot this. With various colors I'm unable to help, sorry. In magic area I know only the basics.

Link to comment
Share on other sites

Any luck ? Improved version using Pellape's advices can look like this:

scn ShieldOfLightScript

short nospell
short equipped
float timer

begin OnEquip player
   set equipped to 1
end

begin OnUnequip player
   set equipped to 0
end

begin GameMode
   if equipped != 0 && IsControlPressed 6 != 0 && player.HasSpell AbShieldLight == 0
      player.AddSpellNS AbShieldLight
      set nospell to 0
      set timer to 3
   endif
   if eval (equipped == 0 || IsControlPressed 6 == 0) && player.HasSpell AbShieldLight != 0
      set nospell to 1
   endif
   if nospell != 0
      if timer <= 0
        player.RemoveSpellNS AbShieldLight
        set nospell to 0
      else 
        if equipped != 0 && IsControlPressed 6 != 0 ;shield equipped and block is pressed again
           set nospell to 0 ;reset spell removal
           set timer to 3
        else
           set timer to timer - GetSecondsPassed
        endif
      endif
   endif
end

This time a timer is in use - after unequipping a shield or releasing a block button, the light disappears after 3s, if nothing happens.

Edited by RomanR
Link to comment
Share on other sites

5 replies in 1 day! Amazing. Thanks a lot for the help both of you.

 

I just tested the script and it works perfectly. I'm so happy. I would never in a million years have worked this script out on my own. I will be sure to give you guys credit for the scripts.

Btw I've been working on and testing my new mod all week and it's almost ready for release. Now I can go back and improve on it. I'm actually going to be using both scripts depending on the effects for each of my new scripted shields.

I found out that the "IsControlPressed 6" works in such a way that you can hack away with your weapon without stopping to block but since the game registers the block key being pressed in between weapon swings I can keep the Light effect going endlessly without actually holding my shield up. :D Pretty neat.

 

Pellape, don't ever worry about getting too basic when explaining me stuff :P

Thanks for the explanation. I didn't know you could have both Begin OnEquip and Begin GameMode in the same script. I thought max 1 "Begin X".

 

 

 

If I wanted the first script to use "IsControlPressed 6"" instead of "player.IsBlocking" would it look like the script below or does it need to be tweaked?

scn ShieldOfLightScript

ref actoritem 

begin
   set actoritem to GetContainer
   if actoritem == player
      set actoritem to actoritem.GetEquippedObject 13
      if actoritem == ShieldOfLight && IsControlPressed 6 != 0 && player.HasSpell AbShieldLight == 0
         player.AddSpellNS AbShieldLight
      endif
      if eval (actoritem != ShieldOfLight || IsControlPressed 6 == 0) && player.HasSpell AbShieldLight != 0
         player.RemoveSpellNS AbShieldLight
      endif
   endif
end
Link to comment
Share on other sites

Coool. I am so happy that I can burst after reading your latest reply as you did find my solution helpful. Damn. :D

 

Honestly, there is no limits at all, as long as we do not misspell the commands that is or try to add OBSE stuff into CS commands as well. :D

Link to comment
Share on other sites

  • Recently Browsing   0 members

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