Plenty Lua Codes and Questions

I used the event you mentioned now and will test it tonight.
I'm getting very fond of 'dummy' buildings and promotions, you can make quite a nice effect with those.

Thank you again.

I'm still looking for a way to use EndCombatSim and RunCombatSim. I found an old page saying whoward69's DLL have a way around to use those, but I don't know if it is still true.
 
DLL V41, CustomModOptions.xml file

Code:
    <!-- Events generated by the RED (by Gedemon) dll mod code -->
    <!--   Turn   ==> PlayerEndTurnInitiated, PlayerEndTurnCompleted, TurnComplete -->
    <!--   Combat ==> PushingMissionTo, MustAbortAttack, CombatResult, CombatEnded -->
    <Row Class="3" Name="EVENTS_RED_TURN" Value="0"/>
    <Row Class="3" Name="EVENTS_RED_COMBAT" Value="0"/>
    <Row Class="3" Name="EVENTS_RED_COMBAT_MISSION" Value="0"/>
    <Row Class="3" Name="EVENTS_RED_COMBAT_ABORT" Value="0"/>
    <Row Class="3" Name="EVENTS_RED_COMBAT_RESULT" Value="0"/>
    <Row Class="3" Name="EVENTS_RED_COMBAT_ENDED" Value="0"/>

From the RED code base
Code:
// RED : CombatEnded
// iAttackingPlayer, iAttackingUnit, attackerDamage, attackerFinalDamage, attackerMaxHP
// iDefendingPlayer, iDefendingUnit, defenderDamage, defenderFinalDamage, defenderMaxHP
// iInterceptingPlayer, iInterceptingUnit, interceptorDamage
// plotX, plotY
that's a lot of parameters passed into the event!
 
So I need both your DLL and Gedemon's RED mod? <- That was dumb, both are DLL modifications.
I'll check on how to make it work. Thanks for the confirmation, whoward69!
If I got it right, I would have to call it as 'GameEvents.CombatEnded.Add(myFunction)', right?

Sounds very exciting! :D

EDIT: Well, another edit... From what I understand, there is no replacement for the 'RunCombatSim', but for 'EndCombatSim' only, right?
So the previous code I got for getting a Combat strength bonus during combat would not work, since it must be set before the calculations for combat resolve.
 
GameEvents.CombatResult is what you want to replace RunCombatSim, it's called just before the combat.
 
Thank you. :D

---

Round 3 now:
UA = Sinister Citadel said:
At the start of your turn, enemies adjacent to the [ICON_CAPITAL] Stronghold are pushed back, or suffer damage if can't be pushed.

Ok, this one is probably a bit messy but I believe it can be done.
I don't know how to use 'pairs' but I've seen some uses in mods and believe this is an UA that probably needs that. Here is what I have so far:

Code:
function SinisterCitadelPush(playerID, CityID, iHex)
	local player = Players[playerID]
	local pcap = player:GetCapitalCity()
	if (player:IsEverAlive()) and player:isNotMinor then
		if (pcap:IsHasBuilding(GameInfoTypes["BUILDING_SPIDERPALACE"])) then -- must have the Spider palace (so any Spider civ is ok)
			local plot = pcap:Plot()
			local iHex = ToHexFromGrid( Vector2(plot:GetX(), plot:GetY()) )  -- check all adjacent plots
			for Units in iHex do
				for Units, in pairs do -- ??
					-- check if unit is from a player at war
					-- if it is, check the ring before that one (absolutely no idea)
						-- move every unit capable of moving
						if Unit:HasMoved
							return
						else
							damage
						end
					end
				end
			end
		end
	end
end
(it theoretically has one extra 'end' because the last 'if' has the comment '--' before it)

I thought about giving the units that didn't move a promotion and use that to check and damage them, until I found "Unit:HasMoved".

Any ideas?

EDIT: After this one I'll work on the finishing touchs of version 0.1 and post the whole codes to help anyone searching for similar things.
 
Ok! This one will have to wait for me to learn more Lua.
Now, the next thing isn't a code per se, but I need the knowledge of superior coders for this:

Is it possible to make identities to Improvements?
I want to make an Improvement that receives bonuses independently from another of the same, like as if a Farm get cultural bonuses and other receives gold, but not because of order (that I could do) but because of some identifier, making them (more) unique.
 
Ok! This one will have to wait for me to learn more Lua.
Now, the next thing isn't a code per se, but I need the knowledge of superior coders for this:

Is it possible to make identities to Improvements?
I want to make an Improvement that receives bonuses independently from another of the same, like as if a Farm get cultural bonuses and other receives gold, but not because of order (that I could do) but because of some identifier, making them (more) unique.

You might want to take a look at the Mexico civ (done by Leugi and TPangolin) for this -- I believe the Hacienda UI has a feature that allows it to start generating one of 3 randomly-selected yields when you get Economics. I suspect this is done by having 3 similar versions of the UI, and replacing the existing improvement with one of the variant ones under certain conditions. So you could have a FARM_CULTURE and FARM_GOLD, that look identical to Farms, but you could step through your city tiles, find Farms, and replace them with the equivalent when necessary?
 
Back
Top Bottom