Results 1 to 7 of 7

Thread: [Scripting] How to create new custom missions without using chapter missions.

  1. #1
    Foederatus
    Join Date
    Apr 2012
    Location
    On a boat
    Posts
    35

    Default [Scripting] How to create new custom missions without using chapter missions.

    How does one create and then trigger a new custom mission without using the chapter missions?

    I have tried using the syntax found in the Attila Scripting resource which is
    Code:
    trigger_custom_mission("mission_key", "mission_issuer_key", "faction_key", turn_limit, "objectives", reward)

    but I'm either using this wrong or it doesn't work. As reward I tried using "money:1000" as a simple option. For objectives I am also confused. Should this be the target settlement or the objective type (CAPTURE_REGIONS)?


    I alternatively tried using the syntax I have found in CA scripts

    Code:
    local grudge_mission = mission_manager:new(                faction_name,
                    "wh_dlc06_grudge_belegar_eight_peaks",
                    false
                );
                
                grudge_mission:add_new_objective("CAPTURE_REGIONS");
                grudge_mission:add_condition("region wh_main_eastern_badlands_karak_eight_peaks");
                grudge_mission:add_payload("effect_bundle{bundle_key wh_dlc06_bundle_eight_peaks_recapture;turns 0;}");
                grudge_mission:set_should_cancel_before_issuing(false);
                grudge_mission:trigger();
    But this doesn't seem to work either. I have entered the missions in db/missions_tables.



    The only thing I have been able to do is use chapter missions through the missions.txt but this replaces the chapter missions and isn't exactly what I want.


    So could I get a quick tutorial on how to create and trigger a custom mission with scripts. Preferably including how to set an effect bundle as the payload.

  2. #2
    Litharion's Avatar Artifex
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    2,622

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    You need to add the required entries to the db tables listed below

    missions_tables
    cdir_events_mission_issuer_junctions_tables
    cdir_events_mission_option_junctions_tables
    cdir_events_mission_payloads_tables

    After you have done this simply use
    cm:trigger_mission("FACTION NAME", "MISSION KEY", true);

  3. #3
    Foederatus
    Join Date
    Apr 2012
    Location
    On a boat
    Posts
    35

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    Quote Originally Posted by Litharion View Post
    You need to add the required entries to the db tables listed below

    missions_tables
    cdir_events_mission_issuer_junctions_tables
    cdir_events_mission_option_junctions_tables
    cdir_events_mission_payloads_tables

    After you have done this simply use
    cm:trigger_mission("FACTION NAME", "MISSION KEY", true);

    Thanks. For the ID entries in cdir_events_mission_option... and cdir_events_mission_payloads, how do I get these? Can I make them up (provided they are not used in the base table?). Do I need to get them from Tweak?


    EDIT: I haven't been able to get this command to work at all. I even tested it launching some of CA's own missions.
    Last edited by Xcam901; November 14, 2017 at 02:32 PM.

  4. #4
    Litharion's Avatar Artifex
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    2,622

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    Quote Originally Posted by Xcam901 View Post
    Thanks. For the ID entries in cdir_events_mission_option... and cdir_events_mission_payloads, how do I get these? Can I make them up (provided they are not used in the base table?). Do I need to get them from Tweak?

    EDIT: I haven't been able to get this command to work at all. I even tested it launching some of CA's own missions.
    You can create the ID entries in pfm, but make sure they are not in use already.

    example script:
    Code:
    cm:add_game_created_callback(
        function() setup_script() end)
    
    
    function setup_script()
        core:add_listener(
            "RandomMissionEvent_listener",
            "FactionTurnStart",
            function(context)
                local faction = context:faction();
                return faction:is_human() -- condition human
            end,
            function(context)
                RandomMissionEvent(context:faction())
            end,
            true
        );
    end;
    
    
    function RandomMissionEvent(faction)
    LogGromril("RandomMeteorEvent: Start")
    local turn_number = cm:model():turn_number();
    
    
        if turn_number == 2 then -- condition detail
         cm:trigger_mission(faction:name(), "MISSION", true);
        end;
    end;

  5. #5
    Foederatus
    Join Date
    Apr 2012
    Location
    On a boat
    Posts
    35

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    I have tried using the following code:

    Code:
    core:add_listener(    "df_dwarf_turn_start",
        "FactionTurnStart",
        true,
        function(context)
            local faction = context:faction();
            local faction_name = context:faction():name();
            
            if faction:is_human() and faction_name == "wh_main_dwf_dwarfs" and cm:model():turn_number() == 2 then
                cm:trigger_mission(faction_name, "wh_main_grudge_ancestor_grudge_of_gunbad", true)
                output("trigger_mission_please");
            end;
        end,
        true
    );

    This produces no errors loading the script but no mission appears. In the logs it says this:


    Code:
    [out] <74.7s>        ++ triggering mission from db wh_main_grudge_ancestor_grudge_of_gunbad for faction wh_main_dwf_dwarfs, fire_immediately: true
    [out] <74.7s>        >> whitelist_event_feed_event_type() called, event_type is faction_event_mission_issuedevent_feed_target_mission_faction
    [out] <74.7s>        trigger_mission_please
    When I use the mission_manager:new(...) syntax like so

    Code:
    core:add_listener(
    	"df_dwarf_turn_start",
    	"FactionTurnStart",
    	true,
    	function(context)
    		local faction = context:faction();
    		local faction_name = context:faction():name();
    		
    		if faction:is_human() and faction_name == "wh_main_dwf_dwarfs" and cm:model():turn_number() == 2 then
    			local ancestor_grudge_one = mission_manager:new(faction_name,"wh_main_grudge_ancestor_grudge_of_gunbad",false);
    			
    			ancestor_grudge_one:add_new_objective("CAPTURE_REGIONS");
    			ancestor_grudge_one:add_condition("region wh_main_rib_peaks_mount_gunbad");
    			ancestor_grudge_one:add_payload("effect_bundle{wh_main_payload_event_grudge_settled; turns 5;}");
    			ancestor_grudge_one:set_should_cancel_before_issuing(false);
    			ancestor_grudge_one:trigger();
    			output("trigger_mission_please");
    		end;
    	end,
    	true
    );

    I get this from the logs but still nothing happens

    Code:
    [out] <56.4s>        ++ mission manager triggering mission from string:[out] <56.4s>        ++ triggering mission from string for faction wh_main_dwf_dwarfs mission string is mission{key wh_main_grudge_ancestor_grudge_of_gunbad;issuer CLAN_ELDERS;primary_objectives_and_payload{objective{type CAPTURE_REGIONS;region wh_main_rib_peaks_mount_gunbad;}payload{effect_bundle{wh_main_payload_event_grudge_settled; turns 5;}}}}
    [out] <56.4s>        >> whitelist_event_feed_event_type() called, event_type is faction_event_mission_issuedevent_feed_target_mission_faction



    For contrast, when the game adds one of CA's own missions the log appears like so

    Code:
    [out] <53.4s>        ++ triggering mission from string for faction wh_main_dwf_karak_izor mission string is mission{key wh_dlc06_grudge_belegar_eight_peaks;issuer CLAN_ELDERS;primary_objectives_and_payload{objective{type CAPTURE_REGIONS;region wh_main_eastern_badlands_karak_eight_peaks;}payload{effect_bundle{bundle_key wh_dlc06_bundle_eight_peaks_recapture;turns 0;}}}}
    [out] <53.4s>        >> whitelist_event_feed_event_type() called, event_type is faction_event_mission_issuedevent_feed_target_mission_faction
    [out] <53.4s>
    Last edited by Xcam901; November 16, 2017 at 05:02 PM.

  6. #6
    Litharion's Avatar Artifex
    Join Date
    Sep 2013
    Location
    Germany
    Posts
    2,622

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    The mission will only trigger successfully if the requirments in the cdir_events_mission_option_junctions_tables are met.

  7. #7
    Foederatus
    Join Date
    Apr 2012
    Location
    On a boat
    Posts
    35

    Default Re: [Scripting] How to create new custom missions without using chapter missions.

    Would it be possible for you to post a .pack of a working mission? I have attached a very simple .pack made in PFM that I can't see why it wouldn't work. According to the log everything is triggering but nothing happens.







    Example.rar

Tags for this Thread

Posting Permissions

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