making players automated

jonsilva

New member
hello

is there a way to take away control from the players and make them walk to a certain coordinate during the level or in an endlevel boss ?

ive see this in 3 games at least that use this
world heroes before you fight zeus
gijoe in the second level (2d level)
and GAremake

iam trying to figure it out how it works on GAremake
but so far there seems to be only 1 script in the level (levelscript data/levels2/castle/lvinit.c)

lvinit.c.txt
void main()
{
    setglobalvar("levelminz", 224);
    setglobalvar("levelmaxz", 360);
    setglobalvar("bbdelay", 40);
    setglobalvar("countdown", 80);
setglobalvar("cstring", NULL());
}
 
jonsilva said:
Is there a way to alter the script so it can be used on an enemie and call the enemie by name like using alias badguy1 in endlevel_anim.txt
then
char Name = getentityproperty(self,"name");
then badguy1 would move along to coordinates ?

nope, but you can mem an entity in a global/localvar and than you can move it
 
the dificult thing for me is to make an enemie stop at certain coordinates in a level
I cant understand very well how it is done in automv.c
iam trying to make a script with a square coord but i no longer know if i have to subtract the entity's x coordinate from openborvariant("xpos") or sum the chosen coordinates with openborvariant x y pos
the entity is not stoping but it stops if i write the values in the script... i must be getting the wrong entity  x/z position...
void stopPos(int Tx1, int Tx2, int Tz1, int Tz2)
{// stops at certain square coordinates
    void self = getlocalvar("self");


int XPos = openborvariant("xpos"); //Get screen edge's position
int YPos = openborvariant("ypos"); // Get camera y position

float x = getentityproperty(self, "x"); // Get entity's x coordinate
float z = getentityproperty(self, "z"); // Get entity's z coordinate

Tx1 = Tx1+XPos;
Tx2 = Tx2+XPos;
Tz1 = Tz1+YPos;
Tz2 = Tz2+YPos;


    if(Tx1 >= Tx2 && Tz1 >= Tz2){
    changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
    }
}

this is the target coordinates witch start counting from the panel
void targetPos(float Vy, int Tx, int Tz)
{// Targetting panel certain position before leaping there
//  Vy : Leaping speed
//  Tx : Leaping destination x coordinate
//  Tz : Leaping destination z coordinate
// Used with 'leap' or 'toss2'
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x"); // Get entity's x coordinate
    float z = getentityproperty(self, "z"); // Get entity's z coordinate

    if(Tx < x){
      changeentityproperty(self, "direction", 0); // Face left
    } else {
      changeentityproperty(self, "direction", 1); // Face right
    }
    setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
    setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable
}

iam using it in the entities death anim
anim death
loop 0
delay 5
offset 100 189
bbox 79 97 50 91
frame data/chars/beyond/3overlord/idle01.gif
@cmd spawn01 "endlevel_anim" 1 0 1
#@cmd spawn01 "automv1" 1 1 1
frame data/chars/beyond/3overlord/idle01.gif
@cmd subwall 0
frame data/chars/beyond/3overlord/idle01.gif
@cmd targetPos 25 7050 310
@cmd dash 15
frame data/chars/beyond/3overlord/wk00.gif
frame data/chars/beyond/3overlord/wk01.gif #4
@cmd stopPos 6900 6920 270 290
frame data/chars/beyond/3overlord/wk02.gif
@cmd stopPos 6900 6920 270 290
frame data/chars/beyond/3overlord/wk03.gif
@cmd stopPos 6900 6920 270 290
frame data/chars/beyond/3overlord/wk04.gif
@cmd looper 4 20

do you know if theres a way to make it work ?
i think the entity coords start to count from the screen edge instead of the begin of the panel level....
 
I see some errors in what you wrote.
Can you explain better what you mean to do?
Would you want your character runs along a square path and that he stops at the corners?

int XPos = openborvariant("xpos"); //Get screen edge's position
int YPos = openborvariant("ypos"); // Get camera y position

Why you use xpos/ypos? You no need them. x/z are the absolute coords yet.

    setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
    setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable

1) here a bug: if Tx > x ok to do Tx-x but else? I advice you to use abs()!
2) then use openborvariant("game_speed")/10 instead of 20 because this value varies according to game_speed.
3) why do you store the coords in localvars? In this way you cant load these vars from another script like script inside endlevel_anim entity. you can use global/entity vars instead. if you use an entityvar, first get the endlevel_anim entity handler then set the var.
 
Can you explain better what you mean to do?
Would you want your character runs along a square path and that he stops at the corners?

i was trying to put some coords togheter for example
x1=150.....x2=200
tz1=10.... tz2=60
the area inside would be x50 z50
then stoped velocity once script @cmd stopPos detected the entity inside 
it could be the only way because the animation death delay of 5 is not fast enought to detect the coordinates in 1 pixel...

if you use an entityvar, first get the endlevel_anim entity handler then set the var.
yes but i dont see how to do it... i have to remove the (player) from the script and replace it with an entity var to make an enemie move... it could be better to use 2 scripts 1 for player and another one for entites...

 
Hi
i know its not the right topic but i wanted to share something...
i got the script working for the player... in the enemie ive used a target/dash/stop script... It still doesnt move to the right coords has the player does but i got a lot of stuff going on... ill try to improve it latter on, i also dont want to put any pressure on white dragons shoulders...

this is in the final part of the game
hope you can get some ideas from the video
i got that frist scene from the alien vs predator 2 movie (the part were goes into the sewer )

http://youtu.be/_khU4mLRDSs?list=UUrm294XWVzDEqKHpYF45Kmw
 
hello
ive made a new script to move the enemy it seems to be working.
but the problem is making him move in Z in the correct velocity...
anim follow14
@script
    void self = getlocalvar("self");
    float x1 = getentityproperty(self, "x");
    float z1 = getentityproperty(self, "z");

if (frame == 2 && x1 <=6640 && z1 <= 315 ){
    changeentityproperty(self, "velocity", 1, 0.5);
}
else if ( x1 >=6640){
    performattack(self, openborconstant("ANI_FOLLOW15"));
}
@end_script
loop 0
delay 100
offset 101 190
bbox 0 0 0 0
frame data/chars/3johnny/idle03.gif
@cmd clearL
@cmd subscreen 0
frame data/chars/3johnny/idle03.gif
delay 9
frame data/chars/3johnny/wk20.gif #2
frame data/chars/3johnny/wk21.gif
frame data/chars/3johnny/wk22.gif
frame data/chars/3johnny/wk23.gif
frame data/chars/3johnny/wk24.gif
frame data/chars/3johnny/wk25.gif
frame data/chars/3johnny/wk20.gif #8
@cmd looper 2 50
frame data/chars/3johnny/idle03.gif
delay         10000
frame data/chars/3johnny/idle03.gif

anim follow15
loop 1 2 10
delay 35
offset 101 190
bbox 0 0 0 0
frame data/chars/3johnny/idle03.gif
@cmd stop
frame data/chars/3johnny/idle03.gif

I cant understand very well how the velocity Z is made in automv.c... but it seems to be getting a correct velocity number that will put him right on the Z coordinates...
Is there a way make him move in Z like the automv.c
 
Hello, I have a question, automv.c works well, but I can not move the two players at the same time

This parameter only lets me move one at a time
@script
    void self = getlocalvar("self");
    setentityvar(self, 5, 1140); // coord x
    setentityvar(self, 6, 375); // coord z
    setentityvar(self, 7, 1); // direction 0 left 1 right
    setentityvar(self, 8, 0); // player nº  ----------------------------------------------
@end_script

The idea is that the two players move at the same time, the coordinates without control, and once there regain control
 
Back
Top Bottom