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: Heroicide_v0.1.patch

File Heroicide_v0.1.patch, 3.3 KB (added by Sandarac, 8 years ago)

Heroicide step 1, works on all maps, including ones like Nomad and Sicilia Nomad (where units start on a ship).

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

     
     1Trigger.prototype.CheckHeroicideDefeat = function(data)
     2{
     3    if (data.entity == this.heroes[data.from])
     4        TriggerHelper.DefeatPlayer(data.from);
     5};
     6
     7Trigger.prototype.InitGame = function(msg)
     8{
     9    let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
     10    let heroTemplates = cmpTemplateManager.FindAllTemplates(false).filter(temp => temp.indexOf("_hero_") > -1 && temp.indexOf("campaigns") == -1);
     11
     12    let numberOfPlayers = TriggerHelper.GetNumberOfPlayers();
     13
     14    for (let i = 1; i < numberOfPlayers; ++i)
     15    {
     16        let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     17        let playerEntities = cmpRangeManager.GetEntitiesByPlayer(i);
     18        let spawnPoints = playerEntities.filter(p => TriggerHelper.EntityHasClass(p, "CivilCentre"));
     19
     20        if (!spawnPoints.length)
     21            spawnPoints = playerEntities.filter(p => TriggerHelper.EntityHasClass(p, "Ship"));
     22
     23        spawnPoints = spawnPoints.length ? spawnPoints : playerEntities;
     24
     25        let cmpPlayer = QueryPlayerIDInterface(i);
     26        let civHeros = heroTemplates.filter(hero => hero.indexOf(cmpPlayer.GetCiv()) > -1);
     27
     28        let heroTemplate = civHeros[Math.floor(Math.random() * civHeros.length)];
     29        this.heroes[i] = TriggerHelper.SpawnUnits(spawnPoints[0], heroTemplate, 1, i);
     30        if (TriggerHelper.EntityHasClass(spawnPoints[0], "Ship"))
     31        {
     32            let cmpUnitAI = Engine.QueryInterface(this.heroes[i][0], IID_UnitAI);
     33            cmpUnitAI.Garrison(spawnPoints[0]);
     34        }
     35    }
     36};
     37
     38let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
     39cmpTrigger.heroes = {};
     40cmpTrigger.DoAfterDelay(0, "InitGame", {});
     41
     42cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckHeroicideDefeat", { "enabled": true });
  • binaries/data/mods/public/simulation/data/settings/victory_conditions/heroicide.json

     
     1{
     2    "TranslatedKeys": ["Title", "Description"],
     3    "Data":
     4    {
     5        "Title": "Heroicide",
     6        "Description": "Keep your Hero alive to win",
     7        "Scripts":
     8        [
     9            "scripts/TriggerHelper.js",
     10            "scripts/ConquestCommon.js",
     11            "scripts/Conquest.js",
     12            "scripts/Heroicide.js"
     13        ]
     14    }
     15}
  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp

     
    1 /* Copyright (C) 2015 Wildfire Games.
     1/* Copyright (C) 2016 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    148148    gameTypes.Add(_T("conquest_units"));
    149149    gameTypes.Add(_T("wonder"));
    150150    gameTypes.Add(_T("endless"));
     151    gameTypes.Add(_T("heroicide"));
    151152
    152153    wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
    153154    gridSizer->AddGrowableCol(1);