|
|
red highlight over selected entities :)
#238426
11/27/08 08:15
11/27/08 08:15
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Ever play a game and when you mouse over an entity the entity has like a little red thingy around it? Well I've wanted this in my game for ever and tonight I had the time to code it. It's small but I never seen this on 3dgamestudio before. So here it is! Check it out it's stand alone! Just copy everything below into your game anywhere above the main function. Then in your main while loop include this line: mouseOver(); That's pretty much it people! Let me know what you think. P.S. Here is a short film on how it works in my test level for my multiplayer game http://www.filesend.net/download.php?f=20f7722eb647b47e07ce9bf0c908bbe5
////////////////////mouse over
ENTITY* mouse_old;
ENTITY* mouse_old_clone;
STRING* mouseEntStr = "#50";
ENTITY* tempEnt;
#define id skill1
#define owner skill99
MATERIAL* redHighlight=
{
ambient_red = 255;
ambient_green = 0;
ambient_blue = 0;
diffuse_red = 255;
diffuse_blue = 0;
diffuse_green = 0;
specular_red = 255;
specular_green = 0;
specular_blue = 0;
}
function mouseOver()
{
if(mouse_old_clone == NULL)
{
mouse_old_clone = ent_create(NULL ,0,NULL);
mouse_old_clone.material = redHighlight;
set(mouse_old_clone,UNTOUCHABLE|TRANSLUCENT|PASSABLE);
mouse_old_clone.id = 123456;
}
if(mouse_ent)
{
mouse_old = mouse_ent;
if(mouse_old != NULL && mouse_old.id != 123456)
{
str_for_entfile(mouseEntStr,mouse_old);
ent_morph (mouse_old_clone, mouseEntStr);
reset(mouse_old_clone,INVISIBLE);
vec_set(mouse_old_clone.x,mouse_old.x);
vec_set(mouse_old_clone.pan,mouse_old.pan);
if(mouse_old.id != 123456)
{
mouse_old_clone.owner = handle(mouse_old);
}
if(mouse_old_clone != NULL)
{
mouse_old_clone.scale_x = 1.1;
mouse_old_clone.scale_y = 1.1;
mouse_old_clone.scale_z = 1.1;
}
}
if(mouse_old.id == 123456)
{
tempEnt = ptr_for_handle(mouse_old.owner);
if(tempEnt == NULL)
{
set(mouse_old_clone,INVISIBLE);
}
}
}
else
{
set(mouse_old_clone,INVISIBLE);
}
}
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: red highlight over selected entities :)
[Re: PadMalcom]
#238495
11/27/08 19:50
11/27/08 19:50
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Ya for some reason half my friends can see it and the other half can't! I dont know why... it was made with fraps... hmmm. Check the code out... just copy and paste it and add that 1 line and that's it. NO THINKING INVOLVED (just the way I like it ;))
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: red highlight over selected entities :)
[Re: VeT]
#259030
04/03/09 14:30
04/03/09 14:30
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
here is a little edited version. you know, you may not want to highlight all entities but some certain ones.(like buildings only in a rts) with the version below, if you want your entity to be highlightable you need set skill98 "highlight" to 1. like my_ent.highlight = 1;
////////////////////mouse over
ENTITY* mouse_old;
ENTITY* mouse_old_clone;
STRING* mouseEntStr = "#50";
ENTITY* tempEnt;
#define id skill1
#define highlight skill98
#define owner skill99
MATERIAL* redHighlight=
{
ambient_red = 255;
ambient_green = 0;
ambient_blue = 0;
diffuse_red = 255;
diffuse_blue = 0;
diffuse_green = 0;
specular_red = 255;
specular_green = 0;
specular_blue = 0;
}
function mouseOver()
{
if(mouse_old_clone == NULL)
{
mouse_old_clone = ent_create(NULL ,0,NULL);
mouse_old_clone.material = redHighlight;
set(mouse_old_clone,UNTOUCHABLE|TRANSLUCENT|PASSABLE);
mouse_old_clone.id = 123456;
}
if(mouse_ent)
{
mouse_old = mouse_ent;
if(mouse_old != NULL && mouse_old.id != 123456 && mouse_old.highlight==1)
{
str_for_entfile(mouseEntStr,mouse_old);
ent_morph (mouse_old_clone, mouseEntStr);
reset(mouse_old_clone,INVISIBLE);
vec_set(mouse_old_clone.x,mouse_old.x);
vec_set(mouse_old_clone.pan,mouse_old.pan);
if(mouse_old.id != 123456)
{
mouse_old_clone.owner = handle(mouse_old);
}
if(mouse_old_clone != NULL)
{
mouse_old_clone.scale_x = 1.1;
mouse_old_clone.scale_y = 1.1;
mouse_old_clone.scale_z = 1.1;
}
}
if(mouse_old.id == 123456)
{
tempEnt = ptr_for_handle(mouse_old.owner);
if(tempEnt == NULL)
{
set(mouse_old_clone,INVISIBLE);
}
}
}
else
{
set(mouse_old_clone,INVISIBLE);
}
}
tanks for the cont Darkness.
Last edited by Quadraxas; 04/03/09 14:30.
3333333333
|
|
|
|