Attila the Hun's "Scourge of God" update Mod

darkonion

"där-kōn-ė-uhn"
Joined
Apr 14, 2006
Messages
265
Location
Shaw AFB, SC
Hello, it's been a while since I've been on this forum. Anyway, I've begun a mod that will change the play style of Attila the Hun to be more in line with his character and to add a new style of play compared to his current just-like-Mongolia style. Here we go:

Previous)
-Start with Animal Husbantry tech
-Raze Cities twice as fast
- +1 production from pastures

(New)
-Start with Animal Husbantry tech
-Raze Cities twice as fast
- +250 Gold, +30 Production, +100 Culture to Attila's Court (Capital) when razing a city.

What this does is it makes for a single-city military oriented powerhouse that gets progression via the razing of enemy cities. Since they already start with ranged horsemen that cost no horses and spearmen that do buttloads of damage to cities, it allows for an early war civ that focuses on their capital and the destruction of others. Since Attila already gets cities that name themselves based off of the other civs in-game, this burning-and-churning playstyle won't defeat the previous goal for this civ (it'll just reward those that follow to it a little more closely).

I did run into a problem, being that I can't find any of the SQL/XML rules for razing beyond the raze speed that is already on Attila. If any of you know how to solve this, please let me know. I'm scared that it's an SDK change that'll have to be made...

-Paul

Moderator Action: Moved to C&C.
 
The first rule of Civ5 modding is that if it's not explicitly allowed within the existing XML of the specific table(s) in question, you can't do it in XML. So no, most of the razing functionality is internal to the game engine, and you can't just add whatever extra effects to it you want. Even if it were in the XML, most of those sorts of things are set on a game-wide basis and can't be adjusted for each individual leader.

The second rule is that nearly anything is possible within Lua, but the AI will almost never be able to understand the change. In this case it's not so bad, since the AI will already think that razing is a good idea, so you're not trying to add a new behavior. All you need to do is find a Lua event that triggers on city razing, and add culture if the person doing the razing has the right civ type.

Obviously, Lua modding is a lot tougher than XML modding, since it's a programming language (of a sort) instead of just a database protocol. But it's at least theoretically possible, and wouldn't require you to wait until the DLL SDK is released.
 
The first rule of Civ5 modding is that if it's not explicitly allowed within the existing XML of the specific table(s) in question, you can't do it in XML. So no, most of the razing functionality is internal to the game engine, and you can't just add whatever extra effects to it you want. Even if it were in the XML, most of those sorts of things are set on a game-wide basis and can't be adjusted for each individual leader.

The second rule is that nearly anything is possible within Lua, but the AI will almost never be able to understand the change. In this case it's not so bad, since the AI will already think that razing is a good idea, so you're not trying to add a new behavior. All you need to do is find a Lua event that triggers on city razing, and add culture if the person doing the razing has the right civ type.

Obviously, Lua modding is a lot tougher than XML modding, since it's a programming language (of a sort) instead of just a database protocol. But it's at least theoretically possible, and wouldn't require you to wait until the DLL SDK is released.

This is fine. Starting spot ideas? There is only a few things in the /assets folders that are actually LUA files. I can see them and open in an editing environment and I kind of understand what I'm looking at. I just don't know where to start as far as looking for the files that deal with razing. That's what I'm more-or-less here to get help with.
 
Starting spot ideas?

The official modding wiki is the place to go. Specifically, the Lua Game Objects page; the Events and GameEvents are your triggers, and everything else are your access functions. So, if you want to change the Culture of a city, you'd use something like City:ChangeJONSCultureStored to adjust the value within a Lua event tied to an appropriate trigger (probably SerialEventCityDestroyed).

Also, if you're looking for Lua, don't focus on the assets; go into the UI directory. Nearly everything in there is paired Lua+XML.
 
Code:
-- Initialize 'Raze' button.
	local bRaze = activePlayer:CanRaze(newCity);
	if (bRaze) then
		local OnRazeClicked = function()
			Network.SendDoTask(cityID, TaskTypes.TASK_RAZE, -1, -1, false, false, false, false);
		end
		
		buttonText = Locale.ConvertTextKey("TXT_KEY_POPUP_RAZE_CAPTURED_CITY");
		strToolTip = Locale.ConvertTextKey("TXT_KEY_POPUP_CITY_CAPTURE_INFO_RAZE", iUnhappinessForAnnexing);
		AddButton(buttonText, OnRazeClicked, strToolTip);
	end



So I'm assuming that I'm to look for "TASK_RAZE" now. >> This is a maze to me.
 
A potentially easier way to do what your aiming for could be achieved with the following pseudo code.

Code:
GameEvents.PlayerDoTurn.Add(AttilaTrait);

function AttilaTrait(playerID)
  if(player is Attila)
    forEach(city in player:cities)
      if(city:IsRazing())
        increment counter;
      endif
    endForEach

    --Give bonuses based on counter
  endif
end

Depending on what kinds of bonuses you're trying to give you'll need to put different code in. Adding non-city specific bonuses, such as gold, science, culture or faith can be done though player:SetJONSCulture(), player:SetGold() and teamTechs:SetResearchProgress() (science requires a few more steps).

If you want to add production or have the bonus be part of the capital city yield then you'll probably want to create a building that gives production/gold/science/etc and then use city:SetNumRealBuilding(buildingType, counter).
 
You more or less want to do what happens in the New World scenario for Treasure Cart generation, so if you have that DLC look in the TurnsRemainig.lua file (in C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\assets\DLC\DLC_02\Scenarios\NewWorldScenario), specifically at the code after "
GameEvents.SetPopulation.Add(function(iX, iY, oldPopulation, newPopulation) "
 
You more or less want to do what happens in the New World scenario for Treasure Cart generation, so if you have that DLC look in the TurnsRemainig.lua file (in C:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\assets\DLC\DLC_02\Scenarios\NewWorldScenario), specifically at the code after "
GameEvents.SetPopulation.Add(function(iX, iY, oldPopulation, newPopulation) "

Code:
GameEvents.SetPopulation.Add(function(iX, iY, oldPopulation, newPopulation) 

    local plot = Map.GetPlot(iX, iY);
    local city = plot:GetPlotCity();

    if (city:IsRazing()) then

		if (newPopulation > 0) then

			if (GenerateTreasureFromRazedCity(Game:GetHandicapType(), city:GetOwner(), city:GetPreviousOwner())) then
				local player = Players[city:GetOwner()];
				local iUnitID;
				iUnitID = GameInfoTypes["UNIT_TREASURE"];
				player:InitUnit (iUnitID, iX, iY);
	    
				local text;
				local heading;
				text = Locale.ConvertTextKey("TXT_KEY_NEWWORLD_SCENARIO_TREASURE_RAZED_CITY", city:GetName());
				heading = Locale.ConvertTextKey("TXT_KEY_NEWWORLD_SCENARIO_TREASURE_FOUND");
     				player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, heading);
			end
     		end
    end

    return true;
end);

function GenerateTreasureFromRazedCity (iHandicap, iNewOwner, iOldOwner)

	print("GenerateTreasureFromRazedCity");

	local bEuroNativeOK = false;
	local bDifficultyOK = false;
	
	local pPlayer1 = Players[iNewOwner];
	local pPlayer2 = Players[iOldOwner];
	
	if (pPlayer1:GetStartingPlot():GetX() < 50 and pPlayer2:GetStartingPlot():GetX() > 50) then
		bEuroNativeOK = true;
	elseif (pPlayer2:GetStartingPlot():GetX() < 50 and pPlayer1:GetStartingPlot():GetX() > 50) then
		bEuroNativeOK = true;
	end
	
	if (not bEuroNativeOK) then
		return false;
	end
	
	if( pPlayer1:IsMinorCiv() ) then
		return false;
	end
	
	if (iHandicap <= 3 or iNewOwner > 0) then
		bDifficultyOK = true;
	elseif (iHandicap == 4) then
        if (Game.Rand(100, "Rolling for treasure") < 80) then
			bDifficultyOK = true;
		end
	elseif (iHandicap == 5) then
        if (Game.Rand(100, "Rolling for treasure") < 70) then
			bDifficultyOK = true;
		end
	elseif (iHandicap == 6) then
        if (Game.Rand(100, "Rolling for treasure") < 60) then
			bDifficultyOK = true;
		end
	else
        if (Game.Rand(100, "Rolling for treasure") < 50) then
			bDifficultyOK = true;
		end
	end		

	if (bDifficultyOK) then
		return true;
	else
		return false;
	end
end

Ok, I have no idea what I'm doing. I'm going to just let go. I thought I could do this easily in XML but this is just too much for right now.
 
Top Bottom