Jump to content


Photo

Making a button usable only when a Certain Hero is present ?

hero command button horde units usable present

  • Please log in to reply
2 replies to this topic

#1 Rider of Rohan

Rider of Rohan

    The Lazy Modder

  • Division Leaders
  • 1,554 posts
  • Location:The Caribbean
  • Projects:Age of the Ring and the HD Editions
  •  Mathijs' Bug fix expert
  • Division:BFME
  • Job:T3A Leader

Posted 29 April 2013 - 11:08 PM

Ok so, 

I want to know if it is possible to make a unit production button (, in this case the Gondor Ranger's own, ) only usable when Faramir is present and the Archery Range is on Level 3? If so, how would I do this ? Thank You in advance :) !


99dxc486ltde132zg.jpgh5je9noaofg3o26zg.jpg

No parent should have to bury their child - King Theoden


#2 Lauri

Lauri

    Let us remember foREVer

  • Hosted
  • 10,419 posts
  • Location:Norway
  • Projects:'The 4th Age' and 'Shadow and Flame'
  •  The very worst T3A Team Chamber Member

Posted 30 April 2013 - 01:44 AM

Via scripting in WB it's quite easy, but other than that.. I can think of a way, but I'm not sure if it'll work:

 

faramir.ini:

Give him a Leadership power that only affects the GondorArcherRange object:

Behavior = AttributeModifierAuraUpdate ModuleTag_LeadershipArcheryRange
	StartsActive	= Yes
	BonusName	= GondorFaramirRangerRequirement
	RefreshDelay	= 2000
	Range		= 200
	ObjectFilter	= NONE +GondorArcherRange
End	

Change the range as you see fit. I sometimes have troubles with the NONE filter, but I think it usually works when I use Object names as opposed to KindOfs.

 

 

attributemodifier.ini:

Well:

ModifierList GondorFaramirRangerRequirement
    ModelCondition = ALTERNATE_FORMATION
    Modifier = RESIST_FEAR 100%
    Modifier = PRODUCTION 500%
End

I don't think you have to have a Modifier, but it doesn't hurt to have one just in case, especially since it's harmless (buildings don't have fear). Also, the PRODUCTION value is there for you to check if the leadership works in game at all. Archer would be coming out 5x as fast as usual if it does, so you can remove it after you confirm it.

 

 

commandbutton.ini:

Change the Ranger's build button by doing two things: Remove the line NeededUpgradeAny = Yes. Then add an aditional upgrade to the NeededUpgrade. Call it, Upgrade_GondorArcheryRangeFaramirNear. It should then look like this:

NeededUpgrade		= Upgrade_GondorArcheryRangeLevel3 Upgrade_GondorArcheryRangeFaramirNear

 

 

archerrange.ini:

Here lies the fun part. You MAY have to add a dummy ModelConditionState, which is adressed in the attributemodifier. I'm not 100% sure if you need this, so you should save it for last. Alternativly, you could add it regardless, and make the Model a weird one to see if it works (the barracks model for instance). That's probably the best thing to do:

ModelConditionState   = ALTERNATE_FORMATION
	Model               = None
End

In the AIUpdateInterface, add a AILuaEventsList, so it looks like this:

Behavior = AIUpdateInterface ModuleTag_SoWeCanUseWeapon
	AutoAcquireEnemiesWhenIdle	= Yes
	MoodAttackCheckRate		= 250
        AILuaEventsList                 = GondorArcherRangeFunctions
End

 

 

scriptevents.xml:

Add these where appropriate:

 

<ModelConditionEvent Name="FaramirNear">
	<Conditions>+ALTERNATE_FORMATION</Conditions>
</ModelConditionEvent>
<ModelConditionEvent Name="FaramirAway">
	<Conditions>-ALTERNATE_FORMATION</Conditions>
</ModelConditionEvent>
<EventList Name="GondorArcherRangeFunctions" Inherit="BaseScriptFunctions">
        <EventHandler EventName="OnCreated"		ScriptFunctionName="OnGondorArcheryRangeCreated"			DebugSingleStep="false"/>
	<EventHandler EventName="FaramirNear"		ScriptFunctionName="OnGondorArcheryRangeFaramirNear"			DebugSingleStep="false"/>
	<EventHandler EventName="FaramirAway"		ScriptFunctionName="OnGondorArcheryRangeFaramirAway"			DebugSingleStep="false"/>
</EventList>

 

scripts.lua:

Add these:

function OnGondorArcheryRangeCreated(self)
	ObjectGrantUpgrade( self, "Upgrade_GondorArcheryRangeDefault" )
end
function OnGondorArcheryRangeFaramirNear(self)
	ObjectRemoveUpgrade( self, "Upgrade_GondorArcheryRangeDefault" )
	ObjectGrantUpgrade( self, "Upgrade_GondorArcheryRangeFaramirNear" )
end
function OnGondorArcheryRangeFaramirAway(self)
	ObjectRemoveUpgrade( self, "Upgrade_GondorArcheryRangeFaramirNear" )
	ObjectGrantUpgrade( self, "Upgrade_GondorArcheryRangeDefault" )
end

 

 

upgrade.ini:

Well, add all upgrades that we've talked about :p

 

Upgrade Upgrade_GondorArcheryRangeDefault
    Type            = OBJECT
End
Upgrade Upgrade_GondorArcheryRangeFaramirNear
    Type            = OBJECT
End

 

I don't think I've forgotten anything, so you should try it out. I haven't tried myself, as I'm rather busy with a couple of exams this week. The only trouble I can guess would be to get the Archery Range to change it's ModelConditionState.


Shadow and Flame BETA 0.6 RELEASED - Link


#3 Rider of Rohan

Rider of Rohan

    The Lazy Modder

  • Division Leaders
  • 1,554 posts
  • Location:The Caribbean
  • Projects:Age of the Ring and the HD Editions
  •  Mathijs' Bug fix expert
  • Division:BFME
  • Job:T3A Leader

Posted 30 April 2013 - 07:57 PM

Ok, I'll try it when I can, got some Chem to worry about at the moment.


99dxc486ltde132zg.jpgh5je9noaofg3o26zg.jpg

No parent should have to bury their child - King Theoden






Also tagged with one or more of these keywords: hero, command, button, horde, units, usable, present

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users