1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Nuclear war in the Age of Lua

Discussion in 'Civ2 - Scenario League' started by techumseh, May 18, 2020.

  1. techumseh

    techumseh Emperor

    Joined:
    Mar 12, 2002
    Messages:
    1,487
    Location:
    in the frozen north
    Not wanting to hijack any other thread, I have a question about the possibility of using Lua to more realistically simulate a nuclear attack. I've never liked the way Civ2 represented nuclear weapons. Loss of half the population seems reasonable (in a sick sort of way), all units eliminated seems a bit rigid and arbitrary, but all the improvements remaining intact is just wrong. So, given what I've seen in OTR, it should be possible to eliminate some or all improvements after a nuclear attack. Correct?

    A related issue is that all nukes in Civ2 are created equal. Different ranges perhaps, but the same effect. Could different types or sizes of nukes have different effects? Bigger bombs would have a bigger effect. Maybe tactical weapons could only be used on ground units, but not cities, and their use could negate the 'no stack kills' feature.

    Finally, could a somewhat different effect be created for chemical weapons? Maybe certain types of units could be vulnerable and others not. City improvements would be unaffected. Could such a weapon inflict partial damage on units, like the spy?

    Any comments appreciated.
     
  2. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,433
    What a timely thread :) Great ideas here.

    Yes, because lua allows you to pinpoint tiles or other objects and work it into an event.

    You could identify what type of unit is attacking and if a particular unit kills any other unit in a certain tile (which is linked in this case to a city), then certain bad things happen to that city.

    Yes. You could use the above idea and have different effects based on the attacking unit. So if an MRBM (attacking unit) hit Washington, you could have a certain effect. Perhaps a "tier" of buildings is destroyed from Washington (Say, Manufacturing plants but not factories, while an ICBM destroys all).

    As to negating the 'no stack kills' feature, yes - you can delete units at a tile and could basically use the same logic to accomplish this by looking at attacking unit vs. defending unit and telling the game to kill all units at the defending units tile.

    Yes - so in OTR you may note that aircraft can't strafe submarines, but can bomb them. We also could have made it so that aircraft only remove X hitpoints from submarines, so you can definitely have units inflict partial damage. You could even have a range and a random (or deliberate) way that the point in the range is selected.

    Lua is extremely powerful and makes scenario designer dreams come true. I would strongly encourage you, as one of the few remaining designers and a great one at that, to spend a little time with @Prof. Garfield 's learning lua lessons and then see what you can do. Maybe take one of your oldest scenarios from back in the day (which I assume would also be one of your simplest) and see if you can manually convert the events and then add a few more using his modules. I think that the possibilities will spark a whole new interest in you (not that you've lost it).

    Now, while people are here to help, is the time to do this. We have three active coders who can assist with questions now, but tomorrow is promised to no one! Jump in! :)
     
  3. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,628
    Location:
    Ontario
    I think the only nuclear attack features that can't be re-created using Lua are the nuke animation and the ability to attack empty cities. In the former case, I suppose you could use civ.playVideo(filename) to play some stock footage of a nuclear explosion (I've never tried this function, but I think it would work like a wonder movie). You would probably also have a problem getting the AI to use the nuke properly.

    I haven't tested the unit killed function with the standard 99-attack nuke, but I suspect that you could re-create some units that were killed, so there isn't a 100% fatality rate for units.

    Instead of nukes, you could have 'missile silo' units that choose a target by opening a menu, and doing something bad to the target city. You'd have to create separate events for the AI to 'use' that system, but it would also allow you to attack over the north pole and/or not worry about the maximum unit movement.
     
  4. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,433
    I guess I was approaching it from a 98 rather than 99 attack unit killing "something" within range of "something else" and then tweaking the effect so that bad things happen to "something else" in addition to "something."

    Basically an offensive splash effect that could change terrain, reduce hit points, delete units, improvements or wonders, etc.
     
  5. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,628
    Location:
    Ontario
    OK, I just decided to test nukes and Lua events, and there is a big problem. Nukes don't seem to trigger the unit killed event, or the combat resolution event. This means that we can't design an event that is triggered by an attack from a 99 attack unit. We would have to infer in some way that an attack took place. Or, not use 99 attack units in scenarios.
     
  6. techumseh

    techumseh Emperor

    Joined:
    Mar 12, 2002
    Messages:
    1,487
    Location:
    in the frozen north

    So that would all depend if you can get the results you want from a unit that's not 99 SP. What is your assessment?
     
  7. techumseh

    techumseh Emperor

    Joined:
    Mar 12, 2002
    Messages:
    1,487
    Location:
    in the frozen north
    I do intend try my hand at a Lua scenario in the near future. I wanted to finish repairing the Macro events for Burma and Sea Lion first, which is now done. Once we're settled in our new place, I will get a start on a Lua project. Having gone back and forth on a few ideas, I think I'll finish a long suspended project - 'Blood and Iron'. It's a scenario about Bismarck and the wars of German unification. Years back, Fairline made me a beautiful set of units, which I'd still like to use. (of course, there are now more unit slots to fill, Gareth) Many of the problems that caused my first effort to fail were resolved in the Lua events done for Tootall's 'Napoleon', notably the ability to restore conquered cities once a peace treaty is signed. Another major requirement is a suitable diplomatic framework. Each of Bismarck's wars was carefully planned, not just militarily but diplomatically as well. I'll sketch out a programming style diagram for the diplomatic strategy and start a new thread for feedback in the next little while.
     
    JPetroski and Fairline like this.
  8. Fairline

    Fairline Emperor

    Joined:
    Mar 21, 2002
    Messages:
    1,059
    Gender:
    Male
    Location:
    UK
    This is good news :thumbsup:

    Any chance you can e-mail me that unit set Brian; I haven't seen it in years
     
  9. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,433
    While we're waiting for Garfield, I'd just say that you can use "onUnitKilled" to achieve pretty much whatever you want. What results do you want? You could have a 98 attack, 9hp, 9fp unit that is not losing any battle, period, cause all sorts of problems for anything on as many surrounding tiles as you'd like. You could have an "asteroid" that "impacts" one point, and as soon as it does, everything with 30 squares has its terrain changed, units destroyed (or weakened), city improvements wiped (or added), city size decreased (or increased), or the city flat out removed from the map, city food yields changed, etc. etc. etc.

    Or, you could just have it destroy every other unit on the tile it attacks (the "tactical" nuke you were referring to). This might create pollution or some other issue as well if you'd like.

    The list of things you can do is much larger than the list of things you can't.
     
  10. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,628
    Location:
    Ontario
    We should be able to re-create everything to do with a nuclear attack, except the animation and the ability to attack empty cities. Well, attacking empty cities could be achieved by a key press for humans. Getting the AI to use "lua-nukes" in a sensible way would probably involve some more events, and if you made an event to choose when the AI uses a nuke, you could also perform the effect on the empty city if that was deemed to be the target. I suppose you could also make it so that the AI's own units aren't killed in the blast, if you just want to leave it to its own devices.

    I'm not sure what else to add. Typically, the things that can't be done in lua are things resulting from bugs/quirks, such as the fact that nukes don't trigger the combat events. When they're not bugs or quirks, they're oversights (like not having access to the item currently being produced by a city). Thus, it is kind of hard to know what can't be done until you actually try to do something.
     
  11. techumseh

    techumseh Emperor

    Joined:
    Mar 12, 2002
    Messages:
    1,487
    Location:
    in the frozen north
    Having the AI respond as desired to Patch changes is really the fly in the ointment, isn't it? In most cases, it just can't. Years ago, Captain Nemo posted the results of an experiment he did with AI missiles. I've lost his post, but it was a guide to which units were targeted by which missiles. He started with standard Civ cruise missiles and battleships. As I remember, missiles with higher attack factors attacked units with higher build costs, eg. cruise missiles with an attack of 18 targeted units with a build cost of 16 (battleships and carriers). Missiles with lower attack factors attacked units with correspondingly lower build costs. He provided a table of the results, but sadly, it has been lost. Clearly though, cities are the only thing AI nukes attack, and non-nukes only target units. So kinda messy.
     
  12. Civinator

    Civinator Blue Lion Supporter

    Joined:
    May 5, 2005
    Messages:
    6,272
    Gender:
    Male
    I think with animated units even different nuclear attack animations could be done for units with an attack value below 99. There exist different nuclear and chemical unit attack animations for Civ 3 that could be converted. May be even the Civ 2 nuclear explosion could be converted into a unit attack animation.



     

    Attached Files:

    Last edited: May 21, 2020 at 9:53 AM
    CurtSibling and JPetroski like this.
  13. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,433
    @Civinator , how do animated units work? Do they animate from unit movement, or just attack?
     
  14. Civinator

    Civinator Blue Lion Supporter

    Joined:
    May 5, 2005
    Messages:
    6,272
    Gender:
    Male
    JPetroski, animated Civ 2 ToT units have their own attack, movement, death and fidget animations.

    Edit: I have attached the single sprite files of the not very beautiful original Civ2 ToT Nuke as zip file. The animated (ugly) Civ 2 ToT nuke can be seen and tested with the animated units enabled in cheat mode. The ugly graphics could be replaced by better ones and the animations could be reduced to less frames.
     

    Attached Files:

    Last edited: May 21, 2020 at 1:17 PM
  15. committed hero

    committed hero Chieftain

    Joined:
    Jan 17, 2010
    Messages:
    90
    Location:
    RTP,NC
    By removing the "destroyed after attacking flag" you can make nukes that will not be carried by subs (but by carriers, unfortunately). The unit still dies in the attack since it is in the blast radius.
     
  16. techumseh

    techumseh Emperor

    Joined:
    Mar 12, 2002
    Messages:
    1,487
    Location:
    in the frozen north
  17. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,433
    And Lua can then be used to restrict carriers from carrying these nukes.
     

Share This Page