@name Prop Breaker
@outputs Models:array
@persist [E Me Prop]:entity TargPos:vector
@model models/hunter/misc/sphere025x025.mdl

if(first())
{
    runOnTick(1)
    
    E = entity()
    E:setMaterial("debug/debugdrawflat")
    E:setMass(50000)
    
    Me = owner()
    
    Models = array("models/props_c17/oildrum001_explosive.mdl",
                   "models/props_c17/FurnitureDrawer002a.mdl",
                   "models/props_junk/garbage_plasticbottle003a.mdl",
                   "models/props_phx/construct/wood/wood_angle360.mdl",
                   "models/props_phx/construct/glass/glass_plate4x4.mdl",
                   "models\Humans/Group03/male_09.mdl",
                   "models/props/cs_militia/wndw01.mdl",
                   "models/Items/item_item_crate.mdl",
                   "models/props_phx/torpedo.mdl",
                   "models\props/cs_office/Bookshelf1.mdl",
                   "models/props_phx/construct/wood/wood_wire1x2.mdl",
                   "models/props_phx/construct/wood/wood_wire2x2.mdl",
                   "models/props_junk/terracotta01.mdl",
                   "models/props_c17/FurnitureCouch001a.mdl",
                   "models/props_c17/FurnitureShelf001b.mdl",
                   "models/props_c17/FurnitureTable001a.mdl",
                   "models/props_c17/FurnitureTable002a.mdl",
                   "models/props_phx/mk-82.mdl",
                   "models/props_interiors/Furniture_Couch02a.mdl",
                   "models/props_interiors/Furniture_Couch01a.mdl",
                   "models/props_interiors/Furniture_Vanity01a.mdl",
                   "models/props_junk/cardboard_box001b.mdl",
                   "models/props_junk/cardboard_box002a_gib01.mdl",
                   "models/props_junk/cardboard_box002b.mdl",
                   "models/props_junk/cardboard_box003a.mdl",
                   "models/props_wasteland/wood_fence02a.mdl",
                   "models/props_c17/FurnitureDrawer001a.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk01.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk02.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk03.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk04.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk05.mdl",
                   "models/props_c17/FurnitureDrawer001a_Chunk06.mdl",
                   "models/props_phx/oildrum001_explosive.mdl",
                   "models/props_phx/ball.mdl",
                   "models/props_phx/ww2bomb.mdl",
                   "models/props_phx/misc/flakshell_big.mdl",
                   "models/props_c17/oildrum001_explosive.mdl",
                   "models/props_combine/breenbust.mdl",
                   "models/props_c17/bench01a.mdl",
                   "models/props_c17/FurnitureCupboard001a.mdl",
                   "models/props_c17/shelfunit01a.mdl",
                   "models/props_junk/wood_crate001a.mdl",
                   "models/props_junk/wood_crate002a.mdl",
                   "models/props_junk/wood_pallet001a.mdl",
                   "models/props_wasteland/wood_fence01a.mdl",
                   "models/props_wasteland/cafeteria_bench001a.mdl",
                   "models/props_wasteland/cafeteria_table001a.mdl",
                   "models/props_junk/propane_tank001a.mdl",
                   "models/props_junk/gascan001a.mdl",
                   "models/props_interiors/Furniture_shelf01a.mdl",
                   "models/props_interiors/Furniture_Desk01a.mdl",
                   "models/props_c17/FurnitureShelf001b.mdl",
                   "models/props_c17/FurnitureChair001a.mdl",
                   "models/props_phx/construct/wood/wood_boardx1.mdl",
                   "models/props_phx/construct/wood/wood_boardx2.mdl",
                   "models/props_phx/construct/wood/wood_boardx4.mdl",
                   "models/props_phx/construct/wood/wood_panel1x1.mdl",
                   "models/props_phx/construct/wood/wood_panel1x2.mdl",
                   "models/props_phx/construct/wood/wood_panel2x2.mdl",
                   "models/props_phx/construct/wood/wood_panel2x4.mdl",
                   "models/props_phx/construct/wood/wood_panel4x4.mdl",
                   "models/props_phx/construct/glass/glass_angle180.mdl",
                   "models/props_phx/construct/glass/glass_angle360.mdl",
                   "models/props_phx/construct/glass/glass_plate1x1.mdl",
                   "models/props_phx/construct/glass/glass_plate1x2.mdl",
                   "models/props_phx/construct/glass/glass_plate2x4.mdl",
                   "models/props_phx/construct/glass/glass_dome360.mdl",
                   "models/props_phx/wheels/wooden_wheel1.mdl",
                   "models/props_phx/wheels/breakable_tire.mdl",
                   "models/props_phx/misc/egg.mdl",
                   "models/Items/item_item_crate.mdl",
                   "models/props_phx/amraam.mdl",
                   "models/props_c17/FurnitureShelf001a.mdl",
                   "models/props_junk/wood_crate001a_damaged.mdl",
                   "models/props_trainstation/bench_indoor001a.mdl",
                   "models/props_c17/FurnitureDresser001a.mdl",
                   "models/props_c17/FurnitureCupboard001a.mdl",
                   "models/props_c17/FurnitureDrawer003a.mdl"
                  )
findInSphere(Me:pos(), 10000000000)}

if(findCanQuery())
{
    findIncludeModel(Models[randint(1, Models:count()), string])
    
    
    Prop = findResult(1)
}

E:setColor(hsv2rgb((curtime() * 10) % 360, 1, 1))

if(Prop:pos():distance(Me:pos()) <= 400 & !Prop:isFrozen())
{       
    TargPos = Prop:pos() - E:pos()
}
else
{
    TargPos = (Me:pos() - E:pos()) + vec(0, 0, 150)
}

E:applyForce((TargPos * 25 - E:vel() / 2) * E:mass() * 2)
