Javito1986 0 Posted April 7, 2004 Let's say I have 4 Squads of Russian soldiers, and 6 armored vehicles. Be they BMP's or tanks or what have you. And they go on the attack. Is it possible for them to retreat after sustaining 75% or 80% casualties? If so, how? Share this post Link to post Share on other sites
Drinker 0 Posted April 7, 2004 Try something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _allgrp=[group1,group2,group3,group4] _initnumb=0 "_initnumb=_initnumb+(count units _x)" forEach _allgrp #begin ~1 _newnumb=0 "_newnumb=_newnumb+(count units _x)" forEach _allgrp ?(_newnumb/_initnumb>0.25):goto "begin" "_x move _retreatposition" forEach _allgrp exit Share this post Link to post Share on other sites
NeMeSiS 11 Posted April 10, 2004 and how do i use this? Share this post Link to post Share on other sites
void_false 1 Posted April 10, 2004 hm... i think using allowflleeing is much easier. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this allowfleeing 0 will result in no fleeing at all. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this allowfleeing 0.5 will result in fleeing after 50% died. so <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this allowfleeing 0.25 will result in fleeing after 75% died Share this post Link to post Share on other sites
T J 0 Posted April 10, 2004 Im not certain that formula is correct Void_false, but you are right, allowfleeing is the best to use in this case. Javito, you might try this. Make a trigger over the playing area, set to EAST PRESENT. Give it a name, say EASTCOUNT, and make it repeating. Now you have a fairly reliable way of counting the number of units that are left on the east side. So now you could do a few things. You could make them retreat when the armour is all dead for instance, using this line in another trigger's condition line; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">! BMP1 in (list EASTCOUNT) && ! BMP2 in (list EASTCOUNT) and so on Or as you originally said, when they are down to 25% strength, use this line in the condition line of another trigger (size set to 0,0 btw); <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">count (list EASTCOUNT) <20 However you do it, to make the russians run away, you have to decide if you want them to go back the way they came, or just scatter. To get them to scatter in their groups, you would put this line in the ON ACTIVATION field for one of the above mentioned triggers. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x allowfleeing 1" foreach (list EASTCOUNT) That should make them run away as desired. To get them to retreat the way them came, you would need to place an object to get them to go to, say a Game Logic called RETREAT, place this where you want them to run to. Then, in the ON ACTIVATION field, use the following line; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x domove (getpos RETREAT)" foreach (list EASTCOUNT) There, that should give you some ideas. TJ EDIT: forgot to mention, the likelihood to flee is tied in with Rank. A colonel for instance has 0.9 courage by default, and it goes down 0.1 with each drop in rank. Share this post Link to post Share on other sites
void_false 1 Posted April 10, 2004 T J, everything you said everything you said running throught my head running throught my head (damn song ) it is all correct BUT: AI does these things automatically! When they retreat, then they come back after some period of time. There's no need to make some gamelogics. Looks like you didnt play enough SP so you didnt study AI's behaviour well Share this post Link to post Share on other sites
ZiRo 0 Posted April 12, 2004 Perfect Place for me to post this: I started this script a while back, if anyone wants to finish it off they can. It basically makes a squad surrender when their "confidence" is at 0, their confidence is set at the start of a mission, then decreases/increases as the following happen: How many Alive Friendlies within 100 there are. How many Alive Enemies within 100 there are. How many Dead Friendlies within 100 there are. How many Dead Enemies within 100 there are. How many Group members are dead. Wether the leader is dead. The Confidence "punishment" of all these variables can be set in the script, it could easily be moved to the scripts execution array but i didnt do it for simplicitys sakes. All that needs fixing really is getting the amount of dead friends there are within 100 of the group, and how many dead enemies there are within 100 of the group. Also what happens when they surrender needs doing (leave that up to you, animations, join a special captive group that has a goto waypoint, etc. Could also be adapted to have a % chance of retreat instead of surrender? a good scripter should be able to work out how it all fits together by reading it: NOTE:It still has a couple hint's left in for debugging. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Surrender script by ZiRo and MI Fred (zpcstrike@hotmail.com) ; Made for USMC Co-op campaign ; ; ; [group,confidence] exec "surrenderscript.sqs" ; #modifiers _groupdeadmodifier = 10 _leaderdeadmodifier = 15 _friendsclosemodifier = 10 _enemyclosemodifier = 15 _friendsclosedeadmodifier = 5 _enemyclosedeadmodifier = 10 #start _group = _this select 0 _confidence = _this select 1 _groupstart = ({alive _x} count (units _group)) _startleader = (leader _group) _newconfidence = _confidence _leaderdone = 0 ?(side _startleader == WEST) : _sidetrigger = westlist; _enemysidetrigger = eastlist ?(side _startleader == EAST) : _sidetrigger = eastlist; _enemysidetrigger = westlist ?(side _startleader == RESISTANCE) : _sidetrigger = reslist; _enemysidetrigger = westlist ?(side _startleader == CIVILIAN) : _sidetrigger = civlist; _enemysidetrigger = westlist _array = list _sidetrigger _enemyarray = list _enemysidetrigger ;_groupdeadsaved = _groupdead _enemyclosedeadsaved = 0 _friendsclosedeadsaved = 0 _friendsclosesaved = 0 _enemyclosesaved = 0 #loop _leadergroup = (leader _group) ?({alive _x} count (units _group) == 0) : goto "exit" ?!(alive _startleader) && _leaderdone == 0 : _newconfidence = _newconfidence - _leaderdeadmodifier; _leaderdone = 1 ;_i = 0; while "_i < (count _array)" do {if ((! alive (_array select _i)) && ((_array select _i) distance _leadergroup < 100)) then {_friendsclosedead = _friendsclosedead + 1;} _i = _i + 1;}; ;_i = 0; while "_i < (count _enemyarray)" do {if ((! alive (_enemyarray select _i)) && ((_enemyarray select _i) distance _leadergroup < 100)) then {_enemyclosedead = _enemyclosedead + 1;} _i = _i + 1;}; ;_i = 0; while "_i < (count _enemyarray)" do {if ((! alive (_enemyarray select _i)) && ((_enemyarray select _i) distance _leadergroup < 100)) then {_enemyclosedead = _enemyclosedead + 1; _deadetemp = _deadetemp + [(_enemyarray select _i)];}; _i = _i + 1;}; ?_friendsclosedead == _friendsclosedeadsaved :goto "skipfriendsclosedead" ?_friendsclosedead > _friendsclosedeadsaved : _newconfidence = _newconfidence - ((_friendsclosedead - _friendsclosedeadsaved)*_friendsclosedeadmodifier) ?_friendsclosedead < _friendsclosedeadsaved : _newconfidence = _newconfidence + ((_friendsclosedeadsaved - _friendsclosedead)*_friendsclosedeadmodifier) _friendsclosedeadsaved = _friendsclosedead #skipfriendsclosedead ;_enemyclosedead = {_x distance _leadergroup < 100&&!(alive _x)} count (list _enemyarray) ?_enemyclosedead == _enemyclosedeadsaved :goto "skipenemyclosedead" ?_enemyclosedead > _enemyclosedeadsaved : _newconfidence = _newconfidence + ((_enemyclosedead - _enemyclosedeadsaved)*_enemyclosedeadmodifier) ?_enemyclosedead < _enemyclosedeadsaved : _newconfidence = _newconfidence - ((_enemyclosedeadsaved - _enemyclosedead)*_enemyclosedeadmodifier) ;_enemyclosedeadsaved = _enemyclosedead #skipenemyclosedead _groupdead = ({alive _x} count (units _group)) ?_groupdead == _groupdeadsaved :goto "skipgroupdead" ?_groupdead > _groupdeadsaved : _newconfidence = _newconfidence + ((_groupdead - _groupdeadsaved)*_groupdeadmodifier) ?_groupdead < _groupdeadsaved : _newconfidence = _newconfidence - ((_groupdeadsaved - _groupdead)*_groupdeadmodifier) _groupdeadsaved = _groupdead #skipgroupdead _friendsclose = ({_x distance _leadergroup < 100} count (list _sidetrigger)) ?_friendsclose == _friendsclosesaved :goto "skipfriendsclose" ?_friendsclose > _friendsclosesaved : _newconfidence = _newconfidence + ((_friendsclose - _friendsclosesaved)*_friendsclosemodifier) ?_friendsclose < _friendsclosesaved : _newconfidence = _newconfidence - ((_friendsclosesaved - _friendsclose)*_friendsclosemodifier) _friendsclosesaved = _friendsclose #skipfriendsclose _enemyclose = ({_x distance _leadergroup < 100} count (list _enemysidetrigger)) ?_enemyclose == _enemyclosesaved :goto "skipenemyclose" ?_enemyclose > _enemyclosesaved : _newconfidence = _newconfidence - ((_enemyclose - _enemyclosesaved)*_enemyclosemodifier) ?_enemyclose < _enemyclosesaved : _newconfidence = _newconfidence + (abs(_enemyclosesaved - _enemyclose)*_enemyclosemodifier) ~0.1 _enemyclosesaved = _enemyclose #skipenemyclose ?_newconfidence <= 0 : goto "surrender" ~1 ;hint format ["%1\n%2",_deadftemp,_deadetemp] hint format["%1 Confidence, %2 newconfidence", _newconfidence, _enemyclosedead] goto "loop" #surrender hint format["%1 Surrenders", _group] #exit exit -ZiRo If anyone shows interest in this i might finish it myself. Share this post Link to post Share on other sites
T J 0 Posted April 12, 2004 it is all correct BUT: AI does these things automatically! When they retreat, then they come back after some period of time. There's no need to make some gamelogics. Looks like you didnt play enough SP so you didnt study AI's behaviour well  That depends if you want to know where they run off to though? I like to know exactly where they are gonna go. Enough SP? Isnt 3 campaigns enough? MP is where its at baby!!! TJ Share this post Link to post Share on other sites
bmgarcangel 0 Posted April 13, 2004 so this would work. Yu just have to activate it right? Share this post Link to post Share on other sites
ruff 102 Posted April 19, 2004 Im not certain that formula is correct Void_false, but you are right, allowfleeing is the best to use in this case.Javito, you might try this. Make a trigger over the playing area, set to EAST PRESENT. Give it a name, say EASTCOUNT, and make it repeating. Now you have a fairly reliable way of counting the number of units that are left on the east side. So now you could do a few things. You could make them retreat when the armour is all dead for instance, using this line in another trigger's condition line; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">! BMP1 in (list EASTCOUNT) && ! BMP2 in (list EASTCOUNT) and so on Or as you originally said, when they are down to 25% strength, use this line in the condition line of another trigger (size set to 0,0 btw); <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">count (list EASTCOUNT) <20 However you do it, to make the russians run away, you have to decide if you want them to go back the way they came, or just scatter. To get them to scatter in their groups, you would put this line in the ON ACTIVATION field for one of the above mentioned triggers. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x allowfleeing 1" foreach (list EASTCOUNT) That should make them run away as desired. To get them to retreat the way them came, you would need to place an object to get them to go to, say a Game Logic called RETREAT, place this where you want them to run to. Then, in the ON ACTIVATION field, use the following line; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x domove (getpos RETREAT)" foreach (list EASTCOUNT) There, that should give you some ideas. TJ EDIT: forgot to mention, the likelihood to flee is tied in with Rank. A colonel for instance has 0.9 courage by default, and it goes down 0.1 with each drop in rank. does the ai need waypoints? what if i set ai squad on guard waypoint will they still flee if more than 75% dies Share this post Link to post Share on other sites
noundo 0 Posted April 19, 2004 ...That depends if you want to know where they run off to though? I like to know exactly where they are gonna go.... They retreat back to their previous WP, or a previous WP out of sight of enemy. Share this post Link to post Share on other sites
deathsai 0 Posted April 20, 2004 Is there any way to use allow fleeing to have the enemy retreat to something else, such as a Game Logic? Or just some way so that they haven't had to have been at the WP they retreat to. Share this post Link to post Share on other sites