OSP Code Combat [MBMC]Mount & Blade Modding Contest scripting archive

Lumos

Section Moderator
WBWF&SNWM&BVC
Best answers
0

Mount & Blade Modding Contest - Scripting

This thread shall serve as a central repository for the submissions of all scripting contests following their conclusion. As normal, all of them are OSPs, and more information about the license can be found here.

Click on the link in the archive for the post containing the downloads and details. Click on 'More' for the specific contest thread.

Contests Archive
 

Lumos

Section Moderator
WBWF&SNWM&BVC
Best answers
0

June 2018 - Combat Features

Original thread

Melee Combo & Combo Effects by Khamukkamu

Download link: Single PY file with All Code Additions (Commented)

Instructions
- Copy the relevant code to its relevant location (module_constants.py additions to module_constants.py; module_mission_templates.py additions to module_missiont_templates.py, and so on...)

- Add the 'combo_effects' mission template trigger list to the mission templates you want it to appear.
-- For instance, in Lead Charge:
Code:
(
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
      (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
      (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
      (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
      (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ], combo_effects+

- Modify the module_constants.py additions to your liking:
-- Set the COMBO TIERS
-- Set the COMBO ACTION TIERS
-- See below:
Code:
# Melee Combo & Effects by Khamukkamu START

# Agent Slots for Counting Hits and Time Since Last Hit

slot_agent_combo_counter = 1002
slot_agent_combo_timer = 1003

# Set the Following Option To 1 if You Want To Reset The Combo to 0 if the Player is Hit. Otherwise, set it to 0.
DAMAGE_TO_PLAYER_RESETS_COMBO = 0

# Change the Value Below in Seconds to Set The Duration / Length of the Combo Time (i.e How Long The Combo Multiplier Lasts Before it Resets to 0)
COMBO_TIMER_ADDITION = 5 #Seconds


# Constants for Combo Tiers (More Can Be Added Depending on Mod)
# Min Values are the start of the tier, Max Values - 1 are the end of a tier.

COMBO_TIER_1_MIN = 2
COMBO_TIER_1_MAX = 4 

COMBO_TIER_2_MIN = COMBO_TIER_1_MAX
COMBO_TIER_2_MAX = COMBO_TIER_2_MIN + 2

# Combo Action Tiers - If You Want To Have A Special Action / Effect To Happen at A Specific Combo Hit, You Can Set it Up Here.
# The Value is the Current Combo Hit That Occurred Which Will Trigger The Effect

COMBO_ACTION_TIER_1 = 3
COMBO_ACTION_TIER_2 = 6
COMBO_ACTION_TIER_3 = 10

# Combo Text Colours
COMBO_TEXT_GOOD = 0x33FF33
COMBO_TEXT_GREAT = 0xFFFF33
COMBO_TEXT_EXCELLENT = 0xFF3333


# Debug Switch - Set to 1 to Show Debug Messages
COMBO_DEBUG = 1

# Melee Combo & Effects by Khamukkamu END

- Modify script_cf_combo_effect to add what combo effects you want. Included in the code is an overpowered Two-Handed Weapon AOE at COMBO ACTION TIER 1.



Necromancy Stones by cwr

Code/OSP installation instructions:
Add this to module_items:
Code:
["skeleton_stones",         "Skeleton Stones", [("throwing_stone",0)], itp_type_thrown |itp_primary ,itcf_throw_stone, 1000 , weight(4)|difficulty(0)|spd_rtng(97) | shoot_speed(30) | thrust_damage(11 ,  blunt)|max_ammo(18)|weapon_length(8),imodbit_large_bag, [
(ti_on_missile_hit, [
(store_trigger_param_1, ":thrower"), 
(play_sound_at_position, "snd_pistol_shot", pos1), 
(particle_system_burst, "psys_village_fire_smoke_big", pos1, 15), 
(agent_get_team, ":throwerteam", ":thrower"),
(set_spawn_position, pos1),
(spawn_agent, "trp_skeleton_for_necromancy"),
(agent_set_team, reg0, ":throwerteam"),
(agent_set_is_alarmed, reg0, 1),
])
], [] ],
Create a troop that you wish to spawn. I have this:
Code:
   ["skeleton_for_necromancy","Hernar Ancestor","Hernar Ancestors",tf_skeleton|tf_allways_fall_dead,no_scene,reserved,fac_commoners,
   [itm_vaegir_fur_helmet,itm_vaegir_spiked_helmet,itm_vaegir_lamellar_helmet,itm_bone],
   def_attrib|level(15),wp(100),knows_common|knows_ironflesh_4|knows_power_strike_4,skeleton_face1, skeleton_face2],
This troop uses Barf's OSP skeleton, so if you are not using that you could use the undead race from Native, or whatever you want really. Just remember to not add this troop to a party as it is not counted in casualties.

In script_count_mission_casualties_from_agents, in the first try for agents block, add:
                (neq, ":agent_troop_id", "trp_skeleton_for_necromancy"),
Below this:
                (agent_get_troop_id, ":agent_troop_id", ":cur_agent"),
In the second try for agents block add this:
                (agent_get_troop_id, ":troop_of_agent", ":cur_agent"),
                (neq, ":troop_of_agent", "trp_skeleton_for_necromancy"),
Below this:
                (agent_is_human, ":cur_agent"),

This prevents script errors from appearing during casualties and prevents the troops from appearing as casualties in the battle reports. (as they are not part of a party they are not relevant information on the actual damage done to either the player or the enemies)

In script_agent_reassign_team add this:
                (agent_get_troop_id, ":troop_of_agent", ":agent_no"),
                (neq, ":troop_of_agent", "trp_skeleton_for_necromancy"),
Below:
                (agent_is_human, ":agent_no"),

This prevents errors during sieges.

Because this troop is spawned during battle rather than being part of the reinforcement waves, you should replace the first trigger in mt_lead_charge (ti_on_agent_spawn) with this:
Code:
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (assign, ":initial_courage_score", 5000),
		 (try_begin),
			(agent_get_troop_id, ":troop_of_agent", ":agent_no"),
			(neq, ":troop_of_agent", "trp_skeleton_for_necromancy"),
			(call_script, "script_agent_reassign_team", ":agent_no"),

                  
			(agent_get_troop_id, ":troop_id", ":agent_no"),
			(store_character_level, ":troop_level", ":troop_id"),
			(val_mul, ":troop_level", 35),
			(val_add, ":initial_courage_score", ":troop_level"), #average : 20 * 35 = 700
         
			(store_random_in_range, ":randomized_addition_courage", 0, 3000), #average : 1500
			(val_add, ":initial_courage_score", ":randomized_addition_courage"), 

			(agent_get_party_id, ":agent_party", ":agent_no"),         
			(party_get_morale, ":cur_morale", ":agent_party"),
         
			(store_sub, ":morale_effect_on_courage", ":cur_morale", 70),
			(val_mul, ":morale_effect_on_courage", 30), #this can effect morale with -2100..900
			(val_add, ":initial_courage_score", ":morale_effect_on_courage"), 
		(else_try),
			(val_add, ":initial_courage_score", 3000), 
         	(try_end),
         (agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"), 
         ]),
For mt_bandits_at_night:
Code:
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (agent_get_troop_id, ":troop_no", ":agent_no"),
         (neq, ":troop_no", "trp_player"),
	 (neq, ":troop_no", "trp_skeleton_for_necromancy"),
         (agent_set_team, ":agent_no", 1),
         ]),
For mt_town_fight (if you still use this mission)
Code:
      (ti_on_agent_spawn, 0, 0, [],
      [
        (store_trigger_param_1, ":agent_no"),
        (agent_get_troop_id, ":troop_of_agent", ":agent_no"),
        (neq, ":troop_of_agent", "trp_skeleton_for_necromancy"),
        (agent_set_team, ":agent_no", 0),
      ]),
The end result will be spawning skeletons, or whatever troop you choose, wherever the rock is thrown.



Battlefield Skills & Effects ᴺᵒᵒᵇ ᴱᵈᶦᵗᶦᵒᶰ by PitchPL