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;
}