-------------------------------------------------------------------------------- -- Weapon Chainsaw -- Unoriginal Carnage Contest Weapon -- Script by ks, April 2010, konstantin.art-fx.org -------------------------------------------------------------------------------- -- setup tables if cc==nil then cc={} end cc.chainsaw={} -- load and prepare ressources cc.chainsaw.gfx_wpn=loadgfx("weapons/chainsaw0.bmp") setmidhandle(cc.chainsaw.gfx_wpn) cc.chainsaw.sfx_attack=loadsfx("chainsawlaunch.wav") -------------------------------------------------------------------------------- -- Weapon: chainsaw! -------------------------------------------------------------------------------- cc.chainsaw.id=addweapon("cc.chainsaw", "Chainsaw", cc.chainsaw.gfx_wpn, 1) cc.chainsaw.ammo=200 function cc.chainsaw.draw() drawinhand(cc.chainsaw.gfx_wpn,6,0) -- draw hud hudcrosshair(7,3) if cc.chainsaw.ammo-weapon_shots>0 then hudammobar(cc.chainsaw.ammo - weapon_shots, cc.chainsaw.ammo) end end function cc.chainsaw.attack(attack) -- actually i don't know what it does, but it seems to be needed if weapon_timer>0 then weapon_timer = weapon_timer - 1 end -- attack the fucker if(weapon_shots <= cc.chainsaw.ammo) then if(attack==1) then useweapon(0) -- no way to use another weapon afterwards! weapon_shots = weapon_shots + 1 -- do the collision if collision(col20x20, getplayerx(0)+getplayerdirection(0)*21, getplayery(0), 1, 1) == 1 then if playercollision()~=0 and playercollision()~=playercurrent() then playerdamage(playercollision(), 1) playsound(sfx_splatter1) blood(getplayerx(playercollision()), getplayery(playercollision())) end if terraincollision(1)==1 then end end terrainexplosion(getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)))*1,getplayery(0)-1-math.cos(math.rad(getplayerrotation(0)))*3,15,2) terrainexplosion(getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)))*10,getplayery(0)-1-math.cos(math.rad(getplayerrotation(0)))*10,15,2) -- ok this one's pretty cool if math.mod(weapon_shots,3) == 0 then playsound(cc.chainsaw.sfx_attack) end end end -- end the turn when no ammo left! if weapon_shots >= cc.chainsaw.ammo then endturn() end end