OSP Kit Combat Camel Kit! - Makes horses react to camels

Users who are viewing this thread

Add horses_spook, in the list of triggers for the mission template you want.
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,[]),
     ],
    [
     horse_spook,
...
 
Thanks for your help but it still did not work.  :sad:
I added the "horses_spook,".
Code:
(
    "lead_charge",mtf_battle_mode|mtf_synch_inventory,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,[]),
     ],
    [
	horses_spook,
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_agent_reassign_team", ":agent_no"),

         (assign, ":initial_courage_score", 5000),

But I got an idea.  :smile:
I am using Diplomacy and I noticed this...
dplmc_battle_mode_triggers = [
    dplmc_horse_speed,
    dplmc_death_camera,
  ]
and this...
  + dplmc_battle_mode_triggers,
I got the horse_speed and death_camera things above the spook_horse thing and the "+ dplmc_battle_mode_triggers," seems to be in 10 different types of battlefields, "village_raid" for example. So I thought maybe that I could try...
Code:
spook_battle_mode_trigger = [
    horses_spook,
and add these...
Code:
  + spook_battle_mode_trigger,

Do you think it could work?  :smile:
 
Somebody said:
You might as well do
Code:
dplmc_battle_mode_triggers = [
    dplmc_horse_speed,
    dplmc_death_camera,
    horses_spook,
  ]

Thanks a lot! This worked!  :mrgreen:
This is sure to make my camels and elephant more useful against cavalry and I am very grateful that you spent some time helping me.
Looks kind of hilarious when a group of horsemen suddenly hits an invisible wall at the same time.  :grin:
 
Hello. Please pardon the necroposting - not sure if I should make a new topic since it's still about this OSP.

Is there a way to check that only enemy horses are affected by camel fear?
 
Somebody said:
Yes, check inside the agent loop and set the chance to 0 if :enemy_rider is friendly instead.

I'm sorry, how to check if :enemy_rider is friendly? I'm not sure - would this code work?

Code:
			(store_random_in_range,":chance",1,11),
			(try_begin),
				(agent_get_rider,":enemy_rider",":enemy_horse"),
				(gt, ":enemy_rider", -1),
				(agent_get_troop_id,":enemy_rider",":enemy_rider"),
				(store_skill_level,":riding","skl_riding",":enemy_rider"),
				(val_add,":chance",":riding"),
			(else_try),
				(assign,":chance",0),
			(try_end),
			(lt, ":chance", 10),
			(agent_set_animation,":enemy_horse","anim_horse_rear"),

Please pardon the silly question/coding, fairly new to modding and reading WB's code...
 
Basically for most single-player contexts (neg|agent_is_ally, ":enemy_rider"), will suffice. In this case you'll want to set the chance to above 10 so that the horse won't rear for allies
Code:
			(try_begin),
				(agent_get_rider,":enemy_rider",":enemy_horse"),
				(gt, ":enemy_rider", -1),
				(try_begin),
					(agent_is_ally,":enemy_rider"),
					(assign,":riding", 99),
				(else_try),
					(agent_get_troop_id,":enemy_rider",":enemy_rider"),
					(store_skill_level,":riding","skl_riding",":enemy_rider"),
				(try_end),
				(val_add,":chance",":riding"),
			(try_end),
 
Ah, again, I'm sorry... I guess I phrased my question wrongly (pardon me, poor English capability)...  :oops: I should have asked this:

"Is there a way to check that only horses in the opposing team are affected by camel fear?"

So if the enemy use camel, our horses will be spooked but their horses will be okay; if we use camel, enemy horses will be spooked but our horses will be okay.

agent_is_ally only checks if agent is the part of our team right? Is there some kind of agent_is_in_opposing_team command? I found this command list page but it doesn't give enough info... should I use agent_get_party_id?
 
No, party id is not always reliable, there are a number of other ways to determine whether one agent is hostile to another. Basically for sake of simplicity you can ignore the riderless camels and assume only two teams, and this can be found with
Code:
agent_get_team
. So in the outer loop (where we don't actually iterate over the rider agents, we can fix this later) find the rider of the horse agent, and record the team in a local variable. In the inner loop we keep the same code, but store the rider's team (if any) in a different local variable. The operation
Code:
teams_are_enemies
can then be used to compare the two, proceeding only if the operation passes.
 
Thanks! I'm not really sure, but would this code work?

Code:
			(store_random_in_range,":chance",1,11),
			
			(try_begin),
				(agent_get_rider,":enemy_rider",":enemy_horse"),
				(gt, ":enemy_rider", -1),
				(agent_get_team,":enemy_team",":enemy_rider"),
				(agent_get_rider,":cur_rider",":cur_horse"),
				(agent_get_team,":agent_team",":cur_rider"),
				(try_begin),
					(teams_are_enemies,":agent_team",":enemy_team"),
					(agent_get_troop_id,":enemy_rider",":enemy_rider"),
					(store_skill_level,":riding","skl_riding",":enemy_rider"),
				(else_try),
					(assign,":riding", 99),
				(try_end),
				(val_add,":chance",":riding"),
			(try_end),

			(lt, ":chance", 10),
			(agent_set_animation,":enemy_horse","anim_horse_rear"),

I'm wondering what's the use of (gt, ":enemy_rider", -1)  :???: Why check if :enemy_rider is greater than -1?
 
The purpose is to check if an agent actually has a rider, if the id is -1 then it does not actually exist and thus there is no appropriate troop template to check the riding skill from. Remember that we are iterating over agents in n^2, so you really want to avoid extra calls. Since we are comparing one agent at a time to other horses, move this
Code:
				(agent_get_rider,":cur_rider",":cur_horse"),
				(agent_get_team,":agent_team",":cur_rider"),
To be above the inner loop - cur_horse will always be the value in the outer loop so we shouldn't need to check the rider every single iteration. Remember to check that the actual agent exists as well and account for riderless camels.
 
By outer loop I assume it means the parent loop of (try_for_agents,":enemy_horse"), right? Just below (agent_get_position,pos2,":cur_horse")?

I'm trying it again... would this code be proper?

Code:
	(try_for_agents,":cur_horse"),
		(agent_is_alive,":cur_horse"),
		(agent_get_item_id,":horse_type",":cur_horse"),
		(is_between,":horse_type",camels_begin,camels_end),
		(agent_get_position,pos2,":cur_horse"),	
		(agent_get_rider,":cur_rider",":cur_horse"),		
		(try_begin),									# check if camel has rider
			(gt, ":cur_rider", -1),							# if it has, go process
			(agent_get_team,":agent_team",":cur_rider"),		# get rider's team
			(try_for_agents,":enemy_horse"),				# then check enemy's horse
				(agent_is_alive,":enemy_horse"),#Make sure he's not dead
				(neg|agent_is_human, ":enemy_horse"),
				(agent_get_item_id,":enemy_horse_type",":enemy_horse"),
				(neg|is_between, ":enemy_horse_type", camels_begin,camels_end),
				(agent_get_position, pos1,":enemy_horse"),
				(get_distance_between_positions,":dist",pos1,pos2),#In CM
				(le,":dist",3500),#Within 35m
				(store_random_in_range,":chance",1,11),
				
				(try_begin),
					(agent_get_rider,":enemy_rider",":enemy_horse"),
					(gt, ":enemy_rider", -1),
					(agent_get_team,":enemy_team",":enemy_rider"),
					(try_begin),
						(teams_are_enemies,":agent_team",":enemy_team"),
						(agent_get_troop_id,":enemy_rider",":enemy_rider"),
						(store_skill_level,":riding","skl_riding",":enemy_rider"),
					(else_try),
						(assign,":riding", 99),
					(try_end),
					(val_add,":chance",":riding"),
				(try_end),

				(lt, ":chance", 10),
				(agent_set_animation,":enemy_horse","anim_horse_rear"),
			(try_end),									# == end of enemy horse check condition
		(else_try),										# if camel has no rider, then...
			# nothing happens?
		(try_end),
	(try_end),
[code]
 
So, after a few playing around this has finally worked nicely. It might be an easy stuff but for an amateur modder like me it takes a while to understand it haha.

I owe Somebody my gratitude! Thanks a lot for the help!

For anyone who want a simple copy-paste, this should work. Horses react only to the opposing team's camels (they should get along with friendly camels)

Code:
horses_spook = (
	6, 0, 0, [],#Every six seconds
	[
	(try_for_agents,":cur_horse"),
		(agent_is_alive,":cur_horse"),
		(agent_get_item_id,":horse_type",":cur_horse"),
		(is_between,":horse_type",camels_begin,camels_end),
		(agent_get_position,pos2,":cur_horse"),	
		(agent_get_rider,":cur_rider",":cur_horse"),		# Store rider info from camel
			(gt, ":cur_rider", -1),						# Camel has rider (greater thn -1)
			(agent_get_team,":agent_team",":cur_rider"),	# Store camel rider info, what team is he?
			(try_for_agents,":enemy_horse"),				# Then  check enemy horse
				(agent_is_alive,":enemy_horse"),#Make sure he's not dead
				(neg|agent_is_human, ":enemy_horse"),
				(agent_get_item_id,":enemy_horse_type",":enemy_horse"),
				(neg|is_between, ":enemy_horse_type", camels_begin,camels_end),
				(agent_get_position, pos1,":enemy_horse"),
				(get_distance_between_positions,":dist",pos1,pos2),#In CM
				(le,":dist",3500),#Within 35m
				(store_random_in_range,":chance",1,11),
				
				(try_begin),		# Check if opposing team, apply horse spook. If not, don't
					(agent_get_rider,":enemy_rider",":enemy_horse"),
					(gt, ":enemy_rider", -1),
					(agent_get_team,":enemy_team",":enemy_rider"),
					(try_begin),
						(teams_are_enemies,":agent_team",":enemy_team"),
						(agent_get_troop_id,":enemy_rider",":enemy_rider"),
						(store_skill_level,":riding","skl_riding",":enemy_rider"),
					(else_try),
						(assign,":riding", 99),
					(try_end),
					(val_add,":chance",":riding"),
				(try_end),

				(lt, ":chance", 10),
				(agent_play_sound, ":enemy_horse", "snd_horse_low_whinny"),		# gives sound
				(agent_set_animation,":enemy_horse","anim_horse_rear"),
			(try_end),	# try_for_agents enemy_horse
	(try_end),
	]
)
 
[For anyone who want a simple copy-paste, this should work. Horses react only to the opposing team's camels (they should get along with friendly camels)
[/quote]

Looks great, I will defo be using this in my upcoming mod. Thanks for making this OSP as well OP.
 
I used it in my mod but, never test it yet,
is this code make horses from both team afraid to enemy camels? or just horses from player team??
 
Tested yours Xaliber, it works very nicely!

Do you mind if I post your OSP-Improved version at the top? Would be easier for people to find maybe.
 
Zarthas said:
Tested yours Xaliber, it works very nicely!

Do you mind if I post your OSP-Improved version at the top? Would be easier for people to find maybe.

Hey, sorry for the extra late reply. Sure, feel free! I just tweak it a bit.
 
Back
Top Bottom