Co-op modder's thread

Users who are viewing this thread

Bad Idea

Knight
To all you WFAS modders out there and soon-to-be: here's a thread dedicated to modding WFAS co-op!!

Share your tips and cool findings to help expand the community's knowledge of Co-op script
This is a thread to help us all discover more about the complicated aspects of co-op. Making everyone's lives a lot easier


How to add custom troops to co-op, the pro way.
Note: The easiest way to change co-op troops is to replace them in module_troops. But this way is more flexible
First open module_constants

Find and copy these lines
captain_multiplayer_coop_new_troops_begin = "trp_coop_moscovite_watchmen"
captain_multiplayer_coop_new_troops_end = "trp_coop_troops_end"

rename the new one to be whatever you want.
troops_begin is the first custom troop on your list, end is the troop right after the last one

captain_multiplayer_coop_new_troops_begin = "trp_coop_moscovite_watchmen"
captain_multiplayer_coop_new_troops_end = "trp_coop_troops_end"
captain_multiplayer_coop_sexy_new_troops_end = "trp_coop_sexy_new_troops_begin"
captain_multiplayer_coop_sexy_new_troops_end = "trp_coop_sexy_new_troops_end"


Save and open module_scripts

At line 3075 add your new units
The numbers to the right decide the units Troop Type/Strength
(troop_set_slot, "trp_coop_janissary", slot_troop_mp_squad_type, 11),
(troop_set_slot, "trp_coop_cossack_swordmen", slot_troop_mp_squad_type, 21),
(troop_set_slot, "trp_coop_polish_axemen", slot_troop_mp_squad_type, 31),
(troop_set_slot, "trp_coop_russian_polearmsmen", slot_troop_mp_squad_type, 41),
(troop_set_slot, "trp_coop_swedish_swordsmen", slot_troop_mp_squad_type, 41),

(troop_set_slot, "trp_coop_volunteer_militia", slot_troop_mp_squad_type, 12),
(troop_set_slot, "trp_coop_cossack_pistoleers", slot_troop_mp_squad_type, 22),
(troop_set_slot, "trp_coop_lithunian_defenders", slot_troop_mp_squad_type, 32),
(troop_set_slot, "trp_coop_crimean_hawkeyes", slot_troop_mp_squad_type, 42),
(troop_set_slot, "trp_coop_miquelet_musketeers", slot_troop_mp_squad_type, 42),

(troop_set_slot, "trp_coop_moscovite_watchmen", slot_troop_mp_squad_type, 13),
(troop_set_slot, "trp_coop_dragoons", slot_troop_mp_squad_type, 23),
(troop_set_slot, "trp_coop_cossack_wildriders", slot_troop_mp_squad_type, 33),
(troop_set_slot, "trp_coop_crimean_horse_archers", slot_troop_mp_squad_type, 43),
(troop_set_slot, "trp_coop_winged_hussars", slot_troop_mp_squad_type, 43),

        (troop_set_slot, "trp_coop_puck", slot_troop_mp_squad_type, 11),
(troop_set_slot, "trp_coop_serpico", slot_troop_mp_squad_type, 21),
(troop_set_slot, "trp_coop_caska", slot_troop_mp_squad_type, 31),
(troop_set_slot, "trp_coop_guts", slot_troop_mp_squad_type, 41),
(troop_set_slot, "trp_coop_griffith", slot_troop_mp_squad_type, 41),


(troop_set_slot, "trp_coop_clone_trooper", slot_troop_mp_squad_type, 12),
(troop_set_slot, "trp_coop_clone_elite", slot_troop_mp_squad_type, 22),
(troop_set_slot, "trp_coop_jedi", slot_troop_mp_squad_type, 32),
(troop_set_slot, "trp_coop_big_alien", slot_troop_mp_squad_type, 42),
(troop_set_slot, "trp_coop_axe_cop", slot_troop_mp_squad_type, 42),


(troop_set_slot, "trp_coop_pig_rider", slot_troop_mp_squad_type, 13),
(troop_set_slot, "trp_coop_horse_dude", slot_troop_mp_squad_type, 23),
(troop_set_slot, "trp_coop_crazy taxi", slot_troop_mp_squad_type, 33),
(troop_set_slot, "trp_coop_monster_horseman", slot_troop_mp_squad_type, 43),
(troop_set_slot, "trp_coop_sexy_hussars", slot_troop_mp_squad_type, 43),  :!: 1 = infantry, 2 = ranged, 3 = cavalry

Make sure you have equal amounts of all three units, for simplicity use the exact same numbers that are there.
Now count every tier 1 infantry.
Change this value to the number of every tier 1 infantry that will be used in the game. (don't count the ones you're replacing)
(assign, "$g_mp_num_troops_per_type_tier123", 6),

do the same for tier 4
(assign, "$g_mp_num_troops_per_type_tier4", 7),

CHECK THE CHANGES ABOVE, ANY MISTAKES WILL SPAWN NAKED TROOPS INSTEAD

Now find this block of code and edit as shown
(try_for_range, ":troop_array_index", 0, 3),
(ge, ":selected_troop", 0),
(try_begin),
(eq, ":troop_array_index", 0),
(assign, ":troop_array_begin", captain_multiplayer_coop_sexy_new_troops_begin),  :!: these lines here determine which troops will be spawn in co-op.
(assign, ":troop_array_end", captain_multiplayer_coop_sexy_new_troops_end),            replace the constants with your new set, voila!! You're done
(else_try),
(eq, ":troop_array_index", 1),
(assign, ":troop_array_begin", captain_multiplayer_new_troops_begin),
(assign, ":troop_array_end", captain_multiplayer_new_troops_end),
(else_try),
(eq, ":troop_array_index", 2),
(assign, ":troop_array_begin", captain_multiplayer_coop_new_troops_begin),
(assign, ":troop_array_end", captain_multiplayer_coop_new_troops_end),
(try_end),
               
(try_for_range, ":cur_troop", ":troop_array_begin", ":troop_array_end"),
(ge, ":selected_troop", 0),
(troop_slot_eq, ":cur_troop", slot_troop_mp_squad_type, ":used_troop_key"),
(val_sub, ":selected_troop", 1),
(lt, ":selected_troop", 0),
(assign, ":used_troop_no", ":cur_troop"),


With some tweaking you can add even more troop varieties, or change variety depending on the wave number. Have fun!!

new troop selection script (overwrites old code)
NEW TROOP SELECTION SCRIPT. SELECTS DIFFERENT TROOPS FOR LATER ROUNDS
(try_begin),
                (lt, "$g_multiplayer_ccoop_wave_no", 10),
(assign, ":troop_array_begin", coop_weak_troops_begin),
(assign, ":troop_array_end", coop_weak_troops_end),
(else_try),
                (gt, "$g_multiplayer_ccoop_wave_no", 10),
(assign, ":troop_array_begin", coop_med_troops_begin),
(assign, ":troop_array_end", coop_med_troops_end),
(else_try),
                (gt, "$g_multiplayer_ccoop_wave_no", 20),
(assign, ":troop_array_begin", coop_strong_troops_begin),
(assign, ":troop_array_end", coop_strong_troops_end),
(try_end),
               

How to get more troops (module_scripts)  (overwrites old code)
(try_begin),
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
(val_mul, ":num_troops_for_wave", 130), <<
(val_div, ":num_troops_for_wave", 100), <<
(else_try),
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),
(try_end),

How to make stronger troops (in module_mission_templates)  (overwrites old code)
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),
(agent_get_team, ":agent_team_no", ":agent_no"),
(try_begin),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++
(agent_set_max_hit_points, ":agent_no", 150), this
(agent_set_damage_modifier, ":agent_no", 130), and this
(else_try),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+
(agent_set_max_hit_points, ":agent_no", 175),
(agent_set_damage_modifier, ":agent_no", 150),
(try_end),
]),

Item unlocks
Annynduir said:
How do you edit what waves, armour and weapons unlock on and their costs?

Line 11491 in the native module code.

find the script
  ("multiplayer_display_available_items_for_troop_and_item_classes",  it's below the block that says # wave information

  (try_begin),
(eq, "$g_multiplayer_game_type", multiplayer_game_type_captain_coop),
(call_script, "script_multiplayer_get_item_value_for_troop", ":item_no", ":troop_no"),
(assign, ":item_price", reg0),
(try_begin),
(is_between, ":item_price", 0, 301),
(assign, ":border_wave", 0),
(else_try),
(is_between, ":item_price", 301, 551),
(assign, ":border_wave", 3),
(else_try),
(is_between, ":item_price", 351, 701),
(assign, ":border_wave", 5),
(else_try),
(is_between, ":item_price", 701, 1101),
(assign, ":border_wave", :cool:,
(else_try),
(gt, ":item_price", 1001),
(assign, ":border_wave", 11),
(try_end),

Basically this code makes the more expensive items unlock later.
":border_wave" is the item's unlock wave. The value of ":item_price" is the exact amount of gold the item costs.

More friendly bots
search files for (assign, "$g_multiplayer_squad_size", 6), and change the value 6 to the number you want

scaled.php
 
NEW TROOP SELECTION SCRIPT. SELECTS DIFFERENT TROOPS FOR LATER ROUNDS
(try_begin),
                (lt, "$g_multiplayer_ccoop_wave_no", 10),
(assign, ":troop_array_begin", coop_weak_troops_begin),
(assign, ":troop_array_end", coop_weak_troops_end),
(else_try),
                (gt, "$g_multiplayer_ccoop_wave_no", 10),
(assign, ":troop_array_begin", coop_med_troops_begin),
(assign, ":troop_array_end", coop_med_troops_end),
(else_try),
                (gt, "$g_multiplayer_ccoop_wave_no", 20),
(assign, ":troop_array_begin", coop_strong_troops_begin),
(assign, ":troop_array_end", coop_strong_troops_end),
(try_end),
               
 
what if i just want to make more soldiers come out? i tried editing the number at the end of the line but i didnt see a change
 
How to get more troops (module_scripts)
(try_begin),
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
(val_mul, ":num_troops_for_wave", 130), <<
(val_div, ":num_troops_for_wave", 100), <<
(else_try),
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),
(try_end),

How to make stronger troops (in module_mission_templates)
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),
(agent_get_team, ":agent_team_no", ":agent_no"),
(try_begin),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++
(agent_set_max_hit_points, ":agent_no", 150), this
(agent_set_damage_modifier, ":agent_no", 130), and this
(else_try),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+
(agent_set_max_hit_points, ":agent_no", 175),
(agent_set_damage_modifier, ":agent_no", 150),
(try_end),
]),
 
Nice stuff. Y'know...the whole idea behind the WFAS co-op seems to be stolen from Full Invasion, but maybe not. Lol
 
Bad Idea said:
How to get more troops (module_scripts)
(try_begin),
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
(val_mul, ":num_troops_for_wave", 130), <<
(val_div, ":num_troops_for_wave", 100), <<
(else_try),
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),
(try_end),

How to make stronger troops (in module_mission_templates)
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),
(agent_get_team, ":agent_team_no", ":agent_no"),
(try_begin),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++
(agent_set_max_hit_points, ":agent_no", 150), this
(agent_set_damage_modifier, ":agent_no", 130), and this
(else_try),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+
(agent_set_max_hit_points, ":agent_no", 175),
(agent_set_damage_modifier, ":agent_no", 150),
(try_end),
]),



how come when i put this number up it seems as though there are less troops?
or is it because it says wave 20 and wave 10 because i saw one for wave 4 and still nothing changed
 
ralfis said:
Bad Idea said:
How to get more troops (module_scripts)
(try_begin),
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
(val_mul, ":num_troops_for_wave", 130), <<
(val_div, ":num_troops_for_wave", 100), <<
(else_try),
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),
(try_end),

How to make stronger troops (in module_mission_templates)
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),
(agent_get_team, ":agent_team_no", ":agent_no"),
(try_begin),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++
(agent_set_max_hit_points, ":agent_no", 150), this
(agent_set_damage_modifier, ":agent_no", 130), and this
(else_try),
(eq, ":agent_team_no", 1), # enemies
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+
(agent_set_max_hit_points, ":agent_no", 175),
(agent_set_damage_modifier, ":agent_no", 150),
(try_end),
]),



how come when i put this number up it seems as though there are less troops?
or is it because it says wave 20 and wave 10 because i saw one for wave 4 and still nothing changed

The code there is for waves 10+ and 20+ (veteran and elite modes) (gt = greater than)
20% more troops for 'normal' mode would look like this
(try_begin),
(gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
(val_mul, ":num_troops_for_wave", 130), <<
(val_div, ":num_troops_for_wave", 100), <<
(else_try),
(gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),
(else_try),
(lt, "$g_multiplayer_ccoop_wave_no", 11), # normal mode, 20% more troops
(val_mul, ":num_troops_for_wave", 120),
(val_div, ":num_troops_for_wave", 100),

(try_end),



 
so, i have to add that code for normal mode under
(try_begin),
            (gt, "$g_multiplayer_ccoop_wave_no", 20), # wave++ mode, 30% more troops
            (val_mul, ":num_troops_for_wave", 130), <<
            (val_div, ":num_troops_for_wave", 100), <<
        (else_try),
            (gt, "$g_multiplayer_ccoop_wave_no", 10), # wave+ mode, 20% more troops
            (val_mul, ":num_troops_for_wave", 120),
            (val_div, ":num_troops_for_wave", 100),
        (try_end),

        (put the code here?)
 
This may seem like really stupid question, but coming from a former console gamer, when you say co-op, do you mean local split screen, or online co-op? split-screen i think might work as far as monitors size is concerned as most people including myself nowadays use a larger monitors or even some cases such as mine their TV.

As far as getting it to work on the same computer while running two different character/profiles simultaneously  would be difficult. still it'd  be cool to play local split screen with a friend, a good way to finally introduce some of them to M&B. Though if that's your plans good luck and I'm rooting for you.
 
Back
Top Bottom