local input_key = 16 --button to press to trigger the freeze/unfreeze local max_psychic = 12 --limit on the amount of "psychic" player can have (adjusts maximum amount of time enemies can be frozen for) local current_psychic = max_psychic / 2 --starting psychic of player local psychic_recharge_time = 1.25 --how fast psychic recharges local first_image = 1 --slot number of first image to use local max_image = 7 --slot number of last image to use local image_delay = 1 --how fast they update (in milliseconds) ---------------- psychic_recharge_time = psychic_recharge_time * 1000 pressed = 0 frozen = 0 local image = 0 local new_image_delay = 1 local init_psychic_recharge_time = psychic_recharge_time local time_to_freeze = 5000 local starting_psychic = 0 local drain_timer = 0 ---------------- function freeze_init(e) Hide(e) CollisionOff(e) LoadImages("the experiment",0) --folder that stores the images of the psychic "effect" end function freeze_main(e) Hide(e) CollisionOff(e) if timer == nil then psychic_recharge_time = g_Time + init_psychic_recharge_time StartTimer(e) timer = 1 starting_psychic = current_psychic else Panel(0,70,20,75) TextCenterOnX(10,72.5,3,"Psychic : "..current_psychic.." / "..max_psychic) if current_psychic < max_psychic then if g_Time > psychic_recharge_time and frozen == 0 then current_psychic = current_psychic + 1 psychic_recharge_time = g_Time + init_psychic_recharge_time end else psychic_recharge_time = g_Time + init_psychic_recharge_time end if frozen == 0 then StartTimer(e) if GetScancode() == input_key and pressed == 0 then if current_psychic > 0 then drain_timer = g_Time image = first_image new_image_delay = image_delay time_to_freeze = (current_psychic * 1000)+100 PromptDuration("Freezing time",1100) pressed = 1 FreezeAI() for a = 1, 9999 do if g_Entity[a] ~= nil and a ~= e then if ai_soldier_state[a] ~= nil then StopAnimation(a) end end end frozen = 1 else PromptDuration("You're too exhausted right now",1100) end end else if g_Time > drain_timer + 1000 then current_psychic = current_psychic - 1 drain_timer = g_Time end if GetTimer(e) > new_image_delay then new_image_delay = new_image_delay + image_delay if image > max_image then image = first_image else image = image + 1 end ShowImage(image) SetImagePosition(50,50) end if GetTimer(e) > time_to_freeze then psychic_recharge_time = g_Time + init_psychic_recharge_time current_psychic = 0 PromptDuration("Real time",1100) frozen = 0 UnFreezeAI() HideImage(image) for a = 1, 9999 do if g_Entity[a] ~= nil and a ~= e then if ai_soldier_state[a] ~= nil then PlayAnimation(a) end end end end if GetScancode() == input_key and pressed == 0 then psychic_recharge_time = g_Time + init_psychic_recharge_time pressed = 1 PromptDuration("Real time",1100) frozen = 0 UnFreezeAI() HideImage(image) for a = 1, 9999 do if g_Entity[a] ~= nil and a ~= e then if ai_soldier_state[a] ~= nil then PlayAnimation(a) end end end current_psychic = math.floor((time_to_freeze - GetTimer(e)) / 1000) end end if GetScancode() == 0 then pressed = 0 end if g_PlayerHealth < 1 then current_psychic = starting_psychic end end --timer set end