Ticket #3477: ticket3477_metacheat.diff

File ticket3477_metacheat.diff, 3.7 KB (added by bb, 9 years ago)

Working patch, implenting a metacheat "gift from the gods". Using exsisting functions (could change to direct cheating) and a loop around the resources might be needed.

  • binaries/data/mods/public/simulation/data/cheats/metaCheat.json

     
     1{
     2    "Name": "gift from the gods",
     3    "Data": {
     4        "Action": "metacheat"
     5    }
     6}
  • binaries/data/mods/public/simulation/helpers/Cheat.js

     
    2222    case "addresource":
    2323        // force input.text to be an array
    2424        input.text = [].concat(input.text);
    25         for each (var type in input.text)
     25        for each (let type in input.text)
    2626            cmpPlayer.AddResource(type, input.parameter);
    27         break;
     27        return;
    2828    case "revealmap":
    2929        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    3030        cmpRangeManager.SetLosRevealAll(-1, true);
    31         break;
     31        return;
    3232    case "maxpopulation":
    3333        cmpPlayer.SetPopulationBonuses(500);
    34         break;
     34        return;
    3535    case "changemaxpopulation":
    3636        cmpPlayer.SetMaxPopulation(500);
    37         break;
     37        return;
    3838    case "convertunit":
    3939        for (let ent of input.selected)
    4040        {
     
    4242            if (cmpOwnership)
    4343                cmpOwnership.SetOwner(cmpPlayer.GetPlayerID());
    4444        }
    45         break;
     45        return;
    4646    case "killunits":
    4747        for (let ent of input.selected)
    4848        {
     
    5252            else
    5353                Engine.DestroyEntity(ent);
    5454        }
    55         break;
     55        return;
    5656    case "defeatplayer":
    5757        var playerEnt = cmpPlayerManager.GetPlayerByID(input.parameter);
    5858        if (playerEnt == INVALID_ENTITY)
    5959            return;
    6060        Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": input.parameter } );
    61         break;
     61        return;
    6262    case "createunits":
    6363        if (!input.selected[0])
    6464        {
     
    7474        }
    7575        for (let i = 0; i < input.parameter; ++i)
    7676            cmpProductionQueue.SpawnUnits(input.templates[i % input.templates.length], 1, null);
    77         break;
     77        return;
    7878    case "fastactions":
    7979        cmpPlayer.SetCheatTimeMultiplier((cmpPlayer.GetCheatTimeMultiplier() == 1) ? 0.01 : 1);
    80         break;
     80        return;
    8181    case "changespeed":
    8282        cmpPlayer.SetCheatTimeMultiplier(input.parameter);
    83         break;
     83        return;
    8484    case "changephase":
    8585        var cmpTechnologyManager = Engine.QueryInterface(playerEnt, IID_TechnologyManager);
    8686        if (!cmpTechnologyManager)
     
    103103        // rewrite input and call function
    104104        input.action = "researchTechnology";
    105105        Cheat(input);
    106         break;
     106        return;
    107107    case "researchTechnology":
    108108        // check, if name of technology is given
    109109        if (input.parameter.length == 0)
     
    166166        // check, if technology is already researched
    167167        if (!cmpTechnologyManager.IsTechnologyResearched(techname))
    168168            cmpTechnologyManager.ResearchTechnology(techname);
    169         break;
     169        return;
     170        case "metacheat":
     171        // resources
     172        input.parameter = 100000;
     173        var type = "food";
     174        cmpPlayer.AddResource(type, input.parameter);
     175        type = "wood";
     176        cmpPlayer.AddResource(type, input.parameter);
     177        type = "stone";
     178        cmpPlayer.AddResource(type, input.parameter);
     179        type = "metal";
     180        cmpPlayer.AddResource(type, input.parameter);
     181
     182        // max population "the hive master"
     183        input.action = "maxpopulation";
     184        Cheat(input);
     185
     186        // change max pupulation "TARDIS"
     187        input.action = "changemaxpopulation";
     188        Cheat(input);
     189
     190        // fast actions "i am too busy"
     191        input.action = "fastactions";
     192        Cheat(input);
     193
     194        // change phase "back to the future" * 2
     195        input.action = "changephase";
     196        Cheat(input);
     197        input.action = "changephase";
     198        Cheat(input);
     199        return;
    170200    default:
    171201        warn("Cheat '" + input.action + "' is not implemented");
    172         break;
     202        return;
    173203    }
    174204}
    175205