My Mod Components

Mylon

Amateur Game Designer
Joined
Nov 4, 2005
Messages
1,013
Here's a central place for my mod components.

Culture Per Population, Forum thread Download

This component adjusts the culture buildings to give culture based on the population in the city. Now the optimum number of cities for focusing in culture is 1, where before building a few more cities would speed up the acquisition of Social Policies.

Flanking XP, Download

This component awards exp to units that assist an attacker in flanking. Even if a unit is not directly involved in combat they are still passively helping and this rewards that.

Naval Counterattack, Download

This mod allows naval units to fire back when attacked. This is primarily meant to be a test run for allowing land-based ranged units to return fire. There is no melee in naval combat, so it makes sense to test this change on sea first.

Wealth to Happiness boost

This component gives civilizations a bonus to happiness based on the amount of cash in their treasury. Current formula is +1 per (gold / 100 ) ^ 0.7. As of yet unreleased as I'm unsure of how to convey this information accurately to the player.

Comments are appreciated! Feel free to study my code to see how I perform these tasks, or include them in your own modpacks.
 
Nice work! I'm planning to use the Culture per Population code later for a couple of new buildings. The concept makes a great addition :goodjob:
 
About Counterattacking:

According to your lua-code, you don't seem to check for the Attack Range.
What if the other unit doesn't have that reach? It wouldn't be plausible to fight back then.

In general, it sounds nice but on the other hand it turns units into whirling dervishes possibly destroying several weak units in one turn.
No battleship could ever be defeated by several weaker destroyers or possibly submarines which rely on stealthy attacks; at least not with a hefty cost.
 
I tested attack range. A ship with range 3 will not be fired back upon. The way the attack is forced automatically checks for that. It also checks to see if the attacker has attacked already, which is why I needed to unflag the defender as having attacked.

As for the "whirling dervish", this is already the case with land melee units. Get one powerful unit in a strong defensive position and it can devastate many weaker units simply because it gets to defend itself multiple times. I figured this was a pleasant alternative to the current person-to-shoot-first-wins style of vanilla naval engagements. As for submarines, the battleship should only be able to return fire if the battleship can see the submarine. Though to be honest I haven't tested that possibility. The mod is mostly a concept and it does need some evaluation.
 
I'm currently doing a test run with my rampaging Barbarians! mod on a small island map.

My Frigate with two "vs Naval" upgrades just confronted two daring Barbarian Caravels who "thought" it might my cool to damage it safely.
Unfortunately, they had no idea I could counter-attack and both sunk in return. My Frigate got way with only 3 HP lost.

See, that's an example of the AI not knowing how to deal with Ranged attacks. It is not coded to receive damage in return.
You can easily roundhouse kick many units this way without the AI knowning what hit it.
 
You were using a frigate versus a caravel. And they were barbarian units, so you probably had some extra bonuses on top of that. Barbarians are stupid and aren't playing to win, so seeing them suicide is about what they'd do even without this mod. I hardly see what the problem is.

The other side of the coin is without this mod you can charge at an enemy fleet, focus fire 1/2 to 1/3rd of their ships down and when they return fire they have a lot less guns to fire, so you've already won.
 
wow... why are the best mods hidden?

Thanks for the counter attack mod - awesome change that definitely was needed for naval warfare.

One recommendation though - Perhaps the counter-attacking unit should only be allowed to return fire at 50% strength. This still gives the attacker the advantage by engaging first (surprise effect) and reflects 'superior positioning', while still ensuring that it isn't a 'risk free' attack.


Can't wait for this to be added to landbased artillery - though judging by the date of last post, i might be waiting for a long while :(.



A few more thoughts about improving this -> Add upgrades that can enhance the effects of return fire? Maybe start at 25% strength, and add 2 upgrade paths that add 25% each for a max total of 75%?
 
think its vital for ships to have this without a promotion, as it does improve naval combat substantially.

Perhaps a default counterattack damage of 25%/strength for ships, 0% for land based and it can be increased 2 times with promotions for 25% each for a total of 50% land and 75% ships


now who's gunna make this since mylon is awol? :)
 
BUMP :P




It seems this mod is now 'broken' - perhaps with the recent patch? I haven't played civ in a while, but it did work back when this mod was released.


Possible for the latest patch to screw things up? Here's the script - someone please have a look:

Spoiler :
Code:
-- Lua Script1
-- Author: Jeff
-- DateCreated: 16-Mar-11 13:56:17
--------------------------------------------------------------

print("Naval Counterattack Loaded")

function NavalCounterAttack(iAttackingPlayer, iAttackingUnit, iAttackingUnitDamage, iAttackingUnitFinalDamage, iAttackingUnitMaxHP, iDefendingPlayer, iDefendingUnit, iDefendingUnitDamage, iDefendingUnitFinalDamage, iDefendingUnitMaxHP)

	-- First, let's make sure we're looking at a naval vs naval engagement
	if iAttackingUnit > 0 and iDefendingUnit > 0 then
	
		local AttackingUnit = Players[iAttackingPlayer]:GetUnitByID( iAttackingUnit )
		local DefendingUnit = Players[iDefendingPlayer]:GetUnitByID( iDefendingUnit )

		if (AttackingUnit:GetDomainType() == DomainTypes.DOMAIN_SEA and DefendingUnit:GetDomainType() == DomainTypes.DOMAIN_SEA) then
			if (AttackingUnit:GetBaseRangedCombatStrength() > 0 and DefendingUnit:GetBaseRangedCombatStrength() > 0) then
			
				--We're in business.  Let's launch a counter-attack.
				-- Initialize the attack-tracking if this is the first attack of the turn.
				--if HasAttackedThisTurn == nil then
					HasAttackedThisTurn = {}
				--end

				--On an initial attack, neither ship will have the flag, so let's flag the attacker.
				if HasAttackedThisTurn[DefendingUnit] ~= true and HasAttackedThisTurn[AttackingUnit] ~= true then
					HasAttackedThisTurn[AttackingUnit] = true
				end

				--If the defending unit has the flag, then this will prevent a counter-counter attack.
				if HasAttackedThisTurn[DefendingUnit] ~= true then
					--print("Qualifies for a counterattack.")
					DefendingUnit:RangeStrike( AttackingUnit:GetX(), AttackingUnit:GetY() )
					--Now that the attack has been made, let's reset the defender's attack flag so that it may defend from another attack.
					DefendingUnit:SetMadeAttack(false)
					-- By this point, the attacker will already have been checked to make a counter-counter attack, so let's delete our table.
					HasAttackedThisTurn = nil
				else
					--print("This unit is flagged as having attacked already, unable to counter-attack.")
				end
			
			end
		end
	end
end

--function ClearCombatMemory()
	--HasAttackedThisTurn = nil
--end

Events.EndCombatSim.Add( NavalCounterAttack )
--Events.PlayerDoTurn.Add( ClearCombatMemory )
 
Back
Top Bottom