Hey Bright,
Kannst dir den Code mal anschauen, den habe ich gemacht, läuft soweit, sry habe gerade nicht wirklich Zeit sonst haette ich dir das wichtigste raus genommen!
Code:
string Gebaeude = geb1.mdl;
bmap Gebaeude_Selected_bmap = <Metallmine_sel.bmp>;
bmap explode_bmap = <explode.bmp>;
bmap Slider_bmap = <Slider.bmp>;
bmap Slider_HG_bmap = <Slider_HG.bmp>;
font arial_font = "cour",0,16;
Panel Gebaeude_Selected_pan
{
bmap = Gebaeude_Selected_bmap;
pos_x = 600;
pos_y = 200;
Layer=5;
flags =refresh,overlay;
button=100,60,explode_bmap,explode_bmap,explode_bmap,explode,null,null;
}
Panel Slider
{
bmap Slider_HG_bmap;
pos_x=600;
pos_y=200;
VSLIDER = 6,10,230,slider_bmap,0,10,ressis_prozent;
Digits = 100,100,3,arial_font,1,ressis_prozent;
Layer=6;
flags =refresh;
}
string Mspawn_str = "Geeignetes Gebiet um die Metallmine zu platzieren";
var mouse_range = 1000000;
font arial_font3 = "cour",0,14;
text Metallmine_Spawn // Textobjekt definieren
{
font = arial_font3;
Red = 255;
Green= 255;
Blue= 255;
layer = 2;
pos_x = 385;
pos_y = 612;
layer=2;
strings = 5; // reserviere 5 string pointer...
string = Mspawn_str; // ...denen existierende Strings zugewiesen werden.
flags = narrow;
}
function highlight_sprite()
{
if (event_type == event_touch)
{
//my.ambient += 100; // highlight the unit
Metallmine_Spawn.visible=on;
}
if(event_type == event_release)
{
Metallmine_Spawn.visible=off;
my.ambient = 0;
}
}
entity* terrain_ent;
action spawn_sprite_action
{
my.enable_touch = on;
my.enable_release = on;
my.event = highlight_sprite;
my.polygon = on;
terrain_ent = my;
my.passable = off;
my.transparent=on;
my.alpha=20;
my.flare=on;
my.bright=off;
my.ambient=0;
my.light=on;
my.red=236;
my.green=118;
my.blue=0;
wait(1);
}
Function Gebaeude_Clicked
{
if (EVENT_TYPE == EVENT_click)
{
//If (my.selected_Geb==1)
//{
my.ambient=40;
my.unlit=on;
Gebaeude_Selected_pan.visible=on;
Slider.visible=on;
selected_ent = my;
//}
}
}
Action Gebaeude_Function
{
my.ENABLE_click = ON; // mache Entity sensitiv für Klicks
my.event = Gebaeude_Clicked;
while(1)
{
if(mouse_left == on && mouse_ent != my && key_ctrl != on) //wenn geklickt wurde, aber die maus nicht auf mir ist, geh aus selektier modus raus.
{
Health_pan.visible = off; // andernfalls schalte es ab
Kreuzer_unit.visible=off;
my.ambient = 0;
Gebaeude_Selected_pan.visible=off;
Slider.visible=off;
my.selected = 0;
}
wait(1);
}
vec_set(temp,my.x);
if (vec_to_screen(temp,camera)) // falls auf dem Bildschirm sichtbar
{
Health_pan.pos_x = temp.x; // plaziere die Healthbar
Health_pan.pos_y = temp.y;
}
wait(1);
}
}
}
Var Spawned; //Variable, damit nur einmal die Metallmine platziert werden kann
Function Spawn_Gebaeude()
{
var trace_start[3];
var trace_end[3];
trace_start.x=mouse_pos.x;
trace_start.y=mouse_pos.y;
trace_start.z=1;
vec_for_screen(trace_start,camera);
trace_end.x=mouse_pos.x;
trace_end.y=mouse_pos.y;
trace_end.z = 100000;
vec_for_screen(trace_end,camera);
c_trace(camera.x,trace_end,null);
if(you) //wenn ich eine entity getroffen habe wird "you" gesetzt.
{
if(you.selected == off)
{
if(you == terrain_ent && Metallmine==1 && Spawned==0)
{
vec_for_vertex(temp,terrain_ent,hitvertex);
you=ent_create(Gebaeude,target,Gebaeude_Function);
you.unlit=on;
spawned+=1;
}
}
else
{
wait(1);
}
}
}
ON_MOUSE_LEFT = Spawn_Gebaeude;
cYa Sebastian