Calling events and finding enemy civs

SO basically what I've concluded from the sanity check that Nutty suggested:
The game has no idea what to do with this line:
Code:
Map.PlotDistance(iUnitX, iUnitY, pEnemyPlayer:GetCapitalCity():GetX(), pEnemyPlayer:GetCapitalCity():GetY())
All the variables and functions used seems to be valid, so maybe this is the problem: On turn 0, as I said before, the game is somehow deducing that I'm at war with someone because otherwise it wouldn't be able to get past this line:
Code:
if Teams[pPlayer:GetTeam()]:IsAtWar(pEnemyPlayer:GetTeam()) then
I think the game is registering the barbarians as the enemy team in question, which would pose a problem since then the game would be trying to index the X and Y coordinates of the barbarian capital...
Have you ever heard of a barbarian capital in Civ5? Neither have I.

So, is there some part of the code we could change to exclude Barbarians as a valid team to check, and see if that solves the problem? Furthermore, just as an aside, I don't remember but are the Barbarians Player ID 63 or Team ID 63?
 
Add something like:

Code:
if not pEnemyPlayer:IsBarbarian() and not pEnemyPlayer:IsMinorCiv() then
if Teams[pPlayer:GetTeam()]:IsAtWar(pEnemyPlayer:GetTeam()) then

As for this one:

Code:
GameEvents.PlayerDoTurn.Add(
function(playerID)
	local pPlayer = Players[playerID]
	if (pPlayer:IsAlive()) then
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_SUPER_SECRET) then
			local num_Techs = pPlayer:GetTeam():GetTeamTechs():GetNumTechsKnown()
			pPlayer:ChangeCulture(num_Techs)
		end
	end
end)

You need to establish the Team and TeamTech objects, so:

Code:
local num_Techs = [COLOR="Red"]TeamTechs[Teams[[/COLOR]pPlayer:GetTeam()[COLOR="Red"]][/COLOR]:GetTeamTechs()[COLOR="Red"]][/COLOR]:GetNumTechsKnown()
 
I made the changes but now the game crashes when I found my first city :p
Because logic, I guess.
 
Erm, JFD, would you know anything about this?
Code:
[51153.039] Runtime Error: C:\Users\travis\Documents\My Games\Sid Meier's Civilization 5\MODS\AW's Super Secret Mod (v 1)\LUA/SupahSecret_Culture.lua:30: attempt to index global 'TeamTechs' (a nil value)

The code in question:
Spoiler :
Code:
GameEvents.PlayerDoTurn.Add(
function(playerID)
	local pPlayer = Players[playerID]
	if (pPlayer:IsAlive()) then
		print('pPlayer identified.')
		if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_SAMANID) then
			print('Valid civ type. Getting number of techs...')
			[COLOR="Red"]local num_Techs = TeamTechs[Teams[pPlayer:GetTeam()]:GetTeamTechs()]:GetNumTechsKnown()[/COLOR]
			print('Number of techs: '..numTechs)
			pPlayer:ChangeCulture(num_Techs)
		end
	end
end)
Unfortunately, now I've discovered that not only does the game crash, but inconsistently. :sad: It crashed about two turns when I moved a unit, very much different than founding my first city. If anyone wants to see if they can figure out what's going on, I can PM them the mod, since heaven forbid I should reveal my plans.
 
Sorry I haven't responded to this thread in a while. Kinda forgot about it...

Code:
local num_Techs = TeamTechs[Teams[pPlayer:GetTeam()]:GetTeamTechs()]:GetNumTechsKnown()

The TeamTechs[] part of this isn't necessary. The GetTeamTechs() function itself accomplishes what you're trying to do (get the pointer for the Team's TeamTechs object). So:

Code:
local num_Techs = Teams[pPlayer:GetTeam()]:GetTeamTechs():GetNumTechsKnown()
 
Back
Top Bottom