Announcement

Collapse
No announcement yet.

My C++ Events Generator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • My C++ Events Generator

    Anzac asked for my C++ thingie, so here it is. It allows great dynamic event generation and compiles to virus-sized DOS executables.

    P.S. I've only made the procedures that I needed.
    P.P.S. Edit Post to see proper tabbing.

    <hr>

    //Leons Petrazickis
    //Roman Riots II Events Generator
    //Uses St Leo's Civ++ Event Engine V1.0

    #include<fstream.h>
    #include<string.h> //Delete this

    ofstream fout("events.txt"); //creates a variable of type ofstream

    //Triggers
    void citytaken(char city[255],
    char attacker[255],
    char defender[255]);
    void negotiation(char talker[255],
    char talkertype[255],
    char listener[255],
    char listenertype[255]);
    void randomturn(int denominator);
    void scenarioloaded();
    void turn(int turn);
    void unitkilled(char unit[255],
    char attacker[255],
    char defender[255]);

    //Actions
    void createunit(char owner[255],
    char unit[255],
    char veteran[255],
    char homecity[255],
    char loc[255]);
    void justonce();
    void noschism(char defender[255]);
    void playwavefile(char filename[255]);
    void text(char text[32000]);

    //Keywords
    void beginevents();
    void endevents();
    void IF();
    void THEN();
    void ENDIF();
    void debug();

    //Useful Variable
    char civs[8][256] = {
    "Roman Legion",
    "Rebels",
    "Invaders",
    "English",
    "Spaniards",
    "French",
    "Independents",
    "Barbarians"};

    void main(){
    //Scenario-specific variables
    char answer = ' '; //Answer to prompts
    int x=0; //Index for loops
    int number = 5;
    int engfreq = 3;
    int galfreq = 4;
    int generalinterval = 15;
    char assloc[] = "70,106";

    cout << "Welcome to the Setup Program for Roman Riots 2:\n";
    cout << "\t-Answer in lowercase and follow up with an [Enter]\n";
    cout << "\t-Run it again whenever needed\n";
    cout << "\t-If it summons aliens from Alpha Centauri, it is not my fault\n\n";

    beginevents();
    //debug();

    IF();
    noschism("ANYBODY");
    THEN();
    ENDIF();

    IF();
    negotiation("ANYBODY","HUMANORCOMPUTER","ANYBODY", "HUMANORCOMPUTER");
    THEN();
    ENDIF();

    IF();
    randomturn(5);
    THEN();
    createunit("Rebels","Pachyderms","Yes","NONE","76, 44");
    ENDIF();
    IF();
    randomturn(5);
    THEN();
    createunit("Rebels","Dark Furies","Yes","NONE","76,44");
    ENDIF();
    IF();
    randomturn(5);
    THEN();
    createunit("Rebels","Rebel Skirmisher","Yes","NONE","76,44");
    ENDIF();
    IF();
    randomturn(10);
    THEN();
    createunit("Rebels","Scout","Yes","NONE","76,44");
    ENDIF();
    IF();
    randomturn(5);
    THEN();
    createunit("Rebels","Rebel Skirmisher","Yes","NONE","29,15");
    ENDIF();
    IF();
    randomturn(5);
    THEN();
    createunit("Rebels","Rebel Skirmisher","Yes","NONE","1,47");
    ENDIF();
    IF();
    randomturn(15);
    THEN();
    createunit("Roman Legion","Praefect III","Yes","NONE","36,2");
    text("^An expert defensive unit has arrived.");
    ENDIF();


    endevents();
    fout.close();
    }

    void createunit(char owner[255],
    char unit[255],
    char veteran[255],
    char homecity[255],
    char loc[255]){
    fout << "CreateUnit\n";
    fout << "owner=" << owner << "\n";
    fout << "unit=" << unit << "\n";
    fout << "veteran=" << veteran << "\n";
    fout << "homecity=" << homecity << "\n";
    fout << "locations\n" << loc << "\nendlocations\n";
    }

    void unitkilled(char unit[255],
    char attacker[255],
    char defender[255]){
    fout << "UnitKilled\n";
    fout << "unit=" << unit << "\n";
    fout << "attacker=" << attacker << "\n";
    fout << "defender=" << defender << "\n";
    }

    void randomturn(int denominator){
    fout << "RandomTurn\n";
    fout << "denominator=" << denominator << "\n";
    }

    void turn(int turn){
    fout << "Turn\n";
    fout << "turn=" << turn << "\n";
    }

    void negotiation(char talker[255],
    char talkertype[255],
    char listener[255],
    char listenertype[255]){
    fout << "Negotiation\n";
    fout << "talker=" << talker << "\n";
    fout << "talkertype="<< talkertype << "\n";
    fout << "listener="<< listener << "\n";
    fout << "listenertype="<< listenertype << "\n";
    }

    void text(char text[32000]){
    fout << "Text\n";
    fout << text << "\n";
    fout << "EndText\n";
    }


    void beginevents(){
    fout << "@BEGINEVENTS\n";
    }

    void endevents(){
    fout << "@ENDEVENTS\n";
    }

    void IF(){
    fout << "@IF\n";
    }

    void THEN(){
    fout << "@THEN\n";
    }

    void ENDIF(){
    fout << "@ENDIF\n";
    }

    void justonce(){
    fout << "JustOnce\n";
    }

    void noschism(char defender[255]){
    fout << "NoSchism\n";
    fout << "defender=" << defender << "\n";
    }

    void citytaken(char city[255],
    char attacker[255],
    char defender[255]){
    fout << "CityTaken\n";
    fout << "city=" << city << "\n";
    fout << "attacker=" << attacker << "\n";
    fout << "defender=" << defender << "\n";
    }

    void playwavefile(char filename[255]){
    fout << "PlayWaveFile\n";
    fout << filename << "\n";
    }

    void scenarioloaded(){
    fout << "ScenarioLoaded\n";
    }

    void debug(){
    fout << "@DEBUG\n";
    }
    Blog | Civ2 Scenario League | leo.petr at gmail.com

  • #2
    Huh ???

    Okay, pretend for a second that I have no idea how to use C++ and all that events lingo confuses me to no end. Now pretend that you need to explain all this to me.

    P.S. just remember that I said pretend, I know what you're talking about. I am just seeing if you know what you're about.
    "I would rather have a German division in front of me than a French one behind me." -- General George S. Patton
    "Guinness sucks!" -- Me

    Comment


    • #3
      This is basically just an interactive preprocessor for the CivII macro language. You can use C++ loops and other control structures and the syntax is much cleaner.
      Blog | Civ2 Scenario League | leo.petr at gmail.com

      Comment


      • #4
        Are you saying that I can copy this down and put it right in an events file and it will work?

        Or do I have to make it into a batch file or something?
        "I would rather have a German division in front of me than a French one behind me." -- General George S. Patton
        "Guinness sucks!" -- Me

        Comment


        • #5
          Thanks St. Leo, though I somewhat understand it. But I think when I get Fictional Americas and see how it works in the field, I will be able to really implement it. Thanks
          Georgi Nikolai Anzyakov, Commander Grand Northern Front, Red Front Democracy Game

          Comment


          • #6
            Is this anything like Angelo Scottos' CPSL?
            Tecumseh's Village, Home of Fine Civilization Scenarios

            www.tecumseh.150m.com

            Comment


            • #7
              Is this anything like Angelo Scottos' CPSL?
              Tecumseh's Village, Home of Fine Civilization Scenarios

              www.tecumseh.150m.com

              Comment


              • #8
                I think this simply randomizes event you get..... for example, I suppose you could set it so that say you could get extra money every 5, 10 or 20 years, depndig on a randomized factor.... *tries to remember more from puny collection of C++ knowledge*
                *grumbles about work*

                Comment


                • #9
                  Is this anything like Angelo Scottos' CPSL?

                  No, CSPL messes with Civ2's memory to create new events. This simply generates a custom events file. Note: I don't know how to run delevent.exe for a C++ file, so you might have to combine this with a batch file for mutli-event file scenarios.

                  I think this simply randomizes event you get..... for example, I suppose you could set it so that say you could get extra money every 5, 10 or 20 years, depndig on a randomized factor....

                  That certainly is possible, but in Fictional Americas and Imperial Ambition I used this to create a distinct file based on who's human and who's not, while in Roman Riots II I simply used it because I prefer C++ function syntax.
                  Blog | Civ2 Scenario League | leo.petr at gmail.com

                  Comment

                  Working...
                  X