Jump to content

SetRestrained not working


scarycave

Recommended Posts

Just a quick problem I'm having....

I'm trying to get the player and a certain Npc to stay restrained during a battle.

 

It's supposed to play out like this:

You enter the house and see the Dawn agent attack it's parent.

The parent has only one health so he's killed, but has time to draw out his weapon.

Once the parents dead the Dog is no longer restrained.

The Dawn Agent's health is set to one, to be killed easily.

Upon death the player is no longer restrained.

 

The problem here is that the player and dog are never restrained and can just jump in.

 

Heres the code in it's entirety:

 

scn A0SCWanderersCabinMythicDawnAgent

ref pref
ref Self
ref dog
short DoOnce

Begin GameMode

Set Pref to getparentref
Set Self to getSelf
set dog to A0SCWDWanderersDog

If Pref.GetDead == 0
{
;Prevents the Dawn Agent from dying before his target is killed.
ForceAv Health 100
;Stop the Player and the Wanderers Dog from getting involved in the struggle.
Player.SetRestrained 1
Dog.SetRestrained 1
;Start Combat
StartCombat Pref
Pref.StartCombat Self
}
endif

If Pref.GetDead == 1
{
;Dawn Agents going down.
If DoOnce == 0
	SetAv Health 1
	Set DoOnce to 1
	Dog.SetRestrained 0
Endif
}
endif

End

Begin OnDeath

Player.SetRestrained 0

End

Link to comment
Share on other sites

The script seems OK. Maybe executing the first block every frame may cause problems. Try a DoOnce there also.

 

You may also print some message to the console to check if the script is running at all.

 

And those brackets shouldn't be there. I tested and, surprisingly, the compiler does not complain and they do not seem to affect the script execution in game.

Link to comment
Share on other sites

I managed to get it to work at one point, then I messed up, and just went..."meh", and decided to scrap the fight and make the guy who's supposed to die a follower. :) Not the route I was expecting to take, but I like how it turned out.

Code not working for reasons I don't understand saves lives! Still, I just can't see anything wrong with this code though. It's mind boggling. :psyduck:

I don't have to use brackets either? I've been using them as I'm not sure when a code considers "it's" endif. :ninja:

Edited by scarycave
Link to comment
Share on other sites

This kind of brackets (not sure what is the formal name of these symbols - { } ) are only used in quite specific situations (e.g. conditional MessageBoxEx and Function statements)

 

The compiler is supposed to pair IFs, ELSEs and ENDIFs and complain about missing or extra ones.

The vanilla compiler not always catches all errors of this kind and sometimes they are hard to find. As far as I know, the brackets will not help in any way.

OBSE and CSE compilers do catch them.

Link to comment
Share on other sites

They { } are called curly brackets in the UK, braces in the US. 8)

C++, and most derivatives, are a "curly bracket language", and usually requires braces, yet Oblivion does not. In fact, most even require that you delineate all conditions with normal brackets, as in:

If ( (Player.GetAv Fatigue) == 10 )

Yet Oblivion does not :thumbsup:

 

 

Back on topic, I see nothing logically wrong with your script. SetRestrained has worked pretty well for me (although starting dialogue when it is affecting the player causes the camera to zoom in front of the player, but not necessarily on the talker's face. Could be useful for some things I guess, like talking animals) in most cases, although I didn't call it every frame. You might be able to salvage the fight scene with a DoOnce loop.

Edited by WarRatsG
Link to comment
Share on other sites

Well, I went back to having him killed off again, so I'll give it another go. :) I deleted the code but I can re-type it, or just copy it from here again. Since I moved him to the shivering Isles I can probably make his death more over the top. I should probably start using doOnce loops more often. Thanks for the lesson on Brackets. ;)
Link to comment
Share on other sites

  • Recently Browsing   0 members

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