Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
particle problem #149766
08/23/07 08:46
08/23/07 08:46
Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
Frederick_Lim Offline OP
User
Frederick_Lim  Offline OP
User

Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
I port the laser script found in User Contribution to lite-c, but I always got E1515 in particle routine.
Code:
function laser_top()
{
VECTOR temp; vec_zero(temp);
my.pan=you.pan;
set(my,PASSABLE);
var shooting=0;
VECTOR mytarget;
var rotation_radius = 1500;
while (1)
{
my.pan=90;
my.tilt=-30;
shooting=0;
my.skill1 += 20 * time_step;
temp.x = my.x - rotation_radius * cos(my.skill1);
temp.y = my.y - rotation_radius * sin(my.skill1);
//temp.z = my.z - rotation_radius * sin(my.skill1);
c_trace(my.x, temp, IGNORE_ME|IGNORE_PASSABLE);
if (result != 0) // the player has hit something
{
if (you != NULL)
{
if((you != NULL)&&(you.skill11==2))
{
while((you != NULL)&&(you.healthpoints>0))
{
mytarget.x=you.x;
mytarget.y=you.y;
mytarget.z=you.z;
vec_set (temp.x,mytarget.x);
vec_sub (temp.x, my.x);
vec_to_angle (my.pan, temp);
if(shooting<=0)
{
snd_play(laser_wav,50,NULL);
vec_for_vertex(temp,my,38);
ent_create(lsrbolt_mdl,temp,laser_bolt);
shooting=random(20);
}
else
{
shooting-=1;
}
wait(1);
}
wait(10);
my.tilt=0;
}
}
}
wait (1);
}
}


function laser_bolt()
{
my.skill20=0;
set(my,TRANSLUCENT);
set(my,BRIGHT);
my.alpha=40;
my.red = 255;
my.green = 0;
my.blue = 0;
my.lightrange = 100;
VECTOR my_vertex;
VECTOR my_vertex2;
var hit_target=0;
my.pan=you.pan;
my.tilt=0;
my.emask |= (ENABLE_ENTITY);
my.event=im_gone;
while ((hit_target==0)&&( my.skill20<100))
{
vec_for_vertex(my_vertex,my,5);
vec_for_vertex(my_vertex2,my,6);
c_trace(my_vertex, my_vertex2, IGNORE_ME|IGNORE_PASSABLE);
if (result == 0)
{
ent_animate(my, "fire", my.skill20, ANM_CYCLE);
my.skill20 +=.2 * time_step;
}
else
{
if (you != NULL)
{
//if ((you != NULL)&&(you.skill11==2))
if (you.skill11==2)
{
you.healthpoints-=75;
vec_scale(normal,10);
effect(sparks,100,my_vertex,normal);
}
}
hit_target=1;
}
//wait(1);
}
wait(10);
ent_remove(me);
}

function sparks(PARTICLE *p)
{
VECTOR temp;
temp.x = random(20) - 10;
temp.y = random(20) - 10;
temp.z = random(20) - 10;
vec_add(p.vel_x, temp);
p.alpha = 70 + random(30);
p.red=255;
p.blue=0;
p.green=0;
p.size = 2;
my.flags |= (BRIGHT|MOVE);
p.lifespan = 20;
my.event = fade_sparks;
}

function fade_sparks(PARTICLE *p)
{
p.alpha -= 20*time_step;
if (p.alpha<=0)
{
p.lifespan=0;
}
}



If I take out the "PRACTICLE *p" in sparks function, and remove all p. attribute, no error occur.

Code:
function sparks()
{
VECTOR temp;
temp.x = random(20) - 10;
temp.y = random(20) - 10;
temp.z = random(20) - 10;
//vec_add(p.vel_x, temp);
//p.alpha = 70 + random(30);
//p.red=255;
//p.blue=0;
//p.green=0;
//p.size = 2;
/*my.flare = on;
my.bright = on;
my.move = on;*/
my.flags |= (BRIGHT|MOVE);
//p.lifespan = 20;
my.event = fade_sparks;
}



Why?

Last edited by Frederick_Lim; 08/23/07 08:50.
Re: particle problem [Re: Frederick_Lim] #149767
08/23/07 09:45
08/23/07 09:45
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
"p" and "my" are two different things. "p" is a particle and "my" is an entity pointer. So your code won't make sense and will probably crash. Both particles and entities have similar parameters, but setting entity parameters in a particle function is probably not what you intended.

Re: particle problem [Re: Frederick_Lim] #149768
08/23/07 09:47
08/23/07 09:47
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Have you try to rearrange the order of those functions?

function fade_sparks(PARTICLE *p)
{
.....
.....
}

function sparks(PARTICLE *p)
{
.....
.....
}

function laser_bolt()
{
.....
}
function laser_top()
{
.....
}

Re: particle problem [Re: jcl] #149769
08/23/07 13:03
08/23/07 13:03
Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
Frederick_Lim Offline OP
User
Frederick_Lim  Offline OP
User

Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
Yes, my original conversion is all "p."

Code:
function sparks(PARTICLE *p)
{
VECTOR temp;
temp.x = random(20) - 10;
temp.y = random(20) - 10;
temp.z = random(20) - 10;
vec_add(p.vel_x, temp);
p.alpha = 70 + random(30);
p.red=255;
p.blue=0;
p.green=0;
p.size = 2;
p.flags |= (BRIGHT|MOVE);
p.lifespan = 20;
p.event = fade_sparks;
}



But still cause E1515.

You may download the code and try lite-c laser

If you remark the "effect(sparks,100,my_vertex,nullvector);", the laser fire nicely.

If remove "PARTICLE *p" in sparks, no E1515 crash, like this
Code:
function sparks()
{
/*
VECTOR temp;
temp.x = random(20) - 10;
temp.y = random(20) - 10;
temp.z = random(20) - 10;
vec_add(p.vel_x, temp);
p.alpha = 70 + random(30);
p.red=255;
p.blue=0;
p.green=0;
p.size = 2;
p.flags |= (BRIGHT|MOVE);
p.lifespan = 20;*/
my.event = fade_sparks;
}



I know it does not make sense, but in case like this
Code:
function sparks(PARTICLE *p)
{
}


It still crash.

Last edited by Frederick_Lim; 08/23/07 14:03.
Re: particle problem [Re: Frederick_Lim] #149770
08/28/07 02:30
08/28/07 02:30
Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
Frederick_Lim Offline OP
User
Frederick_Lim  Offline OP
User

Joined: Oct 2003
Posts: 825
22�21'24"N 114�07'30"E
Post deleted by Frederick_Lim

I found my problem because I haven't include the parameter type in function declaration:
Code:
function sparks(PARTICLE *);
function fade_sparks(PARTICLE *);



Last edited by Frederick_Lim; 08/28/07 05:21.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1