Beginners Custom CO Tutorial

Revision as of 07:58, 16 December 2023 by Knightlord07 (talk | contribs) (Part 1 Tutorial)

This is a beginners Custom CO Tutorial work

This is a simple tutorial for beginners, new or fresh coders to want to make their own custom CO in COW

So first off you need to have this

var Constructor = function () {
    this.init = function (co, map) {
        co.setPowerStars(3);
        co.setSuperpowerStars(3);
    };

    this.activatePower = function(co, map)
    {
        var dialogAnimation = co.createPowerSentence();
        var powerNameAnimation = co.createPowerScreen(GameEnums.PowerMode_Power);
        dialogAnimation.queueAnimation(powerNameAnimation);

        var units = co.getOwner().getUnits();
        var animations = [];
        var counter = 0;
        units.randomize();
        for (var i = 0; i < units.size(); i++)
        {
            var unit = units.at(i);

            var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
            animation.writeDataInt32(unit.getX());
            animation.writeDataInt32(unit.getY());
            animation.writeDataInt32(2);
            animation.setEndOfAnimationCall("ANIMATION", "postAnimationHeal");
            var delay = globals.randInt(135, 265);
            if (animations.length < 5)
            {
                delay *= i;
            }
            animation.setSound("power0.wav", 1, delay);
            if (animations.length < 5)
            {
                animation.addSprite("power0", -map.getImageSize() * 1.27, -map.getImageSize() * 1.27, 0, 2, delay);
                powerNameAnimation.queueAnimation(animation);
                animations.push(animation);
            }
            else
            {
                animation.addSprite("power0", -map.getImageSize() * 1.27, -map.getImageSize() * 1.27, 0, 2, delay);
                animations[counter].queueAnimation(animation);
                animations[counter] = animation;
                counter++;
                if (counter >= animations.length)
                {
                    counter = 0;
                }
            }
        }
        units.remove();
    };


    this.activateSuperpower = function(co, powerMode, map)
    {
        var dialogAnimation = co.createPowerSentence();
        var powerNameAnimation = co.createPowerScreen(powerMode);
        powerNameAnimation.queueAnimationBefore(dialogAnimation);

        var units = co.getOwner().getUnits();
        var animations = [];
        var counter = 0;
        units.randomize();
        for (var i = 0; i < units.size(); i++)
        {
            var unit = units.at(i);

            var animation = GameAnimationFactory.createAnimation(map, unit.getX(), unit.getY());
            animation.writeDataInt32(unit.getX());
            animation.writeDataInt32(unit.getY());
            animation.writeDataInt32(8);
            animation.setEndOfAnimationCall("ANIMATION", "postAnimationHeal");
            var delay = globals.randInt(135, 265);
            if (animations.length < 7)
            {
                delay *= i;
            }
            if (i % 2 === 0)
            {
                animation.setSound("power12_1.wav", 1, delay);
            }
            else
            {
                animation.setSound("power12_2.wav", 1, delay);
            }
            if (animations.length < 7)
            {
                animation.addSprite("power12", -map.getImageSize() * 2, -map.getImageSize() * 2, 0, 2, delay);
                powerNameAnimation.queueAnimation(animation);
                animations.push(animation);
            }
            else
            {
                animation.addSprite("power12", -map.getImageSize() * 2, -map.getImageSize() * 2, 0, 2, delay);
                animations[counter].queueAnimation(animation);
                animations[counter] = animation;
                counter++;
                if (counter >= animations.length)
                {
                    counter = 0;
                }
            }
        }
        units.remove();
    };

    this.loadCOMusic = function (co, map) {
        // put the co music in here.
        switch (co.getPowerMode()) {
            case GameEnums.PowerMode_Power:
                audio.addMusic("mods/testco/music/cos/Power.mp3", 0, 0);
                break;
            case GameEnums.PowerMode_Superpower:
                audio.addMusic("mods/testco/music/cos/Super.mp3", 0, 0);
                break;
            case GameEnums.PowerMode_Tagpower:
                audio.addMusic("mods/testco/music/cos/Super.mp3", 0, 0);
                break;
            default:
                audio.addMusic("mods/testco/music/cos/Theme.mp3", 0, 0);
                break;
        }
    };

    this.getCOUnitRange = function (co, map) {
        return Number;
    };
    this.getCOArmy = function () {
        return "Vanilla Base Game or custom";
    };
    // CO - Intel
    this.getBio = function (co) {
        return qsTr("Type for your own description");
    };
    this.getLongBio = function(co, map)
    {
        return qsTr("\n\n\"Special Message Quote\"");
    };
    this.getHits = function (co) {
        return qsTr("");
    };
    this.getMiss = function (co) {
        return qsTr("");
    };
    this.getCODescription = function (co) {
        return qsTr("Type for your own description only affect D2D or CO zone Effect");
    };
    this.getLongCODescription = function() {
    return qsTr("\nD2D Effect: \nType your D2D ability") +
           qsTr("\n\nZone Effect: \nType your CO Zone ability");
    };
    this.getPowerDescription = function (co) {
        return qsTr("Type for your own description for power (COP)");
    };
    this.getPowerName = function (co) {
        return qsTr("Name");
    };
    this.getSuperPowerDescription = function (co) {
        return qsTr("Type for your own description for super power (SCOP)");
    };
    this.getSuperPowerName = function (co) {
        return qsTr("Name");
    };
    this.getPowerSentences = function (co) {
        switch (co.getPowerMode()) {
            case GameEnums.PowerMode_Power:
            return [qsTr("Type here for your own power quotes")];
            break;
            case GameEnums.PowerMode_Superpower:
            return [qsTr("Type here for your own super power quotes")];
            break;
            case GameEnums.PowerMode_Tagpower:
            return [qsTr("("Type here for your own tag power quotes")];
            break; 
            }
    };
    this.getVictorySentences = function (co) {
        return [qsTr("Type here for your own victory quotes")];
    };
    this.getDefeatSentences = function (co) {
        return [qsTr("Type here for your own defeat quotes")];
    };
    this.getName = function () {
        return qsTr("Name");
    };
}

Constructor.prototype = CO;
var CO_TEST = new Constructor();
//Make sure put that CO_NAME (CO_TEST) in full caps lock in order to getting working

Feel free to copy that code block to get started!

Now you need some stats, just mainly your Custom Co D2D, Power & Super Power

Stats Code Library (D2D, other abilities & ects)

Terrain Codes (Modified terrain itself)

Weather Codes (Weather manipulations)

Building (Props for income bonus)

Or you could visit Github for some COs coding Resource work https://github.com/Robosturm/Commander_Wars/tree/master/resources/scripts/cos

If you got your very first setup (if you got copy it from the code block above) you good to go follow this next step!

Stats, Co zone & abilities

This is the second part of the tutorial