Jump to content
Sign in to follow this  
someguy11

Hide the subobject/mesh when underpowered/EMP'd

Recommended Posts

I want to make the emissary outpost hide the hologram TVs when it is underpowered/affected by emp

Share this post


Link to post

Look at how the powerplant or other buildings do it.

They use lua and the eventlist to hide subobjects.

 

they use the OnPowerOutage and OnPowerRestored events to trigger the lua scripts

 

for example:

 

function OnNODSecretShrinePowerOutage(self)    
    if ObjectHasUpgrade( self, "Upgrade_NODConfessorUpgrade" ) == 1 then
        ObjectHideSubObjectPermanently( self, "GLOWS", true )    
    end
end

function OnNODSecretShrinePowerRestored(self)        
    if ObjectHasUpgrade( self, "Upgrade_NODConfessorUpgrade" ) == 1 then
        ObjectHideSubObjectPermanently( self, "GLOWS", false )    
    end
end
 

Have a look at some of the buildings how they do it.

Share this post


Link to post

I've added the AILuaEventsList="BuildingPowerFunctions" to the emissary outposts, and

 

ObjectHideSubObjectPermanently( self, "TV", true ) & ObjectHideSubObjectPermanently( self, "TV", false )

to

function onBuildingPowerOutage(self) & function onBuildingPowerRestored(self) respectively in the scripts.lua

but ingame the effect isn't working

Share this post


Link to post

Did you add your scripts.lua and sciptevents.xml to your buildmods/mods/modname/data/scripts/ folder (tw) or to your /misc/data/scripts/ folder in KW?

Share this post


Link to post

Don't use Scripts.lua, use a script inside of an animation state instead.

 

Add a script that unhides the "tv" by default, and add a couple of animation states (one for 'EMP', one for 'UNDERPOWERED'), that each have a script that hides the "tv".

Edited by Madin

Share this post


Link to post

Don't use Scripts.lua, use a script inside of an animation state instead.

 

Add a script that unhides the "tv" by default, and add a couple of animation states (one for 'EMP', one for 'UNDERPOWERED'), that each have a script that hides the "tv".

Idd that works aswell. And in this case prob even better.

 

Something like:

 

 

<AnimationState
                    ParseCondStateType="PARSE_DEFAULT">
                    <Script>
                        CurDrawableShowSubObject("TV") 
                    </Script>
</AnimationState>
<AnimationState
                    ParseCondStateType="UNDERPOWERED">
                    <Script>
                               CurDrawableHideSubObject("TV")                    
                    </Script>
 </AnimationState>
 

you might have to add

RetainSubObjects="true"

to the modelconditionstates aswell or you will have to add the scriptig lines to every different modelcondition like really damaged etc.

Something to try out, could be i am wrong and you need to add the scripting part to each conditionstate either way.

 

Edit: made a mistake it should be

ParseCondStateType="NORMAL"

ConditionsYes="UNDERPOWERED">

 

and not

 

ParseCondStateType="UNDERPOWERED">

 

as i stated above

Edited by Ravendark

Share this post


Link to post

Is there even a subobject called TV?

  • Upvote 1

Share this post


Link to post

Iirc there was textures that have TV in it (I had to reskin it two week ago) don't recall if there's object though

 

Better take a look at it again

Edited by Egozi44

Share this post


Link to post

Is there even a subobject called TV?

yes, for both the emissary and outpost

Edited by someguy11

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×