The 3rd Age

Broken Sword: Expansion Pack

Broken Sword: Expansion Pack

New Heroes, new Factions, new Maps,... a new world is waiting.

Button for The 3rd AgeButton for The Dwarf HoldsButton for The Elven AllianceButton for Helm's Deep Last HopeButton for GothmogtheOrcButton for BFME+Button for The Four AgesButton for HDR HeadquartersButton for Middle Earth CenterButton for Project Perfect Mod

Become an affiliate!

   

Quick Lists

Top Rated Popular New Updated Last Comments Users

Register and log in to move these advertisements down

An Easy Way to Hide SubObjects Using Scripts

Avatar of modboy451

modboy451

Category: Code
Level: Intermediate
Created: Friday January 14, 2011 - 15:05
Updated: Saturday February 19, 2011 - 14:58
Views: 5165
Summary: Ever Need Hid a Forged Blade for a unit or hero???

Rating

Staff says

3.0

Members say

-

Average

3.0/5.0

1 vote

One Day I was looking in and out of a units ini....i was wondering how units hide a subobject (like forged blades or fire arrows)

i looked in and out...up and down...all around several different units ini's
I couldn't find anything to make them hide...untill today i was sifting through scipts.lua and found a scripts that was referenced through a couple files to finally end up in the units ini!!!
here i will list how it works...

to set the theme here I'm going to be using my new Hero
My new has two knives like the corsair...but and 2 forge blades that im using for a special power...now i want to hide them...

open up Data1.Big

and go to scripts.lua
and look for

              
Code

function OnMordorCorsairCreated(self)
ObjectHideSubObjectPermanently( self, "Forged_Blade", true )
ObjectHideSubObjectPermanently( self, "Forged_Blade01", true )
end


my hero has then two forged blades named FORGED_BLADE and FORGED_Blade01 beacause i copied them from the corsair...

now as you can plainly see the "OjectHideSubObjectPermantly( self "blablabla", true) scripts says hide this object in the model...

but where does this Reference in the units ini???
you can look all around and you won't find it...but you will find this
i'll use the wildman axeman for example:
              
Code

Behavior = AIUpdateInterface ModuleTag_03
AutoAcquireEnemiesWhenIdle = Yes ATTACK_BUILDINGS
MoodAttackCheckRate = 500
AILuaEventsList = IsengardWildmanFunctions ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
BurningDeathTime = BURNINGDEATH_DURATION_INFANTRY
End


AILuaEveltsList Entry is a reference scriptevents.xml which is also in data1.big

open that up and search for:(im going to use the corsairs functions)

              
Code

<EventList Name="MordorCorsairFunctions" Inherit="InfantryFunctions">
        <!-- This contains events specific to the Gondor Fighter horde member. jba -->
<EventHandler EventName="OnCreated"                ScriptFunctionName="OnMordorCorsairCreated" DebugSingleStep="false"/>
<EventHandler EventName="RecoverFromTerror"        ScriptFunctionName="GondorFighterRecoverFromTerror"                DebugSingleStep="false"/>
<EventHandler EventName="BeAfraidOfGateDamaged" ScriptFunctionName="GondorFighterBecomeAfraidOfGateDamaged"        DebugSingleStep="false"/>
</EventList>



the OnMordorCorsairCreated is a Link to the scripts.lua!

which is the same thing that tell them to hide the sub objects...

so to sum it up...
if i want to do make it so a unit would hide the FORGED_BLADE and FORGED_BLADE1 sub-objects
i would either make a script in scripts.lua
like:

              
Code
function OnYourUnitCreated(self)
ObjectHideSubObjectPermanently( self, "Forged_Blade", true )
ObjectHideSubObjectPermanently( self, "Forged_Blade01", true )
end


and reference that in the a scriptentry in scriptevents.xml

              
Code

<EventList Name="YourUnitFunctions" Inherit="InfantryFunctions">
        <!-- This contains events specific to the Gondor Fighter horde member. jba -->
<EventHandler EventName="OnCreated"                ScriptFunctionName="OnYourUnitCreated" DebugSingleStep="false"/>
<EventHandler EventName="RecoverFromTerror"        ScriptFunctionName="GondorFighterRecoverFromTerror"                DebugSingleStep="false"/>
<EventHandler EventName="BeAfraidOfGateDamaged" ScriptFunctionName="GondorFighterBecomeAfraidOfGateDamaged"        DebugSingleStep="false"/>
</EventList>



and put that in your unit ini in this line:
              
Code

AILuaEventsList = YourUnitFunctions




AND THERE YOU HAVE IT!

Credits

Laurifor letting me know that it works for BFME 1

Comments

Display order: Newest first

Lauri (Team Chamber Member) - Monday January 17, 2011 - 15:49

It works for BFME1

I voted a 3 because you're explaining some things at all.. like what tells scriptevents.xml to use something from scripts.lua (Like OnCreated)
NOTE; I already know all this, but for people that are newer than you, it's easier for them if you explain better
Also, get rid of Page 2.. it's empty.

modboy451 - Saturday January 15, 2011 - 9:00

i like it this way better...that way you dont have to but it on every animation....

JUS_SAURON - Friday January 14, 2011 - 16:42

You Don't really need LUA to do this .
BeginScript
    CurDrawableHideSubObjectPermanently("Forged_Blade")
EndScript

Add to the Idle and Selected Anims and it will hide Also

--------

Look at BFME1 Rohan Peasant who hides the Hammer when Drafted
CurDrawableHideSubObjectPermanently("HAMMER")

Go to top

 

"One site to rule them all, one site to find them,
one site to host them all, and on the network bind them."

 
4:16:57