[SDK] New MISSION - disorders the mission list and make unit Fortify & worker animations buggy

P&nny

Warlord
Joined
Sep 1, 2007
Messages
211
Hey guys, I've been trying to implement missions a couple of times already, but am struggling with an issue I'm sure some of you faced : despite me being extremely careful in the mission order etc. it looks like I "bumped" the order and its producing obvious bugs :
i) All units starts fortified/fortifying when created
ii) all Worker animation is out of whack, they always "run" instead of build stuff

I guess it's pretty obvious (not sure though) that I'm missing an entry somewhere and that it doesn't understand the list properly.

Where am changing : Absolutely everywhere in C++ just under the MISSION_INFILTRATE
Spoiler :
Code:
MISSION_INFILTRATE,
MISSION_GROWTHCITY,//2.06h

What I read here on the forum:
That the Missions in Civ4MissionsInfo.xml need to be in same order than CvEnums.h, but I did that, and I even did all the rest of my SDK code the same way, always behind mission infiltrate

This is how I structured in XML
Spoiler :
Code:
        <MissionInfo>
            <Type>MISSION_INFILTRATE</Type>
            <Description>TXT_KEY_MISSION_INFILTRATE</Description>
            <Help>TXT_KEY_MISSION_INFILTRATE_HELP</Help>
            <Waypoint>NONE</Waypoint>
            <EntityEventType>ENTITY_EVENT_GREAT_EVENT</EntityEventType>
            <iTime>18</iTime>
            <bTarget>0</bTarget>
            <bBuild>0</bBuild>
            <bSound>0</bSound>
            <HotKey/>
            <bAltDown>0</bAltDown>
            <bShiftDown>0</bShiftDown>
            <bCtrlDown>0</bCtrlDown>
            <iHotKeyPriority>0</iHotKeyPriority>
            <HotKeyAlt/>
            <bAltDownAlt>0</bAltDownAlt>
            <bShiftDownAlt>0</bShiftDownAlt>
            <bCtrlDownAlt>0</bCtrlDownAlt>
            <iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
            <bVisible>1</bVisible>
            <Button>,Art/Interface/Buttons/TechTree/Corporation.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,7,16</Button>
        </MissionInfo>
        <MissionInfo>
            <Type>MISSION_GROWTHCITY</Type>
            <Description>TXT_KEY_MISSION_GROWTHCITY</Description>
            <Help>TXT_KEY_MISSION_GROWTHCITY_HELP</Help>
            <Waypoint>NONE</Waypoint>
            <EntityEventType>ENTITY_EVENT_GREAT_EVENT</EntityEventType>
            <iTime>18</iTime>
            <bTarget>0</bTarget>
            <bBuild>0</bBuild>
            <bSound>0</bSound>
            <HotKey/>
            <bAltDown>0</bAltDown>
            <bShiftDown>0</bShiftDown>
            <bCtrlDown>0</bCtrlDown>
            <iHotKeyPriority>0</iHotKeyPriority>
            <HotKeyAlt/>
            <bAltDownAlt>0</bAltDownAlt>
            <bShiftDownAlt>0</bShiftDownAlt>
            <bCtrlDownAlt>0</bCtrlDownAlt>
            <iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
            <bVisible>1</bVisible>
            <Button>,-,Art/Interface/Buttons/and_misc_buttons.dds,4,14</Button>
        </MissionInfo>

What am left with:
My development is actually 100% functional, it's the side consequences I want to fix.
My Mission does that a given unit (workers) can join a city, grow it's population by 1, presuming it has a dedicated (UB) building, and it's not the last 20 turns of the game. This is all working well.
The main piece in CvUnit.cpp. Just under the 2 function that to the job for MISSION INFILTRATE:
Spoiler :
Code:
bool CvUnit::isJoinCity() const //2.06h
{
    return m_pUnitInfo->isJoinCity();
}
bool CvUnit::canGrowthCity(const CvPlot* pPlot, bool bTestVisible) const//2.06h
{
    if (isDelayedDeath())
    {
        return false;
    }
    if (GC.getGameINLINE().getMaxTurns() - GC.getGameINLINE().getElapsedGameTurns() < 20)
    {
        return false;
    }
    if (!isJoinCity())//Attribute of the unit
    {
        return false;
    }
    CvCity* pCity = pPlot->getPlotCity();
    if (pCity == NULL || pCity->isBarbarian())
    {
        return false;
    }
    if (pCity->getAllowsJoin() <= 0)//This counter goes over 1 each time the city builds a building which allows units to join
    {
        return false;//2.06s
    }
    return true;
}
bool CvUnit::GrowthCity()//2.06h
{
    if (!canGrowthCity(plot()))
    {
        return false;
    }
    NotifyEntity(MISSION_GROWTHCITY);
    kill(true);
    CvCity* pCity = plot()->getPlotCity();
    pCity->changePopulation(1);
    return true;
}

What I should be looking at:
I don't know... here below a sample of what I do, you'll see it's a plagiate 1-to-1 of the mission above,
I can send all code (marked with 2.06h) if need be but not sure it's useful.
I don't think am looking at why my units all start fortified,
I think am looking at where else I need to declare something and haven't


CvGameCoreUtils
Spoiler :
Code:
    case MISSION_INFILTRATE: szString = L"MISSION_INFILTRATE"; break;
    case MISSION_GROWTHCITY: szString = L"MISSION_GROWTHCITY"; break;//2.06h
CvSelectionGroup
Spoiler :
Code:
        case MISSION_INFILTRATE:
            if (pLoopUnit->canInfiltrate(pPlot, bTestVisible))
            {
                return true;
            }
            break;
        case MISSION_GROWTHCITY://2.06h
            if (pLoopUnit->canGrowthCity(pPlot, bTestVisible))
            {
                return true;
            }
            break;


I would love some help ! Thanks a ton
 
Hello, appreciate no one answerd but many reads already, thanks a lot

... I found it !
Thanks to this thread : https://forums.civfanatics.com/thre...s-only-using-sdk-and-xml.285810/#post-7344707
- CIV4MissionInfos.xml (basic to show the new buttons on screen). IMPORTANT: It seems imperative to put the new defined mission at the bottom of the file to prevent crashes.
- CvEnums.h (C++ interface to Mission Types in CIV4MissionInfos.xml). IMPORTANT: Its imperative that the new defined missions be added at the bottom of the "enum DllExport MissionTypes" and in the SAME order as in the XML file.

And another comment in another thread on the order of action.

It must be that the action to sleep/fortify is hardcoded somewhere by firaxis for units (I mean the mission order number),
So you are REALLY FORCED to put new missions at the VERY BOTTOM of the files of the XML, and the enum file. And I did so for all my others logic for good measure.
I had done under the "most logical similar mission" and this won't do with the presume hardcoding they did somewhere
 
Back
Top Bottom