Forum
Carnage Contest Weapon recognition problemsWeapon recognition problems
6 replies 1
If you will do this, dont forget to give like to gfx/sfx.
--------------------------------------------------------------------------------
-- Dragon's Egg v1.0 by DannyDeth
-- CC DannyDeth weapon
-- Built and engineered by DannyDeth ( A bit stolen from DC )
--------------------------------------------------------------------------------
-- Setup Tables
if ccdd==nil then cc={} end -- ccdd is the default table used in CC DannyDeth
ccdd.dragonsegg={}
ccdd.dragonsegg.dragonsegg={}
-- Load & Prepare Ressources
ccdd.dragonsegg.gfx_wpn=loadgfx("weapons/dragonsegg.bmp") -- Weapon Image
setmidhandle(ccdd.dragonsegg.gfx_wpn)
ccdd.dragonsegg.sfx_attack=loadsfx("throw.ogg") -- Attack Sound
ccdd.dragonsegg.sfx_bounce=loadsfx("bounce.wav") -- Bounce Sound
--------------------------------------------------------------------------------
-- Weapon: Dragon's Egg
--------------------------------------------------------------------------------
ccdd.dragonsegg.id=addweapon("ccdd.dragonsegg","Dragon's Egg",ccdd.dragonsegg.gfx_wpn) -- Add Weapon
function ccdd.dragonsegg.draw() -- Draw
if weapon_shots<=0 then
setblend(blend_alpha)
setalpha(1)
setcolor(255,255,255)
drawinhand(ccdd.dragonsegg.gfx_wpn,6,0)
end
-- HUD chargebar
if weapon_charge>0 and weapon_shots==0 then
hudchargebar(weapon_charge,100)
end
-- HUD Crosshair / HUD Timer
if weapon_shots==0 then
hudcrosshair(4,3)
hudtimer(3)
end
end
function ccdd.dragonsegg.attack(attack) -- Attack
if (weapon_shots<=0) then
-- Charge
if (attack==1) then
weapon_charge=weapon_charge+1 -- Increase charge
end
-- Fire a projectile (on release/full charge)
if (attack==0 and weapon_charge>0) or (weapon_charge>=100) then
-- No more weapon switching!
useweapon(0)
playsound(ccdd.dragonsegg.sfx_attack)
weapon_shots=weapon_shots+1
id=createprojectile(ccdd.dragonsegg.dragonsegg.id)
projectiles[id]={}
-- Ignore collision with current player at beginning
projectiles[id].ignore=playercurrent()
-- Set initial position of projectile
projectiles[id].x=getplayerx(0)+(4*getplayerdirection(0))+math.sin(math.rad(getplayerrotation(0)))*10.0
projectiles[id].y=getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)))*10.0
-- Set speed of projectile
projectiles[id].sx=math.sin(math.rad(getplayerrotation(0)))*(weapon_charge/100.0)*10.0
projectiles[id].sy=-math.cos(math.rad(getplayerrotation(0)))*(weapon_charge/100.0)*10.0
-- Set timer
projectiles[id].timer=weapon_timer*50
-- Effects
recoil(2)
-- End Turn
endturn()
end
end
end
--------------------------------------------------------------------------------
-- Projectile: Dragon's Egg
--------------------------------------------------------------------------------
ccdd.dragonsegg.dragonsegg.id=addprojectile("ccdd.dragonsegg.dragonsegg") -- Add Projectile
function ccdd.dragonsegg.dragonsegg.draw(id) -- Draw
-- Setup draw mode
setblend(blend_alpha)
setalpha(1)
setcolor(255,255,255)
setscale(1,1)
-- Calculate projectile rotation
setrotation(math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy)))
-- Draw projectile
drawimage(ccdd.dragonsegg.gfx_wpn,projectiles[id].x,projectiles[id].y)
-- Draw Arrow if out of Screen
outofscreenarrow(projectiles[id].x,projectiles[id].y)
end
function ccdd.dragonsegg.dragonsegg.update(id) -- Update
-- Gravity influence on speed
projectiles[id].sy=projectiles[id].sy+getgravity()
-- Move (in substep loop for optimal collision precision)
msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/3)
msubx=projectiles[id].sx/msubt
msuby=projectiles[id].sy/msubt
for i=1,msubt,1 do
-- Move X
projectiles[id].x=projectiles[id].x+msubx
if collision(col5x5,projectiles[id].x,projectiles[id].y,1,1)==1 then
if terraincollision()==1 or playercollision()~=projectiles[id].ignore then
if (math.abs(projectiles[id].sx)>0.5) then playsound(cc.grenade.sfx_bounce) end
projectiles[id].x=projectiles[id].x-msubx
projectiles[id].sx=-projectiles[id].sx*0.3
msubx=-msubx*0.3
end
else
projectiles[id].ignore=0
end
-- Move Y
projectiles[id].y=projectiles[id].y+msuby
if collision(col5x5,projectiles[id].x,projectiles[id].y,1,1)==1 then
if terraincollision()==1 or playercollision()~=projectiles[id].ignore then
if (math.abs(projectiles[id].sy)>0.5) then playsound(cc.grenade.sfx_bounce) end
projectiles[id].y=projectiles[id].y-msuby
projectiles[id].sy=-projectiles[id].sy*0.3
msuby=-msuby*0.3
end
else
projectiles[id].ignore=0
end
-- Water
if (projectiles[id].y)>getwatery()+5 then
-- Effects
particle(p_waterhit,projectiles[id].x,projectiles[id].y)
playsound(sfx_hitwater1)
-- Free projectile
freeprojectile(id)
break
end
end
-- Timer -> Explode
projectiles[id].timer=projectiles[id].timer-1
if projectiles[id].timer<=0 then
-- Cause damage
arealdamage(projectiles[id].x,projectiles[id].y,100,50)
-- Destroy terrain
terrainexplosion(projectiles[id].x,projectiles[id].y,30,1)
-- Crater
grey=math.random(0,40)
if math.random(0,1)==1 then
terrainalphaimage(gfx_crater100,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
else
terrainalphaimage(gfx_crater125,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
end
-- Free projectile
freeprojectile(id)
end
-- Scroll to projectile
scroll(projectiles[id].x,projectiles[id].y)
end
Alright sorry guys, just found out that i had put the weapon in cc origanal instead of my new one, but i do get an error that says something about ccdd being the value of nil and then it says you can proceed or quit, so i proceeded and found my weapon not included in the game
cc is enough, just change weapon name! I thing it is a problem
however I don't get the real problem. you simply don't see your weapon in the game? that's what you have to do to add new weapons to the game/weapon set:
start a game (Host)
click Weapons
select a weapon slot on the right
select your weapon file on the left (use mousewheel to scroll)
now your weapon is assigned to the slot (you see the script file path when pointing at the slot)
confirm your changes with okay (your weapon set will be saved as CC Recent automatically but you can additionally save it with another filename by clicking save)
your script still has errors if you now get error messages! try to fix them and host again afterwards.
if there are no errors you should see your weapon in-game.
It is icon for weapon list
1