home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Stoning + Projectile Stone
- -- Original Carnage Contest Weapon
- -- Script by DC, September 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.stoning={}
- cc.stoning.stone={}
-
- -- Load & Prepare Ressources
- cc.stoning.gfx_icon=loadgfx("weapons/stoning.png") -- Weapon Icon
- setmidhandle(cc.stoning.gfx_icon)
- cc.stoning.gfx_pro=loadgfx("weapons/stone.bmp") -- Projectile Image
- setmidhandle(cc.stoning.gfx_pro)
- cc.stoning.sfx_hit=loadsfx("stoneimpact.ogg")
-
- --------------------------------------------------------------------------------
- -- Weapon: Stoning
- --------------------------------------------------------------------------------
-
- cc.stoning.id=addweapon("cc.stoning","Stoning",cc.stoning.gfx_icon,0,3) -- Add Weapon (0 uses, first in round 3)
-
- function cc.stoning.draw() -- Draw
- -- HUD Positioning
- if weapon_shots==0 then
- hudpositioning(pos_invisible)
- end
- end
-
- function cc.stoning.attack(attack) -- Attack
- if (weapon_shots<=0) and (weapon_position==1) then
- -- No more weapon switching!
- useweapon(0)
- weapon_shots=weapon_shots+1
- weapon_position=0
- -- Random Seed
- randomseed(getframe()*911+getround()*77)
- -- Spawn stones
- for i=1,10,1 do
- pid=createprojectile(cc.stoning.stone.id)
- projectiles[pid]={}
- projectiles[pid].x=weapon_x+random(-100,100)
- projectiles[pid].y=-random(200,350)
- projectiles[pid].sy=random(150,200)*0.1
- projectiles[pid].timer=i*random(15,20)
- end
- -- End Turn
- endturn()
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Stone
- --------------------------------------------------------------------------------
-
- cc.stoning.stone.id=addprojectile("cc.stoning.stone") -- Add Projectile
-
- function cc.stoning.stone.draw(id) -- Draw
- if projectiles[id].timer<=0 then
- -- Stone
- setcolor(255,255,255)
- setblend(blend_alpha)
- setalpha(1)
- setrotation(0)
- drawimage(cc.stoning.gfx_pro,projectiles[id].x,projectiles[id].y)
- end
- end
-
- function cc.stoning.stone.update(id) -- Update
- -- Timer
- if projectiles[id].timer>0 then
- -- Count Down before stone appears
- projectiles[id].timer=projectiles[id].timer-1
- else
- -- Stone appears
- -- Particle Tail
- particle(p_smoke,projectiles[id].x+math.random(-6,6),projectiles[id].y-7)
- particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
- particlefadealpha(0.05)
- -- Move (in substep loop for optimal collision precision)
- msubt=math.abs((projectiles[id].sy)/5)
- msuby=projectiles[id].sy/msubt
- for i=1,msubt,1 do
- projectiles[id].y=projectiles[id].y+msuby
- -- Collision
- if collision(cc.stoning.gfx_pro,projectiles[id].x,projectiles[id].y)==1 then
- -- Player Damage
- if playercollision()~=0 then
- playerdamage(playercollision(),10000)
- else
- -- Object Damage
- if objectcollision()>0 then
- objectdamage(objectcollision(),10000)
- end
- -- Impact
- playsound(cc.stoning.sfx_hit)
- terrainimage(cc.stoning.gfx_pro,projectiles[id].x,projectiles[id].y)
- for angle=0,340,20 do
- particle(p_smoke,projectiles[id].x,projectiles[id].y)
- particlespeed(math.sin(math.rad(angle))*2,-math.cos(math.rad(angle))*2)
- particlecolor(150,150,150)
- end
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- -- Water
- if (projectiles[id].y)>getwatery()+5 then
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- particlesize(1.5,2.0)
- playsound(sfx_hitwater4)
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- end
- end