Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood), 1,268 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to stop the mdl from walking when it is near the player #306309
01/21/10 05:23
01/21/10 05:23
Joined: Jan 2010
Posts: 4
H
Hissatsu Offline OP
Guest
Hissatsu  Offline OP
Guest
H

Joined: Jan 2010
Posts: 4
just want to ask what code should i put inside the while to trigger my if statement. when the gap between the 2 entities is less than 100. the other mdl should stop walking and perform an attack.




var gap = vec_dist(my.x, your.x);

while(1)
{

if(gap >= 100)
{
var distance =-3*time_step;
c_move(me, vector(0,distance,0), NULL, GLIDE);
my.ANIMATION += 2* distance;
ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);

if(gap < 100)
{
my.ANIMATION = 0;
my.ANIMATION += 25 * time_step;
ent_animate(my, "attack", my.ANIMATION,ANM_CYCLE);
}

}

wait(1);
}

Re: how to stop the mdl from walking when it is near the player [Re: Hissatsu] #306311
01/21/10 05:47
01/21/10 05:47
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Code:
var distance = 0;
while(1)
{ 

if(vec_dist(my.x, your.x)>= 100)
{
distance =-3*time_step;
c_move(me, vector(0,distance,0), NULL, GLIDE);
my.ANIMATION += 2* distance;
ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
}
else
{
my.ANIMATION = 0;
my.ANIMATION += 25 * time_step; 
ent_animate(my, "attack", my.ANIMATION,ANM_CYCLE); 
}

wait(1);
}


You need to calculate the distance every frame, so it goes inside the while loop.

Last edited by DJBMASTER; 01/21/10 05:48.
Re: how to stop the mdl from walking when it is near the player [Re: DJBMASTER] #306319
01/21/10 06:46
01/21/10 06:46
Joined: Jan 2010
Posts: 4
H
Hissatsu Offline OP
Guest
Hissatsu  Offline OP
Guest
H

Joined: Jan 2010
Posts: 4
When I put the vec_dist(my.x,your.x) in the condition, the function crahses but the program still run.

Re: how to stop the mdl from walking when it is near the player [Re: Hissatsu] #306328
01/21/10 07:57
01/21/10 07:57
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
The error is probably caused because either 'my' and/or 'your' is not set to a valid ENTITY*, so make sure 'my' and 'your' are both valid.

Last edited by DJBMASTER; 01/21/10 07:58.
Re: how to stop the mdl from walking when it is near the player [Re: DJBMASTER] #306329
01/21/10 08:59
01/21/10 08:59
Joined: Jan 2010
Posts: 4
H
Hissatsu Offline OP
Guest
Hissatsu  Offline OP
Guest
H

Joined: Jan 2010
Posts: 4
I think im gonna go crazy hehehe, i run the program and a message box that says "empty ponter in soldier_enemy" pops out. T,T. Better grab some coffee hhmm. . .

Re: how to stop the mdl from walking when it is near the player [Re: Hissatsu] #306366
01/21/10 13:24
01/21/10 13:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Listen to DJBMASTER and read his last post again (who is you? try you = player; ).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: how to stop the mdl from walking when it is near the player [Re: Superku] #307973
02/01/10 00:56
02/01/10 00:56
Joined: Jun 2009
Posts: 38
H
hungryhobo Offline
Newbie
hungryhobo  Offline
Newbie
H

Joined: Jun 2009
Posts: 38
if you havent figured it out, the you doesnt point to anything.

if this function is going to be called by an enemy, you can do this:

//put up top
entity* player

//put in player action
player = me; //this defines the player entity

//change vec_dist to:
vec_dist(my.x, player.x);

if you dont want you to be the player, you could scan for it

scan will return the entities it hits

look up c_scan perhaps you could do:
scan_var = scan(.....);
if(scan_var > 0) { attack();} //if there is an entity near, attack
else
{
//walk
}

scan also saves the YOU pointer. so, it returns the distance of the entity AND saves the you pointer.

this is all theoretical, but it should work. hope it helps!


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