Problem with scripted platoons

SkelApe

Member
Elder
Joined
Nov 10, 2007
Messages
651
When i create a platoon on a map using the "create platoon with X men and X women" i can't seem to command it without the game crashing. Is there a way to create a platoon that's assigned to you to start with, like on the first japanese land when the archers are already there? (without having to use the recruit command). This function is also used when you do the undead norse challenge and the 7 samurai challenge; the platoons aren't recruited, they are created and are instantly aligned to you, the player.
Thanks  :)
 
Strange, I've used create platoon on occassion and not had a problem with it.
 
By command it, i mean use commands within the script to make the platoon(s) do a particular action. In this case, there are 2 platoons and i ask one to attack another. The script is like this:

Code:
MyPlatoon = create platoon PLATOON_INFO_MARAUDER at {1455,1163} with 500 men and 0 women
EnemyPlatoon = create platoon PLATOON_INFO_SKELETON_MELEE at {1455,1263} with 500 men and 0 women

wait 2 seconds
set army MyPlatoon formation to FORMATION_TYPE_RABBLE
set army EnemyPlatoon formation to FORMATION_TYPE_RABBLE
wait 3 seconds

add action PLATOON_AGENDA_ACTION_ATTACK_ANY_ENEMY_IN_AREA using {MyPlatoon} to EnemyPlatoon action queue
add action PLATOON_AGENDA_ACTION_ATTACK_ANY_ENEMY_IN_AREA using {EnemyPlatoon} to MyPlatoon action queue

wait 30 seconds
end script PlatoonBattle

I've also used other commands to try and get the platoons to attack eachother. Sometimes they just don't respond at all, and other times the game crashes completely. [br][br]Added: [time]1254598923[/time]Oh btw Kays the site won't let me submit an edited version of a previous file in the "Edit this file" page. It just waits a while, then returns me to the main download page, and nothing changes. My file is 15MB, and it has exactly the same name as the previous file, so in theory it should work. I am able to change a file's name, just not the actual file itself. Any help?
PS, i didn't want to start an entirely new thread for this :)
 
Maybe it has something to do with them attacking each other.

A while ago I wrote a script for someone where platoons of increasing size were created and sent to attack his town. I just can't seem to find it right now.

As for the upload problem, Please use the other method to get the file to me and I'll update it. I'll also take a look to see what the problem could be.
 
hey kays, you sent that script to me, i enjoyed it thoroughly, and ive still got it if you need it.
 
Send it my way anglo please, its gonna help my map greatly :)
I won't use the script directly, just look at the platoon creation code. Just post it on this thread if you please  :woot
 
Just looking at that code again. Have you tried assigning a different town to each platoon. I don't think that neutral platoons can attack each other.
 
Hmm, i haven't. How would i assign a platoon to a town? That would give me all the answers i need. I don't want to script that town to actually recruit that platoon though, that would mess things up entirely.
 
Errm with this i can't actually see how the map is scripted, so i don't know how you used the platoons. Do you have the base script? (the text file)
 
whoops,  :sorry .  i hadnt thought about that. i dont have the text file but kays might.
 
Phew, finally found it. At least I think this is it.

Code:
			Melee[0] = create platoon PLATOON_INFO_AZTEC_MELEE_1 at {Spawn}+{0,-25} with Num men and 0 women
			Ranged[0] = create platoon PLATOON_INFO_AZTEC_RANGED_1 at {Spawn} with Num/2 men and 0 women

			set Melee[0] player 1
			set Ranged[0] player 1

This is the whole script.

Code:
begin script siegeStuff

	Siege[5]
	Pos = marker at {1162,1220}
	oWall =0
	Cnt = 0
	Rand = 0
	
start

	begin loop
		Rand = number from 1 to 6
		if Rand == 1		
			oWall = get wall segment nearest {1128,1170} radius 50
		elsif Rand == 2		
			oWall = get wall segment nearest {1194,1173} radius 50
		elsif Rand == 3		
			oWall = get wall segment nearest {1130,1123} radius 50
		elsif Rand == 4		
			oWall = get wall segment nearest {1200,1127} radius 50
		elsif Rand == 5		
			oWall = get wall segment nearest {1230,1176} radius 50
		elsif Rand == 6		
			oWall = get wall segment nearest {1093,1185} radius 50
		end if
	
		if Cnt >= 0 and Siege[0] not exists
			if Cnt > 8
				Siege[0] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_10 belonging to Town[1] at {1166,11,1650}	
			else
				Siege[0] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_2 belonging to Town[1] at {1166,11,1650}	
			end if
			add action SIEGEWEAPON_AGENDA_ACTION_MOVE_TO_POS using {Pos} to siege weapon Siege[0] action queue
			add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using oWall to siege weapon Siege[0] action queue
			enable siege weapon Siege[0] auto attack
			Cnt++
		end if

		if Cnt >= 2 and Siege[1] not exists
			if Cnt > 12
				Siege[1] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_10 belonging to Town[1] at {1190,11,1650}	
			else
				Siege[1] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_4 belonging to Town[1] at {1190,11,1650}	
			end if
			add action SIEGEWEAPON_AGENDA_ACTION_MOVE_TO_POS using {Pos}+{15,0} to siege weapon Siege[1] action queue
			add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using oWall to siege weapon Siege[1] action queue
			enable siege weapon Siege[1] auto attack
			Cnt++
		end if

		if Cnt >= 4 and Siege[2] not exists
			if Cnt > 16
				Siege[2] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_10 belonging to Town[1] at {1175,11,1650}	
			else
				Siege[2] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_6 belonging to Town[1] at {1175,11,1650}	
			end if
			add action SIEGEWEAPON_AGENDA_ACTION_MOVE_TO_POS using {Pos}+{-15,0} to siege weapon Siege[2] action queue
			add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using oWall to siege weapon Siege[2] action queue
			enable siege weapon Siege[2] auto attack
			Cnt++
		end if

/*		if Cnt >= 6 and Siege[3] not exists
			Siege[3] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_8 belonging to Town[1] at {1160,11,1650}	
			add action SIEGEWEAPON_AGENDA_ACTION_MOVE_TO_POS using {Pos}+{-10,0} to siege weapon Siege[5] action queue
			add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using oWall to siege weapon Siege[3] action queue
			enable siege weapon Siege[3] auto attack
			Cnt++
		end if

		if Cnt >= 8 and Siege[4] not exists
			Siege[4] = create siege weapon SIEGE_BALANCE_TYPE_CATAPULT_LEVEL_10 belonging to Town[1] at {1145,11,1650}	
			add action SIEGEWEAPON_AGENDA_ACTION_MOVE_TO_POS using {Pos}+{-20,0} to siege weapon Siege[4] action queue
			add action SIEGEWEAPON_AGENDA_ACTION_ATTACK_THING using oWall to siege weapon Siege[4] action queue
			enable siege weapon Siege[4] auto attack
			Cnt++
		end if*/

	end loop	
end script siegeStuff

begin script platoonStuff
	Melee[3]
	Ranged[3]
	Inc[3]
	Pos = marker at {1162,1220}
	Spawn = marker at {1166,11,1650}
	Num = 0
	Cnt = 0
start

	Inc[0] = 1
	Inc[1] = 1
	Inc[2] = 1

	begin loop
	
		if Melee[0] not exists or Ranged[0] not exists

			delete Melee[0]
			delete Ranged[0]

			Num = 20 + (Inc[0] * 5) 

			Melee[0] = create platoon PLATOON_INFO_AZTEC_MELEE_1 at {Spawn}+{0,-25} with Num men and 0 women
			Ranged[0] = create platoon PLATOON_INFO_AZTEC_RANGED_1 at {Spawn} with Num/2 men and 0 women

			set Melee[0] player 1
			set Ranged[0] player 1

			Cnt = 1
			force while Cnt < Inc[0]
				increment platoon Melee[0] experience
				increment platoon Ranged[0] experience
				Cnt++
			end while
			
			wait 1 second
			add action PLATOON_AGENDA_ACTION_LINK_TO_ARMY_MEMBER using Melee[0] to Ranged[0] action queue
			wait 1 second
			add action PLATOON_AGENDA_ACTION_MOVE_TO_POS_AGGRESSIVE using {Pos} to Melee[0] action queue
			add action PLATOON_AGENDA_ACTION_ATTACK_ANY_ENEMY_IN_AREA using {Pos} to Melee[0] action queue

			Inc[0]++
		end if
	
		if (Melee[1] not exists or Ranged[1] not exists) and Inc[0] > 2

			delete Melee[1]
			delete Ranged[1]

			Num = 20 + (Inc[1] * 5) 

			Melee[1] = create platoon PLATOON_INFO_AZTEC_MELEE_1 at {Spawn}+{30,-25} with Num men and 0 women
			Ranged[1] = create platoon PLATOON_INFO_AZTEC_RANGED_1 at {Spawn}+{30,0} with Num/2 men and 0 women

			set Melee[1] player 1
			set Ranged[1] player 1

			Cnt = 1
			force while Cnt < Inc[1]
				increment platoon Melee[1] experience
				increment platoon Ranged[1] experience
				Cnt++
			end while
			
			wait 1 second
			add action PLATOON_AGENDA_ACTION_LINK_TO_ARMY_MEMBER using Melee[1] to Ranged[1] action queue
			wait 1 second
			add action PLATOON_AGENDA_ACTION_MOVE_TO_POS_AGGRESSIVE using {Pos}+{30,0} to Melee[1] action queue
			add action PLATOON_AGENDA_ACTION_ATTACK_ANY_ENEMY_IN_AREA using {Pos}+{30,0} to Melee[1] action queue

			Inc[1]++
		end if
	
		if (Melee[2] not exists or Ranged[2] not exists) and (Inc[0] > 3 or Inc[1] > 2)

			delete Melee[2]
			delete Ranged[2]

			Num = 20 + (Inc[2] * 5) 

			Melee[2] = create platoon PLATOON_INFO_AZTEC_MELEE_1 at {Spawn}+{-30,-25} with Num men and 0 women
			Ranged[2] = create platoon PLATOON_INFO_AZTEC_RANGED_1 at {Spawn}+{-30,0} with Num/2 men and 0 women

			set Melee[2] player 1
			set Ranged[2] player 1

			Cnt = 1
			force while Cnt < Inc[2]
				increment platoon Melee[2] experience
				increment platoon Ranged[2] experience
				Cnt++
			end while
			
			wait 1 second
			add action PLATOON_AGENDA_ACTION_LINK_TO_ARMY_MEMBER using Melee[2] to Ranged[2] action queue
			wait 1 second
			add action PLATOON_AGENDA_ACTION_MOVE_TO_POS_AGGRESSIVE using {Pos}+{-30,0} to Melee[2] action queue
			add action PLATOON_AGENDA_ACTION_ATTACK_VILLAGER_AND_THOSE_IN_AREA using {Pos}+{-30,0} to Melee[2] action queue

			Inc[2]++
		end if
	
	end loop

end script platoonStuff
 
Ah thanks alot Kays, this should help a ton. It was the "set Melee[0] player 1" that i was after :)
 
Back
Top