Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (monk12), 1,487 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
"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...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

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 crashes


Here's my code (glass sprite is attached to "glass_action1"):


Code:
#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 Offline
Member
Arrovs  Offline
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 Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You forgot about:
Originally Posted By: Manual
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: Uhrwerk] #427640
08/11/13 10:10
08/11/13 10:10
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Ok, but I have for this function a sprite of size 64x64 pixels and I even set the _SIZE to 800 ,even though, the sprite is simply as small as a dot!! And it doesn't move....

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 Offline
Expert
Uhrwerk  Offline
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...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Here's my corrected code


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] #427685
08/12/13 11:57
08/12/13 11:57
Joined: Jul 2013
Posts: 66
Don't have a one...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Must I include another file?

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 Offline
Serious User
PadMalcom  Offline
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:

Code:
function glass_shot()
{
  beep();
}



then add:

Code:
function glass_shot()
{
  if(event_type == EVENT_SHOOT)
  {
    beep();
  }
}



And so on. This is called debugging wink

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...
D
DonaldThief Offline OP
Junior Member
DonaldThief  Offline OP
Junior Member
D

Joined: Jul 2013
Posts: 66
Don't have a one...
Originally Posted By: PadMalcom
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....



Originally Posted By: PadMalcom


- Remove line by line of grass_shot. E.g. start with:

Code:
function glass_shot()
{
  beep();
}



then add:

Code:
function glass_shot()
{
  if(event_type == EVENT_SHOOT)
  {
    beep();
  }
}



And so on. This is called debugging wink


I know this method and I'll see that....

But.....



Originally Posted By: PadMalcom


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.htm

Look at warning W1511

Re: "effect_sprite()" causes engine crash [Re: DonaldThief] #427733
08/12/13 20:42
08/12/13 20:42
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Yes, I know why you put a wait there and it is correct. What I mean is, that the me pointer might not longer be pointing on your glass object after the wait(1). It might already point to the next entity or nowhere.

Does your code work when you comment the line with the "effect_sprite"? Since you said you know how to debug I'm sure that it does(?).

Page 1 of 4 1 2 3 4

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