Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
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
0 registered members (), 631 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
Success! Entity Selection #145128
08/01/07 21:26
08/01/07 21:26
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
Hi folks,

Thanks to a tip from Ottawa, I gave up on the ent_remove bit. I finally have a working entity selection code, and wow, I was really just missing something small. No need to add or remove the selection cursor, only change it to match the next entities position.

Now you can select any entity within the mouse range, deselect by right clicking, or tab through entities (this is buggy, and needs fixing, because it tends to only want to pick certain entities)

But it works pretty good, if you downloaded my rar file from the Entity: Removal post, then you can just swap enemie.c code, with this.

Whew!

Code:
//#Includes
#include <acknex.h>
#include <default.c>

//Entity defines
ENTITY* marker_tga;

function marker_orientation () // the positioning of the marker
{
while (my)
{
set (my, PASSABLE);
my.scale_x = .4;
my.scale_y = .4;
my.scale_z = .4;
my.tilt = 90;
wait (1);
}
}

function enemy_selection() // the event that controls marker placement
{
if ((event_type == EVENT_CLICK) && (marker_tga == NULL))
{
marker_tga = ent_create ("marker.tga", vector (my.x, my.y, my.z -30), marker_orientation);
}

if ((event_type == EVENT_SCAN) && (key_tab == 1) && (marker_tga == NULL))
{
marker_tga = ent_create ("marker.tga", vector (my.x, my.y, my.z -30), marker_orientation);
}

if ((event_type == EVENT_CLICK) && (marker_tga != NULL))
{
reset (marker_tga, INVISIBLE);
vec_set (marker_tga.x, my.x);
vec_set (marker_tga.y, my.y);
vec_set (marker_tga.z, my.z -30);
}

if ((event_type == EVENT_SCAN) && (key_tab == 1) && (marker_tga != NULL))
{
reset (marker_tga, INVISIBLE);
vec_set (marker_tga.x, my.x);
vec_set (marker_tga.y, my.y);
vec_set (marker_tga.z, my.z -30);
}
if (mouse_right == 1)
{
set (marker_tga, INVISIBLE);
}
}

action test_enemy ()
{
my.emask = ENABLE_SCAN | ENABLE_CLICK | ENABLE_RIGHTCLICK | USE_AABB;
my.event = enemy_selection;
}



Last edited by oldschoolj; 08/01/07 21:50.

you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: Success! Entity Selection [Re: oldschoolj] #145129
08/01/07 21:40
08/01/07 21:40
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Congrats on getting it to work. Here are some ideas for improvement:

-Unless you think some other part of your code will change the markers properties, the marker_orientation() function doesn't need a loop. (remove the while and wait)

-vec_set (marker_tga.x, my.x); vec_set (marker_tga.y, my.y); vec_set (marker_tga.z, my.z -30); This is strange. vec_set() will set all 3 elements of the vector. No need for 3 instructions. There are two ways to code it:
vec_set(marker_tga.x, my.x); marker_tga.z -= 30;
or
marker_tga.x = my.x; marker_tga.y = my.y; marker_tga.z = my.z - 30;

If you leave the code like that (using vec_set with the y and z element) you might be overwriting other members of the entity struct.

Re: Success! Entity Selection [Re: Excessus] #145130
08/01/07 21:46
08/01/07 21:46
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
thanks for the info, but I tried just doing it without vec-set:

marker_tga.x = my.x /// causes crashes
vec_set (marker_tga.x, my.x) // that only puts it at the enemies "x"

it seems to work fine, but I think your right about that loop, and I'll change it. Please give me an example of how that loop would be important though, in the senario you mentioned.

Oh here is the rar file for the demo, just replace this code in the enemy.c
download demo


you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: Success! Entity Selection [Re: oldschoolj] #145131
08/01/07 23:32
08/01/07 23:32
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi again !

I was looking at your flags

my.emask = ENABLE_SCAN | ENABLE_CLICK | ENABLE_RIGHTCLICK | USE_AABB;

I had a query about the "=" so I tried it and it worked.



I've posted with the help of D3D a table of flags and I was just wondering if this line should be added?

Ottawa

Last edited by Ottawa; 08/01/07 23:43.

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