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

R.E.D. World War II development thread

Discussion in 'R.E.D. World War II Edition' started by Gedemon, Jul 14, 2011.

  1. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Now that I've solved my pathfinding problem (until we'll find the new bugs it must have generated...), I was able to advance faster on the coding this WE.

    First I've converted the functions from RED DLL for BNW to the WWII mod, basically that means that the support fire and counter-fire mechanisms are now coded in C++ instead of Lua, and I've started to code the plot capture mechanism.

    Then I've coded two major features, that will require a lot of testing:
    - The Max Hit Points value can now be different for each unit, there is a new column <MaxHP> in the Units table to set that.
    - I've also changed the limited stacking based on a limit using two different types of unit to a limited stacking based on a total weight per domain, ie the addition of each unit weight (<StackValue> in the units table) on a plot (cities could use different limit)

    For testing I've set the plot limit to 100 (reusing "PLOT_UNIT_LIMIT" in the Defines table) and I've set:
    "infantry divisions": weight 60, Max HP 400
    "divisions": weight 60, Max HP 200 (medium tank, light tank, "elite" infantry & paratroopers)
    "regiments": weight 30, Max HP 75 (artilleries, tank destroyer, assault gun, ...)
    "heavy regiments": weight 39, Max HP 45 (heavy tank, heavy tank destroyer, ...)
    "special forces": weight 20, Max HP 10

    The damage are still limited to 20% of max HP, which means you can deal a max of 2 HP of damage per combat to special forces, or 80 HP/combat to an infantry division.

    With those values, you can stack 1 "division" and 1 of any "regiment" or 2 "heavy regiments", or 3 "regiments" (that could include 1 "heavy")

    See 999- FinalizeRules.sql in R.E.D. WWII Reloaded for an example of configuration that could be modified by any scenario.

    There is nothing really playable yet, but tests are already possible on two maps, here are the projects in GitHub, that can be compiled with modbuddy for testing (except the DLL that require MS VS C++):

    https://github.com/Gedemon/RED-WWII-Data <- v.6 beta 1 (if you use a gitHub client, you won't have to download everything with each update)
    https://github.com/Gedemon/RED-WWII-Reloaded <- this will replace RED WWII Edition when released, it include the compiled DLL
    https://github.com/Gedemon/RED-WWII-Test-Map <- small test map to play on with IGE or Firetuner
    https://github.com/Gedemon/RED-WWII-World-Map <- It's not ready for edition with the WB yet (we need to add improvements/resources/cities names in the DB first)
    https://github.com/Gedemon/Civ5-DLL/tree/RED_WWII <- the DLL (just in case you want to compile your own, rename it to CvGameCore_RED.dll)
     
  2. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Some bugs/crashes fixing, gitHub updated

     
  3. DEathgod65

    DEathgod65 Chieftain

    Joined:
    Jul 26, 2013
    Messages:
    71
    Location:
    Singapore
    Is there any chance the America/Europe map could be reintegrated into the next upcoming version? Would like to continue my 'mini mod' in the next version!
     
  4. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    In next version the scenarios will be independent mods. I won't be able to fully convert the America/Europe scenario to the new format, but I'll try to make at least a base mod with the map you can work on.
     
  5. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Posting here my draft on population, for reference...

    rename "personnel" to "enlisted" ?

    CvPlayer
    Code:
    InitialNationPopulation // Player initial population (set in the Civilization table at <InitialNationPopulation>)
    
    InitialRuralPopulation = InitialNationPopulation - pPlayer->getRealPopulation() // must be calculated on first turn, after setting Cities population
    CurrentRuralPopulation // Player population outside of cities
    CurrentNationPopulation =pPlayer->getOwnCitiesCurrentPopulation() +pPlayer->getCurrentRuralPopulation() //must not include captured cities !
    CurrentOccupedPopulation =pPlayer->getCapturedCitiesCurrentPopulation()
    
    KilledCivilians // total civilian killed
    KilledPersonnel // total enlisted killed  
    killedOfficers // total officers killed
    
    killedDestroyedLandVehicles // total land vehicles (tanks, assault guns, artilleries, ...) destroyed (can't be repaired)
    DestroyedAirVehicles // total air vehicles (fighters, bombers, ...) destroyed
    DestroyedSeaVehicles // total ship sunk
    CvCity
    Code:
    InitialPopulation // city initial population
    CurrentPopulation// that number includeCivilianWounded (don't draft from rural population or reduce city size when there are wounded, todo : reduce productions in city with wounded ratio ?)
    
    Personnel
    Officers
    
    WoundedCivilians
    WoundedPersonnel
    WoundedOfficers
    Prisonners
    CvUnit
    Code:
    Personnel
    Officers
    Vehicles
    MaxVehicle // for sea units or other case when 1 vehicle != 1 HP
    
    RequiredOfficersPercent
    PersonnelPerHP
    OfficersPerHP
    MaterielPerHP
    FuelConsumption
    
    PersonnelReserve
    OfficersReserve
    VehiclesReserve
    Materiel
    
    WoundedPersonnel
    WoundedOfficers
    DamagedVehicles
    Prisonners
    Mechanism : Recruiting

    Personnel is taken from city CurrentPopulation

    Each turn cities draft population from player CurrentRuralPopulation.
    Captured cities does not draft.
    Size 1 cities can't recruit personnel

    Define:
    Code:
    MAX_DRAFTED_RURAL_POPULATION_PERCENT 
    Pseudo code:
    Code:
    PersonnelRecruted =pCity->getNumRecruit();
    pCity->changeCurrentPopulation( - PersonnelRecruted );
    pCity->changePersonnel( PersonnelRecruted );
    
    OfficersTrained =pCity->getNumTrainedOfficers();
    pCity->changePersonnel( -OfficersTrained);
    pCity->changeOfficers(OfficersTrained);
    
    if (pCity->getOwner() ==pCity->getOriginalOwner()) // Do not draft our rural population to captured city
    {
     RequiredPopulation = pCity->getInitialPopulation() - pCity->getCurrentPopulation();
     PopulationDrafted = min (pPlayer->getCurrentRuralPopulation() *MAX_DRAFTED_RURAL_POPULATION_PERCENT / 100,RequiredPopulation * (pPlayer->getCurrentRuralPopulation()* 100 /pPlayer->getInitialRuralPopulation()) / 100); // less and less population drafted from rural area
     pPlayer->changeCurrentRuralPopulation (- PopulationDrafted);
     pCity->changeCurrentPopulation ( PopulationDrafted );
    }
    
    if (((long)(pow((double)(pCity->getPopulation() - 1), 2.8))) * 1000) > pCity->GetCurrentPopulation())
     pCity->changePopulation(-1, true);
    
    if (((long)(pow((double)(pCity->getPopulation() + 1), 2.8))) * 1000) < pCity->GetCurrentPopulation())
     pCity->changePopulation(1, true);
    Mechanism : City Combat

    Each attack on a city will wound or kill population (use Anti-Personnel value)

    Define:
    Code:
    CITY_COMBAT_BASE_CASUALTY_PERCENT // (or per mil ?)
    CITY_COMBAT_POSSIBLE_EXTRA_CASUALTY_PERCENT
    Pseudo code:
    Code:
    PercentDamage = (CityMaxHealth - Damage) * 100 / CityMaxHealth;
    
    InvolvedPopulation =(pCity->getCurrentPopulation() -pCity->getWounded())*PercentDamage / 100;
    
    // (and calculate InvolvedWoundedCivilians,InvolvedWoundedPersonnel,InvolvedWoundedOfficers, InvolvedPersonnel, InvolvedOfficers)
    
    Casualties =InvolvedPopulation *CITY_COMBAT_BASE_CASUALTY_PERCENT/ 100;
    ExtraCasualties =( InvolvedPopulation -Casualties ) * GC.getGame().getJonRandNum(GC.getCITY_COMBAT_POSSIBLE_EXTRA_CASUALTY_PERCENT(), "population Damage") / 100;
    Casualties +=ExtraCasualties;
    
    Killed =Casualties* GC.getGame().getJonRandNum(pAttacker->getAntiPersonnelValue(), "population Damage") / 100;
    Wounded =Casualties - killed;
    
    pCity->changeCurrentPopulation( -Killed);
    pPlayer->changeKilledCivilians(Killed);
    pCity->changeWoundedCivilians( Wounded);
    Mechanism : Unit Combat

    Each attack on a unit will wound or kill personnel / officers (use Anti-Personnel value)
    Each attack on a unit will damage or destroy vehicles (use Anti-Tank value)

    Define:
    Code:
    UNIT_COMBAT_BASE_KILLED_PERCENT
    UNIT_COMBAT_POSSIBLE_EXTRA_KILLED_PERCENT
    UNIT_COMBAT_MAX_KILLED_PERCENT
    UNIT_COMBAT_BASE_PRISONNERS_PERCENT
    UNIT_COMBAT_POSSIBLE_EXTRA_PRISONNERS_PERCENT
    UNIT_COMBAT_POSSIBLE_ATTACK_PRISONNERS_PERCENT
    UNIT_COMBAT_POSSIBLE_RETREAT_PRISONNERS_PERCENT
    UNIT_COMBAT_BASE_DESTROYED_PERCENT
    UNIT_COMBAT_POSSIBLE_EXTRA_DESTROYED_PERCENT
    UNIT_COMBAT_MAX_DESTROYED_PERCENT
    Pseudo code:
    Code:
    personnelCasualties = Damage * pUnit->getPersonnelPerHP();
    officersCasualties =Damage * pUnit->getOfficersPerHP();
    
    if (pUnit->getRequiredOfficersPercent() > 0)
    {
     OfficerPercent = (pUnit->getOfficers()-officersCasualties)* 100 /pUnit->getPersonnel();
     officersCasualties +=personnelCasualties *OfficerPercent/ 100;
    }
    
    vehicleCasualties = Damage; // 1 HP = 1 vehicle
    
    // Personnel killed
    
    killpercent = GC.getUNIT_COMBAT_BASE_KILLED_PERCENT();
    killpercent += GC.getGame().getJonRandNum(GC.getUNIT_COMBAT_POSSIBLE_EXTRA_KILLED_PERCENT(), "personnel Killed");
    killpercent += GC.getGame().getJonRandNum(pOtherUnit->getAntiPersonnelValue(), "personnel Killed by AP");
    killpercent = min(killpercent,GC.getUNIT_COMBAT_MAX_KILLED_PERCENT());
    
    personnelKilled = min(personnelCasualties ,personnelCasualties*killpercent/ 100);
    personnelCasualties -= personnelKilled;
    
    // those that are not killed are either prisonners or wounded
    
    capturedPercent = GC.getUNIT_COMBAT_BASE_PRISONNERS_PERCENT();
    capturedPercent += GC.getGame().getJonRandNum(GC.getUNIT_COMBAT_POSSIBLE_EXTRA_PRISONNERS_PERCENT(), "personnel Captured");
    
    if (bDefend)
     capturedPercent += GC.getGame().getJonRandNum(GC.getUNIT_COMBAT_POSSIBLE_ATTACK_PRISONNERS_PERCENT(), "personnel Captured");
    
    if (bRetreat)
     capturedPercent += GC.getGame().getJonRandNum(GC.getUNIT_COMBAT_POSSIBLE_ATTACK_PRISONNERS_PERCENT(), "personnel Captured");
    
    personnelCaptured= min(personnelCasualties*capturedPercent/ 100,personnelCasualties);
    personnelCasualties- = personnelCaptured;
    
    // only wounded left
    
    personnelWounded = personnelCasualties;
     
  6. sonihi

    sonihi Chieftain

    Joined:
    Aug 24, 2013
    Messages:
    80
    Well there were Waffen-SS units from other countries, so maybe recruiting for the SS?
     
  7. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    you'll still be able to recruit in captured cities.
     
  8. DEathgod65

    DEathgod65 Chieftain

    Joined:
    Jul 26, 2013
    Messages:
    71
    Location:
    Singapore
    Speaking of Foreign units, is it possible to create a function where AI units will be placed under your control after a condition has been met? Example would be Germany taking control of all Italian units in Africa if Tripoli falls.
     
  9. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    yes, see the code that give french units to it's colony on Fall of France.
     
  10. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Updated the DLL on gitHub with the converted code for plot capture and switching owner when surrounding portions of ennemy territory that are not linked to (controlled by) one of it's cities or units.

    I've also updated the R.E.D. WWII Reloaded files, the mouse over plot now show if an unit or a city is in range to control that plot.

    there is also a visual text (like the healing/damage values) over plots changing ownership when the map is updated.

    and I've also cleaned the OP.
     
  11. sonihi

    sonihi Chieftain

    Joined:
    Aug 24, 2013
    Messages:
    80
    A guide on creating scenarios? Seems intressting cause I want to make a 1st January 1945 scenario.
     
  12. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Yes, but that can't be done before all the mechanisms to load a scenario in the main mod are defined.
     
  13. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    BTW we'll need a complete city listing.

    edit: the convoy mechanism will use the TXT_KEY_CITY_[name] to create routes, so that's something that must be done for at least exporting/importing cities on a map.
     
  14. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    RED WWII Reloaded <- updated
    RED WWII DLL <- updated

     
  15. kogre

    kogre Chieftain

    Joined:
    May 18, 2015
    Messages:
    55
    Hey are the above files for RED WW2 and if so how do i go about installing them? Or are the above files just for testing out the new product you are building?
     
  16. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    Those are the files for the new version, if you have correctly installed modbuddy you just need to build the project and the mod(s) will be available in Civ5 (except the DLL link that is just for those that want to see/edit/build the C++ code, the DLL itself is included in "Reloaded")

    You also need the updated data files and the test map (see OP) and either firetuner of IGE to put stuff on the map.

    The more people that are able to use this, the better, I welcome feedback/suggestions at any stage of the development (I'd say it's "pre-alpha" for the new version/framework)
     
  17. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    I'm converting the supply lines code from Lua, I've got something working, but I need feedback... In v.44 (and before) the supply line can have an infinite length, but:

    - should we have a limited range to get supply ?
    - should we scale the available supplies for an unit with the distance to the city providing those supplies ?
    - should we link to the closest city or the one with the most supply ? Or weight both ?

    Other suggestions on the supply line mechanism ?
     
  18. ZeroZeroSix

    ZeroZeroSix Prince

    Joined:
    Oct 15, 2008
    Messages:
    347
    - should we have a limited range to get supply ?

    I dont think so, supply ships where going from US to Arkhangelsk and from US to Philippine. That is quite a distance.

    - should we scale the available supplies for an unit with the distance to the city providing those supplies ?

    Not sure I understand that, you mean for a nation to have the required supply to build units? If they start with a reserve of supply, that can be the answer.

    - should we link to the closest city or the one with the most supply ? Or weight both ?

    For supply ships, it should be the closest inland city with an habor. Harbor can be seen as some sort of dépot? For ground supply like Romanian oil for Germany it should be the closest city with accomodation like raffinery for oil?
     
  19. ZeroZeroSix

    ZeroZeroSix Prince

    Joined:
    Oct 15, 2008
    Messages:
    347
    By the way, did the coal processing plant where producing ready to use oil or it have to be refined after? But since its a game, anything is possible.
     
  20. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    9,322
    Location:
    France
    I'm not talking of convoy/resource, sorry for the misunderstanding.

    I mean the supply line between a land unit and a city to check each turn if the unit can get reinforcement and "heal".
     

Share This Page