// ambush.txt // This creature will never move, and on aquiring a target, // waits a fixed number of turns before atacking. // Memory Cells: // Cell 0 - How many turns to wait before attacking // Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this // is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when // creature is killed, sets SDF(3,5) to 1.) // Cell 3 - Dialogue node to start with if talked to. if left at 0, this // character doesn't talk. // Cell 4 - whether to not cast summoning spells // Cell 5 - if left at 0, the creature is immobile, otherwise the creature can move. begincreaturescript; variables; short i,target; body; beginstate INIT_STATE; if (get_memory_cell(5) == 0) set_mobility(ME,0); if(get_memory_cell(0) == 0) set_memory_cell(0,3); if(get_memory_cell(4) == 1){ change_spell_level(ME,0,2,-1 * get_spell_level(ME,0,2)); change_spell_level(ME,0,8,-1 * get_spell_level(ME,0,8)); change_spell_level(ME,0,14,-1 * get_spell_level(ME,0,14)); change_spell_level(ME,0,17,-1 * get_spell_level(ME,0,17)); change_spell_level(ME,1,6,-1 * get_spell_level(ME,1,6)); change_spell_level(ME,1,19,-1 * get_spell_level(ME,1,19)); } break; beginstate DEAD_STATE; // Set the appropriate stuff done flag for this character being dead if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0)) set_flag(get_memory_cell(1),get_memory_cell(2),1); break; beginstate START_STATE; // Look for a target, attack it if visible if (select_target(ME,8,0)) { target = get_target(); i = get_memory_cell(0); set_state(4); } // Have I been hit? Strike back! if (who_hit_me() >= 0) { set_target(ME,who_hit_me()); do_attack_tactic(2); set_state(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) set_state(START_STATE); do_attack_tactic(2); 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; beginstate 4; //countdown to attack if (who_hit_me() >= 0) { set_target(ME,who_hit_me()); set_state_continue(3); } if(target_ok() && target == get_target()){ i = i - 1; if(i == 0) set_state_continue(3); end_combat_turn(); } else set_state(START_STATE); break;