--sniper2 script by smallg local fire_range = {} local shot_delay = {} local damage = {} local chance_to_hit = {} function sniper2_init(e) damage[e] = 30 fire_range[e] = 3000 shot_delay[e] = 1100 --1000 = 1 second chance_to_hit[e] = 50 --100 = certain hit CharacterControlManual(e) CharacterControlArmed(e) end --sound1 = normal sniper gun shot function sniper2_main(e) if g_Entity[e]['animating'] == 0 then SetAnimation(0) PlayAnimation(e) g_Entity[e]['animating'] = 1 end if GetTimer(e) > shot_delay[e] then StartTimer(e) if GetPlayerDistance(e) < fire_range[e] then x1 = GetEntityPositionX(e) y1 = GetEntityPositionY(e)+80 --above origin so we can see over cover z1 = GetEntityPositionZ(e) y2 = g_PlayerPosY x2 = g_PlayerPosX z2 = g_PlayerPosZ obstructionhit = IntersectAll(x2,y2,z2,x1,y1,z1,g_Entity[e]['obj']) if obstructionhit == nil then obstructionhit = 0 end if obstructionhit ~= 0 then --Prompt ("obstructed") else if math.random(1,100) >= chance_to_hit[e] then PlaySound(e,1) --normal gun shot sound HurtPlayer(e,damage[e]) else PlaySound(e,1) --normal gun shot sound --PlaySound(e,2) --maybe a gun shot and ricochet sound instead? end end end end end