Leader unit Spawning

ImageImageTalking about Modding for EE2 and EE2 AOS. New maps, patches, programs and Multiplayer scenarios.
Post Reply
PaulStretch
Posts: 37
Joined: 27 Jun 2021, 16:10
Has thanked: 15 times
Been thanked: 1 time

Leader unit Spawning

Post by PaulStretch »

I'm trying to figure out what effect or script spawns leaders. I searched through files related to crowns are unitype area effects and didn't see anything that makes the leaders spawn.

User avatar
Dr.MonaLisa
High Representative
Posts: 8182
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 17 times
Been thanked: 25 times

Re: Leader unit Spawning

Post by Dr.MonaLisa »

I moved this topic to "EE2 files, modding, maps, testing, etc." as this is a modding / designing related subject.

Awarding Leaders is most likely hardcoded. It's done by the game engine on receiving the crown.
However, you could use the "EffectSpawn" area effect to maybe create an UnitType of the Leader? That should do the trick.

Example area effect with spawning:

Code: Select all

// Immigration
DbAreaEffectInfo Immigration
{
	name = text_carea_immigration_name
	desc = text_carea_immigration_desc
	
	bSkipKingOfTheHillUnit = true
	
	effects = [
		EffectSpawn {
			range = Global
			mask = CityCenters
			player = Self
			
			delay = 90	// how many seconds until next spawn time.
			minCount = 3;	// how many units (minimum) to spawn when the time comes
			maxCount = 3;	// how many units (maximum) to spawn when the time comes
			unitTypes = [ "Citizen" ]; // what kind of units to spawn
			showImmigrationMsg = true;
		}

		EffectVisualGlow {
			SuppressGlow = true // don't show the glow
			range = Global
			mask = CityCenters
			player = Self
			GlowType = Good
			OwnerOnly = true
			Icon = icon_crown_immigration_s
			Tooltip = tt_power_Immigration
			VTooltip = vtt_power_unitinfo_Immigration
		}
		EffectIsACrown {
			range = Global
			mask = CityCenters
			player = Self
			
			crownType = kCrownType_Economic
		}
	
	]
}
Could be changed to:

Code: Select all

EffectSpawn {
			range = Global
			mask = CityCenters
			player = Self
			delay = 999	// how many seconds until next spawn time.
			minCount = 1;	// how many units (minimum) to spawn when the time comes
			maxCount = 1;	// how many units (maximum) to spawn when the time comes
			unitTypes = [ "LeaderMilitary" ]; // what kind of units to spawn
			showImmigrationMsg = false;
		}
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
PaulStretch
Posts: 37
Joined: 27 Jun 2021, 16:10
Has thanked: 15 times
Been thanked: 1 time

Re: Leader unit Spawning

Post by PaulStretch »

The one issue with it is, the counter resets every time you load a save. So another leader would spawn every time you start a save. Maybe if this is used as a sub effect that has a trigger, It would prevent this? On side note, Is there is no way of messing with the core files of the game? it seems like everything is packed into DLL files. Also thanks
User avatar
Dr.MonaLisa
High Representative
Posts: 8182
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 17 times
Been thanked: 25 times

Re: Leader unit Spawning

Post by Dr.MonaLisa »

I am not sure how it would behave as a sub-effect, but you could try it. I would recommend you to check my AntiMissile effects to see how it works. ICBMs have an effect that infects anti-missile units to give them attack range. It's to fix a bug where game drastically slows down when there are many anti-missile units. So to fix it, I made it have range 0 and only increase the range when an ICBM is near. Also, with the area effects I infect close anti-missile units to prevent attacking. Thanks to this, anti-missiles won't fire all at 1 target, but will intercept much more incoming ICBMs. That system was done fully with area effect, so even I am impressed of myself.

Anyway, talking about the "hardcoded" stuff, it's in game executables. You can see the procees of applying one fix by assembly on this video:



In short: it's a complicated process, and learning it would take years. So I'm trying to only focus on very important fixes to apply this way, but I never recommend this method for normal modifications.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
These users thanked the author Dr.MonaLisa for the post:
PaulStretch
PaulStretch
Posts: 37
Joined: 27 Jun 2021, 16:10
Has thanked: 15 times
Been thanked: 1 time

Re: Leader unit Spawning

Post by PaulStretch »

lol referencing memory addresses directly, that's def beyond my abilities. The ICBM fix reminds me of an effect I wanted to create. I wanted to introduce power plants as a building type that increased the effects of production and bonus buildings, but some bonus buildings, such as "internet_data_servers" should not provide a benefit if there is no power plant. So I thought using "infect" would ensure that the data server building would only have and effect if it was "infected" by the power plant. I've yet to look more into this specifically, but your video might help me out.
User avatar
Dr.MonaLisa
High Representative
Posts: 8182
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 17 times
Been thanked: 25 times

Re: Leader unit Spawning

Post by Dr.MonaLisa »

Oh, no. That video won't show area effects. It's a totally different fix in assembly only. Don't waste time watching it :)
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
These users thanked the author Dr.MonaLisa for the post:
PaulStretch
PaulStretch
Posts: 37
Joined: 27 Jun 2021, 16:10
Has thanked: 15 times
Been thanked: 1 time

Re: Leader unit Spawning

Post by PaulStretch »

lol oh okay. I'm still curious though. Thanks for the prompt reply
Post Reply

Return to “EE2 files, modding, maps, testing, etc.”