Lua Scripts/Questions/Help
89 replies03.10.09 07:34:26 pm
I am newbie at lua scripting, i not dumb to understand it, but to lazy to do it.
So, i need make the SSG shoot 8 bulets instead of 3
The SSG code:
may anyone help me pls ?
So, i need make the SSG shoot 8 bulets instead of 3
The SSG code:
may anyone help me pls ?
edited 1×, last 16.09.10 05:07:07 pm
Nemesis has written:
I am newbie at lua scripting, i not dumb to understand it, but to lazy to do it.
So, i need make the SSG shoot 8 bulets instead of 3
The SSG code:
may anyone help me pls ?
So, i need make the SSG shoot 8 bulets instead of 3
The SSG code:
may anyone help me pls ?
The changed things are marked big.
I use same for my Quake-Shotgun, but you have to change dmg because 8 bullets are powerfull.
"A work of art is the unique result of a unique temperament." - Oscar Wilde
you can actually do it much easier and better. the original script already is not the best solution
like
etc.
so you don't need all that if crap.
instead of +i you can do +(i*3) for example to increase the spread
like
Code:
1
2
3
4
2
3
4
for i=-3,4,1 do
...
rot=getplayerrotation(0)+i
...
...
rot=getplayerrotation(0)+i
...
etc.
so you don't need all that if crap.
instead of +i you can do +(i*3) for example to increase the spread
I also need a small lua help (and I don't wat to open one more thread):
I tried it 10 times, but it will not function, can someone explain me how to make a "Grenade Launcher"?
Would be great if someone would make it.
I tried it 10 times, but it will not function, can someone explain me how to make a "Grenade Launcher"?
Would be great if someone would make it.
"A work of art is the unique result of a unique temperament." - Oscar Wilde
I think it must be like Mortar.(original) just change energy, damage, explosion power(and range) and projectile picture.
I have question too:
Is there hook "start" or "startgame", and if yes, will that be working in weapon, and player must have that weapon for hook working or just including in weapons options(even 0)?
P.S.: I think this thread must be rename to "lua help" like thread"lua/questions/help" in CS2D
I have question too:
Is there hook "start" or "startgame", and if yes, will that be working in weapon, and player must have that weapon for hook working or just including in weapons options(even 0)?
P.S.: I think this thread must be rename to "lua help" like thread"lua/questions/help" in CS2D
Mortar doesn't jump, it explods after impact.
"A work of art is the unique result of a unique temperament." - Oscar Wilde
simply take the grenade code and allow to throw multiple grenades...
moreover use another image for
drawinhand in the weapon draw function
moreover you should remove the charging part and "shoot" the grenades with a constant speed.
moreover use another image for

moreover you should remove the charging part and "shoot" the grenades with a constant speed.
DC has written:
moreover you should remove the charging part
Thats why I said about mortar. It has no charging part.
Like mortar in Worms
EDIT: Can script from some weapon work, if this weapon isn't used CURRENT turn?
edited 3×, last 09.01.10 08:56:02 pm
Vectar666 has written:
How should it work?Will be server lua in the next version?
There is no server commands parsing.
Weapons Scripting Only
with variables and conditions (simply count down or count up).
note that CC runs with 50 fps.
this means: count to 20 (variable +/- 1 each frame) = 1 second
once (countdown setup):
countdown=10
each frame (increase/decrease countdown, check):
countdown=countdown-1
if (countdown==0) then ...
p.s.: no, you can't/shouldn't "stop" a Lua script and just wait for a certain time because this would stop the whole game (including all animations etc.) and this would be pretty bad.
note that CC runs with 50 fps.
this means: count to 20 (variable +/- 1 each frame) = 1 second
once (countdown setup):
countdown=10
each frame (increase/decrease countdown, check):
countdown=countdown-1
if (countdown==0) then ...
p.s.: no, you can't/shouldn't "stop" a Lua script and just wait for a certain time because this would stop the whole game (including all animations etc.) and this would be pretty bad.
I am dumb to recognize where to add 'em
any basic example please ?
Anyway, i'll try to do some, if i done, i post.
Blazz helped meh, delay work perfect, but i got new problem, sound.
wtf i need to do, to make playsound(cc.bfg.sfx_attack) play just once ? :<

any basic example please ?

Anyway, i'll try to do some, if i done, i post.
Blazz helped meh, delay work perfect, but i got new problem, sound.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function cc.bfg.attack(attack)
if (weapon_shots == 0) then cc.timer = 0 end
if (attack == 1 and weapon_shots == 0) then
weapon_shots = weapon_shots + 1
cc.timer = os.clock()
end
playsound(cc.bfg.sfx_attack)
if (weapon_shots > 0 and cc.timer > 0 and os.clock() > cc.timer + 1) then
cc.timer = 0
id=createprojectile(cc.bfg.ball.id)
projectiles[id]={}
projectiles[id].ignore=playercurrent()
projectiles[id].x=getplayerx(0)+(6*getplayerdirection(0))+math.sin(math.rad(getplayerrotation(0)))*10.0
projectiles[id].y=getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)))*10.0
projectiles[id].sx=math.sin(math.rad(getplayerrotation(0)))*15.0
projectiles[id].sy=-math.cos(math.rad(getplayerrotation(0)))*15.0
recoil(2)
endturn()
end
end
if (weapon_shots == 0) then cc.timer = 0 end
if (attack == 1 and weapon_shots == 0) then
weapon_shots = weapon_shots + 1
cc.timer = os.clock()
end
playsound(cc.bfg.sfx_attack)
if (weapon_shots > 0 and cc.timer > 0 and os.clock() > cc.timer + 1) then
cc.timer = 0
id=createprojectile(cc.bfg.ball.id)
projectiles[id]={}
projectiles[id].ignore=playercurrent()
projectiles[id].x=getplayerx(0)+(6*getplayerdirection(0))+math.sin(math.rad(getplayerrotation(0)))*10.0
projectiles[id].y=getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)))*10.0
projectiles[id].sx=math.sin(math.rad(getplayerrotation(0)))*15.0
projectiles[id].sy=-math.cos(math.rad(getplayerrotation(0)))*15.0
recoil(2)
endturn()
end
end
wtf i need to do, to make playsound(cc.bfg.sfx_attack) play just once ? :<
edited 2×, last 30.05.10 06:32:56 pm

that's why I suggested to use a counter variable. it has to be incremented/decremented in the weapon update or attack (not draw!) function!
most scripts which allow you to shoot multiple projectiles are using such a timer. just check them (pistol for example). it's really simple! you can use the global weapon_timer variable for it.
for a sample of a looping sound check the dynamite script.
principle:





DC has written:
never use os.clock() for action related stuff in your Carnage Contest weapon scripts because os.clock() is different on each PC

Like math.random


Anyway, thx DC, i'll try use Pistol and TNT as examples
