[WIP]Adding Unit Cannon

Discussion in 'Work-In-Progress Mods' started by someonewhoisnobody, September 3, 2014.

  1. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    This is a mod which will hopefully add the Unit Cannon into the game in some sort of functioning form.

    Strategy 1
    The basic idea,
    The basic idea of how to make this work is inspired by the Puppet Master Mod and the way it spawns in units. In this mod a drop pod comes down from the sky(Like when the commander enters at the start of the game) and as the smoke is clearing a unit spawns in.

    The Unit Cannon will be a factory which creates Orbital Drop Pods. When a unit is loaded into the Unit Cannon it is places in a queue and is despawned. When a Orbital Drop Pod is fired and lands it spawns the next unit in the queue. The Unit Cannon will be capable of fabbing 5 Orbital Drop Pods and storing them in the back end of it(Kind of like an anti nuke launcher)

    What I have so far
    • I have made the Unit Cannon a unit that is buildable by advanced fabbers in the game, the cost and and all that good stuff is still undecided
    • I have made the Unit Cannon a factory which fabricates Orbital Drop Pods(Using the model of a folded up atrusius), the cost and balance is still undecided
    • The Unit Cannon is capable of firing Orbital Drop Pods in a somewhat convincing way, more tweaking is needed
    What is needed
    • An icon for the Unit Cannon
    • An Icon for the Orbital Drop Pods
    • Correct cost and balance of all Unit Cannon related units
    • Figure out how to manage Unit Cannon Queue
    • Figure out how to spawn in units when Orbital Drop Pod lands
    • Make Unit Cannon correctly position the 5 stored Orbital Drop Pods at the back of the Unit Cannon
      • The requires adding 5 bones in the spaces where you want each of the 5 Orbital Drop Pods to be stored and then changing the storage slots bone names according to each bone that you added.


    Strategy 2
    The basic idea,
    With this strategy the Unit Cannon is more of a orbital factory for land units. It probably makes more sense for there to be a Bot and Vehicle Unit Cannon if this strategy is used. It looks like the technology used to deliver units from the orbital factory to the orbital layer could be used for a Unit Cannon.

    What I have so far
    • A very loose understanding of how this technology works and how it can be implemented
    What is needed
    • Figure out how to make Unit Cannon deploy these Pods to the correct location with the correct unit inside.


    Git Repository
    I am currently storing all my code in this Github repository. If you want to test this mod set and find any issues then please submit an issue on this Github repo. If you would like to contribute just make pull requests and I will add them if they are productive. When you look at the repo you will notice 2 main folders
    • com.noahhupert.pa.unitCannon
    • com.noahhuppert.pa.unitCannonClientSide
    Each of these folders contains a mod that makes the Unit Cannon possible.

    com.noahhuppert.pa.unitCannon ~ Contains all the server side code needed to create the Unit Cannon and make it function as needed.

    com.noahhuppert.pa.unitCannonClientSide ~ Contains client side code to make the Unit Cannon possible.

    Further explanation of the need for client side code:
    Currently in Planetary Annihilation ammo types(Like nukes or anti nukes) are not added to the unit list in the correct way. This means that the data that is contained within the .json files is not passed on to the UI. As a result of this when you hover over ammo that is not added in a special kinda hacky way no extra info will come up. After a great deal of being confused I came across a couple pieces of code in `live_game.js` which are used to manually add the correct data to the UI for the ammo. What the client side code does is override the method that responds to the engine call to get all unit data for the UI and then add in the data for the Unit Cannon ammo and the rest of the regular units. Without this mod installed on the clients game the only thing that will happen is the user will not be able to see the Orbital Drop Pod ammo details.


    Once again, if you are interested in helping, just submit pull requests to the repo or PM me with suggestions.
    If you do contribute code, please make sure that the game runs successfully before you submit a pull request, otherwise it will be denied. To help with this try and use a linter while writing your code(Most IDEs have plugins that can be installed to help lint your code as you write it)
    Last edited: September 3, 2014
    kjotak109, wondible and SXX like this.
  2. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
  3. liquius

    liquius Well-Known Member

    Messages:
    731
    Likes Received:
    482
    I would get that bit out of the way first. Lots of people have attempted this and the only bit they can't get around is spawning units in.
  4. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Long story short: It is actually possible. However ONLY for projectiles which were created as a capsule for a factory. Look at the orbital launcher for an example.
    Or the specific post linked by raevn for how to overcome the limitation of aiming and packing at the same time.
  5. liquius

    liquius Well-Known Member

    Messages:
    731
    Likes Received:
    482
    You should really be saying "in theory its possible". The method with the orbital launch does look promising, however the chances of that working without running into any brick walls is slim.
  6. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    @exterminans @liquius The real problem is figuring out when the Drop Pod lands and then acting accordingly. I think this is possible to do because somehow PA Stats figures out where units are and how many of them. I believe this is done via looking at all the events. So in theory I could apply similar tech and just spawn.

    It looks like the method I am going with now(Solution #1) is probably the best option. This is because the Drop Pods will always go to where they where aimed, even inter planetary.
  7. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    You can't. You have no possibility of running server side scripts yet. If that was possible, don't you think the Unit Cannon would been long finished as a mod?

    For now (and probably the next few weeks/months), you are stuck with whatever parameters the json files provide. Which is btw. the way to go, either way. Running custom scripts will always be a last resort if everything else fails.

    PA Stats either counts unique unit IDs in game or looks at the final statistic, I don't know. But it's no reference either, since that mod is running purely client side. Unfortunately, that won't help you much with spawning stuff on the server.
  8. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    O.0
    Then how does PA stats do this:
    [​IMG]
  9. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    PA Stats either counts unique unit IDs in game or looks at the final statistic, I don't know. But it's no reference either, since that mod is running purely client side. Unfortunately, that won't help you much with spawning stuff on the server.

    All you could do for now (hint: you shouldn't) is to take a peek at the "Puppet Master"-mod which abuses an additional client with cheat permissions to spawn units.
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Black magic.

    PA Stats internally asks the game to send it ALL unit build/destroyed events. Those contain the camera position that would be used to focus at the event if the event is clicked. That position is used as "unit position". It might very well be that those coordinates are actually somewhere high up in the sky, but since that error is made consistently for all events it doesn't matter at all for what PA Stats needs it for.

    The biggest problem for a unit canon script btw probably is that units spawn in whereever the mouse of the current user is via cheat. I don't think there is any other way to control the position. So your best bet would be a unit cannon that has client side scripts to manage how many units are in it and then have the user click somewhere and cheat in units at that location. I can't think of any way to do anything fancy looking inbetween.

    To add resource costs to the unit cannon you could do the hack I used in murder party: Spawn in a totally invisible building that has negative income. You can additionally add a client side script that will try to look for attempts to delete that structure.

    EDIT:
    Actually you could probably use the event of the finished construction of the drop pods as a trigger to count up some counter that allows the user to select the unit cannon and then click somewhere to spawn in the units. Would be more like a unit teleporter though.
  11. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    So we could rework this idea to make it so when the unit cannon fires a pod it create an allowance for 1 unit that you have to be spawn in. Then the user could select a unit and click on a pod(I am assuming you could check to see if they clicked on the pod).

    If that doesn't work then we could beg @chargrove to give us support for unit spawning at places besides the mouse.
  12. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    You can monitor the selections to check for the click on the pod, yes.
  13. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Once again, you have no access to server side scripting. And creating an "allowance" on the client side is not only ugly, you are BEGGING for players to cheat. This type of cheat also requires you to enable the unit spawn cheat in general.
  14. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    It's the only way to do it right now, so somebody ought to do it. :p
    someonewhoisnobody and igncom1 like this.
  15. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Remember the "Please steal my password"-mod? Someone had to do that too.
  16. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Yeah sure, why not.
  17. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    There can be methods in which the server side part checks to make sure that the client is being legit, or other things...(Purposefully being vague because I don't want to tell people these methods so they can get around them)
  18. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    And there we got yet another deadly programmer sin - "security" by obfuscation.

    Just face it, the unit canon can't be done properly for now. Trying the ballistic approach with the auxiliary projectile is still the best approach for now. From there on, it only goes downwards.
  19. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    You can't script server side. If you enable cheats, cheats are enabled. You can't do anything about that. You can modify the client UI to prevent people from easily cheating, but if someone knows how to enter commands into the console he will be able to cheat.
    You also can't hide anything as mods have to be open source if you want people to actually use them.
  20. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    @exterminans @cola_colin The most I could do is make sure that the code from the client side mod is kinda ok. Thats about it. But as cola said, if cheats are enabled, they are enabled. Unit they add it for real, we will just have to deal with it.

    exterminans:
    He he, yea. Especially since the code is in a public repo :)

Share This Page