[WIP] Phantom

Discussion in 'Work-In-Progress Mods' started by cola_colin, January 17, 2015.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    What? I am surprised to see how many PA players do not know phantom.
    As requested here: https://forums.uberent.com/threads/phantom-mod.57578/

    This is a modification to the PA server that changes some winning conditions and introduces the Phantom FFA gamemode to PA.

    My current implementation of the game has phantoms, a paladin and innocents.
    Phantoms and Paladins get a resource bonus. Every minute from the moment they are assigned they get:
    50 metal/s (EDIT: upped these values a bit)
    5000 energy/s
    10k energy storage
    1k metal storage.

    So after 2 minutes they get twice that, at 3 minutes three times, etc.

    extra "out of thin air".

    The innocents get nothing ofc. Phantoms and Paladins are assigned in minute 7. Before that players can vote how many phantoms they want. Paladins are hardcoded to 1, but that can be configured.

    Winning conditions are:
    - Innocents: Stay alive. You can win as an alliance with other innocents and the paladin.
    - Paladin: Same for innocents, but you cannot win if all innocents die.
    - Phantom: Kill everything

    Ofc who is phantom or paladin is not public knowledge and needs to be talked out.
    Players start in an alliance, dynamic alliances are forced on.

    How to play
    To play you need a server that is modified. This mod needs no client side mod and no transient server mod, it is only a modification of the server. However I added a unit to the unit_list.json, so mods that shadow that file can make troubles. If you want to use such a mod, add the phantom_bonus unit (see below)
    I have setup a modified phantom server in the PTE (cause balance).
    Since I only can run 3 instances of PA + server on my own computer at once I only could do limited testing.
    You need PA Stats installed to see the server. Also it seems there are some bugs in the PA Stats listing, if you cant see the server while it should be there try to close and open the server browser.

    The technical side
    How to setup your own server.
    Setup your custom server as described in the exodus guide. Then modify it like this:

    unpack this zip into the media folder of your pa server:
    http://nanodesu.info/stuff/pa/mods/phantomserver.zip

    server-script/phantom/phantom_ingame:
    configure voteTime, assignTime, for example to 4 and 7. If you want to edit the bonus resources, edit the phantom_bonus unit!

    server-script/states/lobby:
    1.) new LobbyModel => patch it, so the line that creates the new LobbyModel looks like this:
    lobbyModel = require('phantom/phantom_lobby').patchLobby(new LobbyModel());

    2.) patch the handlers a few more lines below, so the line that defines the removeHandlers looks like this:
    var removeHandlers = server.setHandlers(require('phantom/phantom_lobby').patchHandlers({
    ... handlers ... })); // so the whole handlers block is given to patchhandlers which then returns it to be used by setHandlers

    3.) remove all game modes apart from FreeForAll from VALID_GAME_TYPES around line 50

    server-script/states/playing.js:
    1.) eval phantom_ingame right before setHandlers. Make sure to load the file directly at the start so it is ready.
    so load at the start of the file:
    var phantomScript = undefined;
    file.load('/server-script/phantom/phantom_ingame.js', function(contents) {
    phantomScript = contents;
    });

    and parse in the right moment:

    _.assign(transientHandlers ...

    eval(phantomScript); // this is the added eval. Right between the _.assign for the transient handlers and the cleanup.push for the server handlers.

    cleanup.push(server.setHandlers ...


    server-script/states/landing.js: (bugfix for PA @jorgenpt: It seems without this changing alliances while ingame will restart the game countdown. This happens in games with dynamic alliances on default servers)
    In landing.js around line 40 in startPlaying():
    change it so that countdownToPlay is only called if playing is false, so make it do this:
    if (!playing) {
    countdown...
    }
    playing = true;


    unit_list.json:
    insert "/pa/units/air/phantom_bonus/phantom_bonus.json", into unit_list.json

    now the server should be modified to run Phantom


    How is this implemented?

    Alliances and stuff can be modified on the server side easily. It is also in control of the life of the commanders and players and can assign winners and losers. The server can also deal with chat messages, so communication with players for the voting is no issue.
    The only issue is the bonus resources. To solve this I added a new unit to the server and the server only. It is given to phantoms and paladins via spawn unit calls. The unit is unknown to the clients and is not shown by them at all. It is also configured to be invisible to radar and invisible to plain sight as well as has no vision range or radar. The unit is an air unit so it blocks no space. It is spawned in a random location somewhere every minute for every phantom and paladin.
    Last edited: January 17, 2015
  2. stuart98

    stuart98 Post Master General

    Messages:
    6,009
    Likes Received:
    3,888
    20 metal and 1k energy is TINY. Needs moar resources.
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Once per minute from minute 7 onwards. So in minute 8 it is 40, then 60, etc...
    Also join now in the PTE to play a testgame.
  4. stuart98

    stuart98 Post Master General

    Messages:
    6,009
    Likes Received:
    3,888
    Oh I see. Nvm ignore me then. :D
  5. Maldor96

    Maldor96 Active Member

    Messages:
    213
    Likes Received:
    196
    Still testing?
  6. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    on pte the server is open yes
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Gas planets are kinda weird xD I think this probably plays best without them and maybe on a single planet instead of multiple ones.

    EDIT:
    First test was successful, tthough the Pax system is kinda bad for it: players just spam jigs, get crazy amounts of metal and the first player to rush the annihilazor just kills everyone.

    The phantom server will stay open on PTE, anyone may join it. All that is needed is PA Stats to join.
    Last edited: January 17, 2015
  8. Fricia

    Fricia New Member

    Messages:
    14
    Likes Received:
    8
    As a spectator it would be cool to know who the phantom and who the paladin is. Even though I did enjoy the tension :)

    Great work man, keep it up! This looks like a lot fun.
  9. stuart98

    stuart98 Post Master General

    Messages:
    6,009
    Likes Received:
    3,888
    I'm getting one hosted, join up. Play on PTE pl0x.
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    uh lol this works on the server:

    army.econ_rate = 13.37;

    So I guess no need for weird invisible units, I can easily just make it have a % bonus instead via the economy factor.

    Will update the mod with that tomorrow. Once that is in the mod works basically with no hacks. PA has all API required to make this mod directly.
  11. jorgenpt

    jorgenpt Uber Programmer Uber Alumni

    Messages:
    164
    Likes Received:
    390
    I will fix this for a future update.

Share This Page