Jump to content

Need help with a strange script behavior problem in FNV


Thorfkin

Recommended Posts

Posted

I've written an object script attached to an ingestible. It's designed to apply a visual effect to the actor while it's in the actor's inventory. It's a semen script for my sexout mod. What I've done is create an ingestible semen token. That object has a GameMode object script attached that executes immediately and then again every 5 seconds. It's a simple script but it's doing something I can't explain.

Here's what the object script looks like:

scn zNutritiousAlienSemenScript

ref rzNASSTargetActor
ref rzNASSActorEffect
ref rzNASSToken

int izNASSTokenCount

float fzNASSTimer

Begin GameMode
    if fzNASSTimer > 0
        Set fzNASSTimer to fzNASSTimer - GetSecondsPassed
    else
        Set rzNASSTargetActor to GetContainer
        Set rzNASSToken to zNutritiousAlienSemen
        Set rzNASSActorEffect to zSlatheredInSemenActorEffect
        Set izNASSTokenCount to rzNASSTargetActor.GetItemCount rzNASSToken
    
        if izNASSTokenCount > 0
            rzNASSTargetActor.CIOS rzNASSActorEffect
            ShowMessage zDebugMessage
        endif
        Set fzNASSTimer to 5
    endif
End

Whenever the Nutritious Alien Semen ingestible is in my inventory I want it to cover my character in cum using a semen shader. So the zSlatheredInSemenActorEffect activates a Base Effect that in turn actives a shader effect. The shader effect is a membrane effect set to fade the semen texture in over .5 seconds, show at full alpha for 5 seconds, then fade it out over .5 seconds.

So here's what it's doing that I can't figure out; as you can see I've placed a debug message right next to the actor effect. That way I have a very clear indicator when the actor effect has been applied. When I place the semen token in my inventory, the game engine throws the debug message twice in a row. It's almost as though the game were running two instances of the script even though there's only one semen token in inventory.

But that's not the strangest thing. The one that's really driving me nuts is that for some reason the game won't apply the shader effect on the first pass. When I place the semen token into my invetory, the debug message fires twice immediately so I know that section of script did execute. But no visual changes appear on my character. Then if I wait 5 seconds, the debug message fires twice again, and then the shader effect appears on my character. The shader effect itself is obviously working because it does apply on the second pass. But why won't it appear on the first pass?

It matters because I don't intend to leave the reactivation delay at 5 seconds. I want to set it to every 5 minutes but I don't want a 5 minute delay in the application of the first pass shader effect.

Anyone have any idea what might be causing these two problems? I can cope with the duplicate script instance. But I've been banging my head against that shader problem for 3 days.

My apologies if it's something stupid and simple =D This is my first mod attempt.

Posted

Try putting your Get Container as early in the script as possible and then have a check like this to be sure GetContainer  equals something otherwise I've often seen the first time GetContainer returns a <NULL>

 
Set rActor to GetContainer
 
if rActor
 
<do stuff>
 
endif
Posted

That was it! Thanks! That was driving me crazy. It just never occurred to me that the GetContainer might return null. I had assumed that because I have the symbiote set to create the semen in the actor's inventory that getcontainer would always return the actor's ref ID. Here's what I implemented:

Begin GameMode
if rzNASSTargetActor
    if fzNASSTimerB > 0
        Set fzNASSTimerB to fzNASSTimerB - GetSecondsPassed
    else
        Set rzNASSTargetActor to GetContainer
        Set rzNASSToken to zNutritiousAlienSemen
        Set rzNASSActorEffect to zSlatheredInSemenActorEffect
        Set izNASSTokenCount to rzNASSTargetActor.GetItemCount rzNASSToken
    
        if izNASSTokenCount > 0
            rzNASSTargetActor.CIOS rzNASSActorEffect
        endif
        Set fzNASSTimerB to 5
    endif
elseif fzNASSTimerA > 0
    Set fzNASSTimerA to fzNASSTimerA - GetSecondsPassed
elseif fzNASSTimerA <= 0
    Set rzNASSTargetActor to GetContainer
    Set fzNASSTimerA to 1
endif
End

I was concerned that calling getcontainer every frame on every instance of the script might cause a performance issue so I implemented a 1 second timer for it. Now it just checks getcontainer once per second until it returns something other than null and then proceeds to execute the shader code. It works perfectly now.

So far my mod is just an ESP that uses the common resource alien symbiote meshes to create equippable "backpacks". While the alien symbiote backpacks are equipped they add nutritious alien semen to the actor's inventory and they apply a constant health regeneration effect. If the actor eats the NAS it activates additional health regeneration as well as limb regeneration for a duration. I also made the NAS addictive to form a more symbiotic relationship.

I did this because I foolheartedly took the Meltdown perk on my character. Now every time I open fire with my hyperblaster I end up killing half my followers. This helps keep them alive in an entertaining way =D

Thanks again Halstrom!

Posted

Hmm I'd still put your GetContainer up the top, first line after the GameMode then it is only needed once and rechecked every scan, not sure how what you posted above works without a "Set rzNASSTargetActor to GetContainer" before the first if.

Posted

I can answer that!

 

On the first pass through the script, "if rzNASSTargetActor" fails because rzNASSTargetActor has been defined but not set.

 

On the first pass through the script, fzNASSTimerA has also been defined but not set, so "elseif fzNASSTimerA > 0" fails as well.

 

"elseif fzNASSTimerA <= 0" suceeds on the first execution pass because fzNASSTimerA does equal to zero. So the first thing the script does on its first execution is "Set rzNASSTargetActor to GetContainer" and "Set fzNASSTimerA to 1".

 

Then on the scripts second pass of execution "if rzNASSTargetActor" might succeed or fail depending on whether GetContainer returned null or a ref ID on the first pass of execution. If it fails, the script then waits one second by counting fzNASSTimerA to zero. When fzNASSTimerA reaches zero the script executes the GetContainer again and resets the timer to 1. It'll continue checking the container once per second until "if rzNASSTargetActor" succeeds at which point it executes the actor effect.

 

Since this is an object script using GameMode it executes once per rendered frame. I configured it this way so that only a couple of if statements and the getsecondspassed function are called on every frame of execution. It minimizes heavier resource utilization functions to once per second.

 

Your answer solved both problems. Previously the Alien Symbiote backpacks were adding Nutritious Alien Semen to what i can only assume is a null actor on first pass. It executed the debug message twice because the engine actually was running two instances of the script. One on my character and one on that null instance. I put the same structure of if statements and checks into both scripts and both problems resolved.

 

Thanks again for that! :)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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