Seite 21 von 162 ErsteErste ... 111718192021222324253171121 ... LetzteLetzte
Ergebnis 301 bis 315 von 2421

Thema: BASE: SDK & Python Diskussion (Coder's Lair)

  1. #301
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    Funktioniert noch nicht richtig. Man kann eins mit beliebigen GP-Typen starten, aber so wird nur eine einzige Einheit entfernt.

    Mein Code:

    PHP-Code:
    void CvPlayer::killGoldenAgeUnits(CvUnitpUnitAlive)
    {
        
    CvUnitpLoopUnit;
        
    CvUnitpBestUnit;
        
    boolpabUnitUsed;
        
    int iUnitsRequired;
        
    int iValue;
        
    int iBestValue;
        
    int iLoop;
        
    int iI;

        
    pabUnitUsed = new bool[GC.getNumUnitInfos()];

        for (
    iI 0iI GC.getNumUnitInfos(); iI++)
        {
            
    pabUnitUsed[iI] = false;
        }

        
    iUnitsRequired unitsRequiredForGoldenAge();

        if (
    pUnitAlive != NULL)
        {
            
    pabUnitUsed[pUnitAlive->getUnitType()] = true;
            
    iUnitsRequired--;
        }

        for (
    iI 0iI iUnitsRequirediI++)
        {
            
    iBestValue 0;
            
    pBestUnit NULL;

            for(
    pLoopUnit firstUnit(&iLoop); pLoopUnit != NULLpLoopUnit nextUnit(&iLoop))
            {
                if (
    pLoopUnit->isGoldenAge())
                {
                    if (!(
    pabUnitUsed[pLoopUnit->getUnitType()]))
                    {
                        
    iValue 10000;

                        
    iValue /= (plotDistance(pLoopUnit->getX_INLINE(), pLoopUnit->getY_INLINE(), pUnitAlive->getX_INLINE(), pUnitAlive->getY_INLINE()) + 1);

                        if (
    iValue iBestValue)
                        {
                            
    iBestValue iValue;
                            
    pBestUnit pLoopUnit;
                        }
                    }
                }
            }

            
    FAssert(pBestUnit != NULL);
            if (
    pBestUnit != NULL)
            {

    // Cybah: BASE - Nobelpreis Projekt Start
    // Original Code
    //             pabUnitUsed[pBestUnit->getUnitType()] = true;
    //
                
    if (!(GET_TEAM(getTeam()).getProjectCount((ProjectTypes)GC.getInfoTypeForString("PROJECT_NOBEL")) > 0))
                {
                    
    pabUnitUsed[pBestUnit->getUnitType()] = true;
                }
    // Cybah: BASE - Nobelpreis Projekt End

                
    pBestUnit->kill(true);

                
    //play animations
                
    if (pBestUnit->plot()->isActiveVisible(false))
                {
                    
    //kill removes bestUnit from any groups
                    
    pBestUnit->getGroup()->pushMission(MISSION_GOLDEN_AGE0);
                }
            }
        }

        
    SAFE_DELETE_ARRAY(pabUnitUsed);

    Geändert von Cybah (19. November 2013 um 16:03 Uhr)
    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  2. #302
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Ich verstehe das Problem, es wird merhfach die gleiche Einheit so ausgewählt. Ausgewählte Einheiten haben die Mission MISSION_GOLDEN_AGE mit pBestUnit->getGroup()->pushMission(MISSION_GOLDEN_AGE, 0); gesetzt bekommen.

    Man müsste die Mission oben noch abfragen, dass nur Einheiten ohne die Mission in Frage kommen. Muss aber noch nachschauen, wie man das macht.

  3. #303
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Das Problem muss ein anderes sein.

    pBestUnit->kill(true); tötet die Einheit, aber warum wird sie beim zweiten durchgang noch genommen, vertsehe ich nicht. edit: Man muss oben wohl noch überprüfen , ob die Einheit noch existiert sprich nicht kill ausgeführt wurde!

    Code:
    if (pUnitAlive != NULL)
        {
            pabUnitUsed[pUnitAlive->getUnitType()] = true;
            iUnitsRequired--;
        }
    Das Rote muss oben auch noch blockiert werden!

  4. #304
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Zitat Zitat von Cybah Beitrag anzeigen
    Funktioniert noch nicht richtig. Man kann eins mit beliebigen GP-Typen starten, aber so wird nur eine einzige Einheit entfernt.
    Wenn du den Roten Hinweis oben machst, sollte es gehen. Das Problem ist wohl, du hast nur mehrere Spezialisten einer Art gehabt. Das rote musst du dafür blocken(edit), weil sonst dieser Typ gesperrt wird und dann nicht mehr entfernt wird. Da verhindert sonst das killen der anderen.
    Geändert von rucivfan (19. November 2013 um 16:59 Uhr)

  5. #305
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    Hat nichts geändert.
    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  6. #306
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Code bitte anhängen.

  7. #307
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    PHP-Code:
    int CvPlayer::unitsGoldenAgeReady() const
    {
        
    PROFILE_FUNC();

        
    CvUnitpLoopUnit;
        
    boolpabUnitUsed;
        
    int iCount;
        
    int iLoop;
        
    int iI;

        
    pabUnitUsed = new bool[GC.getNumUnitInfos()];

        for (
    iI 0iI GC.getNumUnitInfos(); iI++)
        {
            
    pabUnitUsed[iI] = false;
        }

        
    iCount 0;

        for(
    pLoopUnit firstUnit(&iLoop); pLoopUnit != NULLpLoopUnit nextUnit(&iLoop))
        {
            if (!(
    pabUnitUsed[pLoopUnit->getUnitType()]))
            {
                if (
    pLoopUnit->isGoldenAge())
                {
    // Cybah: BASE - Nobelpreis Projekt Start
    // Original Code
    //                pabUnitUsed[pLoopUnit->getUnitType()] = true;
    //
                    
    if (!(GET_TEAM(getTeam()).getProjectCount((ProjectTypes)GC.getInfoTypeForString("PROJECT_NOBEL")) > 0))
                    {
                        
    pabUnitUsed[pLoopUnit->getUnitType()] = true;
                    }
    // Cybah: BASE - Nobelpreis Projekt ENd
                    
    iCount++;
                }
            }
        }

        
    SAFE_DELETE_ARRAY(pabUnitUsed);

        return 
    iCount;
    }


    void CvPlayer::killGoldenAgeUnits(CvUnitpUnitAlive)
    {
        
    CvUnitpLoopUnit;
        
    CvUnitpBestUnit;
        
    boolpabUnitUsed;
        
    int iUnitsRequired;
        
    int iValue;
        
    int iBestValue;
        
    int iLoop;
        
    int iI;

        
    pabUnitUsed = new bool[GC.getNumUnitInfos()];

        for (
    iI 0iI GC.getNumUnitInfos(); iI++)
        {
            
    pabUnitUsed[iI] = false;
        }

        
    iUnitsRequired unitsRequiredForGoldenAge();

        if (
    pUnitAlive != NULL)
        {
    // Cybah: BASE - Nobelpreis Projekt Start
    // Original Code
    //         pabUnitUsed[pUnitAlive->getUnitType()] = true;
    //
            
    if (!(GET_TEAM(getTeam()).getProjectCount((ProjectTypes)GC.getInfoTypeForString("PROJECT_NOBEL")) > 0))
            {
                
    pabUnitUsed[pUnitAlive->getUnitType()] = true;
            }
    // Cybah: BASE - Nobelpreis Projekt End
            
    iUnitsRequired--;
        }

        for (
    iI 0iI iUnitsRequirediI++)
        {
            
    iBestValue 0;
            
    pBestUnit NULL;

            for(
    pLoopUnit firstUnit(&iLoop); pLoopUnit != NULLpLoopUnit nextUnit(&iLoop))
            {
                if (
    pLoopUnit->isGoldenAge())
                {
                    if (!(
    pabUnitUsed[pLoopUnit->getUnitType()]))
                    {
                        
    iValue 10000;

                        
    iValue /= (plotDistance(pLoopUnit->getX_INLINE(), pLoopUnit->getY_INLINE(), pUnitAlive->getX_INLINE(), pUnitAlive->getY_INLINE()) + 1);

                        if (
    iValue iBestValue)
                        {
                            
    iBestValue iValue;
                            
    pBestUnit pLoopUnit;
                        }
                    }
                }
            }

            
    FAssert(pBestUnit != NULL);
            if (
    pBestUnit != NULL)
            {

    // Cybah: BASE - Nobelpreis Projekt Start
    // Original Code
    //             pabUnitUsed[pBestUnit->getUnitType()] = true;
    //
                
    if (!(GET_TEAM(getTeam()).getProjectCount((ProjectTypes)GC.getInfoTypeForString("PROJECT_NOBEL")) > 0))
                {
                    
    pabUnitUsed[pBestUnit->getUnitType()] = true;
                }
    // Cybah: BASE - Nobelpreis Projekt End

                
    pBestUnit->kill(true);

                
    //play animations
                
    if (pBestUnit->plot()->isActiveVisible(false))
                {
                    
    //kill removes bestUnit from any groups
                    
    pBestUnit->getGroup()->pushMission(MISSION_GOLDEN_AGE0);
                }
            }
        }

        
    SAFE_DELETE_ARRAY(pabUnitUsed);

    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  8. #308
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Unterhalb von for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop)) musst du pUnitAlive und pLoopUnit vergleichen auf ungleichheit.

    if (pUnitAlive == NULL || pUnitAlive->getID() != pLoopUnit->getID())

    edit: Ab 3 Spezialisten sollten 2 sterben ohne die Änderung. Hast du das getestet?

  9. #309
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    Kann ich mal schnell machen.

    Edit: Jo, statt 3 sterben 2.
    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  10. #310
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Dann musst du nur das letzt genannt noch machen.

  11. #311
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    Du meinst so?

    PHP-Code:
        for(pLoopUnit firstUnit(&iLoop); pLoopUnit != NULLpLoopUnit nextUnit(&iLoop))
        {
    // Cybah: BASE - Nobelpreis Projekt Start
            
    if (pUnitAlive == NULL || pUnitAlive->getID() != pLoopUnit->getID())
            {
    // Cybah: BASE - Nobelpreis Projekt End

                
    if (!(pabUnitUsed[pLoopUnit->getUnitType()]))
                {
                    if (
    pLoopUnit->isGoldenAge())
                    {
    // Cybah: BASE - Nobelpreis Projekt Start
    // Original Code
    //                    pabUnitUsed[pLoopUnit->getUnitType()] = true;
    //
                        
    if (!(GET_TEAM(getTeam()).getProjectCount((ProjectTypes)GC.getInfoTypeForString("PROJECT_NOBEL")) > 0))
                        {
                            
    pabUnitUsed[pLoopUnit->getUnitType()] = true;
                        }
    // Cybah: BASE - Nobelpreis Projekt End
                        
    iCount++;
                    }
                }
    // Cybah: BASE - Nobelpreis Projekt Start
            
    }
    // Cybah: BASE - Nobelpreis Projekt End
        

    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  12. #312
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Oh, ich meinte nur in killGoldenAgeUnits-methode. Die andere hat kein pUnitAlive!

    edit: Schiebst du das dann in das Code-Thema?

  13. #313
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    1>CvPlayer.cpp(10298) : error C2065: 'pUnitAlive' : undeclared identifier
    1>CvPlayer.cpp(10298) : error C2227: left of '->getID' must point to class/struct/union
    1> type is ''unknown-type''
    1>CvPlayer.cpp(10298) : error C3861: 'pUnitAlive': identifier not found, even with argument-dependent lookup
    Wo er Recht hat...
    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  14. #314
    Waddehaddedudeda Avatar von Cybah
    Registriert seit
    01.09.06
    Beiträge
    30.456
    Zitat Zitat von rucivfan Beitrag anzeigen
    Oh, ich meinte nur in killGoldenAgeUnits-methode. Die andere hat kein pUnitAlive!

    edit: Schiebst du das dann in das Code-Thema?
    Ach so.

    Ja.
    Pucc's Lets Plays BASE 6.0: #1 #2 #3 #4 #5

    Download von BASE 6.4 [D]: HIER (klick mich!) (Stand: 08.07.2022)

  15. #315
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.017
    Klappt es jetzt einwandfrei?

Seite 21 von 162 ErsteErste ... 111718192021222324253171121 ... LetzteLetzte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •