Page 1 of 2 12 LastLast
Results 1 to 20 of 32

Thread: Scripting If/Then Unit Obsolescence

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Scripting If/Then Unit Obsolescence

    Can one script contingencies for unit obsolescence? Mainly, I'm interested in making units obsolete based on certain events such as year or technological discovery.

  2. #2
    Mooncabbage's Avatar Ducenarius
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    990

    Default Re: Scripting If/Then Unit Obsolescence

    I think it's possible for a technology to obsolete a unit, but I'm not sure about scripting it based on year or anything else. Interesting idea though.
    Not actually on the moon.

    Empire: Tactical Warfare Mod v1.0

  3. #3
    Praepositus
    Join Date
    Mar 2009
    Location
    California
    Posts
    5,616

    Default Re: Scripting If/Then Unit Obsolescence

    I actually thought the opposite lol. I used to know a bit of LUA myself, how conditions work. However I'm unfamiliar with the functions here.

  4. #4
    joedreck's Avatar Artifex
    Join Date
    Jan 2007
    Location
    Frankfurt am Main
    Posts
    2,009

    Default Re: Scripting If/Then Unit Obsolescence

    Make tech is very simple. You see my units in the signature. The Guard, Gens d'Armes and Leib-Karabiener I can only get with techs.

    I did it, cause Prussia have from beginning the palast, so they would have from beginning guards, what I don't want. I will make it for hussars too (the standart hussars stay. The 3 others can be recruit after research tech). So I can decide, how my Army will looks. I plan the same for infantry too.

    The techs need 4 rounds, but I must check it ingame, cause maybe it's to long.
    Edictum mod adds new edicts to Rome II. http://www.twcenter.net / YouTube: Edictum Mod / Click here for Edictum Mod on steam
    Vote Brain Slug for president.

  5. #5

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by joedreck View Post
    Make tech is very simple. You see my units in the signature. The Guard, Gens d'Armes and Leib-Karabiener I can only get with techs.

    I did it, cause Prussia have from beginning the palast, so they would have from beginning guards, what I don't want. I will make it for hussars too (the standart hussars stay. The 3 others can be recruit after research tech). So I can decide, how my Army will looks. I plan the same for infantry too.

    The techs need 4 rounds, but I must check it ingame, cause maybe it's to long.
    But what happens to the old units? How do we make them go away?

  6. #6
    joedreck's Avatar Artifex
    Join Date
    Jan 2007
    Location
    Frankfurt am Main
    Posts
    2,009

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by erasmus777 View Post
    But what happens to the old units? How do we make them go away?
    That's the problem. My techs add only new units. I have a new pc and many problems to get run him, so I can't try many things at moment, but it's possible to script that. As the_vicar said, look for alpaca's script info.

    I plan to create 2 periods for the prussians at first. Before 1740 and after.
    If thats work, I do that for france too. Before 1763 and after.
    Edictum mod adds new edicts to Rome II. http://www.twcenter.net / YouTube: Edictum Mod / Click here for Edictum Mod on steam
    Vote Brain Slug for president.

  7. #7

    Default Re: Scripting If/Then Unit Obsolescence

    If you take a look at Alpaca's script information post, he says something about being able to globally remove a unit from recruitment.

    Maybe look into that?
    Every day takes figuring out all over again how to live.

  8. #8

    Default Re: Scripting If/Then Unit Obsolescence

    Quoting from Alpacas Script-o-Rama (currently page 2 of this forum):


    add_restricted_unit_record(<unit_key>)

    add_restricted_unit_record allows you to remove a unit from being available for recruitment world-wide (similar to the SF units)

    Parameters: Unit key as string (as it appears in the units table)

    Example:
    scripting.game_interface:add_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")





    remove_restricted_unit_record(<unit_key>)
    remove_restricted_unit_record removes the restriction on a unit record that was previously set with add_restricted_unit_record

    Parameters: Unit key as string (as it appears in the units table)

    Example:
    scripting.game_interface:remove_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")
    So my very limited scripting tells me that this could work:


    local function OnFactionTurnStart(context)

    if conditions.TurnNumber(context) == 25 then

    scripting.game_interface:remove_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")

    end

    end


    sadly the turn number and faction name conditions are the only ones i know, i guess a tech-linking is what you are looking for,
    and propably a national lockout, but that can be worked around by giving national units.
    Last edited by Lazy Knight; June 25, 2009 at 06:11 AM.


  9. #9

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by Lazy Knight View Post
    Quoting from Alpacas Script-o-Rama (currently page 2 of this forum):

    So my very limited scripting tells me that this could work:


    local function OnFactionTurnStart(context)

    if conditions.TurnNumber(context) == 25 then

    scripting.game_interface:remove_restricted_unit_record("euro_expat_infantry_regiments_etrangeres")

    end

    end


    sadly the turn number and faction name conditions are the only ones i know, i guess a tech-linking is what you are looking for,
    and propably a national lockout, but that can be worked around by giving national units.
    Thanks for that, LK. Hopefully that's the first step in figuring out how to link this with technology.

  10. #10

    Default Re: Scripting If/Then Unit Obsolescence

    Hi all, I was directed here by erasmus so I shall post here then.

    Would anyone know a way to do changes for Textures only, there are plenty of links for cannon shot types i.e. advanced grapeshot, (removing old types) and for removing units and for including new units (i have done it myself at least twice)

    but to allow new skins for units as time goes on, the easiest way would be to link it to research. I am thinking of this in terms of naval marines. i.e. adding and removing a texture for late game rather than for early game.

    In this case instead of using a script to remove grapeshot and allow advanced grapeshot, would there be a way to remove a model and replace it with another model??

    I have no knowledge of coding, so I am simply stumbling around in the dark


    Thanks if anyone can help

    Rusty

    ALSO DEVELOPERS CAMERA

    Pessimism is a term used by Optimists, to attempt to discredit those who see the world as it really is!

  11. #11
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Scripting If/Then Unit Obsolescence

    The condition you're looking for is FactionTechExists, it takes three arguments: A faction ID string, a unit ID string and a faction event context. Otherwise the script LK posted should be alright, only for disabling a unit you need to use the add_restricted_unit_record command

    No thing is everything. Every thing is nothing.

  12. #12

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by alpaca View Post
    The condition you're looking for is FactionTechExists, it takes three arguments: A faction ID string, a unit ID string and a faction event context. Otherwise the script LK posted should be alright, only for disabling a unit you need to use the add_restricted_unit_record command
    Awesome! That means we can have units change uniforms over time or have a tech trigger a transition from "Early Line Infantry" to "Late Line Infantry." Thanks alpaca!

    er... can you tell me what that would look like scripted, I'm clueless when it comes to scripting.
    Last edited by erasmus777; June 28, 2009 at 05:18 PM.

  13. #13

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by erasmus777 View Post
    Awesome! That means we can have units change uniforms over time or have a tech trigger a transition from "Early Line Infantry" to "Late Line Infantry." Thanks alpaca!

    er... can you tell me what that would look like scripted, I'm clueless when it comes to scripting.
    Tell me too!

  14. #14

    Default Re: Scripting If/Then Unit Obsolescence

    May I ask if there is a similar one for Textures, not just units?

    Apologies if this is redundant.

    ALSO DEVELOPERS CAMERA

    Pessimism is a term used by Optimists, to attempt to discredit those who see the world as it really is!

  15. #15
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Scripting If/Then Unit Obsolescence

    No, putting scripting.lua into a pack is a bad idea because which one is used depends on the timestamp of the file on the disk - so if a player reinstalls after you released your mod chances are they won't see the scripted changes. That's why APE:TI is overwriting the vanilla file.

    And no, you can only create new units with a different texture but not change textures directly.

    No thing is everything. Every thing is nothing.

  16. #16
    joedreck's Avatar Artifex
    Join Date
    Jan 2007
    Location
    Frankfurt am Main
    Posts
    2,009

    Default Re: Scripting If/Then Unit Obsolescence

    Did someone try it? I dindn't have time yesterday .

    Thanks alpaca for support.
    Edictum mod adds new edicts to Rome II. http://www.twcenter.net / YouTube: Edictum Mod / Click here for Edictum Mod on steam
    Vote Brain Slug for president.

  17. #17

    Default Re: Scripting If/Then Unit Obsolescence

    damn, I apologise Alpaca, I meant models, not textures, I.e. early and late models not early and late units.

    But from your last comment I take it that this is the same is it not?

    For naval battles the models is all you can change, not units, unless...

    Two units, twice the work, one with a different model of crew than the other.

    ALSO DEVELOPERS CAMERA

    Pessimism is a term used by Optimists, to attempt to discredit those who see the world as it really is!

  18. #18

    Default Re: Scripting If/Then Unit Obsolescence

    Quote Originally Posted by Rsty Bloodnok View Post
    damn, I apologise Alpaca, I meant models, not textures, I.e. early and late models not early and late units.

    But from your last comment I take it that this is the same is it not?

    For naval battles the models is all you can change, not units, unless...

    Two units, twice the work, one with a different model of crew than the other.
    Yeah, but there are ways to make this easy. I found an awesome freeware app for editing tsv files:http://csved.sjfrancke.nl/index.html. It's what I use for the most part now. Open and save your tsv file as "All files '.*'". If only the first column shows up, press add column as many times as you need to see the rest of the table. For long entries such as the loc file, double click on the cell, then add rows to see all the text at the same time.

    Among the things you can do with this program is add prefixes to existing entries, meaning you could add "early_" onto all the names in unit_stas_land in 5 seconds. You could do that for all the files, so it wouldn't take long. There's also a plug-in for batch renaming files in GIMP and a built-in one for PS, so you can quickly change the file names for textures too.
    Last edited by erasmus777; June 30, 2009 at 08:25 AM.

  19. #19

    Default Re: Scripting If/Then Unit Obsolescence

    Is there any way to tie this to a specific faction?

    That is, the way I'm reading the script you provided, it only applies to the first faction that researches the tech, and then the effects are global, right?

    So, if I have 2 units line_infantry and line_infantry_2, with line_infantry being obsolesced by researching some generic infantry_reforms tech, and line_infantry_2 being enabled, then the effects are felt by every faction upon some random AI researching this tech before the player?

    Because if there isn't a way to tie the call to a specific faction, e.g. event.has.happened(faction_name) or some such, then that would require a LOT of work to get around.
    Every day takes figuring out all over again how to live.

  20. #20
    joedreck's Avatar Artifex
    Join Date
    Jan 2007
    Location
    Frankfurt am Main
    Posts
    2,009

    Default Re: Scripting If/Then Unit Obsolescence

    You can make the tech for special faction, so only this faction would have this tech.
    Edictum mod adds new edicts to Rome II. http://www.twcenter.net / YouTube: Edictum Mod / Click here for Edictum Mod on steam
    Vote Brain Slug for president.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •