// beamgolem.txt // By Lazarus // Shoots beams that do 25d5 damage of random damage type, and one random status effect. // Random target // Memory Cells: // Cell 0 - How creature moves. // 0 - If 0, wander randomly. // 1 - Stands still until a target appears. // 2 - Completely immobile, even if target appears. // Cell 1 - How much to increase flag by. // Cell 2 - If add half an exp, then set this to 5. // Cell 3 - Dialogue node to start with if talked to. if left at 0, this // character doesn't talk. begincreaturescript; variables; short i,status,type, next; short targ, best; body; beginstate INIT_STATE; //if(get_flag(10,9) > 1){ // if(get_species(ME) == 11) // kill_char(ME,2,0); //} if (get_memory_cell(0) == 2) set_mobility(ME,0); break; beginstate DEAD_STATE; if(char_ok(4) == 1){ if(get_memory_cell(2) == 5) inc_flag(250,5,(get_ran(1,get_memory_cell(1),get_memory_cell(1) + 1))); if(Get_memory_cell(20 != 5) inc_flag(250,5,get_memory_cell(1)); } break; beginstate START_STATE; // if I have a target for some reason, go attack it if (target_ok()) { if (dist_to_char(get_target()) <= 16) set_state(3); else set_target(ME,-1); } // Look for a target, attack it if visible next = 3; set_state_continue(4); // Have I been hit? Strike back! if (who_hit_me() >= 0) { set_target(ME,who_hit_me()); set_state_continue(3); } // if we're in combat and the above didn't give me anything to do, just // stop now. Otherwise, game will keep running script, and that eats up CPU time. if (am_i_doing_action() == FALSE) end_combat_turn(); break; beginstate 3; // attacking if ((target_ok() == FALSE) || (can_see_char(get_target()) == 0)) set_state(START_STATE); if(get_ran(1,1,3) == 1){ //Mix things up and choose a new target next = 3; set_state_continue(4); } type = get_ran(1,1,6); while(type == 4){ type = get_ran(1,1,6); } status = get_ran(1,101,110); if(status == 101) status = 0; if(status == 102) status = 6; if(status == 103) status = 7; if(status == 104) status = 8; if(status == 105) status = 10; if(status == 106) status = 11; if(status == 107) status = 12; if(status == 108) status = 18; if(status == 109) status = 20; if(status == 110) status = 21; if(can_see_char(get_target())){ put_jagged_zap(my_loc_x(),my_loc_y(),char_loc_x(get_target()),char_loc_y(get_target()),1); put_boom_on_char(get_target(),6,0); run_animation(); damage_char(get_target(),get_ran(20,1,5),type); set_char_status(get_target(),status,6,0,1); deduct_ap(3); } break; beginstate 4; //Targetting state targ = -1; best = 30000; i = 0; while(i < 120){ if((char_ok(i) == 1) &&(char_attitude_to_char(ME,i) == 2) && (dist_to_char(i) < 12) && can_see_char(i) && (get_char_status(i,29) == 0)){ status = get_health(i); if(i < 6) //a party member status = status/2; status = status + get_ran(1,0,40); if((status + dist_to_char(i)) < best){ targ = i; best = (status + dist_to_char(i)); } } i = i + 1; } set_target(ME,targ); if(targ == -1) set_state(START_STATE); set_state_continue(next); break; beginstate TALKING_STATE; if (get_memory_cell(3) == 0) { print_str("Talking: It doesn't respond."); end(); } begin_talk_mode(get_memory_cell(3)); break;