Hey, all. For an upcoming mod, I'm trying to cause CityState Teams to declare wars on players.
I'm using the following code:
The problem is that it causes a crash about 50% of the time. It crashes on the Teams[pPlotOwner:GetTeam()]
eclareWar(pTarget:GetTeam()) line.
Any ideas about why this would be?
Edit: this is code within other code.
I'm using the following code:
Code:
local pTarget = Players[v.CivilizationID]
print(pTarget)
if pTarget:IsEverAlive() then
print("pTarget is Alive")
if pPlotOwner:IsEverAlive() then
print("pPlotOwner is Alive")
pPopupUnit:SetDamage(999)
print("I killed the unit.")
LuaEvents.GreatPersonExpended(activePlayer:GetID(), iMidew)
print("A Great Person was Expended")
if not Teams[pPlotOwner:GetTeam()]:IsHasMet(pTarget:GetTeam()) then
print("The City State has not met the target.")
Teams[pPlotOwner:GetTeam()]:Meet(pTarget:GetTeam(), true)
print("Introductions facilitated.")
end
Teams[pPlotOwner:GetTeam()]:DeclareWar(pTarget:GetTeam())
print("A Declaration of War!")
print("Our work here is done.")
end
end
The problem is that it causes a crash about 50% of the time. It crashes on the Teams[pPlotOwner:GetTeam()]

Any ideas about why this would be?
Edit: this is code within other code.