mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 15:36:06 +00:00
file update
This commit is contained in:
parent
6f58a6a8a9
commit
a348e55646
@ -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
|
Loading…
x
Reference in New Issue
Block a user