Page 1 of 1

Leader unit Spawning

Posted: 09 Jul 2021, 14:23
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.

Re: Leader unit Spawning

Posted: 09 Jul 2021, 20:10
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;
		}

Re: Leader unit Spawning

Posted: 10 Jul 2021, 02:23
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

Re: Leader unit Spawning

Posted: 10 Jul 2021, 02:39
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.

Re: Leader unit Spawning

Posted: 10 Jul 2021, 04:23
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.

Re: Leader unit Spawning

Posted: 10 Jul 2021, 04:25
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 :)

Re: Leader unit Spawning

Posted: 10 Jul 2021, 04:30
by PaulStretch
lol oh okay. I'm still curious though. Thanks for the prompt reply