Author Topic: (Random)MovingBullets - by Dr.Thrax  (Read 1490 times)

0 Members and 1 Guest are viewing this topic.

Offline Dr.Thrax

  • Major
  • *
  • Posts: 70
    • Lostgalaxy.de
(Random)MovingBullets - by Dr.Thrax
« on: September 14, 2008, 04:18:52 pm »
Script Name: (Random)MovingBullets
Script Description: You can size a square-room and let bullets like flame-snakes go linear through this room.If a bullet-snake reaches the end of the imaginary room it will turn the direction and move for example from left to the right.You can let it go horizontal and vertical. One more option is the random one... if the random_switch is "1" (so it's on) it will change the direction in a random way but will never leave the square-room.
Original Author(s): Dr.Thrax
Core Version: the newest (14.09.2008)
Code:


(2 Flamewalls are moving in different directions)

The Code:

procedure MovingBullets(velo_speed : single; bulletindex, radius , bullets , bullet_interspace, min_steps , max_steps , random_switch : integer; bullettype : byte);

Parameter Info:
  velo_speed(Single): The speed the bullets are moving in one direction.
¬  bulletindex(integer): The index of the array bullet[index][...].
  radius(integer): The size of the square-room.The bullet-string starts in the middle of this room
¬  bullets(integer): The bullets spawned in one bullet-string.
¬  bullet_interspace(integer): The space between two spawned bullets in one bullet-string.
¬  min_steps,max_steps(integer): The steps after which a bullet-string will change its direction (only used with random, so it will create a random number between min_steps and max_steps).
¬  random_switch(integer): If = 1 then the bullet-string goes random.
¬  bullettype(byte): The type of bullet. (I used Flames ; type = 5)



Quote
var
bullet : array[0..10] of array[0..10] of single;

procedure ActivateServer();
begin
bullet[1][1] := 0; //constant xstart , where the flames are emitted at the beginning
bullet[1][2] := 0; //constant ystart ,where the flames are emitted at the beginning
bullet[1][3] := 0; //bullet_x , where the flames are emitted during moving
bullet[1][4] := 0; //bullet_y , where the flames are emitted during moving
//bullet[1][1+3] and bullet[1][2+4] has to be the same (x and y koordinates) , otherwise it won't work
bullet[1][5] := 1; //positiv/negativ multiplicator , default = 1 (the direction , the bullets move)
bullet[1][6] := -1; //bullets moving , horizontal = 1 , vertikal = -1
bullet[1][7] := 10; //constant counter
bullet[1][8] := 10; //counter , after reaching "0" a random direction will be choosen for the bullets
bullet[1][9] := 0; //constant seconds (default: 0)
bullet[1][10] := 0; //seconds , after reaching "0" the bullets-moving goes on
//bullet[1][9] and bullet[1][10] have to be the same , otherwise it won't work
//Please do not change any value during a procedure is running , it will not work!
end;

procedure MovingBullets(velo_speed : single; bulletindex, radius , bullets , bullet_interspace, min_steps , max_steps , random_switch : integer; bullettype : byte);
var
i, w, rand1,rand2 : integer;
begin
rand1 := 0;
rand2 := 0;
w := 0;
if bullet[bulletindex][10] = 0 then
begin

for i := 0 to bullets do
¬  ¬  ¬  ¬  ¬  ¬ begin
¬  ¬  ¬  ¬  ¬  ¬ if bullet[bulletindex][6] < 0 then
¬  ¬  ¬  ¬  ¬  ¬    CreateBullet(bullet[bulletindex][3], bullet[bulletindex][4]+w,0, bullet[bulletindex][5]* velo_speed,100,bullettype,0)
¬  ¬  ¬  ¬  ¬  ¬ else if bullet[bulletindex][6] > 0 then
¬  ¬  ¬  ¬  ¬  ¬    CreateBullet(bullet[bulletindex][3]+w, bullet[bulletindex][4], bullet[bulletindex][5]* velo_speed, 0,100,bullettype,0);
   ¬  w := w + bullet_interspace;
¬  ¬  ¬  ¬  ¬  ¬ if bullet[bulletindex][6] < 0 then
¬  ¬  ¬  ¬  ¬  ¬    CreateBullet(bullet[bulletindex][3], bullet[bulletindex][4]-w, 0, bullet[bulletindex][5]* velo_speed,100,bullettype,0)
¬  ¬  ¬  ¬  ¬  ¬ else if bullet[bulletindex][6] > 0 then
¬  ¬  ¬  ¬  ¬  ¬    CreateBullet(bullet[bulletindex][3]-w, bullet[bulletindex][4], bullet[bulletindex][5]* velo_speed, 0,100,bullettype,0);
   ¬  end;
if random_switch = 1 then
begin
   if bullet[bulletindex][8] = 0 then
   ¬  ¬  ¬  ¬  ¬ begin
   ¬  ¬  ¬  ¬  ¬ while (rand1 = 0) do rand1 := random(0,3)-1;
   ¬  ¬  ¬  ¬  ¬ bullet[bulletindex][6] := bullet[bulletindex][6] * (-1);
   ¬† ¬† ¬† ¬† ¬†bullet[bulletindex][5] := bullet[bulletindex][5] * (-1);
   ¬† ¬† ¬† ¬† ¬†bullet[bulletindex][8] := random(min_steps,max_steps);
   ¬  ¬  ¬  ¬  ¬ end;
   bullet[bulletindex][8] := bullet[bulletindex][8] - 1;
end;
if (Distance(bullet[bulletindex][3],bullet[bulletindex][4],bullet[bulletindex][1],bullet[bulletindex][2]) >= radius) then
   bullet[bulletindex][5] := bullet[bulletindex][5] * (-1);
if bullet[bulletindex][6] > 0 then
   bullet[bulletindex][3] := bullet[bulletindex][3]+ ((velo_speed*20) * bullet[bulletindex][5]);
if bullet[bulletindex][6] < 0 then
   bullet[bulletindex][4] := bullet[bulletindex][4]+ ((velo_speed*20) * bullet[bulletindex][5]);
bullet[bulletindex][10] := bullet[bulletindex][9];
end;
if (bullet[bulletindex][10] <> 0) then
   bullet[bulletindex][10] := bullet[bulletindex][10] - 1;
end;

procedure AppOnIdle(Ticks: integer);
begin
//example: MovingBullets(1, 1, 150, 2, 20, 3, 20, 1, 5);
end;

You have to create this array bullet[index][...]. Most important things are saved in these arrays. So if you want to use this procedure twice , you just have to add a array with the index 2 (bullet[2][1-10]) and modifiy them.
Once you have these array's you can add the procedure in the "AppOnIdle" procedure.

I guess it works with most of the bullets , but i prefer the flame.
For what exactly it is usefull , I can't tell ... I think i'll find a use for it!
Maybe you could add these to climb/adventure maps in several rooms to hinder the players to go through

greets Thrax
« Last Edit: September 14, 2008, 05:03:25 pm by Dr.Thrax »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: (Random)MovingBullets - by Dr.Thrax
« Reply #1 on: September 15, 2008, 07:19:40 am »
sounds cool  [retard]

[edit1]
I know a way to use this :) Flag Guardians.

It should be easier to modify. [edit2] But it doesn't matter so much.
« Last Edit: September 15, 2008, 07:42:20 am by Gizd »

Offline Dr.Thrax

  • Major
  • *
  • Posts: 70
    • Lostgalaxy.de
Re: (Random)MovingBullets - by Dr.Thrax
« Reply #2 on: September 15, 2008, 08:16:09 am »
if you find a way to handle it easier for the user , plz tell me .

Offline PKS|Shooter

  • Soldier
  • **
  • Posts: 130
  • Dont fuck with us!
    • PKS - La Familia
Re: (Random)MovingBullets - by Dr.Thrax
« Reply #3 on: September 17, 2008, 03:24:27 pm »
owned xD

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: (Random)MovingBullets - by Dr.Thrax
« Reply #4 on: September 23, 2008, 01:27:25 am »
Wow, I was goin to make something similar to this for a script I was making, though i might come back to the script.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs