Changeset 2307
- Timestamp:
- 06/10/12 19:13:42 (12 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Enemy-Territory/0.8/et/scripts/goals/goal_checkdisguise.gm
r1072 r2307 1 // This script contains functionality to ignore disguised enemies if they aren t close enough1 // This script contains functionality to ignore disguised enemies if they aren't close enough 2 2 3 3 // These parameters are required … … 19 19 gt = Util.GoalTable("PLANT_.*\nCHECKPOINT_.*\nFLAG_.*"); 20 20 21 foreach ( id andgoal in gt ) {21 foreach ( goal in gt ) { 22 22 i = tableCount( Map.PrimaryGoalPositions ); 23 p = goal.GetPosition();24 23 Map.PrimaryGoalPositions[i] = goal.GetPosition(); 25 24 if ( this.Debug ) { … … 32 31 this.GetPriority = function() 33 32 { 34 nearObj = false;35 33 t = this.Bot.GetTarget(); 34 35 // if they are close to a primary goal, just have the bots shoot them 36 foreach ( position in Map.PrimaryGoalPositions ) 37 { 38 if ( DistanceBetween(t, position) < 250 ) { 39 if (this.Debug) { 40 this.Bot.Say("I'm shooting a disguised target that is near primary objective, dist = " + this.Bot.DistanceTo(t)); 41 } 42 //wait until this thread is killed because target lost disguise after shooting 43 block(0); 44 } 45 } 46 47 // map scripts can also define specific areas to always detect them 48 // key = position, value = radius 49 if ( Map.CovertDetectionSpots ) { 50 foreach ( location in Map.CovertDetectionSpots ) { 51 if ( DistanceBetween(t, location[0]) <= location[1] ) { 52 if (this.Debug) { 53 this.Bot.Say("I'm shooting a disguised target that is near CovertDetectionSpots, dist = " + this.Bot.DistanceTo(t)); 54 } 55 //wait until this thread is killed because target lost disguise after shooting 56 block(0); 57 } 58 } 59 } 36 60 37 61 while(1) 38 62 { 39 // if they are close to a primary goal, just have the bots shoot them40 foreach ( id and position in Map.PrimaryGoalPositions )41 {42 if ( DistanceBetween(t, position) < 250 ) {43 nearObj = true;44 break;45 }46 }47 48 // map scripts can also define specific areas to always detect them49 // key = position, value = radius50 if ( Map && Map.CovertDetectionSpots ) {51 foreach ( location in Map.CovertDetectionSpots ) {52 if ( DistanceBetween(t, location[0]) <= location[1] ) {53 nearObj = true;54 break;55 }56 }57 }58 59 63 // increase odds of shooting with decreased distance to target 60 if (this.Debug) { shootingDisguised = true; }61 64 dist = this.Bot.DistanceTo(t); 62 65 … … 64 67 // f.e. if target is 300 units away and difficulty is 4 and there are 8 total players there is a 22% chance to shoot 65 68 // while 20 total players would equal a 10% chance ... 66 if ( !nearObj && ((dist > 1500) || (RandInt(0, ToInt(dist) > (50 + (10 * this.Bot.aimskill) - (3 * Server.NumPlayersNoSpec))))) ) { 67 if (this.Debug) { shootingDisguised = false; } 69 if ( (dist > 1500) || RandInt(0, ToInt(dist)) > 50 + (10 * this.Bot.aimskill) - (3 * Server.NumPlayersNoSpec) ) { 70 if (this.Debug) { 71 this.Bot.Say("I'm ignoring a disguised target, dist = " + dist); 72 } 68 73 this.Bot.IgnoreTarget( t, 10 - this.Bot.MemorySpan ); 74 // wait until this thread is killed because this bot has no target, 75 // (GetPriority will be called again after IgnoreTarget timeout) 76 block(0); 69 77 } 70 78 71 if ( this.Debug ) { 72 if(shootingDisguised) { 73 this.Bot.Say("I'm shooting a disguised target: nearObj = " + nearObj + " dist = " + this.Bot.DistanceTo(t)); 74 } 75 else { 76 this.Bot.Say("I'm ignoring a disguised target: nearObj = " + nearObj + " dist = " + this.Bot.DistanceTo(t)); 77 } 79 if (this.Debug) { 80 this.Bot.Say("I'm shooting a disguised target, dist = " + dist); 78 81 } 79 82 80 yield();83 sleep(0.5); 81 84 } 82 85 };