Fujita5 - Storm Chasing Game
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Fujita5 - Storm Chasing Game

Official development board of Fujita5
 
HomeSearchLatest imagesRegisterLog in

 

 Lightnings problem

Go down 
2 posters
AuthorMessage
marcrem




Number of posts : 32
Registration date : 2007-03-09

Lightnings problem Empty
PostSubject: Lightnings problem   Lightnings problem Icon_minitimeSat Mar 10, 2007 5:15 pm

Sometimes acknex is having fun giving me errors for nothing. Everything works well, then I ran the game again, and I got those errors everytime the storm was trying to make a lightning strikes:

Lightnings problem 43324591qu3

Now, everytime my conditions are good, the storm starts the lightning function, then I get those errors...

I can't get it.. What's wrong?

the code:

Code:

//The blue ents are buildings, the yellow are clouds
/*
var video_mode = 8;
var video_screen = 1;
var d3d_triplebuffer = 1;
*/
var snd_dist = 450; //set range of 3d sounds here
var flash_dist = 6500; //set lightrange of light flash here

var temporary;
var line_length;
var segment_start;
var segment_end;
var segment_length;

var line_start[4];
var line_end[4];
var lightning_on = 1; //turn lightning on or off
var pos_pick;
var neg_pick;
var pos_flag;
var neg_flag;
var num_of_pos_ents = 0; //holds number of positive assigned ents
var num_of_neg_ents = 0;
var counter;
var thunder_choice; //choice variable

bmap bmp = "flash3.tga";
bmap bmp2 = "l.bmp";

sound thunder1 = "thunder1.wav";
sound thunder2 = "thunder2.wav";
sound thunder3 = "thunder3.wav";
sound rain = "rain_loop.wav";
var_nsave  rain_handle;

entity* cloud;
entity* not_cloud;

//================================================================================
//
//================================================================================

function fade_lightning()
{
  my.lifespan = 0;
}

function particle_lightning()
{
  temp.x = random(8) - 1;
  temp.y = random(8) - 1;
  temp.z = random(8) - 1;
  vec_set(my.vel_x, temp);
  my.bmap = bmp;
  my.size = 5;
  my.move = on;
  my.bright = on;
  my.lifespan = random(5)+1; // the particles live for a single frame
  my.function = fade_lightning;

}

function particle_lightning2()
{
  temp.x = random(8) - 1;
  temp.y = random(8) - 1;
  temp.z = random(8) - 1;
  vec_set(my.vel_x, temp);
  my.bmap = bmp2;
  my.size = 8;
  my.move = on;
  my.bright = on;
  my.lifespan = random(5)+1; // the particles live for a single frame
  my.transparent = on;
  my.alpha = 30;
  my.function = fade_lightning;
}

function particle_segment()
{
  vec_set(temporary, segment_end);
  vec_sub(segment_end, segment_start);
  segment_length = vec_length(segment_end);
  segment_end.x = (segment_end.x * 5) / segment_length; // create particles every 5 quants
  segment_end.y = (segment_end.y * 5) / segment_length;
  segment_end.z = (segment_end.z * 5) / segment_length;
  while(segment_length > 0)
    {
      effect(particle_lightning, 5, segment_start.x, nullvector);
      effect(particle_lightning2, 1, segment_start.x, nullvector);
      vec_add(segment_start, segment_end);
      segment_length -= 5; // same value here
    }
}

function lightning_effect()
{
  vec_set(temporary, line_start);
  vec_sub(line_end, line_start);
  line_length = vec_length(line_end);
  line_end.x = (line_end.x * 50) / line_length; // create segments every 100 quants
  line_end.y = (line_end.y * 50) / line_length;
  line_end.z = (line_end.z * 50) / line_length;
 
  while(line_length > 0)
  {
    vec_add(line_start, line_end);
    vec_set(segment_start, temporary);
    vec_set(segment_end, line_start);
    segment_end.x += random(40) - 20; // displace the lightning segments (don't make the lightning look like a straight line)
    segment_end.y += random(40) - 20;
    segment_end.z += random(40) - 20;
    particle_segment();
    line_length -= 100; // keep the same value here
  }
}


//================================================================================
// ACTION FOR CLOUDS
//================================================================================
//only the first two lines are important for lightning

action lightning_cloud
{
  my.skill1 = 1;
  num_of_pos_ents += 1; //this will auto increment keep count of pos ents

  my.invisible = on;
  my.scale_x = 3;
  my.scale_y = 3;
  my.scale_z = 0.5;
  my.skin = 6;

  my.transparent = on;
  my.alpha = 35;

  while(me)
  {
    my.pan += 1* time;
    c_move(my, vector(2*time,0,0),nullvector, ignore_passable);
    wait(1);

  }
}

//================================================================================
// ACTION FOR BUILDINGS (lightning targets)
//================================================================================
//only the first two lines are important for lightning

action building
{
  my.skill1 = 2;
  num_of_neg_ents += 1;

  my.invisible = on;
  my.scale_z = 5;
  my.skin = 5;
}

//================================================================================
//
//================================================================================
var lightning_dist = 5000;

function lightning_strike()
{
  //while(1)
  {
    if (random(1) > 0.985 && lightning_on == 1) http://0.9
      {

        pos_pick = int(random(num_of_pos_ents)+1); //get a random pos ent num
        neg_pick = int(random(num_of_neg_ents)+1); //get a random neg ent num


        pos_flag = 0;
        counter = 1;
        you = ent_next(NULL); //get first entity
        while(you != 0 && pos_flag == 0)
        {
          if(you.skill1 == 1 && counter == pos_pick)
            {
              vec_set(line_start.x, you.x);
              pos_flag = 1;
              cloud = you;
            }
          if(you.skill1 == 1 && counter != pos_pick)
            {
              not_cloud = you;
            }
          counter += 1;
          you = ent_next(YOU); //get next entity
        }


      neg_flag = 0;
      counter = 1;
      you = ent_next(NULL); //get first entity
      while(you != 0 && neg_flag == 0)
        {
          if(you.skill1 == 2 && counter == neg_pick)/////
          {
            vec_set(line_end.x, you.x);
            neg_flag = 1;
          }
          counter += 1;
          you = ent_next(YOU); //get next entity
        }

    if(vec_dist(line_start.x, line_end.x) < 6000)// strike only if closer than 325
      {
        //create lightning bolt
        lightning_effect();

        //flash cloud
        cloud.red = 127;  // set amount of red in flash here
        cloud.green = 128; // set amount of green in flash here
        cloud.blue = 255;  // set amount of blue in flash here
        cloud.light = on;
        cloud.lightrange = flash_dist;
        wait(2);

        //play random thunder
        thunder_choice = int(random(6)); // returns whole numbers 0 to 5
        if(thunder_choice == 0 || thunder_choice == 3){ent_playsound(cloud, thunder1, snd_dist);}
        if(thunder_choice == 1 || thunder_choice == 4){ent_playsound(cloud, thunder2, snd_dist);}
        if(thunder_choice == 2 || thunder_choice == 5){ent_playsound(cloud, thunder3, snd_dist);}

        //turn off cloud flash
        cloud.light = off;
        cloud.lightrange = 0;
      }
    }
  wait (1);
  //}
}




//================================================================================
//
//================================================================================
//rain_handle = snd_loop(rain, 80, 0); //comment out to turn off rain background
Back to top Go down
xXxGuitar511




Number of posts : 4
Registration date : 2007-03-09

Lightnings problem Empty
PostSubject: Re: Lightnings problem   Lightnings problem Icon_minitimeTue Mar 13, 2007 10:33 pm

Hmmm... I started working on this, but never finished it. Do you have it working now?
Back to top Go down
marcrem




Number of posts : 32
Registration date : 2007-03-09

Lightnings problem Empty
PostSubject: Re: Lightnings problem   Lightnings problem Icon_minitimeTue Mar 13, 2007 10:55 pm

No.. No news.. Did you download the source of the game?
Back to top Go down
Sponsored content





Lightnings problem Empty
PostSubject: Re: Lightnings problem   Lightnings problem Icon_minitime

Back to top Go down
 
Lightnings problem
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Fujita5 - Storm Chasing Game :: Scripting-
Jump to: