Results 1 to 19 of 19

Thread: How to add units midgame

Hybrid View

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

    Default How to add units midgame

    Is it possible to add specific units midgame?

    I tried creating a fourth clan mission to use the "Reward" line but couldn't get it to work. Also tried to search for the flag in savegame file to reset a previously finished mission so that I can do it again but didn't work either.

    Seems like it should be possible. Please help.

    Thank you.

  2. #2

    Default Re: How to add units midgame

    http://www.twcenter.net/forums/showthread.php?t=445950

    Check out this thread for information about adding units on a specific turn.

    Deciphering The Zodiac - Check It Out!

  3. #3

    Default Re: How to add units midgame

    Quote Originally Posted by Tan Zhi Han View Post
    http://www.twcenter.net/forums/showthread.php?t=445950

    Check out this thread for information about adding units on a specific turn.
    Spoiler Alert, click show to read: 


    So if I wanted to add units for myself, I would change the opening line to:
    if conditions.FactionIsHuman... then...?

    1) if conditions.TurnNumber(context) == 1 //This needs to be nested around the above code to add units after certain turns?

    2) What would I put for ForceID if I were to use Uesugi Clan? Am I supposed to change that line to read "Uesugi Patrol"?

    3) What would I put in quotes for the out.ting line of code if I'm using this to add units for myself in Uesugi Clan?

    Thanks for the help.

  4. #4

    Default Re: How to add units midgame

    You don't need out.ting.

    It is a developer console message. You can put in anything you want. I just follow coding standard and put in a message about what the following code does.

    out.ting("I feel like making myself GODLIKE and adding elite troops to my forces.")

    Code:
    if conditions.TurnNumber(context) == TurnNumberHere then
         if conditions.FactionIsHuman("YourFactionHere", context) then
              scripting.game_interface:create_force(--[FACTION]--
    							 "uesugi", 
    					 	      --[SPECIFIC ARMY LIST]--
    							 "Inf_Spear_Yari_Ashigaru,Inf_Spear_Yari_Ashigaru", 
    						      --[COORDINATES]--	
    							 44.0, -81.0,
    						      --[ID]--
    							 "AnyNameHere",                  (ex: Uesugi Gun Toting Hooligans)
    						      --[USE_COMMAND_QUEUE]--
    							 true)

    Deciphering The Zodiac - Check It Out!

  5. #5

    Default Re: How to add units midgame

    Quote Originally Posted by Tan Zhi Han View Post
    You don't need out.ting.

    It is a developer console message. You can put in anything you want. I just follow coding standard and put in a message about what the following code does.

    out.ting("I feel like making myself GODLIKE and adding elite troops to my forces.")

    Spoiler Alert, click show to read: 

    if conditions.TurnNumber(context) == TurnNumberHere then
    if conditions.FactionIsHuman("YourFactionHere", context) then
    scripting.game_interface:create_force(--[FACTION]--
    "uesugi",
    --[SPECIFIC ARMY LIST]--
    "Inf_Spear_Yari_Ashigaru,Inf_Spear_Yari_Ashigaru",
    --[COORDINATES]--
    44.0, -81.0,
    --[ID]--
    "AnyNameHere", (ex: Uesugi Gun Toting Hooligans)
    --[USE_COMMAND_QUEUE]--
    true)

    Do I just copy/paste this code block and drop it into scripting.lua?

    I cut/pasted it to the end of scripting.lua.
    I cut/pasted it to OnFactionTurnStart/INITIAL ENEMY FORCES AND MP CAMERA section for my clan.

    Also, do I paste another block of this code and change the turn number and forceID name to create units on later turns?

    All it does now is ignore the scripting.lua and set the starting camera position in the top of the map in the sea, with no bonuses or startup money that I specified.

    Sorry for taking away from your gaming time.

  6. #6

    Default Re: How to add units midgame

    When the camera is set at the top, the script is broken.

    Did you read the script I provided carefully? There are certain variables you need to change yourself because I didn't know what you wanted to do.

    EX: YOURFACTIONHERE

    means "uesugi" or "oda" etc.

    Deciphering The Zodiac - Check It Out!

  7. #7

    Default Re: How to add units midgame

    There's only three that I saw.

    TurnNumberHere replaced with "1"
    YourFactionHere replaced with "uesugi"
    AnyNameHere replaced with "uesugi army"

    Is there a limit on the number of units that can be listed in the "--[SPECIFIC ARMY LIST]--"?

    I'm not sure where to put this script. Do I put this at the end of the block of code for my faction under "INITIAL ENEMY FORCES AND MP CAMERA" section? Just add it or replace what is already there for my faction?

    Spoiler Alert, click show to read: 

    elseif conditions.FactionName("uesugi", context) and conditions.FactionIsHuman("uesugi", context) then

    if CampaignUI.IsMultiplayer() then
    scripting.game_interface:set_zoom_limit(1.15, 0.61)
    CampaignUI.SetCameraZoom(0.95)
    CampaignUI.SetCameraTargetInstant(83.0, -73.0)

    else
    if conditions.TurnNumber(context) == 1 then
    if conditions.FactionIsHuman("uesugi", context) then
    scripting.game_interface:create_force(--[FACTION]--
    "uesugi",
    --[SPECIFIC ARMY LIST]--
    "Inf_Sword_Katana_Samurai,Inf_Sword_Katana_Samurai,Inf_Missle_Bow_Warrior_Monks,Inf_Missle_Bow_Warrior_Monks,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship,Galleon_The_Black_Ship",
    --[COORDINATES]--
    77.0, -79.0,
    --[ID]--
    "Uesugi Army",
    --[USE_COMMAND_QUEUE]--
    true)


    end

    end

  8. #8

    Default Re: How to add units midgame

    Well. 2 things.
    1. You can't create naval units with land units. That is quite inconceivable... Although maybe on the water if the land units are properly placed onto the naval units, but I am not sure about that.
    2. You must change your coordinates to not be the same as any other unit creation script, or else the unit will crash the game (can't have 2 forces in the same spot). I don't know if you did this, but just a note.

    Deciphering The Zodiac - Check It Out!

  9. #9

    Default Re: How to add units midgame

    Quote Originally Posted by Tan Zhi Han View Post
    Well. 2 things.
    1. You can't create naval units with land units. That is quite inconceivable... Although maybe on the water if the land units are properly placed onto the naval units, but I am not sure about that.
    2. You must change your coordinates to not be the same as any other unit creation script, or else the unit will crash the game (can't have 2 forces in the same spot). I don't know if you did this, but just a note.

    1) Ok, thanks. When I was using the "--Reward--" line, it put the land units next to the castle and the ships next to the port. Thought maybe it would work similarly.

    2) When I changed the coordinates, the units didn't show up at all, even after starting a new turn.

    Could you attach your scripting.lua so I can see where in the script you're placing that code block and how it fits in with the surrounding code?

    Thanks.

  10. #10

    Default Re: How to add units midgame

    http://www.twcenter.net/forums/showthread.php?t=446184

    I have been using this script for testing.

    Deciphering The Zodiac - Check It Out!

  11. #11

    Default Re: How to add units midgame

    Quote Originally Posted by Tan Zhi Han View Post
    http://www.twcenter.net/forums/showthread.php?t=446184

    I have been using this script for testing.

    Finally able to add some units.

    Thanks.

    Suppose I'll have to find a different way to add ships.

    Some units, such as bow warrior monks just won't add, regardless of how I type their name in.

    I've tried using these without success:

    Inf_Missle_Bow_Warrior_Monks
    Inf_Missle_Bow_Warrior_Monk
    inf_missile_bow_warrior_monks_chosokabe
    inf_missile_bow_warrior_monks_uesugi

  12. #12

    Default Re: How to add units midgame

    Be aware that some troops are restricted to factions. I have not had any issue with warrior monks. Have you tried creating a naval force in the OCEAN? It works, I promise. lol

    Deciphering The Zodiac - Check It Out!

  13. #13

    Default Re: How to add units midgame

    I tried using troops that are general instead of the faction-specific troops, such as bow warrior monks instead of Chosokabe bow warrior monks but it didn't work.

    How would you add land and ocean units; turn 1 code to add land units, turn 2 code to add ocean units?

    If I tried to add both in the same code block, it put my ships in the same stack as my land units.

    Where would you add the "if TurnNumber =2... then..." and "if TurnNumber =3... then..." code blocks; immediately following the "if Bool_difficulty is v.hard or legendary... create_force... block?
    Last edited by gatorreefer; April 25, 2011 at 04:13 PM.

  14. #14

    Default Re: How to add units midgame

    No no. Just repeat the Create Force script twice in the same turn. One for naval units. One for land units. (Naval units on water, land units on land)

    Deciphering The Zodiac - Check It Out!

  15. #15

    Default Re: How to add units midgame

    By land and by sea!

    Armies spawn like a parade. lol

    Thanks for your help.

  16. #16

    Default Re: How to add units midgame

    How did you get the coordinates? also i try it but the units never spawn?

  17. #17

    Default Re: How to add units midgame

    Please, mates can you post example of working code?

    Well, this code works fine:
    Code:
    events.FactionTurnStart[#events.FactionTurnStart+1] = function(context)
    	if CampaignUI.IsPlayersTurn() == true and conditions.TurnNumber(context) == 1 then
    		if conditions.FactionIsHuman("uesugi", context) then
              scripting.game_interface:create_force(--[FACTION]--
    							 "uesugi", 
    					 	      --[SPECIFIC ARMY LIST]--
    							 "Inf_Missile_Matchlock_Warrior_Monks_Uesugi,Inf_Heavy_Naginata_Warrior_Monk_Hero_Uesugi,Inf_Sword_Katana_Hero_Shimazu", 
    						      --[COORDINATES]--	
    							 55.0, -85.0,
    						      --[ID]--
    							 "Avans",
    						      --[USE_COMMAND_QUEUE]--
    							 true)
    		end
    	end
    end
    But how to find out appropriate coordinates?
    Last edited by Rodrigo The Scarred; April 26, 2011 at 08:22 AM.

  18. #18

    Default Re: How to add units midgame

    Quote Originally Posted by Rodrigo The Scarred View Post
    Please, mates can you post example of working code?

    Well, this code works fine:
    Spoiler Alert, click show to read: 

    events.FactionTurnStart[#events.FactionTurnStart+1] = function(context)
    if CampaignUI.IsPlayersTurn() == true and conditions.TurnNumber(context) == 1 then
    if conditions.FactionIsHuman("uesugi", context) then
    scripting.game_interface:create_force(--[FACTION]--
    "uesugi",
    --[SPECIFIC ARMY LIST]--
    "Inf_Missile_Matchlock_Warrior_Monks_Uesugi,Inf_Heavy_Naginata_Warrior_Monk_Hero_Uesugi,Inf_Sword_Katana_Hero_Shimazu",
    --[COORDINATES]--
    55.0, -85.0,
    --[ID]--
    "Avans",
    --[USE_COMMAND_QUEUE]--
    true)
    end
    end
    end



    But how to find out appropriate coordinates?
    Look at the scripting.lua for any units that the pc might spawn in your territory; rebellion, etc. and note what the coordinates are for that unit. Spawn your own troops by using coordinates based off of those coordinates.

    x,y coordinates:
    x - goes from left to right on your map, smaller number moves the spawn point to the left, larger number moves it to the right

    y - goes from top to bottom on your map, smaller number moves the spawn point to the bottom, larger number moves it to the top, be careful about negative numbers

    One whole number difference moves the spawn point enough space to fit one unit icon's width. For example, if you make two units spawn at [75.0,-79.0] and [74.0,-79.0], the second unit will be to the left of the first unit. They will be standing shoulder to shoulder.

    Spawning ships works the same way. Be careful that the ship is not too close to land or else it can't move. Also, ships must be placed in areas that are already visible regarding fog of war. Ships put in coordinates still hidden by fog of war simply won't spawn at all.

  19. #19

    Default Re: How to add units midgame

    I explain that in my tutorial. The CRUX of finding good coordinates is that it is VERY difficult given that you can only obtain coordinates based off of the script itself and the startpos. If units are created on another object (mountains, water, city, units, etc.) then bad things happen (script not running, game crashing, units unable to move, etc.)

    I found out all of my coordinates based off of guesses and using the initial ENEMY army coordinates (which spawn if you are playing that faction).

    But seriously, ALOT of guessing and checking. Good luck with it...

    Deciphering The Zodiac - Check It Out!

Posting Permissions

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