mail[Wesnoth-commits] r33797 - /trunk/data/ai/formula/patrol.fai


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dragonking on March 18, 2009 - 03:41:
Author: dragonking
Date: Wed Mar 18 03:41:15 2009
New Revision: 33797

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33797&view=rev
Log:
file update

Modified:
    trunk/data/ai/formula/patrol.fai

Modified: trunk/data/ai/formula/patrol.fai
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/formula/patrol.fai?rev=33797&r1=33796&r2=33797&view=diff
==============================================================================
--- trunk/data/ai/formula/patrol.fai (original)
+++ trunk/data/ai/formula/patrol.fai Wed Mar 18 03:41:15 2009
@@ -1,40 +1,73 @@
 fai 'patrol.fai'
 
-def patrol_move(me)
+def closest_unit(ai*, me)
+       choose(
+               enemy_units, 'unit',
+               -distance_between(me.loc, unit.loc)
+       );
+
+def step_move(me)
+       if( unit_at( desired_path[0] ),
+               if( desired_path.size > 1,
+                       move_partial(
+                               me.loc,
+                               desired_path[1]
+                       ),
+                       end
+               ),
+               move_partial(
+                       me.loc,
+                       desired_path[0]
+               )
+       )
+
+where desired_path = shortest_path( me.loc, me.vars.next_step );       
+
+def move_ahead(ai*, me)
+       if( enemy_units,
+               if( distance_between( closest_unit(ai, me).loc, me.loc ) > 
me.movement_left-1,
+                       move_partial(
+                               me.loc,
+                               me.vars.next_step
+                       ),
+
+                       step_move(me)
+
+               ),
+               move_partial(
+                       me.loc,
+                       me.vars.next_step
+               )
+       );
+
+def patrol_move(ai*, me)
     if( me.vars.next_step = me.loc,
         set_unit_var('next_step',
             me.vars.waypoints[ me.vars.next_step ],
             me.loc
         ),
-        move_partial(
-            me.loc,
-            shortest_path( me.loc, me.vars.next_step )[0]
-        )
+       
+       move_ahead(ai,me)
     );
 
 if( me.movement_left = 0,
     end,
     if(attack,
         attack,
-        patrol_move(me)
+        patrol_move(self, me)
     )
 )
 
 where attack = if( path_to, 
                        if(path_to.size <= me.vars.guard_radius, 
-                               attack( me.loc, path_to.last, 
closest_unit.loc ), 
+                               attack( me.loc, path_to.last, 
closest_unit(self, me).loc ), 
                                0 
                        ),
                        0
                )
                
-where path_to = if( closest_unit, 
-                       shortest_path( me.loc, closest_unit.loc ),
+where path_to = if( enemy_units, 
+                       shortest_path( me.loc, closest_unit(self, me).loc ),
                        []
                )
-
-where closest_unit = choose(
-                       enemy_units, 'unit',
-                       -distance_between(me.vars.next_step, unit.loc)
-               )
 faiend




Related Messages


Powered by MHonArc, Updated Wed Mar 18 05:00:18 2009