Jump to content

Photo

Help in a Scripting Issue

script kotnr oblivion scripting construction set obse knights of the nine revelation elder scrolls auriel

  • Please log in to reply
6 replies to this topic

#1
Nerevairine

Nerevairine

    Fan

  • Members
  • PipPipPip
  • 293 posts

As some of you know, I am working on the new version of "Knights of the Nine: Revelations Continued (Unofficial)" but I seem to have done something wrong with the script for Auriel's Shield. I am trying to make the shield have the same power it has in Skyrim but can't make the script check if the character was hit while blocking with the shield, and so here we are. Is there any expert in Oblivion CS that can help me with this? (I am leaving all the scripts I have for the shield below). By the way "BlockedTimes" is a Global Variable set to "short".
 

Quest Script:

Spoiler

 

Shield Script:

Spoiler

 

Player Effect Script:

Spoiler

 

Spell Script:

Spoiler



#2
DrakeTheDragon

DrakeTheDragon

    Resident poster

  • Staff
  • PipPipPipPipPip
  • 7,903 posts

Hmm, I'm not exactly an expert in this particular topic, but I do know the way you use the OnHit block it doesn't work.

 

According to the CS wiki documentation the block is used to trigger when the "actor" the script is running on is hit by the actor given as parameter. The script with this block cannot run on the shield. It must run on an actor.

However, putting it onto the player actor in the CS also isn't exactly a clean or sane way to go, as only 1 plugin in load order can do that at the same time.

 

I think detecting when the player was hit is nowadays done quite differently. I just can't off the top of my head recall how it's done.

 

And then, your GetEquipped check is totally valid, being executed on "player" specifically. But calling "IsBlocking" when the script runs on the shield will always be false, as the shield will never be in the animation state of blocking. This, too, needs to be called on the player implicitly.

 

 

I'm sorry I'm not of more help right now. Maybe I'll come back when I stumbled across something more. Can't promise though.



#3
Nerevairine

Nerevairine

    Fan

  • Members
  • PipPipPip
  • 293 posts

Hmm, I'm not exactly an expert in this particular topic, but I do know the way you use the OnHit block it doesn't work.

 

According to the CS wiki documentation the block is used to trigger when the "actor" the script is running on is hit by the actor given as parameter. The script with this block cannot run on the shield. It must run on an actor.

However, putting it onto the player actor in the CS also isn't exactly a clean or sane way to go, as only 1 plugin in load order can do that at the same time.

 

I think detecting when the player was hit is nowadays done quite differently. I just can't off the top of my head recall how it's done.

 

And then, your GetEquipped check is totally valid, being executed on "player" specifically. But calling "IsBlocking" when the script runs on the shield will always be false, as the shield will never be in the animation state of blocking. This, too, needs to be called on the player implicitly.

 

 

I'm sorry I'm not of more help right now. Maybe I'll come back when I stumbled across something more. Can't promise though.

Thanks for the help you have given, and by the way the "IsBlocking" actually works on the shield since I have a script on another shield with that same parameter and it works, maybe just doesn't work in this case(?).



#4
Tharkun221

Tharkun221

    Enthusiast

  • Members
  • PipPip
  • 191 posts

I too don't think the OnHit block will work the way you use it.  Have you considered using OBSE's onhit event handler function?

Once set it will trigger anytime an actor is hit.  You can write your code in the function to determine who was hit and if the Auriel shield was equipped at the time.

 

It's pretty straightforward to use:

 

First create the event handler function, (make sure to set it as an object script):

 

Scn aaNerevairineOnHitFunction

 

ref target

ref attacker

ref Pref

 

begin function { target, attacker }

 

set Pref to PlayerRef
If target != Pref        ;exit early if it's not the player that was hit

     Return

EndIf

 

If target.GetEquipped aaKOTNRAurielsShield != 1     ;exit early if player doesn't have Auriels shield equipped.

     Return

EndIf

 

If (target.IsBlocking) && (BlockedTimes < 15)

     set BlockedTimes to BlockedTimes + 1                  ;increment the BlockedTimes global variable

EndIf

 

end     ;end of function

 

 

Now register the function by using SetEventHandler, for example you could put this code in the GameMode block of your Quest script:

 

If getgameloaded  ;needs to be declared only once when the game is loaded

    ;set handlers
    seteventhandler "onhit" aaNerevairineOnHitFunction  

EndIf

 

 

You don't need any script on the shield or player.

This is just a rough outline, I didn't test the code and I may not have fully understood all the details of what you want to do so it may not do exactly what you want as is.  Hope it helps you.


Edited by Tharkun221, 14 September 2020 - 12:00 AM.


#5
Nerevairine

Nerevairine

    Fan

  • Members
  • PipPipPip
  • 293 posts

I too don't think the OnHit block will work the way you use it.  Have you considered using OBSE's onhit event handler function?

Once set it will trigger anytime an actor is hit.  You can write your code in the function to determine who was hit and if the Auriel shield was equipped at the time.

 

It's pretty straightforward to use:

 

First create the event handler function, (make sure to set it as an object script):

 

Scn aaNerevairineOnHitFunction

 

ref target

ref attacker

ref Pref

 

begin function { target, attacker }

 

set Pref to PlayerRef
If target != Pref        ;exit early if it's not the player that was hit

     Return

EndIf

 

If target.GetEquipped aaKOTNRAurielsShield != 1     ;exit early if player doesn't have Auriels shield equipped.

     Return

EndIf

 

If (target.IsBlocking) && (BlockedTimes < 15)

     set BlockedTimes to BlockedTimes + 1                  ;increment the BlockedTimes global variable

EndIf

 

end     ;end of function

 

 

Now register the function by using SetEventHandler, for example you could put this code in the GameMode block of your Quest script:

 

If getgameloaded  ;needs to be declared only once when the game is loaded

    ;set handlers
    seteventhandler "onhit" aaNerevairineOnHitFunction  

EndIf

 

 

You don't need any script on the shield or player.

This is just a rough outline, I didn't test the code and I may not have fully understood all the details of what you want to do so it may not do exactly what you want as is.  Hope it helps you.

That worked!!! Thanks man!



#6
Tharkun221

Tharkun221

    Enthusiast

  • Members
  • PipPip
  • 191 posts

Great! Good luck with your mod.



#7
Nerevairine

Nerevairine

    Fan

  • Members
  • PipPipPip
  • 293 posts

 

I too don't think the OnHit block will work the way you use it.  Have you considered using OBSE's onhit event handler function?

Once set it will trigger anytime an actor is hit.  You can write your code in the function to determine who was hit and if the Auriel shield was equipped at the time.

 

It's pretty straightforward to use:

 

First create the event handler function, (make sure to set it as an object script):

 

Scn aaNerevairineOnHitFunction

 

ref target

ref attacker

ref Pref

 

begin function { target, attacker }

 

set Pref to PlayerRef
If target != Pref        ;exit early if it's not the player that was hit

     Return

EndIf

 

If target.GetEquipped aaKOTNRAurielsShield != 1     ;exit early if player doesn't have Auriels shield equipped.

     Return

EndIf

 

If (target.IsBlocking) && (BlockedTimes < 15)

     set BlockedTimes to BlockedTimes + 1                  ;increment the BlockedTimes global variable

EndIf

 

end     ;end of function

 

 

Now register the function by using SetEventHandler, for example you could put this code in the GameMode block of your Quest script:

 

If getgameloaded  ;needs to be declared only once when the game is loaded

    ;set handlers
    seteventhandler "onhit" aaNerevairineOnHitFunction  

EndIf

 

 

You don't need any script on the shield or player.

This is just a rough outline, I didn't test the code and I may not have fully understood all the details of what you want to do so it may not do exactly what you want as is.  Hope it helps you.

That worked!!! Thanks man!

 

Thanks!







Also tagged with one or more of these keywords: script, kotnr, oblivion, scripting, construction set, obse, knights of the nine, revelation, elder scrolls, auriel

Page loaded in: 1.116 seconds