Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 1,369 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trace_hit not responding right? #260575
04/12/09 06:53
04/12/09 06:53
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
So basically i have enemy action which is their AI; and I have a code in my bullets action saying that if the trace is hit and it's the enemy to make a blood cloud, otherwise make smoke and sparks.

The issue is it only works on one of the two enemies i have on the map. For one he bleeds and eventually dies. For the other he just sits still and smoke and sparks appear.

They both execute their actions, except one will not respond to the trace hit properly

Here's the code for the trace hit part of the bullet action:
Quote:
if(trace_hit)
{
if(you==living)
{

bloodsprayAnzahlPartikel = max(1,random(50));
effect(bloodsprayspezial,max(1,bloodsprayAnzahlPartikel*time),your.x,nullvector);

blood_cloudAnzahlPartikel = max(1,random(60));
effect(blood_cloudspezial,max(1,blood_cloudAnzahlPartikel*time),your.x,nullvector);
your.skill1 -= 10;
}
else
{
wait(1);
vec_for_vertex(temp,me,9);
sparksAnzahlPartikel = max(1,random(60));
effect(sparksspezial,max(1,sparksAnzahlPartikel*time),temp,nullvector);
gun_smokeAnzahlPartikel = max(1,random(60));
effect(gun_smokespezial,max(1,gun_smokeAnzahlPartikel*time),temp,nullvector);
}
wait(1);
ent_remove(me);
return;
}


And here's the code for the enemy:
Quote:
action the_enemey_1
{



wait(1);
define health,skill1;
my.health = 40;
var speed_down_2=0;
// AI();

//position
my.oriented=on;
// my.FAT = OFF;
// my.NARROW = ON;
my.POLYGON = ON;
move_min_z = -1;
move_friction = 0; // strong friction
// enemy = me;
living=me;
while(1)
{






/* var dist_down_2 = 0;
if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
{
dist_down_2 = my.z - target.z; // get distance between player's feet and the ground
}
//else
//{
// dist_down = 0;
//}

// apply gravity when the player is in the air
if (dist_down_2 > 5) // above floor, fall down with increasing speed
{
dist_down_2 = clamp(dist_down_2,0,accelerate(speed_down_2,0.5,0));
// my.z -= 0.5*time_step;
}
else // on or below floor, set downward speed to zero
{
speed_down_2 = 0;
}

// var dist_ahead;
// dist_ahead = (key_w-key_s)*time_step*5;
// dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
c_move(me,vector(0,0,-dist_down_2),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player
wait(1);*/
/////////////////////////////////////////////
if(theplayer!=null)
{
vec_set(temp,theplayer.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
}

////////////////////////////////////////////
///////////////////////////////////////////////

if(my.health<=0)
{
my.passable=on;
ent_morph(me,"mainchardead.mdl");
c_trace (my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME|IGNORE_PASSABLE);
//vec_for_min(temp,my);
my.z = target.z + 1;
break;
}

wait(1);
}


}

sorry my code is so messy, it's because i've been changing everything alot to try to fix it.


-Johnny Thrash
Re: Trace_hit not responding right? [Re: Metal_Thrasher] #260576
04/12/09 07:55
04/12/09 07:55
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
You appear to have a misunderstanging with pointers, or just a simple mistake hiding in a blind spot. grin

In your enemy action you set living=me;, but "living" is a single pointer so what happens is this.
1> Action the_enemy_1 get run by the first entity created or loaded in level. It sets the global pointer living to ##_ENTITY_number_1_##. Cool.
2> Action the_enemy_1 get run by the second entity created or loaded in level. It sets the global pointer living to ##_ENTITY_number_2_##. BAD
"living" is no longer pointing at ##_ENTITY_number_1_## anymore. So it is no longer "living" to any action.

See the problem?

What you need to do is set a flag of some sort onto the entities to mark them as living.
OK, pick a number between One and One Hundred. 50! I guessed it, Ha! laugh
So now we will use skill 50 to store each entities living status in, to do this we go into the
the_enemy_1 action, and replace the line "living=me;" with "my.skill50=1;" instead.
So now what we've done will change the value of skill50 to be "1" when any entity runs the the_enemy_1 action.
Any entities that DONT run the_enemy_1 will still have their skill50 at Zero.
AS LONG AS WE NEVER USE SKILL50 FOR ANYTHING ELSE!! Sorry for yelling but its important.

Now the bullet needs to recognise whether the target is alive or dead.
Change its line "if(you==living)" to be "if(you.skill50==1)"

And that should be it. I havent looked any deeper into your code than that butit looks good at a glance.
Just remember, when the enemy is dead, you MAY want to set the entities skill50 to 0 when it dies,
unless, like me, you enjoy the spatter of blood when shooting corpses!!!
Also again REMEMBER never to use skill50 for any function than living/dead status or things WILL go weird.

Have fun....


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Trace_hit not responding right? [Re: EvilSOB] #260591
04/12/09 09:25
04/12/09 09:25
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
Thanks a ton man, this works. EXCEPT, the else statement never comes into effect, because when it hits level geometry it says empty pointer, I'm assuming because skill50 dosent apply to blocks but only entities.

(PS: Why was this moved to Lite-C? This is in C-script.)

Last edited by Metal_Thrasher; 04/12/09 09:26.

-Johnny Thrash
Re: Trace_hit not responding right? [Re: Metal_Thrasher] #260595
04/12/09 09:52
04/12/09 09:52
Joined: Oct 2003
Posts: 2,194
Saturn
Metal_Thrasher Offline OP
Expert
Metal_Thrasher  Offline OP
Expert

Joined: Oct 2003
Posts: 2,194
Saturn
No sweat I fixed it. Thanks again! You really helped me alot!


-Johnny Thrash
Re: Trace_hit not responding right? [Re: Metal_Thrasher] #260691
04/13/09 00:41
04/13/09 00:41
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
good stuff, glad to be of help.

Dunno why it got moved to lite-c, maybe my fault.
I dont normally post in WDL forums cause Im bad at it.
Moderator may have seen my post and said "EvilSOB is answering, must be lite-c"


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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