Jump to content


Photo

Forbidding the purchase of an upgrade after another specific upgrade has been purchased


  • Please log in to reply
10 replies to this topic

#1 druchii22

druchii22

    WotR Coder

  • Project Team
  • 97 posts
  • Location:Switzerland
  • Projects:RJ-RotWK Beta Tester, Battles of the 3rd Age, some other little mods
  •  INI Coder

Posted 28 April 2012 - 02:09 PM

Hello guys,

I have a question that troubles me : I'm working on some coding right now, which aims to offer the player a few "choices" in the pruchase of technology. But I can't find which codes would do it. For exemple, I added to a porter's commandset two buttons, each one related to an upgrade (more money or more defense to make it simple). What I'd like to do, is that when I purchase one of them, then the other grays out (not sure if it's the word in english). I've tried with the "ConflictsWith = Upgrade_X" code, but it doesn't work. I could tie it to an upgraded commandset, but I'm sure there must be a simplier way. If anyone has it, I'd be glad to know!

Thank you.

Posted Image
Posted Image


#2 Ridder Geel

Ridder Geel

    Master Yelloh

  • T3A Staff
  • 10,852 posts
  • Location:The Netherlands (AKA: Holland)
  • Projects:RC Mod + SEE + RTS Engine
  •  The Dangerous T3A Team Chamber Member
  • Division:BFME
  • Job:T3A Staff

Posted 28 April 2012 - 02:18 PM

Have an upgrade that enables the researching of all the options. After researching the upgrade you want the new upgrade you get removes the "basic" upgrade, thus disabling the other buttons.
Behavior = RemoveUpgradeUpgrade Remove_Upgrades_trolololol
    TriggeredBy        = Upgrade_somethingsomthin
    UpgradeToRemove    = Upgrade_something
End

Ridder Geel

#3 Lauri

Lauri

    Old man Lauri

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

Posted 28 April 2012 - 02:42 PM

Here is an edited piece of code from the Gerousia in The Peloponnesian Wars that I made and does what you want;

;-----------------------------------------	Grant Upgrade
	Behavior = GrantUpgradeCreate ModuleTag_WeStartWithoutUpgrades
		UpgradeToGrant = Upgrade_SpartanGerousiaNoFocus
	End
	
;-----------------------------------------	Harvest
	Behavior = ObjectCreationUpgrade ModuleTag_SpartanFocusHarvest_Removes
		TriggeredBy		= Upgrade_SpartanGerousiaFocusHarvest
		RemoveUpgrade	= Upgrade_SpartanGerousiaNoFocus
		GrantUpgrade	= Upgrade_SpartanGerousiaHaveFocus
	End
	Behavior = AttributeModifierAuraUpdate ModuleTag_SpartanFocusHarvest
		StartsActive	= No
		TriggeredBy		= Upgrade_SpartanGerousiaFocusHarvest Upgrade_SpartanGerousiaHaveFocus
		RequiresAllTriggers	= Yes
		BonusName		= SpartaGerousiaFocusHarvest
		RefreshDelay	= 2000
		Range			= 99999999
		ObjectFilter	= ANY -STRUCTURE -INFANTRY -CAVALRY -HERO +SpartanFarm +SpartanFarmMultiplayer +SpartanFarmInterface
	End
;-----------------------------------------	Warfare
	Behavior = ObjectCreationUpgrade ModuleTag_SpartanFocusWarfare_Removes
		TriggeredBy		= Upgrade_SpartanGerousiaFocusWarfare
		RemoveUpgrade	= Upgrade_SpartanGerousiaNoFocus
		GrantUpgrade	= Upgrade_SpartanGerousiaHaveFocus
	End
	Behavior = AttributeModifierAuraUpdate ModuleTag_SpartanFocusWarfare
		StartsActive	= No
		TriggeredBy		= Upgrade_SpartanGerousiaFocusWarfare Upgrade_SpartanGerousiaHaveFocus
		RequiresAllTriggers	= Yes
		BonusName		= SpartaGerousiaFocusWarfare
		RefreshDelay	= 2000
		Range			= 99999999
		ObjectFilter	= ANY -STRUCTURE -INFANTRY -CAVALRY -HERO +SpartaBarracks
	End

Basically, you have to grant the object a starter upgrade from the start, that kinda tells you that it haven't chosen anything yet. Then, when you purchace one of the alternatives, you get it's respective upgrade, but it also removes the I-have-nothing upgrade and grants an I-have-upgrade-now upgrade. That's how you get the ability you want to work (more money or defence), it needs both the More money\defence upgrade AND the upgrade that says I-have-upgrade-now.

And here are the commandbuttons;
CommandButton Command_SpartanGerousiaFocusHarvest
	Command				= OBJECT_UPGRADE
	Options				= CANCELABLE NEED_UPGRADE
	NeededUpgrade		= Upgrade_SpartanGerousiaNoFocus
	Upgrade				= Upgrade_SpartanGerousiaFocusHarvest
	TextLabel			= CONTROLBAR:SpartanGerousiaFocusHarvest
	ButtonImage			= TBSparta_FocusHarvest
	ButtonBorderType	= UPGRADE
	DescriptLabel		= CONTROLBAR:ToolTipSpartanGerousiaFocusHarvest
	Radial				= Yes
	InPalantir			= Yes
	LacksPrerequisiteLabel = TOOLTIP:LackSpartanNoFocus
End

CommandButton Command_SpartanGerousiaFocusWarfare
	Command				= OBJECT_UPGRADE
	Options				= CANCELABLE NEED_UPGRADE
	NeededUpgrade		= Upgrade_SpartanGerousiaNoFocus
	Upgrade				= Upgrade_SpartanGerousiaFocusWarfare
	TextLabel			= CONTROLBAR:SpartanGerousiaFocusWarfare
	ButtonImage			= TBSparta_FocusWarfare
	ButtonBorderType	= UPGRADE
	DescriptLabel		= CONTROLBAR:ToolTipSpartanGerousiaFocusWarfare
	Radial				= Yes
	InPalantir			= Yes
	LacksPrerequisiteLabel = TOOLTIP:LackSpartanNoFocus
End

As you can see, they both need the Upgrade_SpartanGerousiaNoFocus to be purchased. The object you use (porter was it?) starts with this upgrade, so both are avaliable from the start. But, once you purchase one of them, the Upgrade_SpartanGerousiaNoFocus is Removed and the Upgrade_SpartanGerousiaHaveFocus is Granted, so you can't purchase either of them again.

Hope you understand. Obviously, you'll need to change the stuff around (names, attributes, ect..), but you basically need 4 OBJECT upgrades. (Very important that they are in fact OBJECT, not PLAYER)

Here are mine, in case you want to see them too;
Upgrade Upgrade_SpartanGerousiaHaveFocus
	  DisplayName	   = UPGRADE:SpartanGerousiaHaveFocus
	Type			  = OBJECT
End
Upgrade Upgrade_SpartanGerousiaNoFocus
	  DisplayName	   = UPGRADE:SpartanGerousiaNoFocus
	Type			  = OBJECT
	BuildCost		= 0
;	BuildTime		= SPARTA_GEROUSIA_REMOVE_FOCUS_BUILDTIME		   ;- I use this to be able to abandon the upgrade I chose, and choose a new one, so it's got a BuildTime to "remove" the Focus.
;	ResearchCompleteEvaEvent	= UpgradeBannerCarrierTechnologyReady	;- "We are now free to pursue a new focus"
End
Upgrade Upgrade_SpartanGerousiaFocusHarvest
	  DisplayName	   = UPGRADE:SpartanGerousiaFocusHarvest
	Type			  = OBJECT
	BuildCost		= 0
	BuildTime		= SPARTA_GEROUSIA_FOCUS_HARVEST_BUILDTIME
;	ResearchCompleteEvaEvent	= UpgradeBannerCarrierTechnologyReady	;- "We are now focusing on the harvest"
End
Upgrade Upgrade_SpartanGerousiaFocusWarfare
	  DisplayName	   = UPGRADE:SpartanGerousiaFocusWarfare
	Type			  = OBJECT
	BuildCost		= 0
	BuildTime		= SPARTA_GEROUSIA_FOCUS_WARFARE_BUILDTIME
;	ResearchCompleteEvaEvent	= UpgradeBannerCarrierTechnologyReady	;- "We are now focusing on warfare"
End

If you have any questions, don't be afraid to ask!

edit: Fuck you Geel, did I really take that long to write this post? :p

Edited by Lauri, 28 April 2012 - 02:44 PM.

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#4 Ridder Geel

Ridder Geel

    Master Yelloh

  • T3A Staff
  • 10,852 posts
  • Location:The Netherlands (AKA: Holland)
  • Projects:RC Mod + SEE + RTS Engine
  •  The Dangerous T3A Team Chamber Member
  • Division:BFME
  • Job:T3A Staff

Posted 28 April 2012 - 02:54 PM

Ghehe... yes you did :xd:
I summarized it really small, while you included the grant upgrade piece, and perhaps a bit more info :p
Ridder Geel

#5 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 29 April 2012 - 01:14 AM

Hmm .. I've recently done EXACTLY this with a Defense OR Offense upgrade

While the codes above Will work the problem may arise If you click both upgrades at the same time , even if one goes first the other will follow
even if the buttons are greyed out or the upgrade is conflicting ....

Then I realised the battlewagon does exactly this so don't forget

Behavior = ProductionUpdate ProductionUpdateModuleTag
  GiveNoXP = Yes
  MaxQueueEntries = 1 ; only allow one queued upgrade at a time
End

A simle commandset upgrade functions nicely as well

		   Behavior = CommandSetUpgrade ModuleTag_DualWeaponsUpgrade
   TriggeredBy  = Upgrade_IsengardDualWeapons
   CommandSet  = MordoMorgulFighterHordeCommandSetDualWeapons
				 ConflictsWith  = Upgrade_ModorOrcArmour
  End
			 Behavior = CommandSetUpgrade ModuleTag_TorchesUpgrade
   TriggeredBy  = Upgrade_ModorOrcArmour
   CommandSet  = MordoMorgulFighterHordeCommandSetShields
				ConflictsWith  = Upgrade_IsengardDualWeapons
  End

I realised all the other Upgrade codes were not even necc ..as if the button is not there you can't use it

Or maybe this is just another Solution to the ones posted ..Testing all this upgrade stuff is headaching

Edited by JUS_SAURON, 29 April 2012 - 01:17 AM.


#6 Lauri

Lauri

    Old man Lauri

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

Posted 29 April 2012 - 01:30 AM

A simple commandset upgrade will still lead to the problem you pointed out, that if you click on both upgrades then the other will follow even when the commandset is changed. So that won't work.
Haven't thought about the Battlewagon before, might have a look at that piece of code (but if I rememer correct, I don't have any problems with my code)

edit: Unless, perhaps, you combine your two ways; The battlewagon thing to limit to one upgrade being researched, and a commandset trigger on complete. That way, you can't click on two at the same time, and will avoid the problem all together. Huh, never thought of that..

Edited by Lauri, 29 April 2012 - 01:35 AM.

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#7 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 29 April 2012 - 07:14 AM

My thoughts exactly ... Both sets of codes will do the trick

The Max entries bit will only allow one upgrade at a time , you can't even click ( queue ) the other
I was even giving up on the idea when this worked as I was debugging for the Sword Or Shield Upgrade I wanted

#8 druchii22

druchii22

    WotR Coder

  • Project Team
  • 97 posts
  • Location:Switzerland
  • Projects:RJ-RotWK Beta Tester, Battles of the 3rd Age, some other little mods
  •  INI Coder

Posted 29 April 2012 - 09:16 AM

Hello,

Thanks for the answers! I hadn't thought of the ways you pointed out, thanks! I'll try that then. That's such a pain in the ass that'll go away. :crazed:
What about the fact it must be an OBJECT upgrade and not a PLAYER one? In the coding I've already done, they're PLAYER upgrades. What does it change exactly? I've realized that using the "ConflictsWith" you can still purchase the other upgrade, but it won't be effective. But even after discovering that, I wanted the button to be grayed out/disappeared so it's wonderful!

Posted Image
Posted Image


#9 Lauri

Lauri

    Old man Lauri

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

Posted 29 April 2012 - 09:34 AM

If you use JUS_SAURON's method, then you can use a PLAYER upgrade. That wouldn't have worked with mine though (atleast I never got around it).

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#10 Carthaen

Carthaen
  • Members
  • 6 posts

Posted 30 October 2017 - 06:37 PM

Have an upgrade that enables the researching of all the options. After researching the upgrade you want the new upgrade you get removes the "basic" upgrade, thus disabling the other buttons.

Behavior = RemoveUpgradeUpgrade Remove_Upgrades_trolololol
    TriggeredBy        = Upgrade_somethingsomthin
    UpgradeToRemove    = Upgrade_something
End

Hello. Can you help me? Can I disable specialpower after using it with RemoveUpgradeUpgrade?



#11 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 28 November 2017 - 02:03 PM

did you try a commandset change ?

you cant use power if button is not there






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users