Jump to content


Photo

Hid subobject after toggling weapon


  • Please log in to reply
1 reply to this topic

#1 bluegreenblack

bluegreenblack
  • New Members
  • 4 posts

Posted 08 September 2022 - 09:09 PM

Is there a way to edit an units ini file so that they will say hide their bow and quiver when toggling to sword state?

#2 Lauri

Lauri

    Old man Lauri

  • Hosted
  • 10,436 posts
  • Location:Norway
  • Projects:The 4th Age
  •  The very worst T3A Team Chamber Member

Posted 15 September 2022 - 06:44 PM

Yes, if the model allows it, but you'll need to use scripts. The model has to have a separate model for the bow and quiver, otherwise it won't work.

 

Here's a look at what I use in T4A for a hero that shows and hides a separate shield, depending on if he's using a sword or the bow:

In eoelm.ini (the hero's file)

	Behavior = AIUpdateInterface ModuleTag_03
		AutoAcquireEnemiesWhenIdle = Yes ATTACK_BUILDINGS
		MoodAttackCheckRate        = 500
		HoldGroundCloseRangeDistance = 41
		AILuaEventsList				= EoelmFunctions
	End

In scriptevents.xml

 

<ModelConditionEvent Name="UsingSword">
            <Conditions>+WEAPONSET_TOGGLE_1</Conditions>
</ModelConditionEvent>
<ModelConditionEvent Name="UsingBow">
            <Conditions>-WEAPONSET_TOGGLE_1</Conditions>
</ModelConditionEvent>


<EventList Name="MorgonFunctions" Inherit="BaseScriptFunctions">
<EventHandler EventName="OnCreated" ScriptFunctionName="OnMorgonCreated" DebugSingleStep="false"/>
<EventHandler EventName="UsingSword" ScriptFunctionName="OnMorgonSword" DebugSingleStep="false"/>
<EventHandler EventName="UsingBow" ScriptFunctionName="OnMorgonBow" DebugSingleStep="false"/>
</EventList>

 

In scripts.lua

function OnEoelmCreated(self)
	ObjectHideSubObjectPermanently( self, "SHIELD", true )
end 
function OnEoelmSword(self)
	ObjectHideSubObjectPermanently( self, "SHIELD", false )
	ObjectHideSubObjectPermanently( self, "SHIELD_BACK", true )
end 
function OnEoelmBow(self)
	ObjectHideSubObjectPermanently( self, "SHIELD", true )
	ObjectHideSubObjectPermanently( self, "SHIELD_BACK", false )
end

Change SHIELD to SWORD if you want to hide the sword when using the bow, and change SHIELD_BACK to BOW. You'll have to add the same line and change it to QUIVER as well, but again, the model has to have the subobjects on the model for it to work.

 

Sorry about the rush, I don't have time to explain it more in detail right now.


Edited by Lauri, 15 September 2022 - 06:44 PM.

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users