How do I begin making my mod compatible with Titans?

Discussion in 'Mod Discussions' started by bsergent, December 25, 2015.

  1. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
  2. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    lol really
    cptconundrum and stuart98 like this.
  3. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
  4. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Well, look at other Titans mods, lot's have github repo's so you can browse all the source.
    You'll probably only have to update your unit json's cause stuff changed there.
    cptconundrum likes this.
  5. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    Well there aren't any loadout mods that are working for me to dissect.

    When I launch galactic war with my loadout mod enabled it never loads any of the loadouts.

    (can't upload screenshot, like always)

    I feel like I've forgotten the entire process.

    Trying to get my foot back in the door.
  6. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Well all galactic war source is readable.
    See gamefolder > media > ui > main > game > galactic_war
    bsergent and cptconundrum like this.
  7. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    Yeah, I guess there's a chance the change will be obvious. Thanks. That's a decent starting point.
  8. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    Ok I used coherent debugger and the errors are pretty comprehensive. Basically every file is in error now. /facepalm

    Is this useful to anyone at first glance?

    I'm hoping I'm missing something simple.

    2015-12-25_201405.jpg

    What it looks like on failure is this:
    So I'm not sure where to begin. The folder structure seems the same. For all I know the files are still good, but it's like they aren't being integrated properly. So I'm guessing the error is in my card file?

    2015-12-25_201356.jpg
    Here is the code to my card file: Is anything obviously incompatible with Titans?

    Code:
    // Technological Merits
    // -
    // SXX and requisites Unlocked
    // Subcommanders: 1
    // Direct build of bot fabbers and orbital launcher.
    //
    // Technological Flaws
    // -
    // No Navy
    // 1 Slot
    
    define([
        'module',
        'shared/gw_common',
        'shared/gw_factions',
        'cards/gwc_start',
    ], function (
        module,
        GW,
        GWFactions,
        GWCStart
    ) {
        var CARD = { id: /[^\/]+$/.exec(module.id).pop() };
    
        return {
            visible: function (params) { return false; },
            summarize: function (params) {
                return "Adrianna's Butcher of Meanies";
            },
            icon: function (params) {
                return "coui://ui/mods/images/blank.png";
            },
            describe: function (params) { return "Lo did the minions of the goddess of wisdom and love crusade across the universe purging galaxy after galaxy, large and small, weak and strong, of all agents of pain and death, leaving room only for life, joy, and diversity."; },
            getContext: function (galaxy, inventory) {
                return {
                    faction: inventory.getTag('global', 'playerFaction') || 0
                };
            },
            deal: function (system, context) {
                var minions = _.shuffle(GWFactions[context.faction].minions.slice(0));
                return {
                    params: {
                        minions: minions.slice(0, 1),
                        allowOverflow: true
                    },
                    chance: 0
                };
            },
            buff: function (inventory, context) {
                if (inventory.lookupCard(CARD) === 0) {
                    // Make sure we only do the start buff/dull once
                    var buffCount = inventory.getTag("", "buffCount", 0);
                    if (!buffCount) {
                        GWCStart.buff(inventory);
                       
                        //increase slot count
                        inventory.maxCards(inventory.maxCards() - 2);
    
                        //Unit unlocks
                        inventory.addUnits([
                            //'/pa/units/air/air_factory/air_factory.json',
                            //'/pa/units/air/air_scout/air_scout.json',
                            //'/pa/units/air/bomber/bomber.json',
                            //'/pa/units/air/fighter/fighter.json',
                            //'/pa/units/orbital/orbital_fighter/orbital_fighter.json'
                            //'/pa/units/land/assault_bot/assault_bot.json',
                            //'/pa/units/air/fabrication_aircraft/fabrication_aircraft.json',
                            //'/pa/units/air/fabrication_aircraft_adv/fabrication_aircraft_adv.json',
                            //'/pa/units/land/fabrication_bot/fabrication_bot.json',
                            //'/pa/units/land/fabrication_bot_adv/fabrication_bot_adv.json',
                            //'/pa/units/land/artillery_long/artillery_long.json',
                            //'/pa/units/land/bot_factory/bot_factory.json',
                            //'/pa/units/land/bot_bomb/bot_bomb.json',
                            '/pa/units/orbital/orbital_fabrication_bot/orbital_fabrication_bot.json',
                            '/pa/units/orbital/orbital_laser/orbital_laser.json',
                            '/pa/units/orbital/orbital_factory/orbital_factory.json'
                            //'/pa/units/air/air_cyclops/air_cyclops.json'
                        ]);
                        inventory.removeUnits([
                            "/pa/units/sea/naval_factory/naval_factory.json"
                        ]);
                       
                        //code to add sub-commander(s)
                        _.forEach(context.minions, function(minion) {
                            inventory.minions.push(minion);
                        });
                        var minionSpecs = _.pluck(_.filter(_.pluck(context.minions, 'commander')), 'UnitSpec');
                        inventory.addUnits(minionSpecs);
    
                        //allow commander to build all t1 structures
                        var mods = [];//empty mod array, where mods to units will be added before being applied
    
                        var comm = [//an array of a group of units to mod the same way
                            '/pa/units/commanders/base_commander/base_commander.json'
                        ];
                        var modUnit = function(unit) {//a function to mod a unit
                            mods.push({//add a mod to the mods array
                                file: unit,//the current unit
                                path: 'buildable_types',//the attribute to alter
                                op: 'replace',//the way to alter, another common way is multiply
                                //value: 'CmdBuild | Structure & Basic | Orbital & Structure & Advanced & Recon | Artillery & Advanced & Structure | Fabber & Construction & Bot' //All basic structures
                                value: 'CmdBuild | Fabber & Construction & Bot | orbital & factory & construction & structure & basic' //Com Build Selection Plus Fabber Bots and Orbital Factory
                            });
                           
                           
                        };
                        _.forEach(comm, modUnit);//for every element x of the comm array, execute modUnit(x)
    
                        inventory.addMods(mods);//apply all unit mods in the mods array
    
                    }
                    else {
                        // Don"t clog up a slot.
                        inventory.maxCards(inventory.maxCards() + 1);
                    }
                    ++buffCount;
                    inventory.setTag("", "buffCount", buffCount);
                }
                else {
                    // Don"t clog up a slot.
                    inventory.maxCards(inventory.maxCards() + 1);
                    GW.bank.addStartCard(CARD);
                }
            },
            dull: function (inventory) {
                if (inventory.lookupCard(CARD) === 0) {
                    var buffCount = inventory.getTag("", "buffCount", 0);
                    if (buffCount) {
                        // Perform dulls here
                       
                        inventory.setTag("", "buffCount", undefined);
                    }
                }
            }
        };
    });
  9. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Is the card the only file? I seem to recall that getting the game to load new cards required shadowing out another code file, which may have changed considerably.
    bsergent likes this.
  10. mysticalfists

    mysticalfists Member

    Messages:
    92
    Likes Received:
    40
    Not sure if this is what you're referring to, but to load a new card in GW you also had to add it to gw_dealer.js in ui\main\game\galactic_war\gw_start. I'm having a similar issue finding build.js, which doesn't seem to exist.

    EDIT: I'm dumb, I found build.js, lol.
  11. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    These are the files in my mod:
    modinfo.json
    blank.png
    gw_dealer.js
    gw_start.js
    ino_start_modular.js

    I tried looking for a working loadout mod for titans to dissect.

    I gotta say the debugger isn't helpful to me at all in this instance.

    Thanks guys for trying to help, I appreciate it :)
  12. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Both of the stock files will need be made current with the base game. If you just added card to the list, easiest thing may be to get fresh copies and make your edits. Is the other file the card? I didn't see any red flags there, though you may want to double-check the faction structure.
    bsergent likes this.
  13. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    I've basically remade the mod using the existing files as a guide. I've made some progress, in that now the list loads but Adri's butcher isn't in the list.

    I renamed what I have to .old, and replaced the files one by one with stock shadows and then moved over the edits as best I could using notepad++'s compare plugin as a guide for what needed moving.

    The modular js is named that way because originally the plan was to make a more general type of mod before I understood that this approach wasn't possible. I don't see a point to changing it since players won't see it. /shrugs

    Attached is the current version of the mod. Maybe someone could scroll through the edits and tell me what I've left out or done wrong?

    The four files I've edited are:
    gw_dealer.js (shadowed and edited)
    gw_start.js (shadowed and edited)
    ino_start_modular.js (shadowed vehicle commander card, edited)
    modinfo.json (I incremented the version number in mod info for once I get it working and upload it.)

    Thanks again for helping. It is appreciated.

    Attached Files:

    Last edited: December 27, 2015
  14. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    You don't need anything in the modinfo scenes, but I don't think it hurts anything.

    There is an apostrophe in the single-quoted card name; use double quotes or backslash escape the apostrophe.

    'minions' is undefined in 'deal', and 'context' is undefined in 'buff'. PA and/or the debugger got really bad about reporting undefined symbols a little while ago. See gwc_start_subcdr for how it's structured.
  15. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    You mean inside ino_start_modular.js? Like this?

    Code:
                return "!LOC:Adrianna's Butcher of Meanies";
    I don't know what you mean by undefined. They look fine to me compared to other cards. I'm missing something.

    Specific examples are the most instructive to me. I never was at the stage where I can do this conversationally.

    I don't see the problem you're expecting me to see. I've compared them. I'm looking at them in notepad++ compare and I still don't see a problem.
  16. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Yes

    Code:
            deal: function (system) {
                return {
                    params: {
                        minions: minions.slice(0, 1),
                        allowOverflow: true
                    },
                    chance: 0
                };
            },
    
    When subcommander does something similar there is an additional line

    Code:
                var minions = _.shuffle(GWFactions[context.faction].minions.slice(0));
    
    Which in turn depends on the two factions declarations at top. This one also depends (context.faction) on the faction set up in getContext. If you copy that into yours, you'll also need to add the context parameter to your deal, similar to buff:

    Buff references context.minions, but context isn't provided. You have

    Code:
            buff: function (inventory) {
    
    While subcommander has

    Code:
            buff: function (inventory, context) {
    
  17. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
    I tried doing as you suggested. It's still not showing up in the list at all. But then again neither is the one you're having me mimic.

    I don't know anything about factions, I just want the loadout to come with a subcommander. I'm assuming you're telling me I have to copy that stuff in before it'll be listed at all.

    In anycase here is my entire still unworking ino_start_modular.js plus the changes I think you're telling me to make.

    Remarks at the top of the file match my goals for the loadout.

    Side question: If I get this working for titans does that mean it'll be broken for "classic" users?

    Code:
    // !LOCNS:galactic_war
    // Technological Merits
    // -
    // SXX and requisites Unlocked
    // Subcommanders: 1
    // Direct build of bot fabbers and orbital launcher.
    //
    // Technological Flaws
    // -
    // No Navy
    // 1 Slot
    
    define([
        'module',
        'shared/gw_common',
        'shared/gw_factions',
        'cards/gwc_start',
    ], function (
        module,
        GW,
        GWFactions,
        GWCStart
    ) {
        var CARD = { id: /[^\/]+$/.exec(module.id).pop() };
    
        return {
            visible: function (params) { return false; },
            summarize: function (params) {
    
                return "!LOC:Adrianna's Butcher of Meanies";
            },
            icon: function (params) {
                return 'coui://ui/main/game/galactic_war/shared/img/red-commander.png';
            },
    
            describe: function (params) { return '!LOC:Lo did the minions of the goddess of wisdom and love crusade across the universe purging galaxy after galaxy, large and small, weak and strong, of all agents of pain and death, leaving room only for life, joy, and diversity.'; },
    
            hint: function () {
                return {
                    icon: 'coui://ui/main/game/galactic_war/gw_play/img/tech/gwc_commander_locked.png',
                    description: '!LOC:Seek out First Seeker Osiris on Xianyao. There you will find the loadout your friends desire.'
                };
            },
            getContext: function (galaxy, inventory) {
                return {
                    faction: inventory.getTag('global', 'playerFaction') || 0
                };
            },
    
            deal: function (system, context, inventory) {
                var minions = _.shuffle(GWFactions[context.faction].minions.slice(0));
                return {
                    params: {
                        minions: minions.slice(0, 1),
                        allowOverflow: true
                    },
                    chance: 0
                };
            },
            buff: function (inventory, context) {
                if (inventory.lookupCard(CARD) === 0) {
                    // Make sure we only do the start buff/dull once
                    var buffCount = inventory.getTag('', 'buffCount', 0);
                    if (!buffCount) {
                        GWCStart.buff(inventory);
                       inventory.maxCards(inventory.maxCards() - 1);
                        inventory.addUnits([
    
    
                             '/pa/units/orbital/orbital_fabrication_bot/orbital_fabrication_bot.json',
                            '/pa/units/orbital/orbital_laser/orbital_laser.json',
                            '/pa/units/orbital/orbital_factory/orbital_factory.json'
                        ]);
                        inventory.removeUnits([
                            "/pa/units/sea/naval_factory/naval_factory.json"
                        ]);
                        //code to add sub-commander(s)
                        _.forEach(context.minions, function(minion) {
                            inventory.minions.push(minion);
                        });
                        var minionSpecs = _.pluck(_.filter(_.pluck(context.minions, 'commander')), 'UnitSpec');
                        inventory.addUnits(minionSpecs);
    
                        //allow commander to build all t1 structures
                        var mods = [];//empty mod array, where mods to units will be added before being applied
    
                        var comm = [//an array of a group of units to mod the same way
                            '/pa/units/commanders/base_commander/base_commander.json'
                        ];
                        var modUnit = function(unit) {//a function to mod a unit
                            mods.push({//add a mod to the mods array
                                file: unit,//the current unit
                                path: 'buildable_types',//the attribute to alter
                                op: 'replace',//the way to alter, another common way is multiply
                                //value: 'CmdBuild | Structure & Basic | Orbital & Structure & Advanced & Recon | Artillery & Advanced & Structure | Fabber & Construction & Bot' //All basic structures
                                value: 'CmdBuild | Fabber & Construction & Bot | orbital & factory & construction & structure & basic' //Com Build Selection Plus Fabber Bots and Orbital Factory
                            });
                           
                           
                        };
                        _.forEach(comm, modUnit);//for every element x of the comm array, execute modUnit(x)
    
                        inventory.addMods(mods);//apply all unit mods in the mods array
                    }
                    else {
                        // Don't clog up a slot.
                        inventory.maxCards(inventory.maxCards() + 1);
                    }
                    ++buffCount;
                    inventory.setTag('', 'buffCount', buffCount);
                }
                else {
                    // Don't clog up a slot.
                    inventory.maxCards(inventory.maxCards() + 1);
                    GW.bank.addStartCard(CARD);
                }
            },
            dull: function (inventory) {
                if (inventory.lookupCard(CARD) === 0) {
                    var buffCount = inventory.getTag('', 'buffCount', 0);
                    if (buffCount) {
                        // Perform dulls here
    
                       
                        inventory.setTag('', 'buffCount', undefined);
                    }
                }
            }
        };
    });
    
  18. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    That is pretty bizzare. It does need to be made availiable in gw_start; the brute force way is make everything available.

    Code:
                var known = _.map(startCards, function(cardData, index) {
                    // Note: First card is built-in
                    //if (index !== 0 && !GW.bank.hasStartCard(cardData))
                        //return makeUnknown(cardData);
                    //else
                        return makeKnown(cardData);
                });
    
    One more detail needs to be synced up, I think it's because of the commander change. You have

    Code:
    var minionSpecs = _.pluck(_.filter(_.pluck(context.minions, 'commander')), 'UnitSpec');
    
    start_subcdr has:

    Code:
    var minionSpecs = _.filter(_.pluck(context.minions, 'commander'));
    
    The code is the same, so the file shadows should not be an issue. As long as you don't reference titans-only units, the card ought to work.
  19. bsergent

    bsergent Active Member

    Messages:
    236
    Likes Received:
    73
  20. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Still shows up as locked. I don't see any changes to the known map, what else did you change to try and make it available?

Share This Page