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

Problem with PushMission

Discussion in 'Civ5 - Creation & Customization' started by ispanets, Jan 5, 2014.

  1. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Hi all,

    I have spent today loooooooots of hours trying to figure out why this code doesn't work, and I had to give up.

    I just want a worker to start "Removing a forest" by lua. This is the line of PushMission

    Unit:pushMission(MissionTypes.MISSION_BUILD, 15, -1,0,1,1,18,pUnit:GetPlot(), pUnit);

    15 is "Clear forest" BUILD_ID
    18 is MissionAIType for "Build"

    Actually, I get the "Clearing forest(4)" green icon in the unit panel, that shows that the call has been executed properly. But the unit doesn't animate at all and doesn't do anything. The next turn I repeat it again an the same: "Clearing forest(4)" green icon in the unit panel but no animation at all.

    Can anybody help?

    Thanks in advance.

    Jose Juan
     
  2. Pouakai

    Pouakai It belongs in a museum. Moderator

    Joined:
    Jun 16, 2010
    Messages:
    7,154
    Location:
    Aotearoa
    Moderator Action: Moved to Main C&C forum. The subforums are for completed mods only, not for questions
     
  3. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    1,003
    Code:
    Unit:PushMission(MissionTypes.MISSION_BUILD, 15, 15);
    Unit = worker;
    It makes me wonder why you have Unit and pUnit.
    I assume you have tech allowing clearing forest.
     
  4. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    1) yes, it's pUnit, not Unit. I accidentally didn't paste the first "p" of pUnit:pushMission, but it's correct in my code
    2) yes, I have the technology

    THANKS A LOT for answering, let me try that about 15,15 and I'll come back to you.

    Jose
     
  5. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    No way, with:

    pUnit:pushMission(MissionTypes.MISSION_BUILD, 15, 15,1,1,1,18,pUnit:GetPlot(), pUnit);

    I get the same that with:

    pUnit:pushMission(MissionTypes.MISSION_BUILD, 15, 15)

    or

    pUnit:pushMission(MissionTypes.MISSION_BUILD, 15, -1,0,1,1,18,pUnit:GetPlot(), pUnit);

    ...

    The unit puts the order in the queue, it shows in the unit panel (Clearing Forest(5)) but in the next turn is reset and no Clearing Forests is shown. Moreover, they don't get animate when issued the order PushMission :(
     
  6. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    1,003
    Replace 15 with GameInfoTypes.BUILD_REMOVE_FOREST.
    If you have enabled logging, add before:
    Code:
    print(pUnit:CanBuild(pUnit:GetPlot(), GameInfoTypes.BUILD_REMOVE_FOREST)
    and see what it says.

    I assume you are triggering it on PlayerDoTurn?
     
  7. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Nop, it's a new action button for a special unit. Do you think this could be the cause? Must it be triggered on PlayerDoTurn?
     
  8. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    1,003
    It might be useful if you show whole code related to this issue.

    Do you have a special unit with ability to "summon" worker clearing forest?
     
  9. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    This is the code. It's in my modded UnitPanel.lua, inserted in a piece of code for creating custom action buttons...
    Code:
     { Name = "Clear forest",
        Title = "Clear forest", -- or a TXT_KEY
        OrderPriority = 200, -- default is 200
        --IconAtlas = "UNIT_ACTION_ATLAS", -- 45 and 64 variations required
        --PortraitIndex = 11,--OK
    	IconAtlas = "UNIT_ACTION_ATLAS", -- 45 and 64 variations required
        PortraitIndex = 31,--OK
        ToolTip = "Clears the forest", -- or a TXT_KEY_ or a function
        Condition = function (action, unit) local bW = CheckIfWorker(action,unit); local bCan = CheckIfCanChop(action,unit); local bNotMoved = CanMove(unit); return (bW and bNotMoved and bCan); end,
        Disabled = function(action, unit) return not IsForest(action,unit) end,
        Action = function(pAction, pUnit, eClick)
    		pUnit:PopMission();
    
    		pUnit:PushMission(MissionTypes.MISSION_BUILD, 15, 15,1,1,1,18,pUnit:GetPlot(), pUnit);
    		Events.SerialEventUnitInfoDirty()
    		
    	end,
      },
    
     
  10. LastSword

    LastSword Prince

    Joined:
    Feb 24, 2013
    Messages:
    1,003
    Code:
    	<Unit_Builds>
    		<Row>
    			<UnitType>UNIT_YOUR_SPECIAL_UNIT_TYPE</UnitType>
    			<BuildType>BUILD_REMOVE_FOREST</BuildType>
    		</Row>
    	</Unit_Builds>
    It will make your special unit clearing forest like a worker without LUA.
    Add <WorkRate>100</WorkRate> to the unit.

    In case you really want to create custom action clearing forest, I am unable to help you.
     
  11. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Actualy it's a normal worker, so it has all those parameters already... but anyway I think it should has to do with workrate or other xml pameters... will take a look. Thanks for answering, your help was very useful.
     
  12. S3rgeus

    S3rgeus Emperor

    Joined:
    Apr 10, 2011
    Messages:
    1,270
    Location:
    London, United Kingdom
    I'd just try:

    Code:
    pUnit:PushMission(GameInfoTypes.MISSION_BUILD, GameInfoTypes.BUILD_REMOVE_FOREST)
    Let the rest of the parameters use their default values.
     
  13. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,253
    Trying to use a function unused by Firaxis ? :crazyeye:
    Check your net_message_debug.log, it should have something for you :lol:
     
  14. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Yes, I noticed this function is quite impredictable and very buggy :)

    I have found another way to implement it, thanks anyway for your useful help!
     
  15. bc1

    bc1

    Joined:
    Jan 12, 2004
    Messages:
    1,253
    You need to use Game.SelectionListGameNetMessage(GameMessageTypes.GAMEMESSAGE_PUSH_MISSION, ...
     
  16. bane_

    bane_ Howardianism High-Priest

    Joined:
    Nov 27, 2013
    Messages:
    1,559
    I'm curious, how you did it?
     
  17. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    Aaaaah ! Ok, thank you very much!
     
  18. ispanets

    ispanets Warlord

    Joined:
    Apr 1, 2013
    Messages:
    135
    Location:
    Moscow
    I just wanted some nations to be able to chop down forests and others to be unable, so I just manipulated the xml.
     

Share This Page