Results 1 to 18 of 18

Thread: How to script captured settlement rewards

  1. #1

    Default How to script captured settlement rewards

    Hey all,
    Im trying to find a script that will give you units when you capture a settlement, like when you capture the city n the Italian campaign and you get some artillery units (can't remember it's name).
    I've looked through the scripting files and can't find any refernce to it.
    Anyone got any ideas? Or even better, could someone write me up the few lines?
    i could do most of it, but what worries me is that there doesn't seem to be a spawn command
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  2. #2

    Default Re: How to script captured settlement rewards

    Afaik, we can't do that. At least in ETW, CA has all the interesting bits of the campaign script locked up so that we can't spawn units, kill factions, etc. Give it a try for NTW, though. You can see internal documentation for the campaign library if you open the .exe with a hex editor. Scroll down to offset 011D2170 and you'll see all the fun stuff. Hope you can get it working!

  3. #3

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by erasmus777 View Post
    Afaik, we can't do that. At least in ETW, CA has all the interesting bits of the campaign script locked up so that we can't spawn units, kill factions, etc. Give it a try for NTW, though. You can see internal documentation for the campaign library if you open the .exe with a hex editor. Scroll down to offset 011D2170 and you'll see all the fun stuff. Hope you can get it working!
    I'll take a look now -I've got Winhex, but rarely use it - I suppose now would be a good time to learn
    But how were the units that I mentioned spwawned then? I'm pretty sure that they wern't the result of the mission. They added a few new script commands in NTW, so hopefully I'll get something
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  4. #4

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by -TopCat- View Post
    I'll take a look now -I've got Winhex, but rarely use it - I suppose now would be a good time to learn
    But how were the units that I mentioned spwawned then? I'm pretty sure that they wern't the result of the mission. They added a few new script commands in NTW, so hopefully I'll get something
    Nevermind. It might have helped if I had looked at the scripts.

    Code:
    --
    -- Mission 2 - The Liberation of Milan
    --
    
    local function liberate_milan()
        out.ting ("The Liberation of Milan")
        scripting.game_interface:trigger_custom_mission("ita_liberate_milan", 
                                                        "ita_french_republic", "capture_city", 0, "ita_milano", 
                                                        "mission_text_text_ita_liberate_milan_heading",
                                                        "mission_text_text_ita_liberate_milan_text", 
                                                        "", 0, "", context,
                                                        true, "money:1000,grant_unit:Inf_Line_French_Revolutionary_Infantry#settlement:ita_milano:milan,enable_recruitment:Inf_Line_French_Milan_Revolutionary_Infantry")
    end

  5. #5

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by erasmus777 View Post
    Nevermind. It might have helped if I had looked at the scripts.

    Code:
    --
    -- Mission 2 - The Liberation of Milan
    --
     
    local function liberate_milan()
        out.ting ("The Liberation of Milan")
        scripting.game_interface:trigger_custom_mission("ita_liberate_milan", 
                                                        "ita_french_republic", "capture_city", 0, "ita_milano", 
                                                        "mission_text_text_ita_liberate_milan_heading",
                                                        "mission_text_text_ita_liberate_milan_text", 
                                                        "", 0, "", context,
                                                        true, "money:1000,grant_unit:Inf_Line_French_Revolutionary_Infantry#settlement:ita_milano:milan,enable_recruitment:Inf_Line_French_Milan_Revolutionary_Infantry")
    end
    Where'd you find that?
    I spent all day looking and couldn't find it
    It shouldn't be too hard to rig up a script from there. You think if I altered this:

    Code:
    events.ResearchCompleted[#events.ResearchCompleted + 1] = function (context)
     if conditions.ResearchType("military_army_plug_bayonet",context) then
          scripting.game_interface:add_restricted_unit_record("9_lber_land_cannon_(saker)")
     end
    end
    to include this:
    Code:
    SettlementOccupied = {}
    (and the other changes) i could pull it off?

    I know its not quite as simple as that, but I'm new to scripting
    It seems to just be a measure of common sense thats needed
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  6. #6

    Default Re: How to script captured settlement rewards

    Or ofcourse I could just add my own mission.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  7. #7
    Johan217's Avatar Campidoctor
    Join Date
    Jan 2005
    Location
    Gent, Belgium
    Posts
    1,965

    Default Re: How to script captured settlement rewards

    Related to this, I found something interesting: the units you get as a reward when liberating a country in the Grand Campaign appears to be hard coded (at least I found nothing in the scripts). The real interesting part is that the game only appears to choose units that you would be able to build in that province given its current buildings. In other words, if you tied an AOR unit "Bavarian Infantry" to Bavaria, there is a fair chance that you will get it as a reward when you liberate them. In this way, the player can get multinational armies without actually having to occupy all those foreign regions.
    Rock 'n' roll is the only religion that will never let you down

  8. #8

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by Johan217 View Post
    Related to this, I found something interesting: the units you get as a reward when liberating a country in the Grand Campaign appears to be hard coded (at least I found nothing in the scripts). The real interesting part is that the game only appears to choose units that you would be able to build in that province given its current buildings. In other words, if you tied an AOR unit "Bavarian Infantry" to Bavaria, there is a fair chance that you will get it as a reward when you liberate them. In this way, the player can get multinational armies without actually having to occupy all those foreign regions.
    An easy way to overcome this would be just to let the units be recruitable from low-level buildings. The only thing that justifies, to me atleast, liberating a region is to get the free unit - I'm a bit sick of getting militia.
    I'll agree with what you say about the aor - its not exactly hardcoded, just limited to local units.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  9. #9
    Hazbones's Avatar Senator
    Join Date
    May 2007
    Location
    Iwakuni, Japan
    Posts
    1,104

    Default Re: How to script captured settlement rewards

    Yeah, this is correct. The free units are determined by the units that are available for building in that region you liberate. If you create AORs for units as I have, the free units I get are limited to what I can train with my current buidling levels. I tested with global units and I usually got the best unit I had available (of all global units) but when I removed "global" from the units and created an AOR for that region I only got the best unit that was available in that region (in this case all I got was a line infantry). With global enabled I was offered a grenadier which was the best unit in that instance.

  10. #10

    Default Re: How to script captured settlement rewards

    just one point on the subject it seems the British_Dutch_units were perhaps an early attempt by CA to create an aor style to these bonus units you get when you liberate a zone, but like many things in the CA workshop it got left on the bench.......... (like the spanish campaign that has ai and stuff in NTW but no map,,,,,,,,)

    Good find Johan i take it you had to create resource in a startpos file for your aor, the resource in the vanilla startpos is pretty dang bare from my untrained eyes. ie No england resource to make some brit units only recruit able at home.


    Only other help i can give is the name Alpaca he was a bit of the Scripting guru in ETW perhaps kind words in his direction could spread some light on the subject......



    Good luck.
    Last edited by Dogmeat; April 22, 2010 at 12:29 PM.

  11. #11

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by Dogmeat View Post
    just one point on the subject it seems the British_Dutch_units were perhaps an early attempt by CA to create an aor style to these bonus units you get when you liberate a zone, but like many things in the CA workshop it got left on the bench.......... (like the spanish campaign that has ai and stuff in NTW but no map,,,,,,,,)

    Good find Johan i take it you had to create resource in a startpos file for your aor, the resource in the vanilla startpos is pretty dang bare from my untrained eyes. ie No england resource to make some brit units only recruit able at home.


    Only other help i can give is the name Alpaca he was a bit of the Scripting guru in ETW perhaps kind words in his direction could spread some light on the subject......



    Good luck.
    Well a lot of the old aors from Empire could probably be recycled.

    Aplaca didn't seem very interested when I contacted him about scripting for Napoleon.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  12. #12

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by -TopCat- View Post
    Well a lot of the old aors from Empire could probably be recycled.

    Aplaca didn't seem very interested when I contacted him about scripting for Napoleon.
    For sure its just a pity CA only put area resource in for DLC units and a few ottomans and balkans units. In ETW the resource wernt that extensive but at least most regions had one or two, porbably cause im lazy and updating the new startpos that will come out with every new DLC is a bit of a bore.....

    Hopefully alpaca will show some interest one day, but i can kinda understand a slight disapointment felt by some ETW modders NTW does feel a little small vs the ETW globe. 3 steps fwd and 2 steps back.

    Plus DLC i rekon is the bane for modders - one day the bean counters at CA/Sega will win the argument over the mod friendly CA staff and realise that modders can make new (an better imho) units for free and that could be bad news for mod support.

    then well just have to go bandito...
    Last edited by Dogmeat; April 22, 2010 at 12:49 PM.

  13. #13

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by -TopCat- View Post
    Well a lot of the old aors from Empire could probably be recycled.

    Alpaca didn't seem very interested when I contacted him about scripting for Napoleon.
    It'd be great if we somebody step up to learn Lua, esp for the project we're all working on. Alpaca only has time enough to devote to his core interests. I understand the basics, but I have to head up the tools and I'm starting to get some RL programming projects that are going to start cutting into my time. Programming and scripting is sort of like a Russian novel: the first 100 pages are a grind and you have no idea why every one has 5 different names, who's talking when, etc. Once you power through that bit, it's like "A Ha!" and things start clicking into place and you suddenly realize you've been sucked in and you can't walk away.

    We really need people to step up for the community. Hazbones is helping me out along with just, but if we had a couple more people we could do some really cool stuff. There are things that we know that aren't on the forums and won't be until we put a little more work into figuring them out. But we need people who are smart and will to push themselves to learn things that might seem challenging at first.

    There is genuine payoff for the effort, though. Unlike some areas of modding, the skills you learn developing tools are things you can put on your resume (not Lua so much, because it's not much used outside of the gaming industry, but any C language, Python, etc that we use for the tools). Plus, once you learn the syntax for any C-derived or C-like language (C, C++, C#, Python, Java, etc), then learning any other C-like language is really easy.

    That's enough preaching ftm, but if anyone is interested, please contact me and I will do whatever I can to help you get started.

  14. #14

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by erasmus777 View Post
    It'd be great if we somebody step up to learn Lua, esp for the project we're all working on. Alpaca only has time enough to devote to his core interests. I understand the basics, but I have to head up the tools and I'm starting to get some RL programming projects that are going to start cutting into my time. Programming and scripting is sort of like a Russian novel: the first 100 pages are a grind and you have no idea why every one has 5 different names, who's talking when, etc. Once you power through that bit, it's like "A Ha!" and things start clicking into place and you suddenly realize you've been sucked in and you can't walk away.

    We really need people to step up for the community. Hazbones is helping me out along with just, but if we had a couple more people we could do some really cool stuff. There are things that we know that aren't on the forums and won't be until we put a little more work into figuring them out. But we need people who are smart and will to push themselves to learn things that might seem challenging at first.

    There is genuine payoff for the effort, though. Unlike some areas of modding, the skills you learn developing tools are things you can put on your resume (not Lua so much, because it's not much used outside of the gaming industry, but any C language, Python, etc that we use for the tools). Plus, once you learn the syntax for any C-derived or C-like language (C, C++, C#, Python, Java, etc), then learning any other C-like language is really easy.

    That's enough preaching ftm, but if anyone is interested, please contact me and I will do whatever I can to help you get started.
    I would love to learn .lua, and I would take a good shot at it, except I'm hearing the same thing everywhere -
    "If you want to learn a language, don't do it over the internet - college is the best place to start" (which is unfortunately two years away for me)

    If you can point me in the direction of a good online tutorial or book, I'll gladly attempt to learn lua - I've just been reluctant to do it over the internet and pick up bad habits.

    As for lua towards a resume - I'd love to work in the games industry
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  15. #15

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by -TopCat- View Post
    I would love to learn .lua, and I would take a good shot at it, except I'm hearing the same thing everywhere -
    "If you want to learn a language, don't do it over the internet - college is the best place to start" (which is unfortunately two years away for me)

    If you can point me in the direction of a good online tutorial or book, I'll gladly attempt to learn lua - I've just been reluctant to do it over the internet and pick up bad habits.

    As for lua towards a resume - I'd love to work in the games industry
    Great! I'll poke around for tutorials and PM you. Don't worry about bad habits as what really matters is if your code works.

  16. #16
    ♔Icebear77♔'s Avatar Biarchus
    Join Date
    Jan 2009
    Location
    Switzerland and Germany
    Posts
    673

    Default Re: How to script captured settlement rewards

    I decided to lern lua with the promoted books on the lua-homepage (or should i learn a C-language?? ) . I think it should work, because i was a software-programmer and had no problems to learn languages... this will be fun!!
    Last edited by ♔Icebear77♔; April 23, 2010 at 03:06 AM.

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

    Default Re: How to script captured settlement rewards

    I'm sorry that I've been a bit gruff about this, I just didn't yet have the time nor the motivation to write sensible and understandable tutorials, primarily because there are very few things you can simply do out of the box without some additional overhead scripts that I'm still in the process of writing.

    If you look at APE:TI it has scripts like this but they are very badly written because I was mostly making them up as I went along without really knowing what I was doing (as is usually the case with my programming endeavours), and are therefore hard to read and understand even for myself when looking back at them.

    I will see if I can write a tutorial about some thing or another to lend you a hand in starting.

    Edit: Also, pah! to people saying you can't learn a language over the internet. It's not that hard if you have a sufficient base of decently-commented example code you can play around with and internet resources to check what syntax and some structs mean. I'd be the first to admit I never learned any programming language properly but I'm still able to do a lot. I frequently run into trouble concerning performance, though... this is something I'm still planning to read a book or two about but haven't got around to yet
    Last edited by alpaca; April 25, 2010 at 11:26 AM.

    No thing is everything. Every thing is nothing.

  18. #18

    Default Re: How to script captured settlement rewards

    Quote Originally Posted by alpaca View Post
    I'm sorry that I've been a bit gruff about this, I just didn't yet have the time nor the motivation to write sensible and understandable tutorials, primarily because there are very few things you can simply do out of the box without some additional overhead scripts that I'm still in the process of writing.

    If you look at APE:TI it has scripts like this but they are very badly written because I was mostly making them up as I went along without really knowing what I was doing (as is usually the case with my programming endeavours), and are therefore hard to read and understand even for myself when looking back at them.

    I will see if I can write a tutorial about some thing or another to lend you a hand in starting.

    Edit: Also, pah! to people saying you can't learn a language over the internet. It's not that hard if you have a sufficient base of decently-commented example code you can play around with and internet resources to check what syntax and some structs mean. I'd be the first to admit I never learned any programming language properly but I'm still able to do a lot. I frequently run into trouble concerning performance, though... this is something I'm still planning to read a book or two about but haven't got around to yet
    Np, I dont like being pestered either
    Well Ive spent a few days learning the basics (and I really do mean basics! ) of Lua, and I can say I'm pretty happy to do some basic scripts of my own. What really shied me away from scripting was all the spacings, symbols, and kewords. But I get the idea of them now
    I'm not stopping there; I plan to learn Lua fully, best do it properly while I'm at it
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

Posting Permissions

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