0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
"effect_sprite()" causes engine crash
#427614
08/10/13 17:49
08/10/13 17:49
|
Joined: Jul 2013
Posts: 66 Don't have a one...
DonaldThief
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2013
Posts: 66
Don't have a one...
|
I made a glass sprite entity, then attached the action "glass_action1" to it. After that, I wanted to make some glass breaking effect when the enemy shoots the glass (using "c_trace" weapon)...... I use "effect_sprite()" function to make the broken glass pieces ,but the engine crashes. Even I used "effect_sprite()" in many other small projects and the same problem occurs, the engine crashesHere's my code (glass sprite is attached to "glass_action1"):
#include <particles.c>
function glass_broken(PARTICLE* glassy)
{
vec_add(glassy.vel_x,vector(random(5)-2.5,random(5)-2.5,random(5)-2.5));
vec_set(glassy.blue,vector(random(255),random(255),255));
set(glassy, MOVE | BRIGHT | TRANSLUCENT);
glassy.alpha = 100;
glassy.size = 16-random(12);
glassy.gravity = 0.2;
glassy.alpha = 50;
glassy.lifespan = 16;
glassy.event = NULL;
}
function glass_shot()
{
if(event_type == EVENT_SHOOT && (mouse_left) && (player_shooting) && (ammo[current_weapon] > 0) && (player_health > 0))
{
effect_sprite("glass_piece1.tga",glass_broken,20,my.x,nullvector);
wait(1);
ent_remove(my);
}
}
action glass_action1()
{
my.pan += 360;
set(my,POLYGON);
my.emask |= ENABLE_SHOOT;
my.event = glass_shot;
if(is(my,TRANSLUCENT) == 0) set(my,TRANSLUCENT);
my.alpha = 50;
}
ThanQ for reading
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: DonaldThief]
#427619
08/10/13 20:40
08/10/13 20:40
|
Joined: Apr 2006
Posts: 159 Latvija
Arrovs
Member
|
Member
Joined: Apr 2006
Posts: 159
Latvija
|
at moment only what i could think of is, you here making 20 pieces every frame if you here making trace to that object. Try to put variable in glass skill for letting it break once.
But now i see wait statement and ent_remove. hard to tell if ent_remove is terminating all other functions as it could happen there is function in next frame which tries to do same thing.
So make skill for breaking. In event you will set my.broken = true <-- or anything like that and destroy it from action. Put there while(my != NULL) cycle or so which will check moment when it needs to create sprite effect and destroy himself.
Just fast ideas - possibly it helps. If that not helps then problem could be in effect_sprite. Easy way to check that is to comment that line and see what happens.
Arrovs once will publish game
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: Arrovs]
#427630
08/11/13 00:20
08/11/13 00:20
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
You forgot about: The emulated particle function (func) looks almost like a normal particle function, but some particle-specific parameters and flags are replaced by entity skills skill60..69 and FLAG7 : vel_x/y/z => _VEL_X/Y/Z; gravity => _GRAVITY; size => _SIZE; lifespan => _LIFESPAN; you => _CREATOR; MOVE => _MOVE . BEAM and STREAK are not supported. http://www.conitec.net/beta/particles_c.htm
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: DonaldThief]
#427644
08/11/13 12:35
08/11/13 12:35
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Please post your corrected code.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: Uhrwerk]
#427656
08/11/13 17:02
08/11/13 17:02
|
Joined: Jul 2013
Posts: 66 Don't have a one...
DonaldThief
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2013
Posts: 66
Don't have a one...
|
Here's my corrected code
function glass_broken(PARTICLE* glassy)
{
VECTOR temp;
vec_randomize(temp.x,2);
vec_add(glassy._VEL_X,temp.x);
set(glassy, _MOVE | BRIGHT | TRANSLUCENT);
glassy.alpha = 100;
glassy._SIZE = 800;
glassy._GRAVITY = 0.2;
glassy.alpha = 50;
glassy._LIFESPAN = 16*2;
glassy.event = NULL;
}
function glass_shot()
{
if(event_type == EVENT_SHOOT && (mouse_left) && (player_shooting) && (ammo[current_weapon] > 0) && (player_health > 0))
{
effect_sprite("glass_piece1.tga",glass_broken,20,player1.x,nullvector); //The download link for "glass_piece.tga" is lying below
wait(1);
ent_remove(my);
}
}
action glass_action1()
{
my.pan += 360;
set(my,POLYGON);
my.emask |= ENABLE_SHOOT;
my.event = glass_shot;
if(is(my,TRANSLUCENT) == 0) set(my,TRANSLUCENT);
my.alpha = 50;
}
And here's a download link for the glass piece sprite ("galss_piece1.tga"): I'm the download link!... Click me!!
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: DonaldThief]
#427687
08/12/13 12:58
08/12/13 12:58
|
Joined: Mar 2006
Posts: 1,993 Karlsruhe
PadMalcom
Serious User
|
Serious User
Joined: Mar 2006
Posts: 1,993
Karlsruhe
|
A missing include is not causing a crash but a compiler error. What I would do now: - Remove line by line of grass_shot. E.g. start with:
function glass_shot()
{
beep();
}
then add:
function glass_shot()
{
if(event_type == EVENT_SHOOT)
{
beep();
}
}
And so on. This is called debugging Next step would be to read the manual which says that all pointers are only valid until the next wait call. What you do is that you call a wait(1); and then the ent_remove(me) but the "me" might be empty or point to another entity already. So try to save your me pointer in a temporaty pointer and call a delete on that one.
|
|
|
Re: "effect_sprite()" causes engine crash
[Re: PadMalcom]
#427724
08/12/13 19:00
08/12/13 19:00
|
Joined: Jul 2013
Posts: 66 Don't have a one...
DonaldThief
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2013
Posts: 66
Don't have a one...
|
A missing include is not causing a crash but a compiler error. What I would do now:
OK. I don't have a crash here ,the crash problem was solved ,now the problem changed.... - Remove line by line of grass_shot. E.g. start with:
function glass_shot()
{
beep();
}
then add:
function glass_shot()
{
if(event_type == EVENT_SHOOT)
{
beep();
}
}
And so on. This is called debugging I know this method and I'll see that.... But.....
Next step would be to read the manual which says that all pointers are only valid until the next wait call. What you do is that you call a wait(1); and then the ent_remove(me) but the "me" might be empty or point to another entity already. So try to save your me pointer in a temporaty pointer and call a delete on that one.
That's not the problem of course and I have to put the wait(1) instruction before calling ent_remove(me) so that no crash happens In the manual: http://www.conitec.net/beta/engineerrors.htmLook at warning W1511
|
|
|
|