Page 1 of 1

What's wrong with this code?

PostPosted: Tue Jan 02, 2007 9:04 pm
by Troodon
I'm very confused.
I can't understand where is the error in this code:
Code: Select all
if(distance(x, y, monster.x, monster.y)<=150)
{
   angle=direction(monster.x, monster.y, sini.x, sini.y); +180;
   directional_velocity=2;
}


That should make sini named actor move from the monster actor when closer than 150 pixels. It's not working
:cry:

PostPosted: Tue Jan 02, 2007 9:36 pm
by marathon332
It's a typo...

You have an extra semi-colon on this line:

angle=direction(monster.x, monster.y, sini.x, sini.y); +180;

it should be:

angle=direction(monster.x, monster.y, sini.x, sini.y) +180;

--Steve

PostPosted: Tue Jan 02, 2007 9:54 pm
by Troodon
Thanks but it's still not working:
angle=direction(monster.x, monster.y, sini.x, sini.y) +180;
directional_velocity=2;

It makes the sini jump over the monster and then wait.
:?

PostPosted: Tue Jan 02, 2007 10:40 pm
by Game A Gogo
maybe if you remove the +180 t the end, cuz since you flipped the two actor name it done it right and because of the +180, it resets back, well, i cant even understand what i said, just try it!

PostPosted: Tue Jan 02, 2007 10:52 pm
by Troodon
I removed the +180 but it has no effect.
This code worked in another game but with different actor names. That's why I don't see where is the error. :cry:

PostPosted: Tue Jan 02, 2007 11:22 pm
by Joshua Worth
which actor is this code in?

PostPosted: Wed Jan 03, 2007 9:37 am
by Troodon
This code is in sini actor. I also tried to change the actor name places in the code but it's not still working.
Currently the sini actor just makes strange jumps over the monster and then wait getting eated.

PostPosted: Wed Jan 03, 2007 1:00 pm
by Joshua Worth
it should work with the following code

Code: Select all
if(distance(x, y, monster.x, monster.y) <= 150)
{
   angle=direction(monster.x, monster.y, x, y) + 180;
   directional_velocity = 2;
}


but if it doesn't, either i have no idea what is going on, or there is some other script acting at the same time as that one, changing something

PostPosted: Wed Jan 03, 2007 1:13 pm
by Troodon
Joshua Worth wrote:it should work with the following code

Code: Select all
if(distance(x, y, monster.x, monster.y) <= 150)
{
   angle=direction(monster.x, monster.y, x, y) + 180;
   directional_velocity = 2;
}


but if it doesn't, either i have no idea what is going on, or there is some other script acting at the same time as that one, changing something


It's making the SINI actor run towards monster when closer than 150 pixels.
I tried to remove the +180 and it's still not working.
I tried to export as exe to see if there is difference but it's still not working.

There is many other scripts working the same time but not something crossing this script.
Is there any max draw actor script limit in GE?

PostPosted: Wed Jan 03, 2007 1:29 pm
by makslane
Try swap the values in the direction function:

Code: Select all
angle=direction(x, y, monster.x, monster.y) + 180;

PostPosted: Wed Jan 03, 2007 1:52 pm
by Troodon
Still not working :( .

Here is the whole draw actor script:
(maybe there is something that's distracting the code)
Code: Select all
if (ActorCount("karkki"));
{
    MoveTo("Event Actor", 0.000000, 0.000000, nopeus, "karkki");
}

if  ( ActorCount("karkki") == 0)
{
    xvelocity = 0;
    yvelocity = 0;
}

if (geeni > 8.5)
{
    CreateActor("myrkky", "myrkky", "no parent", "no path", 0, 0, false);
}

if(geeni >= 1.5 && geeni <= 2)
{
  ChangeAnimation("Event Actor", "sinigen2albino", FORWARD);
  r = 255;
  g = 255;
  b = 255;
}

if(geeni >= 4 && geeni <= 4.3)
{
  ChangeAnimation("Event Actor", "geneylihormoni", FORWARD);
}

if(geeni >= 6 && geeni <=6.3)
{
    ChangeAnimation("Event Actor", "genealihormoni", FORWARD);
}

if(geeni == 0 )
{
    ChangeAnimation("Event Actor", "genetauti", FORWARD);
    CreateTimer("Event Actor", "tauti", 20000);
}

if(distance(x, y, monster.x, monster.y)<=150)
{
    angle=direction(x, y, monster.x, monster.y) + 180;
    directional_velocity = 2;
}


if(muurari == 50)
{
    CreateTimer("Event Actor", "muuraa", 4000);
}