Gamestudio Links
Zorro Links
Newest Posts
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
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AbrahamR, 7th_zorro, dr_panther, 1 invisible), 702 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Local Pointer ! #343711
10/09/10 12:45
10/09/10 12:45
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
How can I create an ENTITY pointer which must be LOCAL for a certain entity. I need this for my AI - every NPC has a target1 ponter which must lead to a detected enemy.
Here is the code:

Code:
action ally()
{
ENTITY*target1;
if (my.status==attacking) 
{................}
........
my.event=detect_target;
}

function detect_target ()
{
	 if (event_type == EVENT_DETECT) 
  {
  	if (you.skill2==1)  // enemy detected
  	{
     my.status=attacking; target1=you;       }
   }
}



But the functions just can't recognize the pointer because it is local.

Any ideas how to make this little pointer local BUT recognized by the other functions?

Re: Local Pointer ! [Re: mEnTaL] #343712
10/09/10 13:21
10/09/10 13:21
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
use a skill instead.


3333333333
Re: Local Pointer ! [Re: Quad] #343713
10/09/10 13:49
10/09/10 13:49
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
But the skill can't be used as a pointer.

my.skill15=you;
my.skill15.x=36;

and the engine says : " 'x' is not a member of a function "
I need I pointer local for the entity, but recognized by the other functions.

Re: Local Pointer ! [Re: mEnTaL] #343714
10/09/10 14:04
10/09/10 14:04
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
define the "ENTITY*target1;" outside of the action,

in the enemy-action put in "target1=my;"


Last edited by jane; 10/09/10 14:09.
Re: Local Pointer ! [Re: jane] #343715
10/09/10 14:17
10/09/10 14:17
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
If i put ENTITY*target1; outside the action then it will be a global entity and that means all my allies will shoot at the same target. My idea is to make every ally to have its own target1 entity and shoot at it.

Other ideas?

Re: Local Pointer ! [Re: mEnTaL] #343716
10/09/10 14:49
10/09/10 14:49
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
try "ENTITY* target1 = you;"

other

"STRING* target1;"

other

"STRING* target1 = you;"

Re: Local Pointer ! [Re: jane] #343718
10/09/10 15:12
10/09/10 15:12
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
you can use a handle:
Code:
action ally()
{
ENTITY*target1;
if (my.status==attacking) 
{................}
........
my.event=detect_target;
my.skill99 = handle(target1);
}

function detect_target ()
{
ENTITY* target1 = ptr_for_handle(my.skill99);
	 if (event_type == EVENT_DETECT) 
  {
  	if (you.skill2==1)  // enemy detected
  	{
     my.status=attacking; 
target1=you;      
 }
   }
my.skill99 = handle(target1);
}




Visit my site: www.masterq32.de
Re: Local Pointer ! [Re: MasterQ32] #343721
10/09/10 15:25
10/09/10 15:25
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
You can also do it like that:

my.skill15 = you;
((ENTITY*)my.skill15).x = 36;

But using a handle is safer.

Re: Local Pointer ! [Re: Saturnus] #343722
10/09/10 15:31
10/09/10 15:31
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The entity-struct already has an entity-pointer, called my.parent.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Local Pointer ! [Re: Superku] #343802
10/10/10 14:23
10/10/10 14:23
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
@Richi007 I tried your way, but when the event detect_target() is executed the engine crashes ("Don't send" error). There are no syntax errors, but maybe grammatic?

The others - Maybe I get something from your ideas, but can you give me a code example for my case, cuz I'm still not so skillful programmer.

Page 1 of 2 1 2

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