Jump to content


Photo

Ganon's Coding Questions


  • Please log in to reply
67 replies to this topic

#1 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 19 August 2010 - 11:32 AM

I wanted to make the AI more challenging without editing the AI, If that makes sense. ;)
Now then, I made it so that If I'm playing against a Hard Army, then each faction would have their own particular "type" of upgrade that their units start with.
For example:
Gondor's units start with Heavy Armor
Rohan's units start at Rank 2 and their cavalry start with Horse shields
Isengard's units start with Forged Blades
And Mordor's archers start with Fire Arrows

Here's an example of the code.
[codebox](In GondorHordes.ini)
Behavior = StatusBitsUpgrade ModuleTag_ProductionLegality2
TriggeredBy = Upgrade_GondorHeavyArmor Upgrade_TechnologyGondorHeavyArmor
RequiresAllTriggers = Yes
End

Behavior = StatusBitsUpgrade ModuleTag_ProductionLegality3
TriggeredBy = Upgrade_HardAIMultiPlayer
End

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
(In GondorInfantry.ini)
Behavior = ArmorUpgrade ArmorUpgradeModuleTag
TriggeredBy = Upgrade_GondorHeavyArmor
ArmorSetFlag = PLAYER_UPGRADE
;KillArmorUpgrade = Yes ;This cancels any previous armor upgrade.
End

Behavior = ArmorUpgrade ArmorUpgradeModuleTagFromHardAI
TriggeredBy = Upgrade_HardAIMultiPlayer
ArmorSetFlag = PLAYER_UPGRADE
;KillArmorUpgrade = Yes ;This cancels any previous armor upgrade.
End

Behavior = SubObjectsUpgrade Armor_Upgrade
TriggeredBy = Upgrade_GondorHeavyArmor
UpgradeTexture = GUManAtArms.tga 0 GUManAtArms_HA.tga
RecolorHouse = Yes
ExcludeSubobjects = Forged_Blade
End

Behavior = SubObjectsUpgrade Armor_UpgradeFromHardAI
TriggeredBy = Upgrade_HardAIMultiPlayer
UpgradeTexture = GUManAtArms.tga 0 GUManAtArms_HA.tga
RecolorHouse = Yes
ExcludeSubobjects = Forged_Blade
End[/codebox]


Now, in terms of the system, this works. You can definitely tell that they have Heavy Armor, as it takes a heck of a lot to kill them.
But visually, the heavy armor texture dosen't show.

Now, the curious thing is that if a unit dies, but the horde survives, and has rank, when the dead units are respawned by the banner carrier, they come to life with the Heavy Armor texture.
So you end up with a horde where half of the units look like they have Heavy Armor, and the other half don't. But in reality, they ALL DO.

I'm pretty sure that it's because the code isn't made to have units that start with upgrades.

(I already tested making Gondor soldiers start with Forged Blades and that displays fine.)

But I was wondering if anyone knows a workaround for this. :p

Edited by Ganon, 10 September 2011 - 07:28 PM.


#2 _Haldir_

_Haldir_

    Mapper

  • Project Team
  • 1,203 posts
  • Location:Australia
  • Projects:The Dwarf Holds, The Elven Alliance: Community Edition
  •  T3A Team Chamber Member

Posted 21 August 2010 - 02:22 AM

I'm not a coder, but is this line right?

UpgradeTexture	= GUManAtArms.tga 0 GUManAtArms_HA.tga

What if you just change it to "= GUManAtArms_HA.tga"?

You could possibly do it with scripting, though i've never tried it myself. If you have a look at this post, you might be able to use those conditions to give units their upgrades.

However, i'm not sure how you might get it to work for every unit that is built rather than specific units. You'd probably have to use a "Counter" script that is constantly evaluating. Also, if this was for a mod, rather than a single map, you'd have to copy the scripts for each map in the game.

Posted Image Posted Image


#3 Lauri

Lauri

    Old man Lauri

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

Posted 21 August 2010 - 11:43 AM

It's correct Haldir :thumbsupsmiley:

as for the OP.. no idea, sorry..

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#4 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 21 August 2010 - 11:53 AM

Well the line should be right cause I didn't change anything other than what upgrade would be needed to switch over to the Heavy Armor texture.

I'll try removing "GUManAtArms.tga" like you suggested so that it looks like this:
Behavior = SubObjectsUpgrade Armor_Upgrade
		TriggeredBy		= Upgrade_GondorHeavyArmor
		UpgradeTexture	= GUManAtArms.tga 0 GUManAtArms_HA.tga
		RecolorHouse	= Yes
		ExcludeSubobjects = Forged_Blade
	End

	Behavior = SubObjectsUpgrade Armor_UpgradeFromHardAI
		TriggeredBy		= Upgrade_HardAIMultiPlayer
		UpgradeTexture	= GUManAtArms_HA.tga;GUManAtArms.tga 0 
		RecolorHouse	= Yes
		ExcludeSubobjects = Forged_Blade
	End

I think i'm going to avoid dealing with scripting as I don't have any experience with it. Also because as you said, I would have to edit the scripts on every map.
Although I might look into it as a last resort. ^_^

Edit:...Well I tried removing "GUManAtArms.tga" and that didn't work either :thumbsupsmiley:

Edited by Ganon2020, 31 October 2010 - 04:04 PM.


#5 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 21 August 2010 - 12:21 PM

If only there was a way that you could make it so that upgrades are granted a short time after an object is built, because that would essentially be the same thing as buying the original upgrade. I'm sure it would display then.

I have an idea that would work but it would take a long time and I'll end up editing the AI anyway :thumbsupsmiley:
The idea is this:
1. First, make a copy of GondorFighter in GondorInfantry.ini
2. Rename the copy GondorHeavyArmorFighter and make this fighter so that it only uses the Heavy Armor texture.
3. Make a copy of the GondorFighterHorde (using the same steps as above) that uses the GondorHeavyArmorFighter
4. Create the proper commandsets and commandbuttons to make this new horde.
5. Put a commandset upgrade behavior on the Gondor Barracks, such as this:
Behavior = CommandSetUpgrade ModuleTag_HardAICommandSetUpgrade
		  TriggeredBy = Upgrade_HardAIMultiPlayer
		  CommandSet = GondorBarracksHardAICommandSet
	 End
6. Then finally edit the AI so that it can use this new commandset, specifically the new button that makes the new horde.

Now then, before I go through all this trouble, does anyone see any flaw in this plan? ^_^

Edited by Ganon2020, 21 August 2010 - 12:42 PM.


#6 Spartan184

Spartan184

    :)

  • Project Team
  • 1,592 posts
  • Location:Moon
  • Projects:Random Modding Projects
  •  Coder, Map.ini Coder, Mapper, and Beta Tester

Posted 21 August 2010 - 04:03 PM

Isn't their a tut on how to do this? Here I found it :thumbsupsmiley:


 

safsignature.png

 


#7 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 21 August 2010 - 11:08 PM

I've seen GrantUpgradeCreate behaviors before, I think EA used them on the Rohan and Gondor Wells to fix a bug where the well's discount would be given multiple times, every time the well rebuilt itself.
I thought about it but I didn't remember exactly how it worked so I didn't know if I could apply it in this situation, I'll try it.

Edit: Actually now that I've gone back and looked at it, I don't think I can use it. The way this Behavior works, is that when the object is fully built, it grants a particular upgrade.
Meaning that it won't discriminate between Hard AI, and a Human player, let alone Easy or Medium AI.
That would make ALL Gondor units have Heavy Armor. I want only the Hard AI to get Heavy Armor automatically.

I could try something like this, but I don't think the INI Parser will recognize the "TriggeredBy" field on this particular Behavior.
Behavior = GrantUpgradeCreate ModuleTag_GrantUpgradeCreate
		UpgradeToGrant = Upgrade_GondorHeavyArmor
		TriggeredBy = Upgrade_HardAIMultiPlayer
	End

Edit:...Yep, just tried it, it doesn't recognize "TriggeredBy". It would help if I knew what kind of fields I can use on this Behavior.
"UpgradeToGrant" may be the only one that will work.

Edited by Ganon2020, 21 December 2010 - 02:10 PM.


#8 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 22 August 2010 - 12:16 AM

Why not just copy the line that gives the HA upgrade, change the upgrade to the Upgrade_HardAIMultiPlayer and you should get the effect you want :umad:
Also dont forget to rename the Modules!

Edited by Ridder Geel, 22 August 2010 - 12:17 AM.

Ridder Geel

#9 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 22 August 2010 - 11:31 AM

If you look at my first post, you'll see that's what I did, but unfortunately if a unit is coded to start with Heavy Armor, the texture for it doesn't show. They look like regular troops.

Edited by Ganon2020, 21 December 2010 - 02:11 PM.


#10 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 31 October 2010 - 02:46 PM

Does anyone know which summon enum's can be used anywhere?

I think the ones used with the AOTD summons can be used most places, for example, inside an enemy's base.
But I was wondering if there were others.

Edited by Ganon2020, 01 November 2010 - 11:46 AM.


#11 Lauri

Lauri

    Old man Lauri

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

Posted 31 October 2010 - 03:10 PM

Is it the enum that determines that?

Huh... well in that case, I'd say AotD, or Aragorns mini-AotD..

T4A_Logo_-_article.png

The 4th Age version 0.8 has been released: Link


#12 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 31 October 2010 - 03:56 PM

Yeah, it's the enums that determine that.
For example, I was using the Elven summon enum, and it wouldn't let me summon something in my base. So I changed to the AOTD one and it worked.

So does anyone else know of any others?
...And actually, you might even be able to use a non-summon enum, such as the "Heal" one, on a summon. I haven't tried that.

Edited by Ganon2020, 31 October 2010 - 04:14 PM.


#13 Nertea

Nertea

    ...lo sa raptor!

  • Hosted
  • 3,349 posts
  • Location:Vancouver, Canada
  • Projects:Star Villains and Space heroes, The Dwarf Holds
  •  T3A Chamber Member
  • Division:BFME/Unity

Posted 01 November 2010 - 11:07 PM

The Palantir vision enum is the one you're looking for, it lets you summon pretty much anywhere.

sig.png
I really don't do requests and my Arnor Soldier is not fit for BFME. Don't ask me for either.


#14 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 20 December 2010 - 06:32 PM

Does anyone know how important Hero Sort Order is?
Or what it does?

#15 clank234

clank234

    The guy who is always on the forums :)

  • Members
  • 489 posts
  • Location:England
  • Projects:Scaled war in the South
  •  coder, skinner, modeler, a lot of help from Ridder Geel and Kwen :)

Posted 20 December 2010 - 07:08 PM

maybe it's the order of how ai uses hero's
I'm taking a guess :dry:
"Strayed by the little and it will fail" ~ Galadriel

"So do all you live to see such times, but all we have to decide is what to do with the time that is given to us" ~ Gandalf

"Many that live deserve death, and some that die deserve life" ~ Gandalf

"Men, men are weak" ~ Elrond

"Then i will die as one of them" ~ Aragorn

"Certaincy of death, small chance of success. What are waiting for?" ~ Gimli

"How about dying side by side with a friend" ~ Legolas

"War will make corpses of us all" ~ Faramir


-------------------------------------
Posted Image

#16 Kwen

Kwen

    Vileartist

  • T3A Staff
  • 4,865 posts
  • Location:Korea I wish
  • Projects:It'sa secreeet
  •  T3A's First N00b
  • Division:BFME
  • Job:T3A Expert
  • Donated

Posted 20 December 2010 - 07:34 PM

That's actually a valid guess. Seems logical, there are many bits of code that reference hardcoded things, this could be one of them.

                           https://www.twitch.tv/vileartist - Yes shameless self-promotion

          ----------------------------------------------------------------------------------------------------------------------

                            "Old modders never die, they just fade away" ~ Hostile


#17 clank234

clank234

    The guy who is always on the forums :)

  • Members
  • 489 posts
  • Location:England
  • Projects:Scaled war in the South
  •  coder, skinner, modeler, a lot of help from Ridder Geel and Kwen :)

Posted 20 December 2010 - 08:24 PM

It's sais it in the name really. Hero (the hero) Sort (in order) Order (what order it's put in)
"Strayed by the little and it will fail" ~ Galadriel

"So do all you live to see such times, but all we have to decide is what to do with the time that is given to us" ~ Gandalf

"Many that live deserve death, and some that die deserve life" ~ Gandalf

"Men, men are weak" ~ Elrond

"Then i will die as one of them" ~ Aragorn

"Certaincy of death, small chance of success. What are waiting for?" ~ Gimli

"How about dying side by side with a friend" ~ Legolas

"War will make corpses of us all" ~ Faramir


-------------------------------------
Posted Image

#18 Kwen

Kwen

    Vileartist

  • T3A Staff
  • 4,865 posts
  • Location:Korea I wish
  • Projects:It'sa secreeet
  •  T3A's First N00b
  • Division:BFME
  • Job:T3A Expert
  • Donated

Posted 20 December 2010 - 08:42 PM

Well yes I know that, but it doesn't say what it's used for. Which is his question.

                           https://www.twitch.tv/vileartist - Yes shameless self-promotion

          ----------------------------------------------------------------------------------------------------------------------

                            "Old modders never die, they just fade away" ~ Hostile


#19 DeeZire

DeeZire
  • Members
  • 140 posts

Posted 20 December 2010 - 08:44 PM

Does anyone know how important Hero Sort Order is?
Or what it does?


It's technically ignored but still parsed, I answered this one here - http://forums.revora...topic=76023&hl=

EDIT: ack my bad, I answered it for BFMEII AND BFMEI, it does work as it should in BFMEI but the answer is there all the same.

Edited by DeeZire, 20 December 2010 - 08:47 PM.


#20 Ganon

Ganon

    What's this?

  • Project Team
  • 967 posts
  • Location:Ohio, United States
  • Projects:My Link Mod
  •  Code Scientist

Posted 21 December 2010 - 01:20 PM

...So, basically, all it does is determine which portrait will be shown in the palantir when you have multiple heroes selected?

I know it has nothing to do with the order that the heroes appear when you have a citadel selected, and that it's actually determined by the BuildableHeroesMP in playertemplate.ini, as I've already tested that before.

And I already knew the importance of VoicePriority.

All that leaves, is which portrait appears.
...And maybe some other things I'm not thinking about.

Anyway, so does a hero actually need that in their code?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users