/* * cspread.empfe simple ARexx macro to spread civilians. If a sectors has * many civilians, civilians will be moved to a nearby sector. * * This file is placed in the Public Domain, do what you want with it * and use it at your own risk!!! * Written by Håkan Thörngren 1989 */ /* Modified by David Wright 7/10/90 to work with the new 2.0 version of EmpFE */ me = get_country('my') rowmax = max_row() colmax = max_column() n = get_country('sector',me) r = 0 c = 0 string = out_fix_coordinate(0,0) parse var string rowoffset','coloffset do i=0 to n if btu_left() < 10 then return(0) string = my_next_sector(r,c) parse var string r','c type = get_sector('type',r,c) if type~='u' & type~='-' & type~='f' & type~='^' then if ~get_sector_flag('dirty',r,c) then /* Be wary of changing this number. Increasing it too much can cause you to run out of BTUs due to excessive moves */ if get_sector('civilian',r,c)<45 then do /* We can move at least 32 civilians to this sector. */ string = out_fix_coordinate(r,c) parse var string r2','c2 move_in(r2,c2) end end return 0 move_in: procedure expose me rowmax colmax coloffset rowoffset arg row,col string = out_fix_coordinate(row-1,col-1) parse var string r1','c1 string = out_fix_coordinate(row+1,col+1) parse var string r2','c2 if ok_sector(r1,c1) then move_civ(r1,c1,"\r",row,col) else if ok_sector(r1,col) then move_civ(r1,col,"d",row,col) else if ok_sector(r1,c2) then move_civ(r1,c2,"/l",row,col) else if ok_sector(row,c1) then move_civ(row,c1,"r",row,col) else if ok_sector(row,c2) then move_civ(row,c2,"l",row,col) else if ok_sector(r2,c1) then move_civ(r2,c1,"/r",row,col) else if ok_sector(r2,col) then move_civ(r2,col,"u",row,col) else if ok_sector(r2,c2) then move_civ(r2,c2,"\l",row,col) return 1 /* ok_sector - return 1 if the given sector can spare the civilians. */ ok_sector: procedure expose me arg row,col type = get_sector('type',row,col) if get_sector('owner',row,col)=me then if get_sector('civilian',row,col)>64 then if get_sector('mobility',row,col)>50 then if type~='.' then if type~='u' then if get_sector_flag('dirty',row,col)=0 then do call put_sector_flag('dirty',row,col,1) return 1 end return 0 move_civ: procedure expose coloffset rowoffset rowmax colmax parse arg row_f,col_f,dir,row_t,col_t if btu_left()<10 then say "Too few BTU's left - command not sent!" else do string = 'move c 'row_f','col_f' 32 'dir'e' say 'Queued 'string call do_command(string,-1) call put_sector_flag('dirty',row_f,col_f,1) call put_sector_flag('dirty',row_t,col_t,1) end return 1