PDA

View Full Version : Lasers (SCRIPT)



BaX
4th March 2013, 10:58
Hi,

Do you know any map with moving lasers which are killing people? Or maybe u now script than it would be nice if you will share of it, coz i need it to my map :D

Earliboy
4th March 2013, 11:51
Just make an laser texture and put an trigger to it > done

Moving lasers = just move the lasers itself, for the trigger i think its trigger linkTo(laser.origin);

pollo
4th March 2013, 18:57
Do this:

Make triggers -> hurt over all the lasers you have. Once made them , select all and give them these values (important: select all of them in one time, not one by one):

key: targetname
value: trig_dmg

key: dmg
value: <damage> (ammount of damage. values over 100 = instant death)

Now select the lasers you made, script -> brushmodel and give them these values

key: targetname
value: lasers

In the script:


main()
{
thread lasers();
}

lasers()
{
lasers = getent("lasers","targetname");
trig_damage = getent("trig_dmg","targetname");
trig_damage enablelinkto();
trig_damage linkto(lasers); // linking the damage trigger to the lasers

while(1)
{
lasers moveto((x,y,z),time,accel time,decel time);
lasers waittill("movedone");
lasers moveto((x,y,z),time,accel time,decel time);
lasers waittill("movedone");
}
}

Mitch
4th March 2013, 19:39
You can use trigger_multiple too. You will need to script the damage, but you can disable the damage when you want and hide the brushmodel.

Also you need to add this to the script before the loop starts:


lasers notsolid();


Edit: Just to be clear, you need to use enableLinkTo() before you can link triggers.

Ni3ls
4th March 2013, 20:41
enableLinkTo() is not needed in COD2, only in COD4 ;)

KillerBoB
4th March 2013, 21:46
enableLinkTo() is not needed in COD2, only in COD4 ;)


Some Triggers need, damage trigger for Example :D

kat_
5th March 2013, 19:58
Hey, combined lasers here



thread lasers();


lasers()
{
laser_1 = getent("laser_1","targetname");
laser_hurt_1 = getent("laser_hurt_1","targetname");
laser_2 = getent("laser_2","targetname");
laser_hurt_2 = getent("laser_hurt_2","targetname");
laser_3 = getent("laser_3","targetname");
laser_hurt_3 = getent("laser_hurt_3","targetname");
laser_4 = getent("laser_4","targetname");
laser_hurt_4 = getent("laser_hurt_4","targetname");
laser_5 = getent("laser_5","targetname");
laser_hurt_5 = getent("laser_hurt_5","targetname");
laser_6 = getent("laser_6","targetname");
laser_hurt_6 = getent("laser_hurt_6","targetname");
laser_7 = getent("laser_7","targetname");
laser_hurt_7 = getent("laser_hurt_7","targetname");
laser_hurt_1 linkto(laser_1);
laser_hurt_2 linkto(laser_2);
laser_hurt_3 linkto(laser_3);
laser_hurt_4 linkto(laser_4);
laser_hurt_5 linkto(laser_5);
laser_hurt_6 linkto(laser_6);
laser_hurt_7 linkto(laser_7);

while(1)

{
laser_1 movey(200,0.7);
laser_2 movey(100,0.7);
laser_3 movey(-100,0.7);
laser_4 movex(-150,0.7);
laser_5 movex(150,0.7);
laser_6 rotateyaw(90,0.7);
laser_7 rotateyaw(-90,0.7);
wait 1;
laser_1 movey(-200,0.7);
laser_2 movey(-100,0.7);
laser_3 movey(100,0.7);
laser_4 movex(150,0.7);
laser_5 movex(-150,0.7);
laser_6 rotateyaw(-90,0.7);
laser_7 rotateyaw(90,0.7);
wait 1;
}
}

IzNoGoD
5th March 2013, 20:43
If there is anything solid about the lasers, your movex and movey will probably fuck up their movements.

To ensure proper movements, always use moveto()

kung foo man
6th March 2013, 04:12
Whats wrong with movex()?

BaX
6th March 2013, 12:24
I made something like this :


trap1()
{
kosa = getent("kosa_1", "targetname");
kosa_kill = getent("kosa_2", "targetname");
kosa_kill enablelinkto();
kosa_kill linkto(kosa);
{
kosa movex(82,5,2);
wait (0.5);
kosa movex(-82,5,2);
wait (0.5);
}
}

And it gives me that error:

189

BaX
6th March 2013, 12:24
I made something like this :

trap1()
{
kosa = getent("kosa_1", "targetname");
kosa_kill = getent("kosa_2", "targetname");
kosa_kill enablelinkto();
kosa_kill linkto(kosa);
{
kosa movex(82,5,2);
wait (0.5);
kosa movex(-82,5,2);
wait (0.5);
}
}

And it gives me that error:

189

kat_
6th March 2013, 13:39
@BaX


main()
{

thread OnPlayerConnect();

}


OnPlayerConnect()
{

for(;;)
{

level waittill("connecting", user);
user thread trap1();

}
}



trap1()
{
kosa = getent("kosa_1", "targetname");
kosa_kill = getent("kosa_2", "targetname");
kosa_kill enablelinkto(); //i think it's useless
kosa_kill linkto(kosa);
while(1)
{
kosa movex(82,5,2);
wait 0.5;
kosa movex(-82,5,2);
wait 0.5;
}
}

BaX
6th March 2013, 14:36
It means that i need to add all traps which have linkto into this line ?

Tally
6th March 2013, 16:20
I made something like this :

trap1()
{
kosa = getent("kosa_1", "targetname");
kosa_kill = getent("kosa_2", "targetname");
kosa_kill enablelinkto();
kosa_kill linkto(kosa);
{
kosa movex(82,5,2);
wait (0.5);
kosa movex(-82,5,2);
wait (0.5);
}
}

And it gives me that error:

189

When you get an error like that - calling an entity for which there is more than 1 - it is telling you that you need to use getEntArray() (plural) and not getEnt() (singlular).

When you use getEntArray() you must use a for() loop to find each member of the entity set. So, this is what you want:


trap1()
{
kosa = getentArray("kosa_1", "targetname");
kosa_kill = getentArray("kosa_2", "targetname");

for( i=0; i < kosa.size; i++ )
{
for( j=0; j < kosa_kill.size; j++ )
{
kosa_kill[j] enablelinkto();
kosa_kill[j] linkto( kosa[i] );

kosa[i] movex(82,5,2);
wait( 0.5 );
kosa[i] movex(-82,5,2);
wait( 0.5 );
}
}
}

Tally
6th March 2013, 16:22
@BaX


main()
{

thread OnPlayerConnect();

}


OnPlayerConnect()
{

for(;;)
{

level waittill("connecting", user);
user thread trap1();

}
}



trap1()
{
kosa = getent("kosa_1", "targetname");
kosa_kill = getent("kosa_2", "targetname");
kosa_kill enablelinkto(); //i think it's useless
kosa_kill linkto(kosa);
while(1)
{
kosa movex(82,5,2);
wait 0.5;
kosa movex(-82,5,2);
wait 0.5;
}
}

That code completely ignores the error stated in his first post, as it is still using getEnt() and not getEntArray().

IzNoGoD
6th March 2013, 16:30
@Tally

Your code would make the lasers wait for one another to finish their "run"

Tally
6th March 2013, 16:37
@Tally

Your code would make the lasers wait for one another to finish their "run"

It's not "my code". I was merely demonstrating how to use for() loops to find each member of a class. I did not test the code for efficiency or otherwise. You really do need to stop thinking everything is some sort of contest, where you are always the hero.

BaX
7th March 2013, 08:02
Ok thanks a lot for help it worked :)

But i have one more problem do you know why this trap work only once?


trap5()
{
reka = getent("reka_1", "targetname");
trig = getent("t3","targetname");
reka_kill = getent("reka_kill", "targetname");
reka_kill enablelinkto();
reka_kill linkto(reka);
{
trig waittill ("trigger");

reka movex(208,0.7);
reka waittill ("movedone");
wait (0.5);
reka movex(-208,0.7);
reka waittill ("movedone");
wait (6);
}
}

Jeplaa
7th March 2013, 08:07
reka movex(208,0.7);
reka waittill ("movedone");
wait (0.5);
reka movex(-208,0.7);
reka waittill ("movedone");
wait (6);

should be in a loop or thread it as loop... I'm not sure which method is better and correct.

BaX
7th March 2013, 08:11
But can you made example script for me?

BaX
7th March 2013, 09:02
Ok i made it in this way and now it work, thanks man :)


trap5()
{
reka = getent("reka_1", "targetname");
trig = getent("t3","targetname");
reka_kill = getent("reka_kill", "targetname");
reka_kill enablelinkto();
reka_kill linkto(reka);
{
trig waittill ("trigger");

reka movex(208,0.7);
reka waittill ("movedone");
wait (0.5);
reka movex(-208,0.7);
reka waittill ("movedone");
wait (6);
thread trap_5();
}
}

This is result :


http://www.xfire.com/video/5e9590

kung foo man
7th March 2013, 09:38
Nice map :)

Jeplaa
7th March 2013, 11:27
Sorry for no response, I was busy.
I'm glad that you done it.