Forum

> > Carnage Contest > Weapon recognition problems
Forums overviewCarnage Contest overviewLog in to reply

English Weapon recognition problems

6 replies
To the start Previous 1 Next To the start

old Weapon recognition problems

DannyDeth
User Off Offline

Quote
I am a newbie to the world of Carnage Contest and the Lua scripting language but have managed ( barely ) to create a new weapon named " Dragon's Egg ", I was very impressed with myself once i had gotten to the last line of code but soon found that when i tried to test and debug it, CC wouldn't recognise it. I had made a new file in scripts named CC DD and clicked on it when i was in the program, but it couldn't find it i think it was because i changed the cc.xxx to ccdd.xxx. Could anyone shed light on this question?

old Re: Weapon recognition problems

Nem
User Off Offline

Quote
Maybe you will upload your script or post a code ? maybe ppl will help ya
If you will do this, dont forget to give like to gfx/sfx.

old Here's the code I used

DannyDeth
User Off Offline

Quote
( You guys may recognise something familiar, that's coz I stole most of the script from Grenade from CC Origanal )




--------------------------------------------------------------------------------
-- 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

old Re: Weapon recognition problems

DC
Admin Off Offline

Quote
no, that's not the problem and it is GOOD that he changed the cc to ccdd because "cc" is something like a namespace for original carnage contest weapons. so it's good that he changed it because his weapon is not an original one

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.

old Re: Weapon recognition problems

DannyDeth
User Off Offline

Quote
I just found out what was going on, I had put the new weapon in CC origanal, not CC DD. I aslo found out, after a little while of examining the script, that when I was altering the script I forgot to change the defintion of the table. If you look at the part of the script where you have to make sure that ccdd exists, you will see that I had left it out and instaed of definging ccdd, it was defining cc. That was my problem. But thanks for all the help. But I have a small question, how do I load a profile picture? I'm eager to know.
To the start Previous 1 Next To the start
Log in to replyCarnage Contest overviewForums overview