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());
}
 
This is a big work.
I wrote a complete library to make a player walk or jump or run for a cut scene.
Its a difficulty work. You can see a cut scene also on my game (tmnt ss) at the end of level (also I wrote an AI to perform a ladder/area climbing action for cpu characters).

For my work I decided to divide a cut scene into 3 steps:
1) switch off aicontrol if some conditions are verified.
2) check if the path that a character has to follow is "free" to walk.
3) walk the path. (walk or jump or other!!)

Its a long and hard work.
You can see a cut scene as an amount of steps and you can use a semaphore variable to make this.
You have to write a library to check tha path and you have to write a library to make an action in that path.
A professional approach is to make a smooth movement and if you want to walk point by point in a path your have to check these points point by point.
A smooth movement is a dynamic change of speed depending from direction (no sudden speed changes).
So if you want to walk from A to B check if the diagonal is free (better if you use a smooth movement).
If you want to walk from A to C passing by B use a smooth movement like bezier curve or use a custom AI obstacle linear bypass.

This is a little example of code (linear walking) from my lib (no checks but only the walk function):
Code:
int smovetoxz_smoothed(void player, float dir_x, float dir_z, int final_direction, float speed) {
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");
    float a = getentityproperty(player, "y");
    float base = getentityproperty(player, "base");
    float threshold = 0.99; // precisione
    float speed_x, speed_z;
    float max_dist = 0, x_dist, z_dist, mdf_speedx, mdf_speedz;

    if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") && getentityproperty(player, "animationid") != openborconstant("ANI_RESPAWN") ) {
        if ( a != base ) changeentityproperty(player, "position", x, z, base);

        // Calcola quale coord è in progresso: x,z,a?? condizioni di speed_x == 0 x es. if ( x > dir_x-threshold && x < dir_x+threshold )
        // Dunque impostiamo tutte le distanze. Se la distanza == 0 allora è stata raggiunta
        if ( x < dir_x+threshold ) x_dist = abs(dir_x-x);
        else if ( x > dir_x-threshold ) x_dist = abs(x-dir_x);
        else x_dist = 0;

        if ( z < dir_z+threshold ) z_dist = abs(dir_z-z);
        else if ( z > dir_z-threshold ) z_dist = abs(z-dir_z);
        else z_dist = 0;

        // Poi calcolare dist max. da x a dir_x per es.
        if ( x_dist > 0 ) max_dist = x_dist;
        if ( z_dist > max_dist ) max_dist = z_dist;

        // Associare speed a dist min. Stabilire attraverso una percentuale la velocità per le altre distanze.
        // L'associacione avviene tramite proporzioe -> speed:max_dist = new_speed:new_dist
        // Ovviamente la speed == a max_speed rimarrà immodificata se dist/max_dist = 1
        mdf_speedx = (x_dist*speed)/max_dist;
        mdf_speedz = (z_dist*speed)/max_dist;
        if ( max_dist <= 0 ) max_dist = 1;

        if ( x > dir_x-threshold && x < dir_x+threshold  ) {
            speed_x = 0;
        } else if ( x < dir_x+threshold ) { // pg deve andare a destra
            changeentityproperty(player, "direction", 1);
            speed_x = mdf_speedx;
            if ( (dir_x-x) <= threshold ) speed_x = (dir_x-x)*(2/3); // Impostiamo la velocità proprio uguale alla distanza che manca
        } else if ( x > dir_x-threshold ) { // pg deve andare a sinistra
            changeentityproperty(player, "direction", 0);
            speed_x = -1*mdf_speedx;
            if ( (x-dir_x) <= threshold ) speed_x = -1*(x-dir_x)*(2/3);
        }

        // Diamo la priorità all'animazione UP/DOWN
        if ( z > dir_z-threshold && z < dir_z+threshold  ) {
            speed_z = 0;
        } else if ( z < dir_z+threshold ) { // pg deve andare giù
            speed_z = mdf_speedz;
            if ( (dir_z-z) <= threshold ) speed_z = (dir_z-z)*(2/3);
        } else if ( z > dir_z-threshold ) { // pg deve andare su
            speed_z = -1*mdf_speedz;
            if ( (z-dir_z) <= threshold ) speed_z = -1*(z-dir_z)*(2/3);
        }

        if ( speed_x == 0 && speed_z == 0 ) {
            changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
            changeentityproperty(player, "direction", final_direction);

            return 1;
        }

        changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
    } // fine if spawn

  return 0;
}

PARAMS:
player = entity that you move
dir_x = final x coord
dir_z = final z coord
final_direction = final direction
speed = speed (try a value)

the func returns 1 if you are in the final coords, else returns 0.
 
thanks white dragon this script looks much simplier than previous scripts ive seen...

iam trying to use the script in one entity type none
it spawns01 in a boss anim death
Code:
anim	death
	loop	0
	delay	10
	offset	100 189
	bbox	79 97 50 91
	frame	data/chars/beyond/3overlord/idle01.gif
	frame	data/chars/beyond/3overlord/idle01.gif

	@cmd	spawn01 "automv1" 1 1 1

	frame	data/chars/beyond/3overlord/idle01.gif
	frame	data/chars/beyond/3overlord/idle01.gif

automv1.txt
name automv1
type none
nolife  1
shadow 0
offscreenkill 10000
subject_to_wall 0

animationscript data/scripts/automv.c #<----(smovetoxz_smoothed int)

#int smovetoxz_smoothed
#(void player, float dir_x, float dir_z, int final_direction, float speed)


anim idle
loop 1
delay 10
offset 360 635
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif

@cmd smovetoxz_smoothed "ryo" 6350 260 1 1

frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif

but this way is turning out with the cant compile error i mean
should the (int smovetoxz_smoothed) start with a (void smovetoxz_smoothed)
like in most @cmd stuff ?
 
my script works in script event, not in animationscript event.
load it into:
script script.c
in an entity that you spawn at the end of a level or where you want.
than retrieve your player entity and call my function
 
ive tried using
script data/scripts/automv.c  in automv1.txt
the frist time ive tried ive just misplaced the copy paste

ive also added the abs in lib.c to the script
float abs(float num) {
    if (num < 0) num *= -1;

    return num;
}

int smovetoxz_smoothed(void player, float dir_x, float dir_z, int final_direction, float speed) {
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");
    float a = getentityproperty(player, "y");
    float base = getentityproperty(player, "base");
    float threshold = 0.99; // precisione
    float speed_x, speed_z;
    float max_dist = 0, x_dist, z_dist, mdf_speedx, mdf_speedz;

    if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") && getentityproperty(player, "animationid") != openborconstant("ANI_RESPAWN") ) {
        if ( a != base ) changeentityproperty(player, "position", x, z, base);

        // Calcola quale coord è in progresso: x,z,a?? condizioni di speed_x == 0 x es. if ( x > dir_x-threshold && x < dir_x+threshold )
        // Dunque impostiamo tutte le distanze. Se la distanza == 0 allora è stata raggiunta
        if ( x < dir_x+threshold ) x_dist = abs(dir_x-x);
        else if ( x > dir_x-threshold ) x_dist = abs(x-dir_x);
        else x_dist = 0;

but iam getting the error There's an exception while executing the script without a line / column nº

in tmn ss it seems hard to track how the script is being used
in rocksteady /support theres the (wait_boss1_death) that uses the endlevel1_anim and goes to script ?!

can this line
int smovetoxz_smoothed(void player,
be changed to (void name,

so it can be used in all entities by name? iam sure if i change it the script will stop function... but in tmn ss it seems to work for both player and enemies
 
player is the entity handler (address).
for example player = getplayerproperty(0,"entity"); if you want to move the player 1 (but you can retrieve any entity like an enemy).
ok for abs.

example:
void player = getplayerproperty(0,"entity"); // retrieve player 1 handler

if ( smovetoxz_smoothed(player,240,120,1,0.5) ) {
  drawstring(10,10,0,"player has finished to move on");
}

if you get an exception you have to post the log file so that I can understand your issue ('couse my func works well and tested).

jonsilva said:
in tmn ss it seems hard to track how the script is being used
in rocksteady /support theres the (wait_boss1_death) that uses the endlevel1_anim and goes to script ?!

so in my (TMNT SS) lv1.txt file (not levels.txt) I spawn wait_boss1_death.txt
this entity check if two bosses are death together (bebop & rocksteady). If it is so, this entity spawn another entity: endlevel1_anim
that use a endlevel1_anim.c that is a cut scene animation.
 
thanks but i just dont know how to put it all together

iam using the script in an entity

automv1.txt
name automv1
type none
nolife  1
shadow 0
offscreenkill 10000
subject_to_wall 0

script data/scripts/automv.c #<----(smovetoxz_smoothed int)


#int smovetoxz_smoothed
#(void player, float dir_x, float dir_z, int final_direction, float speed)


anim idle
loop 1
delay 10
offset 360 635
frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif

#@cmd smovetoxz_smoothed "Ryo" 6350 260 1 1

frame data/bgs/beyond/lvl13/bck/empty.gif
frame data/bgs/beyond/lvl13/bck/empty.gif

@cmd smovetoxz_smoothed "Ryo" 6350 260 1 1... makes the execption error
using it with # show a diferent eeor in log

iam using it in a death anim along with spawn01
anim death
loop 0
delay 5
offset 100 189
bbox 79 97 50 91
@cmd subwall 0
frame data/chars/beyond/3overlord/idle01.gif
@cmd spawn01 "automv1" 1 1 1
frame data/chars/beyond/3overlord/idle01.gif
@cmd targetPos 25 1730 380
@cmd dash 25
frame data/chars/beyond/3overlord/wk00.gif
frame data/chars/beyond/3overlord/wk01.gif
frame data/chars/beyond/3overlord/wk02.gif
@cmd targetPos 35 1730 380
@cmd dash 25
frame data/chars/beyond/3overlord/wk03.gif
frame data/chars/beyond/3overlord/wk04.gif
@cmd looper 3 30

frame data/chars/beyond/3overlord/wk01.gif
frame data/chars/beyond/3overlord/wk02.gif

frame data/chars/beyond/3overlord/wk03.gif
frame data/chars/beyond/3overlord/wk04.gif

drawmethod 256 256 1
frame data/chars/beyond/3overlord/wk01.gif#11
frame data/chars/beyond/3overlord/wk02.gif
@cmd targetPos 35 1730 380
@cmd dash 25
frame data/chars/beyond/3overlord/wk03.gif
frame data/chars/beyond/3overlord/wk04.gif
@cmd looper 11 30
frame data/chars/beyond/3overlord/wk01.gif
@cmd stop
delay 7
frame data/chars/beyond/3overlord/wk02.gif
frame data/chars/beyond/3overlord/wk03.gif
frame data/chars/beyond/3overlord/wk04.gif
delay 12
frame data/chars/beyond/3overlord/wk00.gif
delay 9
frame data/chars/beyond/3overlord/idle01.gif
frame data/chars/beyond/3overlord/idle02.gif
frame data/chars/beyond/3overlord/idle03.gif
frame data/chars/beyond/3overlord/idle04.gif

frame data/chars/beyond/3overlord/pain1.gif
frame data/chars/beyond/3overlord/pain2.gif
frame data/chars/beyond/3overlord/pain3.gif
delay 500
frame data/chars/beyond/3overlord/pain3.gif

the previous @cmd below are the ones i was using before to make the entity move to a certain coordinate you can see i had to use drawmethod to get the entity turn left  ;D !!!

the log doesnt show much execpt when using the (@cmd smovetoxz_smoothed "Ryo" 6350 260 1 1 ) without the #
 
@cmd smovetoxz_smoothed "Ryo" 6350 260 1 1

Code:
Total Ram: 3488911360 Bytes
 Free Ram: 1354252288 Bytes
 Used Ram: 2904064 Bytes

debug:nativeWidth, nativeHeight, bpp  1360, 768, 32

0 joystick(s) found!
OpenBoR v3.0 Build , Compile Date: Nov  2 2014

Game Selected: ./Paks/My Mod.pak

FileCaching System Init......	Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video.............	480x272 (Mode: 1, Depth: 32 Bit)

Loading menu.txt.............	Done!
Loading fonts................	1 2 3 4 Done!
Timer init...................	Done!
Initialize Sound..............	Done!
Loading sprites..............	Done!
Loading level order..........	Done!
Loading model constants......	Done!
Loading script settings......	Done!
Loading scripts..............	Done!
Loading models...............

Cacheing 'water_puddle_test' from data/chars/misc/ladder/water_puddle_test.txt
Cacheing 'water_splash' from data/chars/misc/water/water_splash/water_splash.txt
Cacheing 'water_ripple_front' from data/chars/misc/water/water_ripple/water_ripple_front.txt
Cacheing 'water_ripple_back' from data/chars/misc/water/water_ripple/water_ripple_back.txt
Cacheing 'Flash0' from data/chars/misc/flash/flash/flash0.txt
Cacheing 'Flash' from data/chars/misc/flash/flash/flash.txt
Cacheing 'Flash2' from data/chars/misc/flash/flash/flash2.txt
Cacheing 'Flash3' from data/chars/misc/flash/flash/flash3.txt
Cacheing 'Flash4' from data/chars/misc/flash/flash/flash4.txt


Loading 'Flash0' from data/chars/misc/flash/flash/flash0.txt
Loading 'Flash' from data/chars/misc/flash/flash/flash.txt
Loading 'Flashb' from data/chars/misc/flash/flash/flashb.txt
Loading 'Flash2' from data/chars/misc/flash/flash/flash2.txt
Loading 'Flash3' from data/chars/misc/flash/flash/flash3.txt
Loading 'Flash4' from data/chars/misc/flash/flash/flash4.txt
Loading 'Flashc' from data/chars/misc/flash/flash/flashc.txt
Loading 'Flash5' from data/chars/misc/flash/flash/flash5.txt
Loading 'Flash6' from data/chars/misc/flash/flash/flash6.txt
Loading 'brkrock' from data/chars/misc/flash/rock/brkrock.txt
Loading 'Flash7' from data/chars/misc/flash/flash/flash7.txt
Loading 'blooda' from data/chars/misc/flash/flash/blooda.txt
Loading 'bloodb' from data/chars/misc/flash/flash/bloodb.txt
Loading 'exel' from data/chars/misc/flash/flash/exel.txt
Loading 'kohkn' from data/chars/misc/flash/flash/kohkn.txt
Loading 'haskk' from data/chars/misc/flash/flash/haskk.txt
Loading 'kohkn2' from data/chars/misc/flash/flash/kohkn2.txt
Loading 'haskk2' from data/chars/misc/flash/flash/haskk2.txt
Loading 'hsken' from data/chars/misc/flash/flash/hsken.txt
Loading 'pwwv' from data/chars/misc/flash/flash/pwwv.txt
Loading 'pwgs' from data/chars/misc/flash/flash/pwgs.txt
Loading 'wwup' from data/chars/misc/flash/flash/wwup.txt
Loading 'scup' from data/chars/misc/flash/flash/scup.txt
Loading 'zero' from data/chars/misc/dusts/zero.txt
Loading 'dust' from data/chars/misc/dusts/dust.txt
Loading 'dust2' from data/chars/misc/dusts/dust2/dust2.txt
Loading 'dust3' from data/chars/misc/dusts/dust3/dust3.txt
Loading 'repk' from data/chars/misc/flash/flash/repk.txt
Loading 'blink' from data/chars/0misc2/blink.txt
Loading 'rstorm' from data/chars/misc/flash/flash/rstorm.txt
Loading 'qfx' from data/chars/misc/flash/qfx.txt
Loading 'fmoney' from data/chars/misc/flash/money/fmoney.txt
Loading 'allsp' from data/chars/misc/power/player/super/allsp.txt
Loading 'yupw' from data/chars/0yuri/pw/yupw.txt
Loading 'hadok2' from data/chars/1ryo/pw/hadok2.txt
Loading 'exp5ene' from data/chars/misc/explosion/5/exp5ene.txt
Loading 'mseffect' from data/chars/misc/traps/missle/effect/mseffect.txt
Loading 'plrocket2' from data/chars/beyond/4stank/cannon/plrocket2.txt
Loading 'plgrdaim' from data/chars/beyond/4stank/cannon/plgrdaim.txt
Loading 'explosion8' from data/chars/misc/explosion/7/explosion8.txt
Loading 'plrocket1' from data/chars/beyond/4stank/cannon/plrocket1.txt
Loading 'explosion2' from data/chars/misc/explosion/2/explosion2.txt
Loading 'plpw7' from data/chars/misc/power/7/plpw7.txt
Loading 'plcannon' from data/chars/beyond/4stank/plcannon.txt
Loading 'mrzero' from data/chars/0null/mrzero.txt
Loading 'ryo' from data/chars/1ryo/ryo.txt
Loading 'Robert' from data/chars/1robert/robert.txt
Loading 'Yuri' from data/chars/0yuri/yuri.txt
Loading 'fastryo' from data/chars/1ryo/fastryo/fastryo.txt
Loading 'kgnrob' from data/chars/1robert/kgnrob/kgnrob.txt
Loading 'sYuri' from data/chars/0yuri/syuri/syuri.txt
Loading 'choppene1' from data/chars/misc/car/Mtruck/choppene1.txt
Loading 'bullene' from data/chars/misc/traps/bullets/bullene.txt
Loading 'pltank' from data/chars/beyond/4stank/pltank.txt
Loading 'rbikecrash' from data/chars/misc/junk/bike/rbikecrash.txt
Loading 'explosion1' from data/chars/misc/explosion/explosion1.txt
Loading 'Ryobike' from data/chars/1ryo/ryobike.txt
Loading 'Ryobike2' from data/chars/1ryo/ryobike2.txt
Loading 'Ryofall' from data/chars/1ryo/ryofall.txt
Loading 'gold' from data/chars/misc/points/gold.txt
Loading 'Ring' from data/chars/misc/points/ring.txt
Loading 'moneybag' from data/chars/misc/points/moneybag.txt
Loading '1up' from data/chars/misc/food/1up.txt
Loading 'food5' from data/chars/misc/food/food5.txt
Loading 'food6' from data/chars/misc/food/food6.txt
Loading 'smoke4' from data/chars/misc/dusts/smoke4/smoke4.txt
Loading 'ryobed1' from data/chars/1ryo/ryobed1.txt
Loading 'diamond' from data/chars/misc/points/diamond.txt
Loading 'ruby' from data/chars/misc/points/ruby.txt
Loading 'food3' from data/chars/misc/food/food3.txt
Loading 'food4' from data/chars/misc/food/food4.txt
Loading 'ryobed2' from data/chars/1ryo/ryobed2.txt
Loading 'splash3' from data/chars/misc/traps/wale/splash3.txt
Loading 'swater2' from data/chars/misc/dusts/water/swater2.txt
Loading 'Ryowtr' from data/chars/1ryo/Ryowtr.txt
Loading 'ryovent' from data/chars/1ryo/ryovent.txt
Loading 'fastryofall' from data/chars/1ryo/fastryo/fastryofall.txt
Loading 'dust4' from data/chars/misc/dusts/dust4/dust4.txt
Loading 'Robcar' from data/chars/1robert/robcar.txt
Loading 'robcar2' from data/chars/1robert/robcar2.txt
Loading 'robvent' from data/chars/1robert/robvent.txt
Loading 'robfall' from data/chars/1robert/robfall.txt
Loading 'robwtr' from data/chars/1robert/robwtr.txt
Loading 'kgnrobfall' from data/chars/1robert/kgnrob/kgnrobfall.txt
Loading 'kgnrobvent' from data/chars/1robert/kgnrob/kgnrobvent.txt
Loading 'kgnwtr' from data/chars/1robert/kgnrob/kgnwtr.txt
Loading 'yurifall' from data/chars/0yuri/yurifall.txt
Loading 'ybikecrash' from data/chars/misc/junk/bike8/ybikecrash.txt
Loading 'yuribike' from data/chars/0yuri/yuribike.txt
Loading 'yuribike2' from data/chars/0yuri/yuribike2.txt
Loading 'yurivent' from data/chars/0yuri/yurivent.txt
Loading 'yurwtr' from data/chars/0yuri/yurwtr.txt
Loading 'syurifall' from data/chars/0yuri/syuri/syurifall.txt
Loading 'syuribike' from data/chars/0yuri/syuri/syuribike.txt
Loading 'syuribike2' from data/chars/0yuri/syuri/syuribike2.txt
Loading 'syurivent' from data/chars/0yuri/syuri/syurivent.txt
Loading 'syurwtr' from data/chars/0yuri/syuri/syurwtr.txt
Loading 'mapcurs' from data/bgs/0map/icons/mapcurs.txt
Loading 'elect' from data/chars/misc/starts/elect.txt
Loading 'fightstrt' from data/chars/misc/starts/fightstrt.txt
Loading 'toturiRyo' from data/chars/misc/HTplay/toturiRyo.txt
Loading 'toturiRob' from data/chars/misc/HTplay/toturiRob.txt
Loading 'toturiYur' from data/chars/misc/HTplay/toturiYur.txt
Loading 'toturiFRyo' from data/chars/misc/HTplay/toturiFRyo.txt
Loading 'toturiKRob' from data/chars/misc/HTplay/toturiKRob.txt
Loading 'toturiSYur' from data/chars/misc/HTplay/toturiSYur.txt
Loading 'splash2' from data/chars/misc/traps/wale/splash2.txt

Loading models...............	Done!
Object engine init...........	Done!
Input init...................	No Joystick(s) Found!
Done!
Create blending tables.......	Done!
Save settings so far........	Done!


Level Loading:   'data/levels/test.txt'
Total Ram: 3488911360 Bytes
 Free Ram: 1261187072 Bytes
 Used Ram: 92082176 Bytes

Loading 'ghosttest' from data/chars/misc/food/ghosttest.txt
Loading 'ldrpwr' from data/chars/beyond/3overlord/bck/ldrpwr.txt
Loading 'ldrpwr2' from data/chars/beyond/3overlord/bck/ldrpwr2.txt
Loading 'ldrpwr3' from data/chars/beyond/3overlord/bck/ldrpwr3.txt
Loading 'ovtlk' from data/chars/beyond/text/overlord/ovtlk.txt
Script compile error: can't find function 'smovetoxz_smoothed'

Script compile error in 'automv1': smovetoxz_smoothed line 9, column 12

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script 'automv1' data/bgs/beyond/lvl13/bck/automv1.txt
Total Ram: 3488911360 Bytes
 Free Ram: 1232732160 Bytes
 Used Ram: 116371456 Bytes

Level Unloading: 'data/levels/test.txt'
Total Ram: 3488911360 Bytes
 Free Ram: 1232179200 Bytes
 Used Ram: 116436992 Bytes

Done.
Total Ram: 3488911360 Bytes
 Free Ram: 1232896000 Bytes
 Used Ram: 115560448 Bytes

Release level data...........	Done!
Release graphics data........	Done!
Release game data............

Unload 'Flash0' ............done.
Unload 'Flash' ............done.
Unload 'automv1' ............done.

Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

Can't compile script 'automv1' data/bgs/beyond/lvl13/bck/automv1.txt


#@cmd smovetoxz_smoothed "Ryo" 6350 260 1 1 (off)
Code:
Loading 'toturiSYur' from data/chars/misc/HTplay/toturiSYur.txt
Loading 'splash2' from data/chars/misc/traps/wale/splash2.txt

Loading models...............	Done!
Object engine init...........	Done!
Input init...................	No Joystick(s) Found!
Done!
Create blending tables.......	Done!
Save settings so far........	Done!


Level Loading:   'data/levels/test.txt'
Total Ram: 3488911360 Bytes
 Free Ram: 1241055232 Bytes
 Used Ram: 92098560 Bytes

Loading 'ghosttest' from data/chars/misc/food/ghosttest.txt
Loading 'ldrpwr' from data/chars/beyond/3overlord/bck/ldrpwr.txt
Loading 'ldrpwr2' from data/chars/beyond/3overlord/bck/ldrpwr2.txt
Loading 'ldrpwr3' from data/chars/beyond/3overlord/bck/ldrpwr3.txt
Loading 'ovtlk' from data/chars/beyond/text/overlord/ovtlk.txt
Loading 'automv1' from data/bgs/beyond/lvl13/bck/automv1.txt
Loading 'overlord' from data/chars/beyond/3overlord/overlord.txt

Level Loaded:    'data/levels/test.txt'
Total Ram: 3488911360 Bytes
 Free Ram: 1210273792 Bytes
 Used Ram: 118497280 Bytes
Total sprites mapped: 4795


********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'updateentityscript' data/bgs/beyond/lvl13/bck/automv1.txtTotal Ram: 3488911360 Bytes
 Free Ram: 1215660032 Bytes
 Used Ram: 119050240 Bytes

Release level data...........Level Unloading: 'data/levels/test.txt'
Total Ram: 3488911360 Bytes
 Free Ram: 1211568128 Bytes
 Used Ram: 118603776 Bytes

Done.
Total Ram: 3488911360 Bytes
 Free Ram: 1212432384 Bytes
 Used Ram: 117727232 Bytes

	Done!
Release graphics data........	Done!
Release game data............

Unload 'Flash0' ............done.
Unload 'Flash' ............done.
Unload 'ovtlk' ............done.
Unload 'automv1' ............done.

Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

There's an exception while executing script 'updateentityscript' data/bgs/beyond/lvl13/bck/automv1.txt

 
jonsilva said:
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 ?

There is a way to do that but you will need to deactivate controls for all players AND prohibit inactive players to join the game before automatically controls active players
The idea is almost the same as victory pose script except that this requires more work, as White Dragon pointed. In victory pose, you simply forcefully change player's animation to certain animation then end the level some time later OTOH for automated move, you will also need to control how long player will play the changed animation before ending this mechanic
That's what White Dragon's script , posted above, does I believe :)

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

2nd level? you mean the intro? no, players aren't automatically controlled there. You don't even see them on screen ;)
Well, the truth is, in that intro level, players are placed offscreen and there are only enemy and NPC acting on screen
 
There is a way to do that but you will need to deactivate controls for all players AND prohibit inactive players to join the game before automatically controls active players

but how to deactivate the controls and others players from join in... i rebember seeing a script some time ago that used to do this, stoping the level scroll and camera position also seem a good way... ive tried the targetpos script that checks the panel coordinates but then it dashes to that position like an arrow... ive made a script wich ive deleted already that would set the velocity 0 0 0 once certain coordinates were reached but the entetie would never stoped... it's like it just needs to be that exact 1 pixel in coordinate x500 x220 for example... its almost impossible to do with a delay 5 and a dash... the script and the coordinate pixel would never connect...
anim  death
  loop  0
  delay  5
  offset  100 189
  bbox  79 97 50 91
  @cmd  subwall 0
  frame  data/chars/beyond/3overlord/idle01.gif
  @cmd  spawn01 "automv1" 1 1 1
  frame  data/chars/beyond/3overlord/idle01.gif
  @cmd  targetPos 25 1730 380
  @cmd  dash 25
  frame  data/chars/beyond/3overlord/wk00.gif
  frame  data/chars/beyond/3overlord/wk01.gif
  frame  data/chars/beyond/3overlord/wk02.gif
  @cmd  targetPos 35 1730 380
  @cmd  dash 25
 
  #@cmd stopPos 1730 380 <------i was using the script in here 
  frame  data/chars/beyond/3overlord/wk03.gif
  frame  data/chars/beyond/3overlord/wk04.gif
  @cmd  looper 3 30

i still havent manadge to make white dragons script work... i dont know were the error is coming from i could be doing something right or wrong i wouldnt know...

2nd level? you mean the intro? no, players aren't automatically controlled there. You don't even see them on screen
Well, the truth is, in that intro level, players are placed offscreen and there are only enemy and NPC acting on screen

yes if i rebember correctly comander cobra was an enemy hostile to npc or obstacle that killed the soldier...
but i mean the frist level you play in the game that is in 2d that player can only walk back foward jump and crouch... (snake eyes comes walking in alttitude from behind a water fall then jumps down to the level and walks foward a bit more all without the player controling it)
 
well, these are the steps to create a basic example:

1) create an entity that you spawn when you want during a level.
2) this entity uses script data/scripts/endlevel_anim.c (for example):
Code:
name	endlevel_anim
type	enemy
health 1
nolife 1
#setlayer 1
facing 2
nomove 1 0

script data/scripts/endlevel_anim.c

anim idle
	loop	0
	bbox	0

	delay	100
	offset	20 25
	frame	data/chars/misc/empty.gif

in endlevel_anim.c write:
Code:
void main() {
   void self = getlocalvar("self");
   void player = getplayerproperty(0,"entity"); // retrieve player 1 handler

   if ( getentityproperty(player,"exists") ) {
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( smovetoxz_smoothed(player,240,120,1,0.5) ) {
         if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
         drawstring(10,10,0,"player has finished to move on");
         //killentity(self); // to finish the script
      }
   }

}

Ps. remember to import the function smovetoxz_smoothed().
This is the right way to use my script.
Not use it in animationscript.
test it ;)
 
thanks its working with no errors
but i cant understand very well to were the player is moving...
i think is moving towards the endlevel_anim entity
and he keeps moving until he reaches the end of the panel hes also moving in idle

is there a way to change the smovetoxz_smoothed variables in endlevel_anim.txt ? to make him play an animation and stop at a certain point... it could be better also to change void player to void Name so it could move the entity by name


 
smovetoxz_smoothed(player,240,120,1,0.5) moves a character in coords x = 240 and z = 120.
you will get an issue if your way isnt free. (in fact you need for checks first).
however try for example:
smovetoxz_smoothed(player,100,openborvariant("player_min_z")+100,1,0.5)

the coords are x and z that you retrieve with
getentityproperty(player,"x");
getentityproperty(player,"z");
in the last case z = openborvariant("player_min_z")+100
so to retrieve it use getentityproperty(player,"z") - openborvariant("player_min_z");

what you ask (to change entity handler named player, in a name of an entity) is a non-sense request.
Infact I can spawn 100 RYU enemies
when I call smovetoxz_smoothed("RYU",...)
what RYU moves himself between 100 RYUs?
It's more logic to work with entity address.
example:
      void ent;
      clearspawnentry();
      setspawnentry("name", "RYU");
      ent = spawn();
      smovetoxz_smoothed(ent,...) // this is the right way


...and yes when you arrive in final destination your entity stops.

here another example with an animation change:
Code:
int movetoxz(void player, float dir_x, float dir_z, int final_direction) {
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");
    float a = getentityproperty(player, "y");
    float base = getentityproperty(player, "base");
    float threshold = 0.99; // precisione
    float speed = getentityproperty(player,"speed");
    float speed_x, speed_z;

    if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") && getentityproperty(player, "animationid") != openborconstant("ANI_RESPAWN") ) {
        if ( a != base ) changeentityproperty(player, "position", x, z, base);

        if ( x > dir_x-threshold && x < dir_x+threshold  ) {
            speed_x = 0;
        } else if ( x < dir_x+threshold ) { // pg deve andare a destra
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_WALK") ) changeentityproperty(player, "animation", openborconstant("ANI_WALK"));
            changeentityproperty(player, "direction", 1);
            speed_x = speed;
            if ( (dir_x-x) <= threshold ) speed_x = (dir_x-x)*(2/3); // Impostiamo la velocità proprio uguale alla distanza che manca
        } else if ( x > dir_x-threshold ) { // pg deve andare a sinistra
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_WALK") ) changeentityproperty(player, "animation", openborconstant("ANI_WALK"));
            changeentityproperty(player, "direction", 0);
            speed_x = -1*speed;
            if ( (x-dir_x) <= threshold ) speed_x = -1*(x-dir_x)*(2/3);
        }

        // Diamo la priorità all'animazione UP/DOWN
        if ( z > dir_z-threshold && z < dir_z+threshold  ) {
            speed_z = 0;
        } else if ( z < dir_z+threshold ) { // pg deve andare giù
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_DOWN") ) changeentityproperty(player, "animation", openborconstant("ANI_DOWN"));
            speed_z = speed/2;
            if ( (dir_z-z) <= threshold ) speed_z = (dir_z-z)*(2/3);
        } else if ( z > dir_z-threshold ) { // pg deve andare su
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_UP") ) changeentityproperty(player, "animation", openborconstant("ANI_UP"));
            speed_z = -1*(speed/2);
            if ( (z-dir_z) <= threshold ) speed_z = -1*(z-dir_z)*(2/3);
        }

        if ( speed_x == 0 && speed_z == 0 ) {
            changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
            if ( getentityproperty(player, "animationid") != openborconstant("ANI_IDLE") ) changeentityproperty(player, "animation", openborconstant("ANI_IDLE"));
            changeentityproperty(player, "direction", final_direction);

            return 1;
        }

        changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
    } // fine if spawn

  return 0;
}
 
thanks its working  :D
the player is moving towards coordinates and stoping

iam trying to change the script endlevel_anim.c so that
(player,240,120,1,0.5) could be inserted into entity endlevel_anim.txt
the only vaule i see fit is HP and MP although i dont know if MP can be changed into an item drop or entity spawn...

#import "data/scripts/automv.c"

void main() {
  void self = getlocalvar("self");
  int HP = getentityproperty(self,"health");
  void player = getplayerproperty(0,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,HP,310,1,0.5) ) {
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
        drawstring(10,10,0,"player has finished to move on");
        //killentity(self); // to finish the script
      }
  }

}

i had to remove nolife from entity endlevel_anim.txt to make it work thoug
there could be better ways in water puddle entity you can set vars in spawn
spawn water_puddle_test
@script
void main() {
void self = getlocalvar("self");

setentityvar(self, 0, "water_puddle"); // name/type
setentityvar(self, 1, 2000); // width
setentityvar(self, 2, 50);    // height
setentityvar(self, 3, 380);  // depth
setentityvar(self, "map", 0);  // ripple/splash map
setentityvar(self, "transp", 60);  // alpha transp value
}
@end_script
coords 0 910 0
at 0

could this be used also in endlevel_anim to make the values in script (player,240,120,1,0.5) alter to diferent ones ?

ill try to put it togheter


 
jonsilva said:
the player is moving towards coordinates and stoping

Yes, it works both movetoxz() and smovetoxz_smoothed() too.  ;)
NOTE: if you use smovetoxz_smoothed() you have to change by yourself the walk animation

jonsilva said:
could this be used also in endlevel_anim to make the values in script (player,240,120,1,0.5) alter to diferent ones ?

ill try to put it togheter

Yes, you can!!

Example:
Code:
#import "data/scripts/automv.c"

void main() {
   void self = getlocalvar("self");
   void player = getplayerproperty(0,"entity"); // retrieve player 1 handler
   float final_x = getentityvar(self,"final_x");
   float final_z = getentityvar(self,"final_z");

   if ( getentityproperty(player,"exists") && final_x != NULL() && final_z != NULL() ) {
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,final_x,final_z,1) ) {
         if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
         drawstring(10,10,0,"player has finished to move on");
         //killentity(self); // to finish the script
      }
   }

}

NOTE:
1) the NULL() checks else the game can crash!  ;)
2) movetoxz() has only 4 parameters (not like smovetoxz_smoothed() that has 5 params).
    With movetoxz() you no need to set the speed (0.5 value for ex.).
    This is because movetoxz() use the player speed setted into entity txt file.
 
i have it working like this
#import "data/scripts/automv.c"

void main() {
  void self = getlocalvar("self");


float x = getentityvar(self, 5);
float z = getentityvar(self, 6);




  void player = getplayerproperty(0,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,1,0.5) ) {
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
        drawstring(200,200,0,"player has finished to move on");
        //killentity(self); // to finish the script
      }
  }

}


in level spawn
spawn  endlevel_anim
@script
void main() {
void self = getlocalvar("self");

setentityvar(self, 5, 500); // coord x
setentityvar(self, 6, 410); // coord z

}
@end_script
coords  250 400
at      900

but in (player,240,120,1,0.5) if i change the 1,0.5 to other values the animation plays the same way
are (1,0.5) velocities for x and z ? coming from player.txt walk speed ?

i also notice that something changed when the player stops moving and the string "player has finished to move on" show on screen the aicontrol turns active but the player stays stuck on the coordinate when you try to move it on...
only when i press jump aicontrol turns off...
i cant understand very well why its happening could it be something in player base
int movetoxz(void player, float dir_x, float dir_z, int final_direction) {
    float x = getentityproperty(player, "x");
    float z = getentityproperty(player, "z");
    float a = getentityproperty(player, "y");
    float base = getentityproperty(player, "base");
    float threshold = 0.99; // precisione
    float speed = getentityproperty(player,"speed");
    float speed_x, speed_z;
 
OK, I comment your script:
#import "data/scripts/automv.c"

void main() {
  void self = getlocalvar("self");
  float x = getentityvar(self, 5); // use getentityvar(self, "final_x"); indeed (I prefer label entityvars indeed of indexed entityvars)
  float z = getentityvar(self, 6);
  void player = getplayerproperty(0,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) { // MISSING NULL() checks
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,1,0.5) ) { // movetoxz() doesnt use the speed param (it uses the entity speed), so 0.5 is an unused value in this case
        if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
        drawstring(200,200,0,"player has finished to move on");
        //killentity(self); // to finish the script. UNCOMMENT THIS ONE TO FINISH THE AUTO WALK (and to regain player control)
      }
  }
}

Dont change anything into the function (base or other). the problem is that you dont kill the entity that moves the character.

now I explain both functions:

movetoxz(entity,x,z,direction);
-entity = entity handler
-x = final x coord
-z = final z coord
-direction = flag for final direction (direction when the entity stops). 1 == dx, 0 == sx
RETURN: the func returns 1 if the entity is in final (x,z) coords, else it returns 0.
DESCRIPTION: This func moves the entity from (x0,z0) to (x,z) with an animation change (using UP,DOWN,WALK when the entity moves himself).

smovetoxz_smoothed(entity,x,z,direction,speed);
-entity = entity handler
-x = final x coord
-z = final z coord
-direction = flag for final direction (direction when the entity stops). 1 == dx, 0 == sx
-speed = a float value. its walk speed
RETURN: the func returns 1 if the entity is in final (x,z) coords, else it returns 0.
DESCRIPTION: This func moves the entity diagonally from (x0,z0) to (x,z) without an animation change.
 
thanks everything seems to be working
i had to remove the final
if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);

to keep the noaicontrol on
my idea was make it look like the cadilacs and dinasours ending were the players move to a certain position and the boss moves to another...

i have it work like this
#import "data/scripts/automv.c"

void main() {
  void self = getlocalvar("self");

float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8); //  ***(self,8)***  player nº 0 1 2




  void player = getplayerproperty(p,"entity"); // retrieve player 1 handler

  if ( getentityproperty(player,"exists") ) {
      if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
      if ( movetoxz(player,x,z,d,0.5) ) {
        //if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
        drawstring(200,200,0,"player has finished to move on");
        //killentity(self); // to finish the script
      }
  }

}

this time ive set vars in endlevel_anim.txt along with spawn01 in boss death anim
name endlevel_anim
type none
health 6400
#nolife 1
#setlayer 1
facing 2
nomove 1 0

script data/scripts/endlevel_anim.c



anim idle
@script

void self = getlocalvar("self");
setentityvar(self, 5, 6700); // coord x
setentityvar(self, 6, 310); // coord z
setentityvar(self, 7, 1); // direction 0 left 1 right
setentityvar(self, 8, 1); // player nº

@end_script
loop 0
delay 100
offset 20 25
bbox 0 0 0 0
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

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 ?
 
Back
Top Bottom