[Questions] "What's possible?" list

Discussion in 'Mod Discussions' started by swizzlewizzle, October 27, 2014.

  1. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Hello guys. Just wanted to post up some things i'm wondering about regarding what is doable with the scripts and engine that we currently have access to.

    1. On-hit event hooking - basically, the ability to run code whenever a weapon projectile weapon hits something (including the ground). This would be mainly to modify weapon's to include effects that change gameplay such as chain-lightning, projectile reflection, multi-explosion weapons, etc..
    If so, how can we do this now?

    2. Damage event interception - to add armor, damage types, etc... I'm asking here about if we can intercept the damage event between an projectile and a target so that we can add things such as damage types, armor, and other more complicated mechanisms.
    If so, what might be a possible way as things stand currently?

    3. Unit "Abilities" and/or changing guns dynamically - basically, the abilities system from games like dota 2, warcraft, sc 2, etc... If so, is it also possible to get the AI to use these abilities?

    4. "Spawners" - basically, an object that once created in the world will spawn other objects, projectiles, or graphical effects. Is this possible?
  2. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    1 & 2: I think you can turn on damage alerts for everything, but that's it.

    The uber-cannon uses a general secondary-weapon system with auto_attack off, so you can do things like that. I gave the Junkyard Wars units reclaim lathes, and then having gone to all that trouble, gave some of them the ability to build one structure, which acts kind of like a special ability.

    Units, weapons, ammo, and some effect objects (look for _ent.json) are all entites of a sort, but I don't think you can mix and match them much. The main avenue to explore would be factories with with an initial build spec and infinite build (see nuke and anti nuke for examples) We've used a unit with effectively infinite weapon range to make it self destruct, but that probably wouldn't work if you wanted the spawned projectile to have finite range ;^) Constant pure effects can be done - see jets on many aircraft.

    More might be possible if you did a Puppetmaster-style hack around create-unit, and one of the few things the server-scripts can do is spawn units and effects.
  3. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    @wondible 1/2 .. "damage alerts"? Perhaps you could be a bit more detailed about that? I have never see any mention of that before on the mod forums here..

    About your junkyard units being able to build one structure.. was the AI able to be modified to build when it should using those units?

    Finally, for your infinite weapon range unit.. was it able to target units on other planets? Also, is it possible to fire a projectile-less gun through the center of a planet (as long as it can aim down of course), basically telling the "projectile" to ignore collisions?
  4. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    live game has
    Code:
                engine.call('watchlist.setDamageAlertTypes', JSON.stringify(['Commander']), JSON.stringify([]));
    
    Use alertsManager if you are going to be changing alert filters; it's possible that the only current version is embedded in PA Stats.

    The AI build rules are based around things like AnyBasicFabber; I didn't mark the units as fabbers because they can't build a lot of stuff. I believe you'd need modified AI config to make it use them; I believe it would work at some level, but I don't know if the AI can be made to build things situationally (ie, walls or turrets in a hot situation)

    I highly doubt interplanetary targeting is in, but I've never tried it. I believe the sniper bot was changed to to avoid obstructions not too long ago, so through-planet may be possible.
  5. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Great info wondible. :)
  6. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    For #2, you can take a look at unit armor types. You might want to look at the way the Uber Cannon does less damage to commanders and structures.
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    indeed it is: http://pastats.com/mod/live/lib/alertsManager.js
    And if you don't use it you'll break PA Stats, I know this is a suboptimal situation :s
    wondible likes this.
  8. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Is Alertsmanager something coded by PA Stats or does it come from the vanilla PA files?
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    it's my work so multiple mods can work with alerts while the user still only sees the default alerts.
  10. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    I see, so if someone is wanting to change the damage alert types due to them wanting to add new damage systems such as armor reduction, they need to include and use alertsmanager or they will break everything for people using PAstats?

    Edit: Btw... the 3rd value being passed into the engine call in Alertsmanager.. is there no way to know what it does besides trial and error? I suppose to know for sure we would need documentation about the engine API between our scripts and the hardcoded engine correct?

    I hope that you can recode things a bit so that PAstats doesn't break based on how the damage alerts are currently filtered....
    Last edited: October 28, 2014
  11. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    That is not possible anyway, so I've noot even considered it so far.
  12. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Alerts are only alerts. They happen after the fact and you can't change it.

    The game has an armor system, but it's used very sparingly in vanilla to fix corner cases. Generally the base spec defines a single armor type, and then ammo can define a modifier for each type. Search for armor_type and armor_damage_map.

    The way I understand it is: alerts are on or off for the engine as a whole. The only API is is to set the value, so there is no native way to reflect on what is currently set and make modifications without stomping on any other mods that want to modify alerts. alertsManager maintains that state so it's possible for multiple mods to place nice together. Twiddling with alerts can also cause extra stuff to appear in the player-visible alerts; I don't know if the work-around for that is officially part of alertsManager or PA Stats.
  13. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Any idea how exactly two mods might play nice with each other via using the Alertsmanager as opposed to just doing their own engine calls? Perhaps an example?
  14. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    PA Stats actually won't break at all if you add engine level filters for any type of alerts, but PA Stats won't get any data about units if you filter those alerts.

    Basic usage of alertsManager looks like this:
    include alertsManager.js into your mod:
    http://pastats.com/mod/live/lib/alertsManager.js

    I think the best choice is to directly put that link into your modinfo. So you get always the newest version. I won't make changes that break the API unless PA requires that.

    Then do this in your mod:

    alertsManager.addListener(function(list) {console.log(list);});

    list is an object that holds a list of all alerts that happen, no filtering is applied. There is also addFilteredListener, but I can't write up the full definition of that by heart, basically it accepts a filtering object that defines which alerts you want. Read the alertsManager code if you are interested into that.

    Damage alerts are btw still not supported I think. Not sure how well they work, I don't think they trigger for every single damage that is applied somewhere.

    It's part of alertsManager.
  15. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Thanks Colin. Very helpful to know. I wonder how much of a performance impact there would be to apply some basic math to each hit on a target to simulate something like shielding or armor.
  16. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    you cant affect gameplay like that
  17. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    Why not? Just intercept the damage event and apply math to change the event target's unit's health based on arbitrary math.
  18. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    A notification is just that. A message that tells you : some unit of type bla from army bla on planet p on location x/y/z just took damage.
    There is no information what damage, who did the damage, what health remains, etc. You also can't access the unit health or change it. The alerts system that we have access to is a pure information device that delivers you information about the game. It's part of the UI of a player and has no access to more information and especially cannot, ever, by definition of "Client UI", change the gameplay in such a fundamental way. If it could it would allow massive cheating.

    What you want is a modding hook to do gameplay scripting on the server on a very low level. That doesn't exist at least for now.

Share This Page