Problem with Maigrets Companions
Posted: February 17th, 2014
First of all, I love the simplicity of you mods. But I have a small problem. When I put a companion in 'sneak' mode they always stay in sneak mode. I looked at the code and found the reason why. I thought I would share it with you. I do use OBSE and Construction Set Extender.
Here is you code:
First thing I saw was a reference variable by the name of GetSelf. That is a name of a function in the game. Construction Set Extender won't even compile that line. I'm guessing that the regular Construction Set will. This causes the line 'GetSelf.GetForceSneak' to always to evaluate to '0'. So in the above code, the only part of the sneak code that can ever fire is the one where the 'SetForceSneak' is set to '1' putting the companion is sneak mode.
Again I use OBSE so maybe thats why it has become an issue.
Good news is that it is an easy fix. Just delete the line 'ref GetSelf' and the four 'Getself' in the sneak part of the code.
The 'GetForceSneak' and 'SetForceSneak' don't need qualifiers in this case. The new code looks like this:
I haven't looked at all your companions yet. I have only have looked at Rosie, Rocky & Spike, and Sable.
One other thing that I noticed in the Rosie mod, is the Global Variable 'DogFollow' is very generic and could cause issues if other modders use the same name. In the other mods of yours I looked at, you prefix your Global Variables with 'MA' which is good.
BTW, Rosie has saved my sorry butt many times.
Here is you code:
Code: Select all
scn AASherJaScript
ref rEnemy
short doOnce
ref GetSelf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
begin OnActivate
if IsActionRef player
SetIgnoreFriendlyHits 1
if doOnce == 0
Player.addspell AASherJaSpell
set doOnce to 1
endif
if (GetSelf.GetForceSneak == 0) && (player.IsSneaking == 1)
GetSelf.SetForceSneak 1
elseif (GetSelf.GetForceSneak == 1) && (player.IsSneaking == 0)
GetSelf.SetForceSneak 0
endif
if LionFollow == 1
set LionFollow to 0
Message "'Sher Ja, wait for me.'"
elseif LionFollow == 0
set LionFollow to 1
Message "'Sher Ja, come with me.'"
endif
EvaluatePackage
playGroup Idle 1
else
activate
endif
end
Again I use OBSE so maybe thats why it has become an issue.
Good news is that it is an easy fix. Just delete the line 'ref GetSelf' and the four 'Getself' in the sneak part of the code.
The 'GetForceSneak' and 'SetForceSneak' don't need qualifiers in this case. The new code looks like this:
Code: Select all
scn AASherJaScript
ref rEnemy
short doOnce
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
begin OnActivate
if IsActionRef player
SetIgnoreFriendlyHits 1
if doOnce == 0
Player.addspell AASherJaSpell
set doOnce to 1
endif
if (GetForceSneak == 0) && (player.IsSneaking == 1)
SetForceSneak 1
elseif (GetForceSneak == 1) && (player.IsSneaking == 0)
SetForceSneak 0
endif
if LionFollow == 1
set LionFollow to 0
Message "'Sher Ja, wait for me.'"
elseif LionFollow == 0
set LionFollow to 1
Message "'Sher Ja, come with me.'"
endif
EvaluatePackage
playGroup Idle 1
else
activate
endif
end
One other thing that I noticed in the Rosie mod, is the Global Variable 'DogFollow' is very generic and could cause issues if other modders use the same name. In the other mods of yours I looked at, you prefix your Global Variables with 'MA' which is good.
BTW, Rosie has saved my sorry butt many times.