OSP Kit Combat Battlefield Tactics kit. Multiple formations per team+command revamp!

Users who are viewing this thread

dariel said:
Speaking of light cavalry, is it possible to assign different numbers to light cavalry and heavy cavalry?
Actually, Caba'drin extended formations to the other divisions back in March, putting the formations system in slots. So now the AI has the potential to remember what it was doing from one moment to the next! The code just went through trial-by-fire (i.e. Brytenwalda players). I was going to further exploit slots, but it appears that the code is stable enough if you guys want what I have now. Only thing is there have been a couple complaints of unresponsive cavalry, but I've not been able to replicate the problem.

EDIT: Or do you mean for the AI? That's one of the things I wanted to do...
Sayd Ûthman said:
Nevermind, i've got another question, i've made one faction always holding, but i want the cavalry to charge, is there something like call_script, charge_for_division, grc_cavalry... ??
Like (team_give_order, ":team_no", grc_cavalry, mordr_charge)?
 
motomataru said:
Like (team_give_order, ":team_no", grc_cavalry, mordr_charge)?

This !! this will work without any problem if i add it here ?? :
Code:
        (try_begin),
          #Sayd modification begin
        (eq,":enemy_faction_no","fac_kingdom_1"), #Almoravids
        (assign,":battle_tactic",btactic_hold), #Almoravids will always hold their ground
        (team_give_order,":team_no", grc_cavalry, mordr_charge),
        (else_try),#Sayd modification end
          (eq, ":defense_not_an_option", 0),
          (gt, ":ai_perc_archers", 50),
          (lt, ":ai_perc_cavalry", 35),
          (assign, ":battle_tactic", btactic_hold),
        (else_try),
          (lt, ":rand", 80),
          (assign, ":battle_tactic", btactic_follow_leader),
        (try_end),
      (try_end),
      (assign, reg0, ":battle_tactic"),
  ]),
 
No, not there. Here's the triggers from mission_templates (snipping out the intervening crashers for morale):
Code:
      AI Triggers
      (0, 0, ti_once, [
          (store_mission_timer_a,":mission_time"),(ge,":mission_time",2),
          ],
       [(call_script, "script_select_battle_tactic"),
        (call_script, "script_battle_tactic_init"),
        #(call_script, "script_battle_calculate_initial_powers"), #deciding run away method changed and that line is erased
        ]),
      
      (5, 0, 0, [
          (store_mission_timer_a,":mission_time"),

          (ge,":mission_time",3),
          
          (call_script, "script_battle_tactic_apply"),
          ], []), #applying battle tactic
So you have an initial decision and setup, then the chosen tactic is applied every 5 seconds.

By contrast, in my AI module, the tactical decision is revisited in the archer field tactics section every 5 seconds.

So your actual cavalry charge belongs in the apply section. You'll see the team_give_order in battle_tactic_apply_aux. All but ONE of them are to charge everybody. So you could reacquire your faction info and put your order there, at line 26102 module_scripts:
Code:
          (team_give_order, ":team_no", grc_everyone, mordr_hold),
          (team_set_order_position, ":team_no", grc_everyone, pos63),
          (agent_get_position, pos1, ":ai_leader"),
          (try_begin),
            (lt, ":distance_to_enemy", 50),
            (ge, ":mission_time", 30),
            (assign, ":battle_tactic", 0),
            (team_give_order, ":team_no", grc_everyone, mordr_charge),
            (agent_set_speed_limit, ":ai_leader", 60),
          (try_end),
 
Oh i see  :oops: so if i put this :

Code:
          (store_faction_of_party,":party_faction","$g_enemy_party"),
          (try_begin),
          (eq,":party_faction","fac_kingdom_1"),
          (team_give_order,":team_no", grc_cavalry, mordr_charge),
          (assign,":party_faction",1),
          (try_end),

above the code you marked , that should work ,right ??
 
Ok, ignore the previous question, I have decided to modify the ranks script.

So my questions now are:

Is using the native spread out order as part of the formation script the best way to create a scattered formation, or is there some way I can increase the distance between troops for that particular formation? I am exceedingly new to coding, so am really not sure how I'd go about this.

I also have a weird problem where archers will always create their formation several metres to the left of where they are ordered to.. annoying! Any thoughts on what could cause that?

 
Dain Ironfoot said:
Ok, ignore the previous question, I have decided to modify the ranks script.
Sorry to not reply earlier; I was away.

Just as a partial answer, you usually get the complaint about "cf_" if you have a script test not enclosed by a condition (try_begin, etc). So "cf_*" scripts return true/false, and if you have a non-cf script do that, the compiler gives the helpful warning.
Dain Ironfoot said:
So my questions now are:

Is using the native spread out order as part of the formation script the best way to create a scattered formation, or is there some way I can increase the distance between troops for that particular formation? I am exceedingly new to coding, so am really not sure how I'd go about this.

I also have a weird problem where archers will always create their formation several metres to the left of where they are ordered to.. annoying! Any thoughts on what could cause that?
Mm, yeah. If we change spacing for one formation, it throws script_get_centering_amount, which is tricked to think there's only one archer formation. So maybe it's best to bump up the extra spacing.

So before this:
(call_script, "script_player_attempt_formation", grc_archers, formation_ranks)

You'd need a:
(val_max, "$archer_space", N),

Where N is your minimum number of half-meters...
 
Ah, I may have heavily modified the kit so archers can form a variety of formations, only one of which I want to be a loose formation.
 
In that case, skip the extra space and instead add hard-coded centimeters to the formation_ranks section of script_form_archers.

Then add a troop type argument to script_get_centering_amount, update all calls to that script, then make sure not only your archers' formation_ranks includes your extra centimeters but check all your new archer formations for centering calculation.

You may wish to add a loose formation minimum spacing constant to formations_constants so you can tweak it there instead of the two hard-coded places.

Let me know if something is still weird after this. These changes can be tricky in this complex system.
 
Ok, so we're going to see how bad I am at coding here.

In that case, skip the extra space and instead add hard-coded centimeters to the formation_ranks section of script_form_archers.

Like this? (wedge is the specific formation I'm replacing)

Code:
(else_try),
		(eq, ":archers_formation", formation_wedge),
	(store_div, ":rank_dimension", ":num_troops", 2),		
		(val_add, ":rank_dimension", 1),
		[b](val_max, "$archer_space",500),	[/b]	
		(assign, ":max_level", 0),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_archers, ":fleader", ":agent"),
			(agent_get_troop_id, ":troop_id", ":agent"),
			(store_character_level, ":troop_level", ":troop_id"),
			(gt, ":troop_level", ":max_level"),
			(assign, ":max_level", ":troop_level"),
		(end_try),

I'm not quite sure what you mean in the script_get_centering_amount, I tried a few things but had a bunch of errors.

I may have broken things through overly enthusiastic pruning, I may have to revert back to the begining and make the changes from scratch. To be honest there weren't that many..

is the current version supporting formations for multiple battlegroups?
 
Dain Ironfoot said:
is the current version supporting formations for multiple battlegroups?
This one does

http://dl.dropbox.com/u/8432316/FormAIv4%20Dev.zip

It's a serious transformation from the last time I posted it in January. It has been running a couple versions of Brytenwalda. About the only issue is that it division typing confuses the players. It'd probably be better to provide something to have the player SET the division type...
 
Is it possible to have something automatically set the division? Set it based on troop name for example (so all troops of name A,B,C would end up in division 1 and so forth)
 
Dain Ironfoot said:
Is it possible to have something automatically set the division? Set it based on troop name for example (so all troops of name A,B,C would end up in division 1 and so forth)
:?: The player assigns the troop to the division. That's our problem: guessing from the division composition how the player intends to use it... They all have bows? Piece of cake. Half bows, half polearms, and half mounted; it's an educated guess.
 
Yeah, I knew players usually have to set the divisions, was just vaguely wondering if it was possible to have the divisions automatically be set instead.

Are the changes in the new version still in the mod merger files?
 
Hallo, me again.

While I have succesfully got the spread out formation working (aside from a problem with centring, see the Q&A thread) I've been having a few more thoughts. I'd basically like the rear rank to take one step to their left or right, just for improved LOS. Now I'm guessing

Code:
(gt, ":column", ":rank_dimension"),	#next rank?
				(position_move_y, pos1, ":neg_distance", 0),
				(try_begin),
					(neq, ":form_left", 1),
					(assign, ":form_left", 1),
					(position_move_x, pos1, ":neg_distance", 0),
				(else_try),
					(assign, ":form_left", 0),
					(position_move_x, pos1, ":distance", 0),
				(try_end),			
				(assign, ":column", 1),
				(val_add, ":rank", 1),

Controls the rear rank position? Can I add some values there to cause them to take a few steps to the left?

Also, I'd like to fire off a script only when a formation has finished forming..

 
Sorry not to reply sooner. Just spent almost a week tweaking things diplomatic...

Dain Ironfoot said:
While I have succesfully got the spread out formation working (aside from a problem with centring, see the Q&A thread) I've been having a few more thoughts. I'd basically like the rear rank to take one step to their left or right, just for improved LOS. Now I'm guessing

Code:
(gt, ":column", ":rank_dimension"),	#next rank?
				(position_move_y, pos1, ":neg_distance", 0),
				(try_begin),
					(neq, ":form_left", 1),
					(assign, ":form_left", 1),
					(position_move_x, pos1, ":neg_distance", 0),
				(else_try),
					(assign, ":form_left", 0),
					(position_move_x, pos1, ":distance", 0),
				(try_end),			
				(assign, ":column", 1),
				(val_add, ":rank", 1),

Controls the rear rank position? Can I add some values there to cause them to take a few steps to the left?
That's correct, though you ought not need to add anything. I suspect (not looking right now) that :distance is half the distance between troops (including extra spacing ordered by player).
Dain Ironfoot said:
Also, I'd like to fire off a script only when a formation has finished forming..
Actually, this is a problem I haven't solved. The AI makes similar decisions based on the average position of the troops -- not terribly ideal. I suppose you could write a script that would loop through all agents, pick the ones in the formation, and compare position with scripted destination, then make some judgments about how many are how close...
 
So if I replace :distance with an integer that is a little more or less than half the distance between troops, that would have the desired effect?

Actually, this is a problem I haven't solved. The AI makes similar decisions based on the average position of the troops -- not terribly ideal. I suppose you could write a script that would loop through all agents, pick the ones in the formation, and compare position with scripted destination, then make some judgments about how many are how close...

Eep. Sounds tricky. What I'm trying to do is fire off a script which causes the front rank to brace spears, easy enough to do.. except they become immobile, which can result in the first rank getting left behind. And I guess I'd need a stand up script for every movment etc. Flibbertigibbet.
 
Back
Top Bottom