---------------------------------------------------------------------- -- Settings -- ---------------------------------------------------------------------- -- Attack speed dmg_length = 1.0 rush_dmg_length = 2.0 -- Close range. When should Che use her close range attack close_range = 200 grenade_range = 400 fire_dmg_range = 150 -- Was 100 fire_anim_time = 2.0 -- Close slash time close_slash_time = 1.2 -- 0.8 close_attack_time = 0.8 close_sound_delay = 0.2 -- Double slash double_slash_time = 2.6 -- 1.8 fall_time = 2.0 sound_done = 0 -- the delay between two flames in seconds flame_delay = 1 fire_sleep_time = 0.4 fire_index = 1 fire_sleep = 0 occ_fire_delay = 0 next_occ_fire = 0 fire_state = 0 rush_x = 0 rush_z = 0 quick_strafe_range = 400 grenade_speed = 1.5 pre_throw_state = think_move -- FIRE VECTOR x_fire_vec = 70 -- 140 z_fire_vec = 70 -- 140 x_fire_pos = 0 z_fire_pos = 0 last_fire = 0 next_flame_delay = 0.1 counter = 0 flame_time = 12 final_start_fire_time = 12 start_fire_time = 2 fire_activate = 0 sleep_grenade = 0 fireFinished = 0 sleep_attack_until = 0 sector = 1 crouch_delay = 0.7 wheeled = 0 -- EVENTS distance_to_middle = 0 quick_time = 0.8 -- the delay between two thrown grenades grenade_throw_delay = 1.0 -- maximum and minimum event delay (in seconds) max_event_delay = 1 min_event_delay = 0 -- Sound counters general_sound_no = 0 inflicting_sound_no = 0 taking_sound_no = 0 angered_sound_no = 0 -- Time che moves... move_time = 1.5 paw_delay = 0.7 draw_delay = 0.7 putawaydelay = 0 -- counter nof_attacks = 0 -- AGGRO STUFF attack_aggro = 100 -- Time to recover after double_slash recover_time = 1 -- Anim speed of recover anim recover_speed = 1 -- run_speed run_speed = 1.4 -- 1.5 -- 2.0 -- Put away sword anim speed putaway_speed = 1.5 draw_speed = 1.5 -- Pause between rushes rush_pause_time = 1 long_recover_time = 2 put_down_time = 1.2 draw_time = 2.4 -- Probabiltyy for base attacks -- TYPE 1 walk_prob = 35 -- 25% quick_strafe_prob = 45 --25% grenade_strafe_prob = 60 -- 15% rush_prob = 90 -- the number of seconds che will run when -- doing a run-slash (or run-double slash) -- if che is closer than 150 centimeters -- from the player, she will slash no matter -- what time it is slash_run_time = 3 -- Slash time slash_time = 1.0 stand_speed = 1 stand_between_phases = 1.5 -- the number of seconds to strafe until -- che should change direction or stop strafe_time = 3.9 -- 4.5 -- Start health start_health = 450 -- strafe speed strafe_speed = 1 --1 double_attack_speed = 1 quick_strafe = 1.5 -- Stumble time stumble_time = 0.8 -- Time between animation of throw and the release of the knives throw_anim_length = .2 -- Amount of dmg needed two eneter attack state 1 (doublke slash etc.) trigger_dmg_normal = 90 -- Amount of dmg needed two eneter attack state 0 (normal behaviour) trigger_dmg_rush = 150 -- Time che backs up walk_back_time = 1.5 -- Walk speed walk_speed = 1 walk_back_speed = 0.75 -- Speed at wheel anim wheel_speed = 1.5 -- WHeel time wheel_time = 1.2 -- 2.8 wheel_to_middle_time = 1.0 wheel_to_middle_start = 0.2 -- ditance che wheels wheel_distance = 500 one_wheel = wheel_distance two_wheel = 2*wheel_distance strafe_distance = 600 -- Coordinates in room x_min_room = 4777 x_max_room = 6610 y_min_room = -2656 y_max_room = -2656 z_min_room = 4941 z_max_room = 6371 x_inner_max = 6524 x_inner_min = 4933 z_inner_max = 6249 z_inner_min = 5092 middle_x = 5506 middle_z = 5561 -- ----------------------------------- -- some properties of che -- ----------------------------------- SetRotationSpeed(350) SetHealth(start_health) SetTargetable(1) moving = 0 sleep_until = GetTime() strafe_until = GetTime() -- global variables last_health = GetHealth() last_grenade_thrown = 0 -- GetTime()*GetTime()*10000 last_grenade_wave = 0 last_rush = 0 player_distance = 1000 slash_combo = 0 invulnerable = 1 acc_dmg = 0 slash_rush_counter = 0 next_event_time = 0 next_event = 1 -- consider_move -- Attack state 0 = normal ::: 1 = second stage attack_state = 0 player_health = PlayerHealth() delayed_damage = { in_use = 0, time = 0, x = 0, y = 0, z = 0, radius = 0 } -- Fire damage y_fire = y_min_room x1_fire = 0 z1_fire = 0 x2_fire = 0 z2_fire = 0 x3_fire = 0 z3_fire = 0 x4_fire = 0 z4_fire = 0 x5_fire = 0 z5_fire = 0 fire_counter = 0 num_fire_dmgs = 5 do_dmg_until_1 = 0 do_dmg_until_2 = 0 do_dmg_until_3 = 0 do_dmg_until_4 = 0 do_dmg_until_5 = 0 fire_duration = 0.4 -- ----------------------------------- -- SOUND STUFFZ -- ----------------------------------- function ShuffleArray(soundarray,size) local a = {} for i = 1, size do a[i] = '' end for i = 1, size do random_number = mod(rand(),size)+1 while a[random_number] ~= '' do random_number = mod(rand(),size)+1 end a[random_number] = soundarray[i] end return a end che_stumble_sounds = { 'CHE_TAKING_DAMAGE_01', 'CHE_TAKING_DAMAGE_02', 'CHE_TAKING_DAMAGE_03', 'CHE_TAKING_DAMAGE_04', 'CHE_TAKING_DAMAGE_05', 'CHE_ANGERED_04' } stumble_sound_counter = 1 function play_stumble() if(stumble_sound_counter == 1) then che_stumble_sounds = ShuffleArray(che_stumble_sounds,6) end PlaySound(che_stumble_sounds[stumble_sound_counter]) stumble_sound_counter = stumble_sound_counter + 1 if(stumble_sound_counter > 6) then stumble_sound_counter = 1 end end che_starting_fire_sounds = { 'CHE_ANGERED_01', 'CHE_ANGERED_02', 'CHE_ANGERED_03', 'CHE_GENERAL_07' } start_fire_sound_counter = 1 function play_start_fire() if(start_fire_sound_counter == 1) then che_starting_fire_sounds = ShuffleArray(che_starting_fire_sounds,4) end PlaySound(che_starting_fire_sounds[start_fire_sound_counter]) start_fire_sound_counter = start_fire_sound_counter + 1 if(start_fire_sound_counter > 4) then start_fire_sound_counter = 1 end end che_inflicting_damage_sounds = { 'CHE_INFLICTING_DAMAGE_05', 'CHE_INFLICTING_DAMAGE_06', 'CHE_INFLICTING_DAMAGE_07', 'CHE_INFLICTING_DAMAGE_08' } inflicting_damage_sound_counter = 1 function play_inflicting_dmg() if(inflicting_damage_sound_counter == 1) then che_inflicting_damage_sounds = ShuffleArray(che_inflicting_damage_sounds,4) end PlaySound(che_inflicting_damage_sounds[inflicting_damage_sound_counter]) inflicting_damage_sound_counter = inflicting_damage_sound_counter + 1 if(inflicting_damage_sound_counter > 4) then inflicting_damage_sound_counter = 1 end end che_starting_rush_sounds = { 'CHE_GENERAL_05', 'CHE_GENERAL_06', 'CHE_GENERAL_08', 'CHE_LOSING_01', 'CHE_LOSING_02' } starting_rush_sound_counter = 1 function play_starting_rush() if(starting_rush_sound_counter == 1) then che_starting_rush_sounds = ShuffleArray(che_starting_rush_sounds,5) end PlaySound(che_starting_rush_sounds[starting_rush_sound_counter]) starting_rush_sound_counter = starting_rush_sound_counter + 1 if(starting_rush_sound_counter > 5) then starting_rush_sound_counter = 1 end end function callback0() ShowObject(0) end function callback1() ShowObject(1) end function callback2() think0 = wait_for_anims end function check_damage() -- damage = GetBossDamage() real_dmg = last_health - GetHealth() last_health = GetHealth() Print('\n dddddddd REAL DMG' .. real_dmg .. '\n') acc_dmg = acc_dmg + real_dmg if(GetHealth() > 0) then if(attack_state == 0 and acc_dmg > trigger_dmg_normal and think_state ~= think_fall) then activate_fall() acc_dmg = 0 end if(GetAggro() >= attack_aggro and think_state == think_walk_back) then activate_move() elseif(GetAggro() < attack_aggro and think_state == think_move) then activate_walk_back() elseif( GetAggro() >= attack_aggro and think_state == think_move) then SetAnimSpeed(0,walk_speed*((GetAggro() - attack_aggro)/attack_aggro)) elseif( GetAggro() < attack_aggro and think_state == think_walk_back) then SetAnimSpeed(0,walk_speed*((attack_aggro - GetAggro())/attack_aggro)) end if ( IsHit()== 1 and GetShootFromBehind() == 0) then x, y, z = GetHitPoint() ex, ey, ez = Position() PlayParticleSystem(0, x, y, z, x-ex, y-ey, z-ez, 0, 1, 0) elseif(invulnerable == 1) then return elseif (real_dmg > 0) then if(think_state ~= think_stumble and think_state ~= think_fall) then play_stumble() activate_stumble() end end end ----- react to death ----- if (GetHealth() <= 0) then PlayAnimNow(0, ANM_CHE_DIE, APT_BLEND_THEN_PLAY_ONCE) think0 = state_idle PlaySound('CHE_LOSING_03') sleep_until = GetTime() + 3 Print('health <= 0, goto idle\n') think_state = think_wait DisableBossHealth() end end function do_fire_damage(xf,zf) -- Print('do_fire_dmg\n') dx = xf - px dz = zf - pz fire_distance = sqrt(dx*dx + dz*dz) if (fire_distance < fire_dmg_range) then -- Print('Player was injured') GivePlayerDamage(DMG_FIXED_AMOUNT, 7) end end function set_fire_dmg(x_fd,z_fd) -- Print('Set_fire_dmg\n') new_fire_dmg = mod(fire_counter,num_fire_dmgs) + 1 if(new_fire_dmg == 1) then x1_fire = x_fd z1_fire = z_fd do_dmg_until_1 = GetTime() + fire_duration elseif(new_fire_dmg == 2) then x2_fire = x_fd z2_fire = z_fd z1_fire = z_fd do_dmg_until_2 = GetTime() + fire_duration elseif(new_fire_dmg == 3) then x3_fire = x_fd z3_fire = z_fd z1_fire = z_fd do_dmg_until_3 = GetTime() + fire_duration elseif(new_fire_dmg == 4) then x4_fire = x_fd z4_fire = z_fd z1_fire = z_fd do_dmg_until_4 = GetTime() + fire_duration else x5_fire = x_fd z5_fire = z_fd z1_fire = z_fd do_dmg_until_5 = GetTime() + fire_duration end end function check_fire_dmg() if(GetTime() < do_dmg_until_1) then do_fire_damage(x1_fire,z1_fire) end if(GetTime() < do_dmg_until_2) then do_fire_damage(x2_fire,z2_fire) end if(GetTime() < do_dmg_until_3) then do_fire_damage(x3_fire,z3_fire) end if(GetTime() < do_dmg_until_4) then do_fire_damage(x4_fire,z4_fire) end if(GetTime() < do_dmg_until_5) then do_fire_damage(x5_fire,z5_fire) end end function checkwalls() if(think_state ~= think_wheel or think_state ~= think_wheel_middle) then cx,cy,cz = Position() if(cx > x_max_room or cx < x_min_room) then AimAt(middle_x,middle_z) elseif(cz > z_max_room or cz < z_min_room) then AimAt(middle_x,middle_z) end end end function check_rear() cx,cy,cz = Position() if(cx > x_max_room or cx < x_min_room) then return 1 elseif(cz > z_max_room or cz < z_min_room) then return 1 else return 0 end end function check_dist_to_point(xx,zz,range) mx, my, mz = Position() temp_x = mx - xx temp_z = mz - zz point_dist = sqrt(temp_x*temp_x + temp_z*temp_z) if(point_dist < range) then return 1 else return 0 end end function check_distance(range) px, py, pz = PlayerPos() mx, my, mz = Position() x = mx - px z = mz - pz player_distance = sqrt(x*x + z*z) if(player_distance < range) then return 1 else return 0 end end function do_wait() PlayAnimNow(0, ANM_CHE_STAND, APT_PLAY) think0 = state_in_event think_state = think_wait mx, my, mz = Position() SetEnemyPosition(mx,my,mz) SetInvulnerable(1) invulnerable = 1 end function check_explosion() bClose,gx,gy,gz = ExplosiveCloseTo(180) if(bClose == 1 and think_state ~= think_throw_grenade and think_state ~= think_strafe and think_state ~= think_wheel and think_state ~= think_slash and think_state ~= think_double_slash and think_state ~= think_close_attack and think_state ~= think_run_double_slash and think_state ~= think_run_slash and think_state ~= think_fall) then if(check_move(wheel_distance) == 1) then activate_evade_right() elseif(check_move(-wheel_distance) == 1) then activate_evade_left() end end end function check_events() -- Print('check events\n') if(attack_state == 0) then --NORMAL_MODE if(moving == 1) then return else if (GetTime() > next_event_time) then if(next_event == 1) then consider_move() elseif(next_event == 2) then activate_quickstrafe() elseif(next_event == 3) then -- Throw grenades if(check_move(strafe_distance) == 1 and (check_distance(grenade_range)==0)) then activate_putdownsword() else consider_move() end elseif(next_event == 4) then activate_run_double_slash() else activate_fire() end randomize_event() end end elseif(attack_state == 1) then -- rush_mode if( nof_attacks < 2) then -- 2 first activate_run_slash() nof_attacks = nof_attacks + 1 else local randvar = mod(rand(),3) if(randvar == 0) then activate_run_double_slash() nof_attacks = 0 elseif (nof_attacks < 4) then activate_run_slash() nof_attacks = nof_attacks + 1 else -- final one activate_run_double_slash() nof_attacks = 0 end end else -- Attack_state == 2 FIRE MODE return end end function state_main() if(player_health > PlayerHealth()) then play_inflicting_dmg() player_health = PlayerHealth() end px, py, pz = PlayerPos() mx, my, mz = Position() x = mx - px z = mz - pz player_distance = sqrt(x*x + z*z) ----- react to being near the player ----- if ((check_distance(close_range)==1) and attack_state == 0 and (think_state ~= think_run_slash) and (think_state ~= think_slash) and (think_state ~= think_close_attack)) then close_attack() Print('Close attack due to closeness...\n') else check_events() end check_damage() check_explosion() check_fire_dmg() checkwalls() think_state() if(fire_activate == 1 and GetTime() < fireFinished) then think_start_fire() else fire_activate = 0 fire_on() end end function state_in_event() if(player_health > PlayerHealth()) then play_inflicting_dmg() player_health = PlayerHealth() end px, py, pz = PlayerPos() mx, my, mz = Position() x = mx - px z = mz - pz player_distance = sqrt(x*x + z*z) check_fire_dmg() check_damage() check_explosion() checkwalls() think_state() if(fire_activate == 1 and GetTime() < fireFinished) then -- Print('Running Activate wfire' .. fire_activate .. '\n') think_start_fire() else fire_activate = 0 end end function state_idle() if (GetTime() > sleep_until) then Print('Sending death message, goto dead\n') SendMsg(script_argument2) think0 = state_dead end Pause() end function state_dead() Pause() end ---------------------------------------------------------------------- -- Activation functions (changes ai state) -- ---------------------------------------------------------------------- function activate_putdownsword() SetInvulnerable(1) invulnerable = 1 sleep_until = GetTime() + put_down_time think_state = think_putaway think0 = state_in_event putawaydelay = GetTime() + paw_delay PlayAnimNow(0,ANM_CHE_PUTAWAY_SWORD, APT_BLEND_THEN_PLAY_ONCE,putaway_speed) PlayLoadedSound(7,0.4) end function activate_drawsword() SetInvulnerable(1) invulnerable = 1 -- AttachParticleSystem(5, 100, 10, -1, 70, 90, 0, 0, 1, 0) -- AttachParticleSystem(6, 100, 10, -1, 70, 90, 0, 0, 0, 0) sleep_until = GetTime() + draw_time think_state = think_draw think0 = state_in_event draw_delay = GetTime() + draw_delay HideWeapon(0,0) PlayAnimNow(0,ANM_CHE_PUTAWAY_SWORD,APT_PLAY_ONCE_BACKWARDS,draw_speed) PlayLoadedSound(2,0.2) end function activate_grenade_wave() SetInvulnerable(1) invulnerable = 1 Print('Activate_grenade_wave \n') tempo = mod(rand(),100) if(tempo > 49) then activate_strafe_right() else activate_strafe_left() end end function activate_strafe_right() SetInvulnerable(1) invulnerable = 1 Print('activate_strafe_right \n') PlayAnimNow(0, ANM_CHE_STRAFE_RIGHT, APT_BLEND_THEN_PLAY, strafe_speed) strafe_until = GetTime() + strafe_time think_state = think_strafe think0 = state_in_event end function activate_strafe_left() Print('activate_strafe_left \n') SetInvulnerable(1) invulnerable = 1 PlayAnimNow(0, ANM_CHE_STRAFE_RIGHT, APT_BLEND_THEN_PLAY_BACKWARDS, strafe_speed) strafe_until = GetTime() + strafe_time think_state = think_strafe think0 = state_in_event end function activate_recover(the_recover_time) sleep_until = GetTime() + the_recover_time think_state = think_recover think0 = state_in_event PlayAnimNow(0,ANM_CHE_RECOVER, APT_BLEND_THEN_PLAY_ONCE,recover_speed) end function activate_wheel_right() SetInvulnerable(1) invulnerable = 1 Print('activate_wheel_right \n') x,y,z = PlayerPos() xc,yc,zc = Position() sleep_until = GetTime() + wheel_time think_state = think_wheel think0 = state_in_event PlayAnimNow(0,ANM_CHE_CARTWHEEL_RIGHT, APT_BLEND_THEN_PLAY, wheel_speed) end function activate_wheel_left() SetInvulnerable(1) invulnerable = 1 Print('activate_wheel_left \n') x,y,z = PlayerPos() xc,yc,zc = Position() sleep_until = GetTime() + wheel_time think_state = think_wheel think0 = state_in_event PlayAnimNow(0,ANM_CHE_CARTWHEEL_LEFT, APT_BLEND_THEN_PLAY, wheel_speed) end function activate_evade_left() SetInvulnerable(1) invulnerable = 1 Print('activate_evade_left \n') x,y,z = PlayerPos() xc,yc,zc = Position() sleep_until = GetTime() + wheel_time - 0.3 think_state = think_wheel think0 = state_in_event PlayAnimNow(0,ANM_CHE_CARTWHEEL_LEFT, APT_PLAY_ONCE, wheel_speed) -- APT_BLEND_THEN_PLAY end function activate_evade_right() SetInvulnerable(1) invulnerable = 1 Print('activate_wheel_left \n') x,y,z = PlayerPos() xc,yc,zc = Position() sleep_until = GetTime() + wheel_time - 0.3 think_state = think_wheel think0 = state_in_event PlayAnimNow(0,ANM_CHE_CARTWHEEL_RIGHT, APT_PLAY_ONCE, wheel_speed) -- APT_BLEND_THEN_PLAY end function activate_stand(the_stand_time) SetInvulnerable(1) invulnerable = 1 play_starting_rush() PlayAnimNow(0, ANM_CHE_STAND, APT_BLEND_THEN_PLAY, stand_speed) sleep_until = GetTime() + the_stand_time think_state = think_stand think0 = state_in_event end function activate_stumble() Print('Activate_STUMBLE\n') SetInvulnerable(0) invulnerable = 0 think_state = think_stumble think0 = state_in_event sleep_until = GetTime() + stumble_time if(GetShootFromBehind() == 0) then PlayAnimNow(0, ANM_CHE_STUMBLE_BACK, APT_PLAY_ONCE) else PlayAnimNow(0, ANM_CHE_STUMBLE_FRONT, APT_PLAY_ONCE) end end function activate_movetomiddle() SetInvulnerable(1) invulnerable = 1 Print('activate_movetomiddle \n') think0 = state_in_event think_state = think_turn_middle end function activate_wheel_to_middle(arg,dir) SetInvulnerable(1) invulnerable = 1 if(arg == 1) then sleep_until = wheel_to_middle_start + wheel_to_middle_time + GetTime() Print('============ONE WHEEL PLZ ================\n') elseif(arg == 2) then sleep_until = wheel_to_middle_start + wheel_to_middle_time * 2 + GetTime() Print('============TWO WHEEL PLZ ================\n') else sleep_until = wheel_to_middle_start + 0.4 + wheel_to_middle_time * 3 + GetTime() Print('============THREE WHEEL PLZ ================\n') end if(dir == 0) then PlayAnimNow(0, ANM_CHE_CARTWHEEL_LEFT, APT_BLEND_THEN_PLAY,wheel_speed) else PlayAnimNow(0, ANM_CHE_CARTWHEEL_RIGHT, APT_BLEND_THEN_PLAY,wheel_speed) end think0 = state_in_event think_state = think_wheel_middle end function activate_rush() SetInvulnerable(1) invulnerable = 1 slash_rush_counter = slash_rush_counter + mod(rand(),4) + 1 if(slash_rush_counter > 4) then activate_run_double_slash() else activate_run_slash() end end function activate_fall() SetInvulnerable(1) invulnerable = 1 Print('<<< Activate FALL>>>>>>>>>>>>>\n') PlayAnimNow(0, ANM_CHE_FALL_BACK, APT_PLAY_ONCE) -- ska vara fall anim sleep_until = GetTime() + fall_time think_state = think_fall think0 = state_in_event end function think_fall() AimAt(px,pz) if(GetTime() > sleep_until) then sleep_until = GetTime() + 4 think_state = think_paus -- Say rush stuff play_starting_rush() end Pause() end function think_paus() AimAt(px,pz) if(GetTime() > sleep_until) then if(mod(rand(),5) > 2) then -- RUSH Print(' sssssssssssss RUSH MODE ACTIVATED ssssssssssssssssss\n') attack_state = 1 think0 = state_main think_state = think_advance else -- FIRE Print(' sssssssssssss FIRE MODE ACTIVATED ssssssssssssssssss\n') attack_state = 2 activate_putdownsword() end end Pause() end function activate_fire() SetInvulnerable(1) invulnerable = 1 Print('activate_fire \n') play_start_fire() PlayAnimNow(0, ANM_CHE_ACTIVATE_FIRE, APT_BLEND_THEN_PLAY_ONCE) PlayLoadedSound(1) sleep_until = GetTime() + fire_anim_time think_state = think_fire_anim think0 = state_in_event end function think_fire_anim() AimAt(px,pz) if(GetTime() > sleep_until) then sleep_until = GetTime() + start_fire_time cx,cy,cz = Position() x_fire_pos = cx + x_fire_vec z_fire_pos = cz + z_fire_vec think_state = think_activate_fire fireFinished = GetTime() + flame_time fire_activate = 1 end Pause() end function activate_final_fire() SetInvulnerable(1) invulnerable = 1 Print('activate_final_fire \n') play_start_fire() PlayAnimNow(0, ANM_CHE_CROUCH, APT_BLEND_THEN_PLAY_ONCE) sleep_until = GetTime() + final_start_fire_time cx,cy,cz = Position() x_fire_pos = cx + x_fire_vec z_fire_pos = cz + z_fire_vec think_state = think_activate_final_fire send_fire_delay = GetTime() + 3 PlayLoadedSound(1) fireFinished = GetTime() + flame_time think0 = state_in_event last_grenade_thrown = GetTime() + 5 -- START DELAY end function activate_run_slash() Print('activate_run_slash \n') SetInvulnerable(1) invulnerable = 1 x, y, z = PlayerPos() AimAt(x, z) think_state = think_run_slash think0 = state_in_event PlayAnimNow(0, ANM_CHE_RUN, APT_BLEND_THEN_PLAY, run_speed) sleep_until = GetTime() + slash_run_time end function activate_run_double_slash() Print('activate_run_double_slash \n') SetInvulnerable(1) invulnerable = 1 play_starting_rush() x, y, z = PlayerPos() AimAt(x, z) rush_x = x rush_z = z think_state = think_run_double_slash think0 = state_in_event PlayAnimNow(0, ANM_CHE_RUN, APT_BLEND_THEN_PLAY,run_speed) sleep_until = GetTime() + slash_run_time end function activate_quickstrafe() SetInvulnerable(1) invulnerable = 1 Print('activate_quickstrafe \n') tempo = mod(rand(), 100) if(tempo > 49) then activate_quickstrafe_right() else activate_quickstrafe_left() end end function activate_quickstrafe_right() Print('activate_quickstrafe_right \n') PlayAnimNow(0, ANM_CHE_STRAFE_RIGHT, APT_BLEND_THEN_PLAY, quick_strafe) sleep_until = GetTime() + quick_time think_state = think_quickstrafe think0 = state_in_event end function activate_quickstrafe_left() Print('activate_quickstrafe_left \n') PlayAnimNow(0, ANM_CHE_STRAFE_RIGHT, APT_BLEND_THEN_PLAY_BACKWARDS, quick_strafe) sleep_until = GetTime() + quick_time think_state = think_quickstrafe think0 = state_in_event end function activate_walk_back() SetInvulnerable(1) invulnerable = 1 if(check_rear()==1) then activate_crouch() end moving = 1 think_state = think_walk_back think0 = state_in_event PlayAnimNow(0, ANM_CHE_WALK, APT_PLAY_BACKWARDS, walk_back_speed*((attack_aggro - GetAggro())/attack_aggro)) sleep_until = GetTime() + walk_back_time end function consider_move() Print('consider_move \n') if(GetAggro() >= attack_aggro) then activate_move() else activate_walk_back() end end function activate_move() -- Print('activate_move \n') moving = 1 think_state = think_move sleep_until = GetTime() + move_time think0 = state_in_event PlayAnimNow(0, ANM_CHE_WALK, APT_PLAY,walk_speed*((GetAggro() - attack_aggro)/attack_aggro)) end function activate_crouch() SetInvulnerable(1) invulnerable = 1 Print('activate_crouch \n') think0 = state_in_event PlayAnimNow(0, ANM_CHE_ACTIVATE_FIRE, APT_BLEND_THEN_PLAY_ONCE) sleep_until = GetTime() + crouch_delay think_state = think_crouch end function activate_forced_back() SetInvulnerable(1) invulnerable = 1 if(check_rear()==1) then activate_crouch() end moving = 1 think_state = think_forced_back think0 = state_in_event PlayAnimNow(0, ANM_CHE_WALK, APT_PLAY_BACKWARDS, walk_back_speed) sleep_until = GetTime() + 2 AimAt(px,pz) end ---------------------------------------------------------------------- -- help functions -- ---------------------------------------------------------------------- function randomize_event() next_event_time = GetTime() + mod(rand()/1000, max_event_delay - min_event_delay) + min_event_delay local temp = mod(rand(), 100) if(temp < walk_prob) then next_event = 1 elseif(temp < quick_strafe_prob) then next_event = 2 elseif(temp < grenade_strafe_prob) then next_event = 3 elseif(temp < rush_prob) then next_event = 4 else next_event = 5 end Print(next_event) end function double_slash() think_state = think_double_slash think0 = state_in_event FireUtilWeapon(UTILSLOT1,UTILITYFIRE_CHESWORD, 0, rush_dmg_length) PlayAnimNow(0, ANM_CHE_RUN_SLASH, APT_PLAY_ONCE,double_attack_speed) if(mod(rand(),3) > 1) then PlayLoadedSound(3,0.1) else PlayLoadedSound(4,0.1) end sleep_until = GetTime() + double_slash_time end function close_slash() SetInvulnerable(1) invulnerable = 1 think_state = think_slash think0 = state_in_event FireUtilWeapon(UTILSLOT1,UTILITYFIRE_CHESWORD, 0, dmg_length) PlayAnimNow(0, ANM_CHE_RUN_SLASH, APT_PLAY_ONCE,double_attack_speed) sleep_until = GetTime() + close_slash_time sound_delay = GetTime() + close_sound_delay if(mod(rand(),3) > 1) then PlayLoadedSound(3,0.3) else PlayLoadedSound(4,0.3) end end function close_attack() think0 = state_in_event think_state = think_close_attack FireUtilWeapon(UTILSLOT1,UTILITYFIRE_CHESWORD, 0, dmg_length) PlayAnimNow(0, ANM_CHE_CLOSE_ATTACK, APT_PLAY_ONCE) sleep_attack_until = GetTime() + close_attack_time PlayLoadedSound(6,0.3) end function fire_flame() -- Print('fire_flame \n') counter = counter + 1 particle_num = mod(counter, 4) + 1 PlayParticleSystem(particle_num, x_fire_pos, y_min_room, z_fire_pos, 0, 1, 0, 1, 0, 0) -- Print('Played particle system:' .. particle_num .. '\n') -- Print('XPOS: ' .. x_fire_pos .. ' ZPOS:' .. z_fire_pos .. '\n') PlayLoadedSound(5) set_fire_dmg(x_fire_pos,z_fire_pos) end function check_move(factor) cx,cy,cz = Position() px,py,pz = PlayerPos() x = cx - px z = cz - pz player_distance = sqrt(x*x + z*z) posx = -(pz-cz)/player_distance*factor+cx posz = (px-cx)/player_distance*factor+cz if((posx > x_max_room) or (posx < x_min_room) or (posz > z_max_room) or (posz < z_min_room)) then return 0 end return 1 end function fire_on() if(fire_index < 5) then if(GetTime() > fire_sleep) then sector = mod(rand(),4) if(sector == 0) then x = mod(rand(),x_max_room - z_inner_max)+z_inner_max y = y_min_room z = mod(rand(),z_max_room-z_min_room)+z_min_room elseif(sector == 1) then x = mod(rand(),x_inner_min-x_min_room)+x_min_room y = y_min_room z = mod(rand(),z_max_room-z_min_room)+z_min_room elseif(sector == 2) then x = mod(rand(),x_max_room-x_min_room)+x_min_room y = y_min_room z = mod(rand(),z_max_room-z_inner_max)+z_inner_max elseif(sector == 3) then x = mod(rand(),x_max_room-x_min_room)+x_min_room y = y_min_room z = mod(rand(),z_inner_min-z_min_room)+z_min_room end -- Print('Fire Random Fire!!!\n') PlayParticleSystem(fire_index, x, y, z, 0, 1, 0, 1, 0, 0) -- Is Player hit PlayLoadedSound(5) set_fire_dmg(x,z) fire_sleep = GetTime() + fire_sleep_time fire_index = fire_index + 1 end else fire_index = 1 fire_state = 0 next_occ_fire = GetTime() + occ_fire_delay end end ---------------------------------------------------------------------- -- think states -- ---------------------------------------------------------------------- function think_advance() x, y, z = PlayerPos() AimAt(x, z) Pause() end function think_move() px, py, pz = PlayerPos() AimAt(px,pz) mx, my, mz = Position() x = mx - px z = mz - pz player_distance = sqrt(x*x + z*z) if(GetAggro() < attack_aggro) then activate_walk_back() return else SetAnimSpeed(0,walk_speed*((GetAggro()-attack_aggro)/attack_aggro)) end if(GetTime() > sleep_until or (check_distance(close_range)==1)) then think0 = state_main moving = 0 end -- Pause() end function think_forced_back() AimAt(px,pz) if(check_rear()==1) then activate_crouch() end if(GetTime() > sleep_until) then moving = 0 think0 = state_main end end function think_stumble() if(GetTime() > sleep_until) then SetInvulnerable(1) invulnerable = 1 if(check_move(wheel_distance) == 1) then activate_evade_right() elseif(check_move(-wheel_distance) == 1) then activate_evade_left() else think0 = state_main think_state = think_advance end end Pause() end function think_wheel_middle() if (GetTime() > sleep_until) then activate_final_fire() end Pause() end function think_throw_grenade() x, y, z = PlayerPos() AimAt(x, z) ----- throw grenade ----- if (GetTime() > last_grenade_thrown + grenade_throw_delay and player_distance > close_range) then PlayAnimNow(1, ANM_CHE_SUB_GRENADE, APT_PLAY_ONCE,grenade_speed) last_grenade_thrown = GetTime() sleep_until = GetTime() + throw_anim_length think_state = think_end_throw_grenade end Pause() end function think_end_throw_grenade() x, y, z = PlayerPos() AimAt(x, z) if (GetTime() > sleep_until) then FireUtilWeapon(UTILSLOT1,UTILITYFIRE_CHEGRENADE) end Pause() end function think_wait() Pause() end function play_fire_at_barrels() -- Print('Fire Random Fire!!!\n') PlayParticleSystem(1, 5274, -2612, 5788, 0, 1, 0, 1, 0, 0) -- Is Player hit PlayLoadedSound(5) PlayParticleSystem(2, 5155, -2612, 6000, 0, 1, 0, 1, 0, 0) -- Is Player hit PlayLoadedSound(5) PlayParticleSystem(3, 5285, -2612, 5504, 0, 1, 0, 1, 0, 0) -- Is Player hit PlayLoadedSound(5) SendMsg('Bossfight_Script:Break:DSO08-10') end function wait_for_anims() if(AssignDynamicAnimations() == 1) then EnableBossHealth() SetCamoMode(0) AttachObject('Che_Shield', 150, 25, 13, -16, 90, 0, 0) mx, my, mz = Position() SetEnemyPosition(mx,my,mz) think0 = state_main activate_move() HideWeapon(0,0) -- AttachParticleSystem(5, 100, 10, -1, 70, 90, 0, 0, 1, 0) -- AttachParticleSystem(6, 100, 10, -1, 70, 90, 0, 0, 0, 0) SetInvulnerable(1) invulnerable = 1 play_fire_at_barrels() end Pause() end function think_recover() if(GetTime() > sleep_until) then SetInvulnerable(1) invulnerable = 1 activate_putdownsword() end Pause() end function think_strafe() px, py, pz = PlayerPos() AimAt(px,pz) if (GetTime() > last_grenade_thrown + grenade_throw_delay) then PlayAnimNow(1, ANM_CHE_SUB_GRENADE, APT_PLAY_ONCE,grenade_speed) last_grenade_thrown = GetTime() pre_throw_state = think_strafe sleep_until = GetTime() + throw_anim_length think_state = think_throw_grenade_and_strafe end if(GetTime() > strafe_until) then activate_drawsword() HideWeapon(0,0) end Pause() end function think_throw_grenade_and_strafe() AimAt(px,pz) if (GetTime() > sleep_grenade) then FireUtilWeapon(UTILSLOT1,UTILITYFIRE_CHEGRENADE) think_state = pre_throw_state Print('grenade thrown \n') end Pause() end function think_run_slash() px, py, pz = PlayerPos() AimAt(px,pz) if ((check_distance(close_range)==1) or GetTime() > sleep_until) then close_slash() end Pause() end function think_walk_back() SetInvulnerable(1) invulnerable = 1 px, py, pz = PlayerPos() AimAt(px,pz) if(GetAggro() >= attack_aggro) then activate_move() return else SetAnimSpeed(0,walk_back_speed*((attack_aggro - GetAggro())/attack_aggro)) end if(check_rear()==1) then activate_crouch() end if(GetTime() > sleep_until) then moving = 0 think0 = state_main end -- Pause() end function think_putaway() AimAt(px,pz) if(GetTime() > sleep_until) then HideWeapon(1,0) if(attack_state == 2) then activate_movetomiddle() else activate_grenade_wave() end end Pause() end function think_draw() AimAt(px,pz) if(GetTime() > sleep_until) then consider_move() end Pause() end function think_run_double_slash() AimAt(rush_x,rush_z) if ((check_distance(close_range)==1) or (check_dist_to_point(rush_x,rush_z,close_range) == 1)) then -- GetTime() > sleep_until) then double_slash() return end Pause() end function think_slash() if (GetTime() > sleep_until) then x, y, z = PlayerPos() AimAt(x,z) sleep_until = GetTime() + rush_pause_time think_state = think_rush_pause think0 = state_in_event end Pause() end function think_close_attack() -- Print('Think_close_attack \n') if (GetTime() > sleep_attack_until) then sound_done = 0 x, y, z = PlayerPos() AimAt(x,z) if(check_move(wheel_distance) == 1) then activate_wheel_right() elseif(check_move(-wheel_distance) == 1) then activate_wheel_left() else activate_forced_back() Print('Think_close_attack couldnt wheel \n') end end Pause() end function think_rush_pause() if(GetTime() > sleep_until) then think0 = state_main think_state = think_advance end Pause() end function think_double_slash() if (GetTime() > sleep_until-1.5) then -- DAMAGE WINDOW SetInvulnerable(0) invulnerable = 0 end if (GetTime() > sleep_until) then SetInvulnerable(1) invulnerable = 1 if(attack_state == 1) then acc_dmg = 0 attack_state = 0 end if(player_distance > close_range) then consider_move() else if(check_move(wheel_distance) == 1) then activate_wheel_right() elseif(check_move(-wheel_distance) == 1) then activate_wheel_left() else activate_forced_back() end end end Pause() end function think_activate_fire() x, y, z = PlayerPos() AimAt(x,z) if(GetTime() > sleep_until) then think0 = state_main think_state = think_advance end Pause() end function think_activate_final_fire() if(GetTime() > send_fire_delay) then fire_activate = 1 end x, y, z = PlayerPos() if (GetTime() > last_grenade_thrown + grenade_throw_delay and player_distance > close_range) then pre_throw_state = think_activate_final_fire PlayAnimNow(1, ANM_CHE_SUB_GRENADE, APT_PLAY_ONCE,grenade_speed) last_grenade_thrown = GetTime() sleep_grenade = GetTime() + throw_anim_length think_state = think_throw_grenade_and_strafe end AimAt(x,z) if(GetTime() > fireFinished) then fire_activate = 0 activate_drawsword() attack_state = 0 end Pause() end function think_start_fire() if(GetTime() > last_fire) then last_fire = GetTime() + next_flame_delay fire_flame() -- update next fire pos x_fire_pos = x_fire_pos + x_fire_vec z_fire_pos = z_fire_pos + z_fire_vec if(z_fire_pos > z_inner_max) then x_fire_pos = x_fire_pos + x_fire_vec z_fire_pos = z_inner_max z_fire_vec = -z_fire_vec elseif(z_fire_pos < z_inner_min) then x_fire_pos = x_fire_pos + x_fire_vec z_fire_pos = z_inner_min z_fire_vec = -z_fire_vec elseif(x_fire_pos > x_inner_max)then x_fire_pos = x_inner_max z_fire_pos = z_fire_pos + z_fire_vec x_fire_vec = -x_fire_vec elseif(x_fire_pos < x_inner_min) then x_fire_pos = x_inner_min z_fire_pos = z_fire_pos + z_fire_vec x_fire_vec = -x_fire_vec end -- mx, my, mz = Position() ax = mx - x_fire_pos az = mz - z_fire_pos distance_to_fire = sqrt(ax*ax + az*az) if(distance_to_fire < fire_dmg_range and think_state ~= think_throw_grenade and think_state ~= think_strafe and think_state ~= think_wheel and think_state ~= think_slash and think_state ~= think_double_slash and think_state ~= think_close_attack and think_state ~= think_run_double_slash and think_state ~= think_run_slash and think_state ~= think_fall) then Print('<<<<<<< AVOID FIRE >>>>>>> \n') if(check_move(wheel_distance) == 1) then activate_evade_right() elseif(check_move(-wheel_distance) == 1) then activate_evade_left() -- else -- consider_move() end end end end function think_stand() x, y, z = PlayerPos() AimAt(x,z) if(GetTime() > sleep_until) then think0 = state_main think_state = think_advance end Pause() end function think_wheel() if(GetTime() > sleep_until) then if(attack_state == 0 or attack_state == 1) then consider_move() else Print('GO TO DAVED STATE: ' .. attack_state .. '\n') PlayAnimNow(0, ANM_CHE_CROUCH, APT_BLEND_THEN_PLAY_ONCE) think_state = think_activate_final_fire end end Pause() end function think_crouch() AimAt(px,pz) if(GetTime() > sleep_until) then think0 = state_main think_state = think_advance end Pause() end function think_quickstrafe() px, py, pz = PlayerPos() AimAt(px,pz) if(GetTime() > sleep_until) then consider_move() end Pause() end function think_turn_middle() mx, my, mz = Position() x = mx - middle_x z = mz - middle_z distance_to_middle = sqrt(x*x + z*z) v_middle_x = middle_x - mx v_middle_z = middle_z - mz -- right target v_righty_x = v_middle_z + mx v_righty_z = -v_middle_x + mz distance_to_middle_right = sqrt((v_righty_x-px)*(v_righty_x-px) + (v_righty_z-pz)*(v_righty_z-pz)) -- left target v_lefty_x = - v_middle_z + mx v_lefty_z = v_middle_x + mz distance_to_middle_left = sqrt((v_lefty_x-px)*(v_lefty_x-px) + (v_lefty_z-pz)*(v_lefty_z-pz)) if(distance_to_middle_left < distance_to_middle_right) then if (abs(AimAt(v_lefty_x,v_lefty_z)) < 0.01) then if(distance_to_middle < one_wheel) then activate_wheel_to_middle(1,0) Print('1 wheel \n') elseif(distance_to_middle < two_wheel) then activate_wheel_to_middle(2,0) Print('2 wheel \n') else activate_wheel_to_middle(3,0) Print('3 wheel \n') end end else if (abs(AimAt(v_righty_x,v_righty_z)) < 0.01) then if(distance_to_middle < one_wheel) then activate_wheel_to_middle(1,1) Print('1 wheel \n') elseif(distance_to_middle < two_wheel) then activate_wheel_to_middle(2,1) Print('2 wheel \n') else activate_wheel_to_middle(3,1) Print('3 wheel \n') end end end Pause() end -- initialize the think state and the think0 function -- (the think0 function is the one called every frame) CreateUtilWeapon(UTILSLOT1,UTILITYWEAPON_CHE) LoadParticleSystem(0, 'Particles/Impact_Metal_boss.pcf') --'Particles/Che_Riotshield.pcf') LoadParticleSystem(1, 'Particles/Flametrower_Manufacturing2.pcf') LoadParticleSystem(2, 'Particles/Flametrower_Manufacturing2.pcf') LoadParticleSystem(3, 'Particles/Flametrower_Manufacturing2.pcf') LoadParticleSystem(4, 'Particles/Flametrower_Manufacturing2.pcf') -- LoadParticleSystem(5, 'Particles/Che_Sword_Glow.pcf') -- LoadParticleSystem(6, 'Particles/Che_Sword_Smoke.pcf') LoadSound(1,'CHE_KEYPAD_BEEPS') LoadSound(2,'CHE_SWORD_DRAW') LoadSound(3,'CHE_DOUBLE_ATTACK') LoadSound(4,'CHE_DOUBLE_ATTACK_NO_VOICE') LoadSound(5,'CHE_FIRE_02') LoadSound(6,'CHE_SLASH_1') LoadSound(7,'CHE_SWORD_SHEATH') HideWeapon(1,0) do_wait()