[MA] SDK and Python

Why will there be 500 unless you have 500 unit types affected.

A more ugly but still simple way.
Use getUpgradePriceOverride to change the upgrade price to 9 million.
No one will have that amount of $ to upgrade :D

The only thing that triggers on upgrade is onUnitCreated, and that will not help you at all.

Lastly, canUpgradeAnywhere this is your last chance, but I confirmed with The_J that it is totally useless function that is most likely a leftover unused code.
 
Yeah, it will affect every single unit.
But if you want it to affect 300 units and 300 units not affected, then they have to have some "common" stuff, else you end up with 600 lines for each and every unit type.

For instance, I want it to affect land units but not naval units, then I can check by domain type.
Or I want it to affect modern era units, but not future era units, then check tech requirements, and check tech era.

Most simple one is, simply affect all, then just change one variable, done
 
Are we talking about changing the upgrade cost? Because if so then no check really necesary since gunpowders units will never be upgraded in a scneario (unless you play for way longer then the scenario is). So no worries about that I would be fine if all were increased

Only question I have is how would you go about doing htis? Is it everyturn you need to change the cost, or is it when a unit is selected or can it be set all the time? Because with a scenario with 1000s of units and already pretty slow I do not want it to be slower
 
Code:
	def getUpgradePriceOverride(self, argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList
		return -1	# Any value 0 or above will be used

Use this and that is it.
When is it called? Ask Jamie, I don't bother to read the SDK to find out
 
I can't be sure when it's called, other than using debug statements. Searching the entire DLL for that function's use may be a wild goose chase
 
Let me talk to jamie on this one but I think it is possible. I can create a carrier-based fighter class. I then can create the Spitfire variant you were talking about as a UU. You can build it just like spitfire, but you can also take a normal spitfire and turn it into the varriant. Basically it would be the same concept as upgrading it - it would cost a bit of money but it would then just turn into that unit.
What do you guys think? Jamie we talked about doing something like this before. Basically it would be a button that would be the exact same as upgrading it. You click the button, it cost money, and the unit changes. (Why not just make it upgrade? Because these are variants of the unit, so you need to built the spitfire first then you can create a variant out of it).

Only question is can this be done on a mass scale? Could there be some 200 variants (obvoiusly not all for the same unit) without any toll on gameplay? Of course AI will not understant to do this, but I am not worried about that. It isnt important they know plus this seems like something that Lemon Merchant can help us with since she told me she is interested in helping with some SDK things
 
not sure If I understand completely. If you try and explain it a bit more I'm sure I would be gald to help!
 
So take the Russian T-55 tank. In the mod many countries can build this tank as a UU for the MBT. But in real life, there are many variants of the T-55, they are not all the same. But I do not want all of the variants to be buildable because to many units and to confusing.

Now lets take one variant of the T-55 called ZSU-57-2. It is a variant that has an Anti-Aircraft Gun on it. I would have another unit called ZSU-57-2 but it is unbuildable.

A civ builds the T-55. Now when they select the unit, a button apears. That button lets them convert it to the ZSU-57-2 variant. When they press that button it deletes that unit and places the ZSU-57-2 unit but with all the same promos etc. (so very similar to upgarding).

I brought this up before with having a cruiser be able to convert to a carrier, it is the exact same concept. The only problem is If I do that for some couple hundred units, it has to check each one everytime a unit is clicked does it not? I do not want hundreds of line of code gone through each time a unit is clicked (since AI is using it I think first a check tke make sure the player is a human would save a lot of lag, so if it is not a human, do not check the code)
 
it's the same priciple as my recycling code. I would add a button to the interface I would have to figure out how to get all the variants but it shouldn't be very code draining at all...
 
It shouldnt if there is just one, but theres already 500 UUs (and counting). I guarentee you atleast 300 of them have 10 variants. Obvoiusly i do not plan in putting in all of those - or even close. But if I did even one for each, you would have to know which button goes on which unit, and just to do that would quiet a bit of code.
What if there was just but one button for all units. And when you pressed that button it then brought up the options for variants? A new screen would be nice but I am sure that is a bit complicated so maybe just some options come up for which one to switch? At that point you have to write some code to check which unit it is and the variants. That would take hundreds of line of code depending on how many variants I put in, but I would write most of it, you would just have to set me up with an example from there its Copy and paste
 
new screen? no problem. Way back when, we had this idea for JRM which was senate missions (yet to be implemented) and one of the rewards was the senate founded a city in a historical spot. A popup would be used to display multiple options. I can do this if I learn the workings of the PyPopup... easy. The only problem is getting the variants. What could be done is we use the SDK to define a new XML tag for units which defines variants of it... I then get it as a list in the popup and append each one via for loop
 
SDK sounds good actually really good.

What I planned on doing was create a bunch of units which would be the varriants, and have them unbuildable then just specifically in python say if unit X, variants is unit Y, Z, W.

Would I have to create units for it? It would be a lot better if I didnt. Im sure you can have the name be in the variant, the only problem is the stat. Would it be easy to move some tags? So the tag would look like this
Code:
<Variants>
[tab]<Variant>
[tab][tab]<Name>X</Name>
[tab][tab]<iCombat>1</iCombat>
[tab][tab]<iMoves>2</iMoves>
[tab]</Variant>
[tab]<Variant>
[tab][tab]<Name>Y</Name>
[tab][tab]<iCombat>3</iCombat>
[tab][tab]<iHillsAttack>10</iHillsAttack>
[tab]</Variant>
</Variants>
I dont think you can do that but might as well ask. Basically copy the tags and make them optional to be there, so whichever tags are needed for the variant you can place in there and then when the variant is created, it changes what is in there? The optional tags are okay if they arent optional and need to be there
 
problem lies within the tags I'm afraid even the Name. The Name might be possible to do (but the original type would still be there just like a great general). I think you would have to make the variant units my hand I'm afraid. Then when the python button is pushed the PyPopup lists the variants under the Variants tag and the unit is converted when a selection is made

also by happy coincidence the method I will use for the conversion of units also carries over all promotions etc :D
 
Only question is can this be done on a mass scale? Could there be some 200 variants (obvoiusly not all for the same unit) without any toll on gameplay? Of course AI will not understant to do this, but I am not worried about that. It isnt important they know plus this seems like something that Lemon Merchant can help us with since she told me she is interested in helping with some SDK things

This is the most important point.
The upgrade system, AI understands fully.
It knows when it should spend the gold to upgrade because the upgraded unit may suit its needs more.

This new system without AI is totally screwing the AI up.
It does not know why it should convert to new unit, and chances are without codes, they will never even use the new system.
 
BUt lemonmerchant can help!

Anyway on the isGraphicalOnly() there is a wierd problem... There is no xml field for it though it appears to read it? I can add a field to the XML and hook it up to the method (it always returns false atm) then it will work..
 
It wasn't working for buildings as well, but I just add it to the building schema without bothering to do anything to SDK, and it works lol, so I guess it should work for units as well.

But the main question to the upgrade thing is, why dump a working system with AI fully implemented and make your own system without AI and mess with SDK etc
 
Because its not really upgrading it. Its more just changing it. You hten need to make sure that the original unit is able to be built, the others arent. IT doesnt show up in the upgrade graph, and make sure the unit is not being able to be built after it is outdated.

I mean i guess most of the problems could be solves if there is a way to hide it in the upgrade graph
 
Top Bottom