Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 1,246 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Check if entity still exist #387086
11/14/11 08:27
11/14/11 08:27
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Hi folks, how am I able to check if the entity still exist? in C it is able to check a pointer with...

if(ptr) { do something }

But this cant seems to work for ENTITY in 3DGS. Therefore is there anyway I could check if the entity still exist?

Thanks

Re: Check if entity still exist [Re: hanselkoh] #387091
11/14/11 11:02
11/14/11 11:02
Joined: Nov 2009
Posts: 201
Logitek Offline
Member
Logitek  Offline
Member

Joined: Nov 2009
Posts: 201
Maybe you mean something like this?

if (enemy != null) {do something}

Re: Check if entity still exist [Re: Logitek] #387096
11/14/11 11:28
11/14/11 11:28
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Nice try logitek, but that wont work UNLESS you set it up to...

Lets stick with the 'enemy' pointer for simplicity.

When the engine does an 'ent_remove(enemy)', the entity DOES get removed...
BUT the enemy pointer still holds the OLD ADDRESS of where the entity was,
so the if(enemy != NULL) (which is the same as if(!enemy)) will still
show as enemy being 'not zero', and therefore APPARENTLY in existence. FAIL!

So what you need to do is STRAIGHT AFTER the ent_remove, you will also need to
change the enemy pointer to NULL, so any later if's will work as expected.
Code:
action enemy_action()
{
   enemy = me;
   me.health = 100;
   while(me.health>0)
   {
      ## do whatever ##
      wait(1);
   }
   ## run dying animations ##
   ent_remove(me);
   enemy = NULL;
}


BUT REMEMBER, if there any OTHER pointers ANYWHERE in your code that were pointing
to this entity, they will STILL be pointing at the old address...
Catching them and NULLing them is where it gets tricky, and application dependant...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Check if entity still exist [Re: EvilSOB] #387121
11/14/11 15:14
11/14/11 15:14
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
So perhaps the safest way to do it is to use a handle instead of a pointer, and ptr_for_handle for getting temporary pointers to the object -- this'll automatically be NULL when the object has been removed.


Formerly known as JulzMighty.
I made KarBOOM!
Re: Check if entity still exist [Re: JibbSmart] #387184
11/15/11 14:16
11/15/11 14:16
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Thanks guys, enemy = NULL works for me.. just what I wanted. Thanks.


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