#define scr_npg_init //scr_npg_init(stop,gr,anim) //initialize the npc grid movement script. Suggested to be placed in create //stop is the chance of stopping as a movement action. 1 / stop. //gr is how large each grid square is. Default (enter 0) is 16. //anim determines how the sprite will respond to the movement //0 means no responce //1 means change sprite for direction and animate while walking //2 means change sprite for direction only //Note, keep same sprite names, and have number on the end. //0 for right, 1 for up, 2 for left, 3 for down //3 means animate only //4 means use subimages as direction sprites //subimage 0 is right, 1 is up, etc. //note, default replaces a 0 argument with the default value. //vvv change this variable vvv// sp = 2 //the speed at which to move //^^^ change this variable ^^^// stop = argument0 grid = argument1 switch argument2 { case 0: change = 0; anim = 0; sub = 0; break case 1: change = 1; anim = 1; sub = 0; break case 2: change = 1; anim = 0; sub = 0; break case 3: change = 0; anim = 0; sub = 0; break case 4: change = 0; anim = 0; sub = 1; break } if grid = 0 { grid = 16 } alarm = grid / sp if change { mysprite = sprite_get_name(sprite_index) mysprite = string_copy(mysprite,0,string_length(mysprite)-1) } moving = true dir = floor(random(4)) while !place_free(lengthdir_x(grid,dir*90),lengthdir_y(grid,dir*90)) { dir = floor(random(4)) } direction = dir * 90 if floor(random(stop)) = 0 && stop != 0 { speed = 0 } else { speed = sp } if change { execute_string("sprite_index = " +mysprite +string(dir)) } if anim { if speed = 0 { image_single = 0 } else { image_single = -1 } } if sub { image_single = dir } #define scr_npg_alarm //spr_npg_alarm() //place in the alarm 0 event //no arguments speed = 0 moving = !moving alarm = grid / sp if moving { dir = floor(random(4)) while !place_free(lengthdir_x(grid,dir*90),lengthdir_y(grid,dir*90)) { dir = floor(random(4)) } direction = dir * 90 if floor(random(stop)) = 0 && stop != 0 { speed = 0 } else { speed = sp } } if change { execute_string("sprite_index = " +mysprite +string(dir)) } if anim { if speed = 0 { image_single = 0 } else { image_single = -1 } } if sub { image_single = dir }