Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (TipmyPip, izorro), 556 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
C_scan question #124787
04/18/07 03:38
04/18/07 03:38
Joined: Sep 2006
Posts: 148
Ireng Offline OP
Member
Ireng  Offline OP
Member

Joined: Sep 2006
Posts: 148
Does it scan for the nearest entity, or for all of them?
How come I wanna scan for the second nearest entity?


"When the battlefield is under total control, war becomes routine." Old Snake
Re: C_scan question [Re: Ireng] #124788
04/18/07 09:03
04/18/07 09:03
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Quote:

If the my entity has ENABLE_DETECT set, it's event function is triggered once for every detected entity. During the event, event_type is set to EVENT_DETECT and you is set to the detected entity. This way all detected entities can be enumerated.



manual

you want the pointer or distance or position?


nipx

Re: C_scan question [Re: nipx] #124789
04/18/07 09:13
04/18/07 09:13
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Like the manual says c_scan modifies YOU to the pointer to the closest detected entity, and using event_detect all detected entities can be enumerated.

1) Imagine a function SCAN_ENTITIES;

2) In that function you call numberOfEntities = C_SCAN..., gives you the number of detected entities at all the time;

3) Turn the entity detectable using my.enable_detect = on, and call the event that will trigger the detection process, f.e. my.event = SCAN_ENTITIES_EVENT;

4) And now the event funtion (SCAN_ENTITIES_EVENT()):
Code:

if(scanEntityID >= numberOfEntities)
{
return;
}

if(event_type == event_detect)
{
TEMP_SCANNED_ENTITY = you;
scan_array_list[scanEntityID] = you;
scan_array_list[scanEntityID] = handle(TEMP_SCANNED_ENTITY);
scanEntityID += 1;
}




This way you save all detected entities in the handle array list.

5) Dont forget to turn the entities you want to be detected using my.enable_detect = on;

6) Now, when you need to acess those detected entities, just use the handle:

Code:

while (i < numberOfEntities)
{
if (scan_array_list[i])
{
you = ptr_for_handle(scan_array_list[i]);
}
}





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