"Create" nothing on destination

Posted By: Mythran

"Create" nothing on destination - 06/03/11 19:19

Quote:
function main()
{
level_load (rpg1_wmb);
mouse_map = pointer_pcx;
mouse_mode = 2;
camera.x = player.x;
camera.y = player.y;
camera.z = 200;
camera.pan = 90; // initial pan angle
camera.tilt = -60;
while (1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
if ((mouse_pos.x < 2) && (camera.x > -2500)) {camera.x -= 10 * time;}
if ((mouse_pos.x > screen_size.x - 2) && (camera.x < 2500)) {camera.x += 10 * time;}
if ((mouse_pos.y > screen_size.y - 2) && (camera.y < 2500)) {camera.y -= 10 * time;}
if ((mouse_pos.y < 2) && (camera.y > -2500)) {camera.y += 10 * time;}
wait (1);
}
}

entity* destination;

action warlock
{
player = me;
while (1)
{
my.skill1 = 5 * time;
my.skill2 = 0;
vec_set (temp, my.x);
temp.z -= 3000;
trace_mode = ignore_you + ignore_passable + use_box;
my.skill3 = -trace (my.x, temp);

if (destination != null)
{
vec_set (temp.x, destination.x);
vec_sub (temp.x, my.x);
vec_to_angle (my.pan, temp);
my.tilt = 0; // don't bow laugh
if (vec_dist (my.x, destination.x) > 40)
{
move_mode = ignore_passable;
ent_move (my.skill1, nullvector); // moves using skill1..3
ent_cycle("walk", my.skill46);
my.skill46 += 10 * time; // "walk" animation speed
my.skill46 %= 100; // loop animation
}
else
{
destination.invisible = on;
ent_cycle("idle", my.skill46); // play "stand" frames animation
my.skill46 += 2 * time; // "stand" animation speed
my.skill46 %= 100; // loop animation
}
}
wait (1);
}
}

on_mouse_left = set_target;

function set_target()
{
var pos1;
var pos2;
pos1.x = mouse_pos.x;
pos1.y = mouse_pos.y;
pos1.z = 0;
vec_for_screen (pos1, camera);
pos2.x = mouse_pos.x;
pos2.y = mouse_pos.y;
pos2.z = 20000; // use a big value here
vec_for_screen (pos2, camera);
trace (pos1, pos2); // now "target" holds the coordinates of the hit point
destination = ent_create (destination_mdl, target, show_target);
}

function show_target()
{
my.passable = on;
while (mouse_left == 1) {wait (1);}
while (mouse_left == 0) {wait (1);}
ent_remove (me);
}


This code is from aum 34.
I just want to know how can i make it so that when you click
to set a destination nothing is created. I believe this change
wont matter if it's lite-c or c-script.

Thanks.
Posted By: Pappenheimer

Re: "Create" nothing on destination - 06/03/11 19:36

Remove this:
"destination = ent_create (destination_mdl, target, show_target);"
Posted By: Mythran

Re: "Create" nothing on destination - 06/03/11 19:55

It's true i do like things simple, but that simplicity lead me 2 days ago
to find that when i press the mouse button the character wont move(disables the destination)...
So i need to replace the ent_create or something else.

I also tryed

destination = mouse_pos;
destination = target;
Posted By: Slin

Re: "Create" nothing on destination - 06/03/11 20:00

Code:
function show_target()
{
my.passable = on;
my.invisible = on;
while (mouse_left == 1) {wait (1);}
while (mouse_left == 0) {wait (1);}
ent_remove (me);
}


Posted By: Mythran

Re: "Create" nothing on destination - 06/03/11 20:07

I dont want it to be created, not to get invisible.
I'll explain why, i changed the code to a point that it keeps creating those bottles, and after a while it chrashes saying that i exceeded the number of entities...
But i also thought on that one tongue
Posted By: Pappenheimer

Re: "Create" nothing on destination - 06/03/11 20:27

Change destination to a vector:

VECTOR destination;

Remove the if conditions with destination.

After the trace:
vec_set(destination, target);
Posted By: Mythran

Re: "Create" nothing on destination - 06/03/11 20:41

thank you SO VERY MUCH Pappenheimer!
That did it, it's so perfect laugh
Really, thanks alot!
Posted By: Pappenheimer

Re: "Create" nothing on destination - 06/03/11 21:05

Great to hear that it worked. wink
Posted By: lostclimate

Re: "Create" nothing on destination - 06/04/11 00:22

i believe if you put NULL in for the string in ent_create you get a dummy model that doesnt have any geometry. im not 100% about it though. sounds like youve already got a solution anyways.
Posted By: Mythran

Re: "Create" nothing on destination - 06/04/11 01:19

lostclimate i tryed it yestarday, and no that doesnt work, even if you put NULL in the ent_create something else in the code keep creating it, mysterious hein?
Yes it is done laugh

Thank you all wink
© 2023 lite-C Forums