UU replacing prophets

Then learn? It's really not that hard. Get a spoonfeed or something.

Nah its not hard, c++ is hardcore for me.
But learing Lua is a interesting aspect of CiV in general;)
 
Ok, so after many funny mistakes, I managed to edit Neirai's code so the override'd prophet keeps its religion! All thanks to Unit:Convert() :D

Here it is (it should also work with missionaries btw):

Code:
-- ProphetReplacer
-- Author: Neirai the Forgiven (lil' changes by Leugi)
-- DateCreated: 8/24/2013 2:56:18 PM
--------------------------------------------------------------
local sUnitType = "UNIT_PROPHET"
local iProphetID = GameInfo.Units.UNIT_PROPHET.ID
local iProphetOverride = GameInfo.Units.UNIT_XUEPRIEST.ID
local iCivType = GameInfo.Civilizations["CIVILIZATION_MUISCA"].ID

print ("This is the Override Prophet Script thing.")


function ProphetOverride(iPlayer, iUnit)
	print ("This script is intended to turn Prophets into other units.")
	print ("Checking to see if the player is Alive...")
	local pPlayer = Players[iPlayer];
	if (pPlayer:IsEverAlive()) then
		print (pPlayer:GetCivilizationType())
		if (pPlayer:GetCivilizationType() == iCivType) then 
			print("Let's find out if this unit is a prophet!")
			print(iUnit)
			print(GameInfoTypes["UNIT_PROPHET"])
		--	print(iUnit:GetID())
			for pUnit in pPlayer:Units() do
				print(pUnit:GetUnitType())
				if (pUnit:GetUnitType() == iProphetID) then
					print ("Converting")
					local newUnit = pPlayer:InitUnit(iProphetOverride, pUnit:GetX(), pUnit:GetY())
					newUnit:Convert(pUnit);
					iUnitID:Kill(false, -1);
					print ("Conversion Complete")
				end
			end
		end
	end
end


Events.SerialEventUnitCreated.Add(ProphetOverride)

Of course, the Great Prophet notification still says "A Great Prophet has been born", but that's a minor issue compared to actually having a GP replacement!
 
Just wanted to say that there was some looping issue with the last code, this fix by LS should work:

Code:
-- ProphetReplacer
-- Author: LastSword
-- DateCreated: 8/24/2013 2:56:18 PM
--------------------------------------------------------------
local sUnitType = "UNIT_PROPHET"
local iProphetID = GameInfo.Units.UNIT_PROPHET.ID
local iProphetOverride = GameInfo.Units.UNIT_XUEPRIEST.ID
local iCivType = GameInfo.Civilizations["CIVILIZATION_MUISCA"].ID

function ProphetOverride(iPlayer, iUnit)
    local pPlayer = Players[iPlayer];
    if (pPlayer:IsEverAlive()) then
        if (pPlayer:GetCivilizationType() == iCivType) then
       	    if pPlayer:GetUnitByID(iUnit) ~= nil then
		pUnit = pPlayer:GetUnitByID(iUnit);
                if (pUnit:GetUnitType() == iProphetID) then
                    local newUnit = pPlayer:InitUnit(iProphetOverride, pUnit:GetX(), pUnit:GetY())
                    newUnit:Convert(pUnit);
                end
            end
        end
    end
end

Events.SerialEventUnitCreated.Add(ProphetOverride)
 
So yeah, for anyone doing Great Prophet UUs, this might come in handy.
 
Back
Top Bottom