Jump to content

Major problem with being naked


phoneyLogic

Recommended Posts

Hey there,

need some help with a script..

For a Mod I need to check what clothes are euipped by the player.

 

I already tried the FOSE function

player.GetEquippedObject, 6 which returns the refernce ID of the armor which is equipped.

 

But unfortunately the script stopps to procede while the player is naked since the "GetEquippedObject" function expects a reference ID ==> being naked doesn't have any and so the whole script stopps working.

 

Now I need to get around the problem.

Is there a way to check if the Players is being naked and to bypass the *GetEquippedObject* function if so?

 

 

Thanks in advance :)

tT

Link to comment
Share on other sites

Always try to test first is the general rule. If you run a FOSE function on a null reference, the script will halt. Slot 2 is Upperbody armor. Slot 6 is the pipboy.

 

If ([b]player.GetEquippedObject 2)	;See if player is wearing Upperbody Armor  (slot 2) before setting the variable
set rArmorREF to Player.GetEquippedObject 2
endif

 

But usually you can just do :

set rArmorREF to Player.GetEquippedObject 2

Then when you need to do more stuff - check to see if rArmorREF is non-zero

 

if (rArmorREF)
 set iRating to GetArmorAR rArmorREF
endif

Link to comment
Share on other sites

Always try to test first is the general rule. If you run a FOSE function on a null reference, the script will halt. Slot 2 is Upperbody armor. Slot 6 is the pipboy.

Yep, sorry, this was a typing error. I spent almost two days of testing and I was hardly ready to give up. But now I have an update.

 

The script is not stopping by calling set rArmorREF to Player.GetEquippedObject 2 like I thought, It is stopping by Player.UnEquipItem rArmorREF 0 1.

=> after getting the rArmorRef I planned to unequip it.

 

Script:

ref rArmorRef (;tracks the armors reference)

Begin OnDrop (Token)
    set rArmorRef to ( player.GetEquippedObject, 2 )
    ... some more code ...
    Player.UnEquipItem rArmorREF 0 1
    ... some more code ...
End

 

 

 

But usually you can just do :

...

Then when you need to do more stuff - check to see if rArmorREF is non-zero

 

if (rArmorREF)
 set iRating to GetArmorAR rArmorREF
endif

Would be possible but might extend the script too much. I already have round about 100 lines of code.

Now, since I know where the script is stopping exactly, I'll do some more testing ... should be possible

 

Thanks for the reply anyways, kudos given :thumbsup:

Link to comment
Share on other sites

Update:

The problems is whenever a equipItem or unequipItem is called after the GetEquippedObject 2 function on a nude, all further references - no matter what, even integer variables - get nullified or unusable as well. It completely borkers the whole script.

 

So I still need a propper method to check if the player is currently nude to avoid running the GetEquippedObject function completely. I tried several variables and dump references, but I haven't found any smart solution for this nasty problem :confused:

Link to comment
Share on other sites

else if?

:laugh:

Nope,this would be too easy.

Okey, here is a short video to illustrate the problem.

http://www.youtube.com/watch?v=rUO48rfg4nU

I removed the "GetEquippedObject 2" passage since it only is necessary to update the armor the player is currently wearing. This is needed to fix the stupit hole in the Players left arm after unequipping the pipboy on second 33.

Afaik this only can be done by re-equipping the armor => in other words: unequip, equip said armor, but not for sure :unsure:

 

This stupid reference buck bothers me...

Please give me a hint folks, im stuck here :mellow:

There must be a proper way to check for nudity before calling "GetEquippedObject".

 

But if there is a way to update the armor without "GetEquippedObject", I'll glady do this instead.

Link to comment
Share on other sites

Update:

The problems is whenever a equipItem or unequipItem is called after the GetEquippedObject 2 function on a nude, all further references - no matter what, even integer variables - get nullified or unusable as well. It completely borkers the whole script.

 

 

Where are you running the script? The examples I gave for using GetEquippedObject assumed it was used from a quest script, which i've done many times for the player and NPCs. If you are equipping and unequipping the object that is running the script, that may be the problem. Are you running the script on the Pipboy? Perhaps you could make a quest/with script just to store variables. And/Or use the quest script to do the unequip/equip thing

Link to comment
Share on other sites

Update:

The problems is whenever a equipItem or unequipItem is called after the GetEquippedObject 2 function on a nude, all further references - no matter what, even integer variables - get nullified or unusable as well. It completely borkers the whole script.

 

 

Where are you running the script? The examples I gave for using GetEquippedObject assumed it was used from a quest script, which i've done many times for the player and NPCs. If you are equipping and unequipping the object that is running the script, that may be the problem. Are you running the script on the Pipboy? Perhaps you could make a quest/with script just to store variables. And/Or use the quest script to do the unequip/equip thing

The script is running on the Pipboy item in the players inventury. No quest is involved in order to keep it fast and dandy. It seems that as soon as the "GetEquippedObject" function is called on a naked, every further (un)equipt function causes all reference and integer variables to fail in the whole script. And I cant save them by creating dump references like: "set dumpRef to rArmorREF" before calling GetEquippedObject since the dumpRef will be terminated, even if it wouldn't be related to the armor.

 

But I'm not running it on the pipboy. It is a separatet Item in the inventury. The normal Pipboy can't be droped.

 

Maybe I could save them by an script external Quest, defining dump variables there, but this would slow down the whole mod and I want to keep it simple. This is really bothering since everithing is working, except the case of being naked.

 

Basicly I need this function only to close the hole which is caused by the unequipped Pipboy.

Link to comment
Share on other sites

In general, if you have a bit of code that is stopping your script because the return value is invalid, you can isolate this bit of code in another script. So, for your case, make a new quest that is repeatable and put your call to GetEqObj in that quest script, but have the variable defined in your other script and use an explicit reference to the ref variable. Then if the new quest script borks, the original one will still run. Just use a check of the ref variable in the original script to ensure it is non zero. You can start and stop the new quest from the original, then wait a few frames for the new quest to do its thing before checking the ref variable.
Link to comment
Share on other sites

In general, if you have a bit of code that is stopping your script because the return value is invalid, you can isolate this bit of code in another script. So, for your case, make a new quest that is repeatable and put your call to GetEqObj in that quest script, but have the variable defined in your other script and use an explicit reference to the ref variable. Then if the new quest script borks, the original one will still run. Just use a check of the ref variable in the original script to ensure it is non zero. You can start and stop the new quest from the original, then wait a few frames for the new quest to do its thing before checking the ref variable.

Hm... yes this unfortunately seems to be the only way. Maybe I'm not going to use a quest but another token or sth.

Or does another way to check the players nudity exists?

Is there a way to check if a reference is valid?

 

(kudos given :biggrin: )

Link to comment
Share on other sites

  • Recently Browsing   0 members

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