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

limited guns and ammo

Discussion in 'Civ4 - Fury Road Modpack' started by davidlallen, Sep 9, 2008.

  1. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    Several threads have discussed adding limits on the number of guns and amount of ammunition in Fury Road. This thread is to centralize the discussion.

    We have established some facts. Even automatic weapons like AK47 can be built by a blacksmith with hand tools. There are several different calibers of weapons whose ammo cannot be interchanged. Making ammo is probably harder than making weapons. Gunpowder is not that hard to make, but smokeless powder and proper cartridges are harder. Automatic weapon cartridges are even harder. Primitive rifles like flintlocks only require gunpowder and lead balls, which can be cast in the field.

    I think those were the main facts established in the previous threads around this link.

    The next couple of posts will give more information about limited guns, and then limited ammo. They are closely linked.
     
  2. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    Several people have suggested that it should be possible to scavenge weapons from units destroyed in combat. This is a main focus of the Fallout games.

    Because of different caliber, it is highly likely that different civs will create incompatible weapons. So, if we have limited guns, where a gun can be scavenged from an opponent, we also have to track ammo caliber. We can choose to ignore that and say only one caliber will be used.

    One way to handle this which I mentioned before is to remove all the different infantry types from the game, and just have one unit called "guy". Then buildings produce "weapon counters" like promotions which can be added to any unit. People who have played FFH (and now I do include myself in this category!) point out the idea of bronze / iron / mithril weapons. But a better example is Orthus' Axe, which can be transferred from unit to unit and gives +1 Fire damage.

    This is possible, and it is even possible to swap different art types as the unit gets different weapons. (This is the way the utility truck works as of version 9 thanks to linked unit art by refar.) The most significant problem with this is having the AI understand it; picking up and swapping these weapon kits would require a change to the AI for all units.

    Another possible way to handle this is by limiting the number of such units that could be built at any time. For example, making weapon armed units a national unit. The drawback to this is that both small civs and large civs would have the same limit, and scavenging weapons from opponents would not raise the limit. We could also make the rate at which the units are produced, limited by the number of a certain building built, or the number of improvements of a certain type. There is a whole modcomp under development for "quantifiable resources" which covers this. Again, the AI development seems to be the limiting factor.

    I'm sure there are other ways this could be handled, but I think this summarizes the discussion so far.
     
  3. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    As a separate topic from limited guns, limited ammo involves tracking when a unit runs out of ammo, and adding some way for units to be resupplied. This was a factor in the Fallout games, and a major factor in The Road Warrior. In the current version of the game, I have assumed that if you find a pre-war munitions dump, you have unlimited ammo for advanced weapons. As of version 9, the ammo factory represents the ability to create unlimited ammo for rifle type weapons.

    One way to handle ammunition is to literally duplicate the fuel handling system. Ammo factories would produce ammo trucks, and each unit would use up some of its ammo when it attacks. Also when it defends, even without moving -- that is a small change from the fuel code.

    However, it's not clear this would be any more "fun". Two different supply streams to manage just makes things painful.

    Are there different methods we could use to represent limited ammo? There was one suggestion to merge both supply types together and have supply trucks. This makes it kind of generic, more like a WW II strategic level simulation rather than a Road Warrior feel.
     
  4. phungus420

    phungus420 Deity

    Joined:
    Mar 1, 2003
    Messages:
    6,296
    While interesting in concept, I just don't think it will be worth all the work to teach the AI how to handle limited ammo and rearming. Though you have had success with the Gas truck and refueling, you could probably port this over pretty easy as a way to deal with ammo. Scavanging though, I think it would be too much work getting the AI to really use it properly.
     
  5. Rasma

    Rasma Warlord

    Joined:
    Sep 7, 2007
    Messages:
    146
    I like the idea but as Phungus said it will probably make the AI wish to kill itself.
    But what if you did not put calibers it may work better
     
  6. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    Well, the AI can handle fuel - not perfect but well enought to live with.

    In my eyes ammo would be the [and only] reason to make people [and players] use primitive weapons like XBows again.

    I would not bother with different types of ammo tho. Some level of abstrction is needed in a game like civ compared to fallout.

    Another possibility would be creating ammo "tiers", while keeping single supply unit for everything - if a civ has access to say "machinegun ammo" then a supply truck can resupply MG units (even if the truck was technically created before we gained that tier)

    A simplier - and maybe sufficient - possibility to show the limitation would be simply limiting the number of units of certaint type a civ can field.
     
  7. jefmart1

    jefmart1 Prince

    Joined:
    Aug 16, 2005
    Messages:
    463
    I think the item idea, but more like the healing salve from FFH, might be the most workable.

    Various weapons are an item that is either carried or used. When used it grants a promo and the unit graphic would change , like for the Utes. That I think is easy, because they are one time uses, its making the item redrop when the unit dies.

    You could have a carried item like Orthus' Axe, but the unit graphic wouldn't change, and the graphics for this mod are a lot of the fun...
     
  8. Jabie

    Jabie Wanted in Monte Carlo...

    Joined:
    Dec 16, 2003
    Messages:
    1,024
    Location:
    Southampton, UK
    At the end of the day, this boils down to a trade-off between realism and gameplay. Limiting Guns and/or Ammo is more realistic but it also increases the micromanagement and the need for the AI to understand the concept. Unlimitted guns is easier to understand and easier for the new player, but is less flavoursome.

    Personally I wouldn't bother splitting down to both Guns *and* Ammo. After all, you not going to bother making guns if you don't have the ammo for it, and vice versa. I also wouldn't get too hung up on all the guns out there, I'd just subdivide between pistols, rifles, machine guns and heavy weapons.

    Let's propose the the pistol is the basic weapon. Rifles could give First Strike, Machine Guns a bonus to Attack Strength and Heavy Weapons grant a bombard capacity or a bonus vs tanks and artillery.

    A unit can switch weapons in any friendly town - think crews in FfH - provided a) you have at least one source of Munitions and b) you have discovered the necessary technology associated with that type of weapon.

    @David, congrats on getting round to FfH. Did you enjoy it?
     
  9. Temrek

    Temrek Chieftain

    Joined:
    Jun 19, 2008
    Messages:
    28
    I would abstract it even further and limited the amount of firearm units you can have at any one time depending only on the amount of ammunition sources you have access too, wheter they are salvaged or produced in factories.
     
  10. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    The possibility that gets mentioned the most is limiting the number of a unit type, based on how many resources you have. For example, the limit on rifle units might be the sum of how many ammo factories you have plus how many munitions resources you control. Let's explore that in a little more detail.

    If we give unlimited ammo, then a unit could go off into a barbarian wasteland for forever, and keep firing. If a gas powered unit does that today, they would have to bring fuel trucks, but an infantry or ute unit would need no supply. Is it OK to lose this detail in the abstraction?

    There is a python callback, cannotTrain, which can be used to prevent construction of a unit. So I could use this, to count up the number of rifle units and prevent construction of units if the limit is reached. This is exactly what is done by the "quantitative resources" modcomp at this link. I see I was the last one to post on that, about a month ago, so I am not sure if it is still active.

    One complication with this, is that the allowable number of units may decrease while the unit is on your build queue. For example, suppose you have three rifle units building, and you lose one of your munitions resources. There is no way to allow the user to choose which rifle unit to remove from the queue. In vanilla, either you have the resource or you don't, so you may get a message that you can no longer train *any* of those units on the queue.

    Maybe there is a solution which works for this mod. Suppose you start training an infantry with rifles, but during the build you run out of rifle ammo resources. When the build finishes, instead of getting nothing, you get an unarmed infantry unit (survivor). So you would wind up with three survivors built in your three cities, plus a hammer bonus for the difference. Then if a rifle upgrade cost a certain number of hammers, you could pick the one or two units to upgrade. If you had two rifle resources available, then you would wind up upgrading two survivors to rifles, one plain survivor, and a small hammer bonus.

    That is complicated, but might work. Here the difference is that a unit built above the quota can gracefully "degrade" to something else.
     
  11. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    I'm not sure about that. For the fuel system, people have also suggested that you should automatically refuel when you are in friendly territory. That assumes there is infinite transport to ferry the equipment around, basically instantly. You could downgrade four units on one side of your territory, then upgrade four units on the other side of your territory. Maybe that is OK to lose in the abstraction, but I'd have to think about it some more.

    Yes, it's fun, and as I feared it is a big timesink. But I've played 4-5 of the civs, and 4-5 I don't have much interest in (too defensive).
     
  12. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    I dont know, i would be seriously [pissed] if at some point midgame i suddenly get 3 survivors, which i did not order...
    Tho the example is rather extreme - loosung 3 units from the cap at once...

    Would it be possible to just push the "forbidden" unit back in the queue ? Putting the survivor on top of it, but not diveting hammers ?
    This way the player would have the chance to change the top build in the queue, while keeping the half done unit mothballed, unitll it can be completed (or decayes).

    Another possibility would be unit-dependant replacement - say if you was going to train Guardina you get a Crossbowman instead - wich is the same... kind of...
    This involves more coding of course, as each unit would have to be handled in a diffrent way...
     
  13. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    To define my example more clearly, suppose you have resources to support 5 rifle units, you have 2 in the field, and at each of city A,B,C you put a Guardian into the queue. Then the next turn you lose one resource.

    Ideally a popup would come listing the three cities and asking you to change *one* of the queued units. But that isn't going to be possible. If that was possible, then the user would also expect a dialog to change the unit back, after recapturing the resource, and that seems like too much paperwork.

    A guardian costs 60 hammers, a survivor costs 15. I was thinking that after the build time of the guardian, you would instead get three survivors and each city would have a 45 hammer bonus. Then (this part I am not so sure about) you could somehow use the 45 hammers to upgrade two of them back to the guardians you ordered, and use the 45 hammers at the third city for something else. But I am not sure how to use hammers to upgrade. Maybe convert into some gold equivalent, and then the standard upgrade mechanism would work.

    It is possible that this mechanism is subject to abuse, transforming hammers into gold somehow. If you pillage your own improvement to reduce the resources, you would effectively convert production into gold at 1:1.

    Is there a better way to accomplish this?
     
  14. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    Oh... it cancels all 3 of them. That's odd.
    So basicly what happens there is, they use a empire wide "cannotTrain" even if we actually can train, just not as many as we would like to...

    But why does cannotTrain return "no", while in fact training is possible....

    This shouldn't happen... the game, as we all know, is turn based, the cities are handled in sequence, meaning, that it should be possible to cut in exactly at the right moment - supposing all 3 units would finish on the same turn, the expected behavior would be to finish the 2 that come first, and then to cancel/override the 3rd...

    I will have to look up in the code to see where and when exactly "cannotTrain" is called...
     
  15. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    I'm not sure which "they" you mean. The only working example we have is vanilla BTS, where you are prompted to change all the queued builds when the resource is lost. If I understand correctly from the quantitative resource thread, cannotTrain is called to determine if you are allowed to put something into the queue, only. I have not experimented with it.

    I do not think there is any way to register a callback to trigger when a build queue item has a required resource lost. I guess I could write code at the end of each turn, which examined all the build queues and compared against available resources, and reject things out of the queue. But I am nervous about adjusting the build queue in the middle of the end-of-turn bookkeeping, and doing it properly seems like quite a project. Plus of course if the player can make choices about which to abandon, then the AI has to also make this sort of choice.

    It is no better to have end-of-turn code simply reject the ones over quota effectively at random. This will treat the player just as badly as it treats the AI. People will complain that the one canceled is the one closest to their war front, while the one kept is produced out in the middle of nowhere. Predicting where the user would "want" the advanced resource build preserved also sounds like too much work.
     
  16. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    They refers to the Quantitative Ressources Mod / Comp / Idea you described.

    Removing just the overhead one, instead off all seem far better - even if you can not control which one you loose - which is kind of realistc - on ressurce shortage just a "random" victim got hit.

    A very simple way to do that would be using the EventManager hook-in "OnUnitCreated" or "OnUnitBuilt" - and disbaning, or downgrading the unit if it is over the limit (possible refunding some of the invested hammers)...
     
  17. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    I can use cannotTrain to prevent over-quota units from going into the build queue, and use onUnitBuilt to catch over-quota units coming out of the build queue. In the case of over-quota units coming out, as a player, I would feel cheated if I did not get 100% of the wasted hammers. So I would put a guardian into the queue; then after 60 hammers of production time, I would get a survivor out, plus 45 hammers. Then I can immediately build three more survivors if I wanted. That might work.

    What should the "downgrade" path be? It makes sense to be the opposite of the upgrade path. Today, survivor can upgrade to guardian or machine gunner. Guardian can upgrade to machine gunner, SAM or AT infantry. Since I never put back jeep crossbow, there is no downgrade path for jeep rifle but it's easy to add. Since the ute scavenges fuel, I guess it can scavenge ammo too, so it would not count against the limits. The rebuilt units would never downgrade. Their ammo is rebuilt along with the unit itself.

    I guess there would need to be "double downgrades". Suppose I queued a machine gunner, but when it came out, neither machine gun ammo nor rifle ammo was available. Then it would come out as a survivor.
     
  18. Refar

    Refar Deity

    Joined:
    Apr 10, 2005
    Messages:
    4,608
    On downgrading i was thinking along the lines, thet every "limited" unit probably will have some kind of counterpart filling a somewhat similar task, but without the cool gun...
    However the only couple i can think of right now is Guardian/XBow, because both are ranged... So maybe the "downgrade" idea is not that good...

    Still XBow might be overall a better choice than Guardian - all units in question are ranged.
    Also XBow is a somewhat capable city-defender, so it could be less annoying to get them.
    Also the difference in hammers is less huge there.
     
  19. davidlallen

    davidlallen Deity

    Joined:
    Apr 28, 2008
    Messages:
    4,743
    Location:
    California
    I can add upgrade from xbow to guardian, then the downgrade can be written to pick the one which is more expensive.
     
  20. Temrek

    Temrek Chieftain

    Joined:
    Jun 19, 2008
    Messages:
    28
    A little ugly but viable solution would be to provide all players cities with a resource "Spare Ammunition" when you can build firearm units, but when you can no longer build those units remove the "Spare Ammunition" resource from the cities.
     

Share This Page