A couple modding questions

ArchangelOfDoom

Chieftain
Joined
Jun 10, 2014
Messages
55
1) Are the trade route completion hooks used for the Ottomans and tourism exposed to lua?

2) Is it possible to change specialists yields on a per city basis through a dummy building? I know the original Building_SpecialistYieldChanges affects your whole nation.

3) Has Building_SpecialistYieldChanges been fixed to work with culture?

4) Is it possible to reduce the unit supply cost of a certain unit or class of units ( eg. Naval ) for a single nation through lua or sql?
 
Last edited:
1) Are the trade route completion hooks used for the Ottomans and tourism exposed to lua?
Looked through the DLL code, seems to be one called PlayerTradeRouteCompleted.
Code:
GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerTradeRouteCompleted, pOriginCity->getOwner(), pOriginCity->GetID(), pDestCity->getOwner(), pDestCity->GetID(), eDomain, pTradeConnection->m_eConnectionType)

2) Is it possible to change specialists yields on a per city basis through a dummy building? I know the original Building_SpecialistYieldChanges affects your whole nation.
There's a Building_SpecialistYieldChangesLocal in CPDLL.

3) Has Building_SpecialistYieldChanges been fixed to work with culture?
Not sure, but it is likely to be fixed because of the unified yields project. Try it and see.

4) Is it possible to reduce the unit supply cost of a certain unit or class of units ( eg. Naval ) for a single nation through lua or sql?
As far as I know, not directly, but maybe this method works: using lua, get the number of unit classes a player has, then spawn dummy buildings somewhere that gives supply.
 
Holy necromancy, Batman!

Does "GAMEEVENT_PlayerTradeRouteCompleted()" still work? I'm trying to write a code that spawns a unit whenever a sea trade route ends:
Code:
function BalangaySpawn(iFromPlayer, iFromCity, iToPlayer, iToCity, iDomain, iConnectionType)
    local pPlayer = Players[iFromPlayer]
    print("Trade Route Ended!!!")  
    if not (pPlayer and pPlayer:GetCivilizationType() == iPhilippines) then return end
    print(iDomain)
  
    if iDomain == 1 then
        local pCity = pPlayer:GetCityByID(iFromCity)
        local iX, iY = pCity:GetX(), pCity:GetY()
        local pBalangayUnit = pPlayer:InitUnit(GameInfoTypes.UNIT_PHILIPPINES_BALANGAY, iX, iY, -1, DirectionTypes.NO_DIRECTION, false)
    end
end
GameEvents.PlayerTradeRouteCompleted.Add(BalangaySpawn)
So first off, I can't find any documentation indicating which domain is sea and which is land. I was going to just trial and error, but the event doesn't even fire.

I can't seem to find this event in the CPP github, so I'm wondering if it's just gone now? @Gazebo?
 
Holy necromancy, Batman!

Does "GAMEEVENT_PlayerTradeRouteCompleted()" still work? I'm trying to write a code that spawns a unit whenever a sea trade route ends:
Code:
function BalangaySpawn(iFromPlayer, iFromCity, iToPlayer, iToCity, iDomain, iConnectionType)
    local pPlayer = Players[iFromPlayer]
    print("Trade Route Ended!!!") 
    if not (pPlayer and pPlayer:GetCivilizationType() == iPhilippines) then return end
    print(iDomain)
 
    if iDomain == 1 then
        local pCity = pPlayer:GetCityByID(iFromCity)
        local iX, iY = pCity:GetX(), pCity:GetY()
        local pBalangayUnit = pPlayer:InitUnit(GameInfoTypes.UNIT_PHILIPPINES_BALANGAY, iX, iY, -1, DirectionTypes.NO_DIRECTION, false)
    end
end
GameEvents.PlayerTradeRouteCompleted.Add(BalangaySpawn)
So first off, I can't find any documentation indicating which domain is sea and which is land. I was going to just trial and error, but the event doesn't even fire.

I can't seem to find this event in the CPP github, so I'm wondering if it's just gone now? @Gazebo?

It is there, yes:

GAMEEVENTINVOKE_HOOK(GAMEEVENT_PlayerTradeRouteCompleted, pOriginCity->getOwner(), pOriginCity->GetID(), pDestCity->getOwner(), pDestCity->GetID(), eDomain, pTradeConnection->m_eConnectionType);
Line 2690 of CvTradeClasses.

G
 
Hmm. I posted a code snippet above; the print("Trade Route Ended!!!") doesn't appear
 
Oooh.... no I didn’t. I had no idea I had to enable an option. I’ll try that this evening.

thanks!
 
Top Bottom