This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Ticket #2160: regicideWIP.patch

File regicideWIP.patch, 8.5 KB (added by Sandarac, 8 years ago)

This is a rough version of a "Regicide" game mode. Works on maps that start with civic centers.

  • binaries/data/mods/public/maps/scripts/Regicide.js

     
     1var saint = "units/athen_hero_saint"
     2
     3Trigger.prototype.CheckRegicideDefeat = function(data)
     4{
     5    if (data.entity == cmpTrigger.saints[data.from])
     6        TriggerHelper.DefeatPlayer(data.from);
     7
     8};
     9
     10Trigger.prototype.InitGame = function(msg)
     11{
     12    var numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
     13
     14    for (var i = 1; i < numberOfPlayers; ++i)
     15    {
     16        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     17        var playerEntities = cmpRangeManager.GetEntitiesByPlayer(i);
     18       
     19        for (let entity of playerEntities)
     20            if (TriggerHelper.EntityHasClass(entity, "CivilCentre"))
     21                cmpTrigger.playerCivicCenter[i] = entity;
     22    }
     23   
     24    let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     25    let numPlayers = cmpPlayerManager.GetNumPlayers();
     26
     27    let player = 1
     28    for (let civCenter in cmpTrigger.playerCivicCenter)
     29    {
     30        TriggerHelper.SpawnUnits(cmpTrigger.playerCivicCenter[civCenter], saint, 1, player);
     31        ++player;
     32    }
     33
     34    for (var i = 1; i < numberOfPlayers; ++i)
     35    {
     36        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     37        var playerEntities = cmpRangeManager.GetEntitiesByPlayer(i); // Get all of each player's entities
     38       
     39        for (let entity of playerEntities)
     40            if (TriggerHelper.EntityHasClass(entity, "Saint"))
     41                cmpTrigger.saints[i] = entity;
     42    }
     43
     44};
     45
     46var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
     47cmpTrigger.playerCivicCenter = {};
     48cmpTrigger.saints = {};
     49cmpTrigger.DoAfterDelay(0, "InitGame", {});
     50
     51cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true });
  • binaries/data/mods/public/simulation/components/Identity.js

     
    6464        "</element>" +
    6565    "</optional>" +
    6666    "<optional>" +
    67         "<element name='Classes' a:help='Optional list of space-separated classes applying to this entity. Choices include: Unit, Infantry, Melee, Cavalry, Ranged, Mechanical, Ship, Siege, Champion, Hero, Elephant, Chariot, Mercenary, Spear, Sword, Bow, Javelin, Sling, Support, Animal, Domestic, Organic, Structure, Civic, CivCentre, Economic, Defensive, Gates, Wall, BarterMarket, Village, Town, City, ConquestCritical, Worker, Female, Healer, Slave, CitizenSoldier, Trade, Market, NavalMarket, Warship, SeaCreature, ForestPlant, DropsiteFood, DropsiteWood, DropsiteStone, DropsiteMetal, GarrisonTower, GarrisonFortress'>" +
     67        "<element name='Classes' a:help='Optional list of space-separated classes applying to this entity. Choices include: Unit, Infantry, Melee, Cavalry, Ranged, Mechanical, Ship, Siege, Champion, Hero, Elephant, Chariot, Mercenary, Saint, Spear, Sword, Bow, Javelin, Sling, Support, Animal, Domestic, Organic, Structure, Civic, CivCentre, Economic, Defensive, Gates, Wall, BarterMarket, Village, Town, City, ConquestCritical, Worker, Female, Healer, Slave, CitizenSoldier, Trade, Market, NavalMarket, Warship, SeaCreature, ForestPlant, DropsiteFood, DropsiteWood, DropsiteStone, DropsiteMetal, GarrisonTower, GarrisonFortress'>" +
    6868            "<attribute name='datatype'>" +
    6969                "<value>tokens</value>" +
    7070            "</attribute>" +
  • binaries/data/mods/public/simulation/components/interfaces/Saint.js

     
     1Engine.RegisterInterface("Saint");
  • binaries/data/mods/public/simulation/components/Saint.js

     
     1function Saint() {}
     2
     3Saint.prototype.Schema = "<a:component type='system'/><empty/>";
     4
     5Saint.prototype.Init = function()
     6{
     7};
     8
     9Saint.prototype.Serialize = null;
     10
     11Engine.RegisterComponentType(IID_Saint, "Saint", Saint);
  • binaries/data/mods/public/simulation/data/settings/victory_conditions/regicide.json

     
     1{
     2    "TranslatedKeys": ["Title", "Description"],
     3    "Data":
     4    {
     5        "Title": "Regicide",
     6        "Description": "Keep your special unit alive to win",
     7        "Scripts":
     8        [
     9            "scripts/TriggerHelper.js",
     10            "scripts/ConquestCommon.js",
     11            "scripts/Conquest.js",
     12            "scripts/Regicide.js"
     13        ]
     14    }
     15}
  • binaries/data/mods/public/simulation/templates/template_unit_support_saint.xml

     
     1<?xml version="1.0" encoding="utf-8"?>
     2<Entity parent="template_unit_support">
     3  <Cost>
     4    <Resources>
     5      <food>250</food>
     6    </Resources>
     7  </Cost>
     8  <Health>
     9    <Max>600</Max>
     10  </Health>
     11  <Identity>
     12    <Classes datatype="tokens">Saint</Classes>
     13    <GenericName>Saint</GenericName>
     14    <VisibleClasses datatype="tokens">Saint</VisibleClasses>
     15    <Tooltip>Special unit for Regicide games.</Tooltip>
     16    <Rank>Basic</Rank>
     17  </Identity>
     18  <Minimap>
     19    <Type>hero</Type>
     20  </Minimap>
     21  <Selectable>
     22    <Overlay>
     23      <AlwaysVisible/>
     24      <Texture>
     25        <MainTexture>star/256x256.png</MainTexture>
     26        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
     27      </Texture>
     28    </Overlay>
     29  </Selectable>
     30  <Sound>
     31    <SoundGroups>
     32      <trained>interface/alarm/alarm_create_infantry.xml</trained>
     33      <select>voice/{lang}/civ/civ_{gender}_select.xml</select>
     34      <order_walk>voice/{lang}/civ/civ_{gender}_walk.xml</order_walk>
     35      <order_attack>voice/{lang}/civ/civ_{gender}_go_out_against.xml</order_attack>
     36      <order_gather>voice/{lang}/civ/civ_{gender}_gather.xml</order_gather>
     37      <order_repair>voice/{lang}/civ/civ_{gender}_repair.xml</order_repair>
     38      <order_heal>voice/{lang}/civ/civ_{gender}_heal.xml</order_heal>
     39      <order_garrison>voice/{lang}/civ/civ_{gender}_garrison.xml</order_garrison>
     40      <walk>actor/human/movement/walk.xml</walk>
     41      <run>actor/human/movement/run.xml</run>
     42      <death>actor/human/death/{gender}_death.xml</death>
     43    </SoundGroups>
     44  </Sound>
     45  <Saint />
     46  <UnitMotion>
     47    <WalkSpeed>9</WalkSpeed>
     48    <Run>
     49      <Speed>12.0</Speed>
     50      <Range>200.0</Range>
     51      <RangeMin>0.0</RangeMin>
     52    </Run>
     53  </UnitMotion>
     54  <Vision>
     55    <Range>30</Range>
     56  </Vision>
     57  <VisualActor>
     58    <Actor>units/mauryans/hero_chanakya.xml</Actor>
     59  </VisualActor>
     60</Entity>
  • binaries/data/mods/public/simulation/templates/units/athen_hero_saint.xml

     
     1<?xml version="1.0" encoding="utf-8"?>
     2<Entity parent="template_unit_support_saint">
     3  <Identity>
     4    <Civ>athen</Civ>
     5    <Lang>greek</Lang>
     6    <SelectionGroupName>units/athen_support_healer_b</SelectionGroupName>
     7    <SpecificName>Saint</SpecificName>
     8    <Icon>units/hele_support_healer.png</Icon>
     9  </Identity>
     10</Entity>
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp

     
    148148    gameTypes.Add(_T("conquest_units"));
    149149    gameTypes.Add(_T("wonder"));
    150150    gameTypes.Add(_T("endless"));
     151    gameTypes.Add(_T("regicide"));
    151152
    152153    wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
    153154    gridSizer->AddGrowableCol(1);