[MOD][MM] Cannon automatic attack

Discussion in 'Modding' started by StriKe jk, Sep 30, 2016.

  1. StriKe jk

    StriKe jk Member

    Hello Cossacks3 Fans!

    My name is StriKe and I was quite annoyed by playing with a lot of cannons, mostly because they refused to attack a target automatically. After digging through some files I found out that cannons have a max. range of 2000 but only fire automatically at a range of 450. Furthermore the minimum range of the normal cannon-shot is 550, and after that they use their shrapnel-shot only. This leads to the problem that they are only able to fire their shrapnel-shot automatically.

    So this mod fixes it by increasing the automatic attack range from 450 to 2000. This only changes the basic cannons (no ships, towers, etc). With this mod your cannons will shoot at enemies in range automatically!

    This mod supports the Mod Manager, visible by the tag [MM]. You can get it here.
    Credits for the Mod Manager to Lieutenant-Général.

    Warranty:
    Feel free to use this mod as you like, however if you include this in another project I would appreciate some credit. ;)
    Use it at your own risk! I haven't tried it in multiplayer and I do not know if it is allowed. If you get banned, or your computer explodes - you have been warned.

    -StriKe

    How to Install:
    Download the latest file from this link.
    Code:
    cannon autoattack.json
    Copy the file to:
    Code:
    Cossacks 3/mod
    Install the file via Mod Manager
     
    Last edited: Oct 4, 2016
    andyvandala and Anatotitan like this.
  2. A. Soldier

    A. Soldier Active Member

    So autofire works if you increase the range eh? Good to know, I was going to test it myself but got lazy.

    Or actually I got side-tracked with the Prussian Musketeer's building speed and trying to make towers shoot through walls.
     
  3. StriKe jk

    StriKe jk Member

    Yep they do auto fire, the range is just super low (even lower than cossacks 1). It's almost the same range as the capture range.

    I may look into the tower thingy tomorrow if you want.
     
  4. A. Soldier

    A. Soldier Active Member

    I know about the range, I read it my.

    I just wasn't sure if increasing it would work, that's all.

    Anyhow yeah, be my guest.
     
  5. StriKe jk

    StriKe jk Member

    I hope you enjoy it :D
     
  6. StriKe jk

    StriKe jk Member

    Update: Mod Manager compatible!
     
  7. Gambler71

    Gambler71 New Member

    I tried this mod yesterday. Thank you thank you thank you. Now I can play this game in the style that I like. This should have been a part of the game from day 1.
     
  8. StriKe jk

    StriKe jk Member

    Thanks! :cool: Check out my other mods too, they are mostly made to make the game more enjoyable while playing!
     
  9. Hansol333

    Hansol333 Active Member

    nice, I tried hat in my mod and cannons finally auto attack.

    I tried to do the same with mortars but they do not attack automatically. It takes so much times to destroy everything if capture is disabled. Why cant mortars attack by themselfes.

    I also tried to increase mortar dmg, the unit says it has 100 mortar dmg but it always inflitcs 250 dmg, even if I change that. I tried to make a upgrade with +mortar damage but it is useless. In fact I wanted to make a repeatable upgrade (like healing) so sooner or later the mortars had like 1000+ damage, but I thing I can skip that idea.
     
  10. Francesco_Cavalli

    Francesco_Cavalli Active Member

    It's because in the weapons.script the mortar shot has a damage value. In the case of arrows (and muskets in my realism test mod) this is overridden here:

    // Use owner damage
    _weapon_SetWeaponUseOwnerDamage('NUCL2P2');
    _weapon_SetWeaponUseOwnerDamage('STRELA');
    _weapon_SetWeaponUseOwnerDamage('OSTRELA');
    _weapon_SetWeaponUseOwnerDamage('NUCLGRE');

    you need to add the following, and then your changes should take effect:

    _weapon_SetWeaponUseOwnerDamage('NUCL3MONO');
     
  11. StriKe jk

    StriKe jk Member

    Because mortars are set to not search for enemies, regardless of the search radius.
     
  12. Hansol333

    Hansol333 Active Member

    I found that in weapons.script except there was no _weapon_SetWeaponUseOwnerDamage('NUCL2P2');
    I added that line aswell at NUCL3MONO but it still deals always 250 dmg.

    Edit:
    how did you managed to increase search radius of units if you do +range attack. in the script it only increases attack range but not search radius. For cannons that is no big deal because there are stand still most the time but I am thinking about a +attackrange upgrade for musketeers but that is useless unless I also increase the search radius.
     
  13. Francesco_Cavalli

    Francesco_Cavalli Active Member

    [/QUOTE]I found that in weapons.script except there was no _weapon_SetWeaponUseOwnerDamage('NUCL2P2');
    I added that line aswell at NUCL3MONO but it still deals always 250 dmg.

    Edit:
    how did you managed to increase search radius of units if you do +range attack. in the script it only increases attack range but not search radius. For cannons that is no big deal because there are stand still most the time but I am thinking about a +attackrange upgrade for musketeers but that is useless unless I also increase the search radius.[/QUOTE]

    That's because NUCL2P2 is the custom missile I created to facilitate musket accuracy. Try doing the same with 'NUCL3MONONEWDMG' as that also does 250 damage in weapons.script.

    Search radius is controlled in the unit script here: SetObjBaseSearchBuildVisionScore(objprop, objbase, 0, 800, 1, 100);

    As you can see, at the moment the Mortar has a search radius of 0
     
  14. A. Soldier

    A. Soldier Active Member

    Search radius is next to build time I believe.

    Just search for "search" in the unit.script file.
     
  15. Hansol333

    Hansol333 Active Member

    nice mortar work fine now.
    To the range problem. I have already figured out how to change basis units (I made small balance mod for C1 as well).
    The problem is however that I want a upgrade for 17c musketeers +5% attack range. if I do that the unit has 840 range but still has 800 search radius, so the unit behaves like without upgrade. I tried with +50% attack range.
    Thats not totally true if I select the shooter and right click direct on a enemy unit he fires from a great distance, but if I use go and attack everyone on the way he moves to his normal distance 800 and fires then.

    If I give him 800 attack range but 900 search radius, he moves to the enemy without firering
     
  16. StriKe jk

    StriKe jk Member

    There are multiple values. There is a min range, max range, min search distance, max search distance and further below is the auto search distance.
     
  17. Hansol333

    Hansol333 Active Member

    for normal 17c musketeer:

    if I perform a range bonus research I will increase the attack range
    SetObjBaseWeapon(objprop, objbase, weapInd, 11, 90, 400, 800, 0, 100000, gc_obj_weapon_kind_bullet, True);

    However the search value must be the same as attack range to be of any use
    SetObjBaseSearchBuildVisionScore(objprop, objbase, 800, 400, 2, 20);

    So I had a look at gc_upg_type_attrangeperc in player.script I tried
    gPlayer[plInd].objbase[cid][iarr2].weapon[j].radiusmax := gPlayer[plInd].objbase[cid][iarr2].weapon[j].radiusmax*(1+value/100);
    gPlayer[plInd].objbase[cid][iarr2].weapon[j].search := gPlayer[plInd].objbase[cid][iarr2].weapon[j].search*(1+value/100);

    as well as some other methods but nothing workes, I am not really god in stuff like that.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice