English Lua Scripts/Questions/Help

89 replies
Goto Page
To the start Previous 1 2 3 4 5 Next To the start
03.10.09 07:34:26 pm
Up
Nemesis
User
Offline Off
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:
Spoiler >


may anyone help me pls ?
edited 1×, last 16.09.10 05:07:07 pm
03.10.09 07:39:21 pm
Up
RAVENOUS
BANNED
Offline Off
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:
Spoiler >


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
03.10.09 09:55:05 pm
Up
DC
Admin
Online On
you can actually do it much easier and better. the original script already is not the best solution

like
Code:
1
2
3
4
for i=-3,4,1 do
     ...
     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
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
04.10.09 01:27:02 pm
Up
RAVENOUS
BANNED
Offline Off
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.
"A work of art is the unique result of a unique temperament." - Oscar Wilde
04.10.09 02:47:00 pm
Up
Vectarrio
User
Offline Off
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
04.10.09 03:30:24 pm
Up
RAVENOUS
BANNED
Offline Off
Mortar doesn't jump, it explods after impact.
"A work of art is the unique result of a unique temperament." - Oscar Wilde
06.10.09 07:46:51 pm
Up
Vectarrio
User
Offline Off
I think it must be like grenade.
06.10.09 07:50:02 pm
Up
DC
Admin
Online On
simply take the grenade code and allow to throw multiple grenades...

moreover use another image for cc cmd drawinhand in the weapon draw function

moreover you should remove the charging part and "shoot" the grenades with a constant speed.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
06.10.09 07:55:51 pm
Up
Vectarrio
User
Offline Off
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
09.01.10 09:11:46 pm
Up
DC
Admin
Online On
no, that's impossible. only scripts of the current weapon are parsed.
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
09.01.10 09:14:28 pm
Up
Vectarrio
User
Offline Off
Will be server lua in the next version?
09.01.10 09:21:37 pm
Up
SQ
Moderator
Offline Off
Vectar666 has written:
Will be server lua in the next version?
How should it work?
There is no server commands parsing.
Weapons Scripting Only
09.01.10 09:24:02 pm
Up
Vectarrio
User
Offline Off
Blazzingxx has written:
There is no server commands parsing.

yet?
26.05.10 05:48:39 pm
Up
DC
Admin
Online On
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.

www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
26.05.10 09:20:41 pm
Up
Nemesis
User
Offline Off
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.
Code:
1
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

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
30.05.10 07:19:25 pm
Up
DC
Admin
Online On
× never use os.clock() for action related stuff in your Carnage Contest weapon scripts because os.clock() is different on each PC. it will make your scripts asynchronous (run different for all players) which CAN result in strange bugs. all CC weapon scripts have to be written in a way that guarantees that they run equally on all PCs every time they are executed.
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:
• use cc cmd playsound and assign a channel with the optional channel parameter
• use cc cmd channelplaying to check if the sound is still playing
• play it again (step 1) if it is not playing anymore
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
30.05.10 07:57:08 pm
Up
Nemesis
User
Offline Off
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 i used once with ammo, its different on each PC, lol

Anyway, thx DC, i'll try use Pistol and TNT as examples
30.05.10 08:31:48 pm
Up
DC
Admin
Online On
yes, exactly. random values are bad as well. always set the random seed to a value which is equal at all PCs before using it
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
To the start Previous 1 2 3 4 5 Next To the start