Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,295 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moving Targets #3479
05/11/01 12:28
05/11/01 12:28
Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
W
WildCat Offline OP
Expert
WildCat  Offline OP
Expert
W

Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
Is anyone willing to share some code that will have a projectile hit a moving target?

It would be very educational. I'm suprised at the difficulties I am having with this. (I'm trying to do it in 3 dimentions, but if anyone has something that works in 2, I will get the idea)

Thanks.

-WildCat



Visit us at [url=http://www.vertexgames.com]Vertex Games[/url]!
Re: Moving Targets #3480
05/13/01 15:57
05/13/01 15:57

A
Anonymous
Unregistered
Anonymous
Unregistered
A



My idea would be to create a rocket model, or whatever, on a key command from the player position. then use the vec_to_angle code (see the war.wdl where the enemies turn to the player) so it aligns on the target you want.

You could use a synonym entity that it aligns or another idea would be to use scan command to find the nearest enemy.

Just an idea.

Brandon


Re: Moving Targets #3481
05/14/01 23:08
05/14/01 23:08
Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
W
WildCat Offline OP
Expert
WildCat  Offline OP
Expert
W

Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
Thanks Again AcidCrow,

But the problem is that I am using "relatively Slow Moving" projectiles. If I just point at the target and shoot, the target will no longer be there by the time the bullet arrives.

I need to aim at where the target is going to be by the time the bullet covers that distance.

- WildCat



Visit us at [url=http://www.vertexgames.com]Vertex Games[/url]!
Re: Moving Targets #3482
05/15/01 01:32
05/15/01 01:32

A
Anonymous
Unregistered
Anonymous
Unregistered
A



WildCat,

You need the code for an AI script? As to tell the NPC where the player is supposed to be on hit time, knowing the rocket speed and player movement?

The code for a guided rocket, as AcidCrow said?

Or other?

------------------

Acid, I think you could help me on a similar case with a hand in the back:


I'm trying to write a cinematic action. The objective is to make it so easy to use, no wdl would be touched by the level developer. In WED the user would have just to create an entity for camera (and attach the action to it), a path, and a target. All the names would have to be "camera_#", "caminho_#", and "camalvo_#" respectively, where # is the number of the group. And for last, he should provide some information on the camera trought skills. This way could be easily added several cameras to create a beautiful cinematic sequence full of travelings or rough cuts. The skills necessary are:
Skill 1 - Time to start the # camera movement;
Skill 2 - Time to end it;
Skill 5 - How many ticks it must take to fly from one to the next point of the path;
Skill 8 - The # of the group.

I got the cam entity follow the right path, I got my camera following the cam entity, I got the camera looking where my cam entity is looking to, but I didn't get my cam entity to look to the target entity. I can make it look to a given point in 3d space with wdl, but couldn't make it look to an entity which name is given by a string. This is vital since, proving myself I can do this, I plan to improve the action giving mobile targets, maybe smooth movement trought paths (algebra here I come!), and make the sequence start on a trigger event, not only based on time since start of the level. And at the end, optimize everything.

Following is the part of the code I have something wrong.

///////////////////////////////////////////
...
SYNONYM entidade {type entity;}
STRING camalvo_num = " ";
STRING cine_numstr = " ";

ACTION cinematica
{
...
DEFINE cine_num = MY.skill8;
to_string cine_numstr, cine_num;

str_cpy(camalvo_num,"camalvo_");
str_cat(camalvo_num,cine_numstr);

entidade = syn_for_name(camalvo_num);
...
temp.x = entidade.x - my.x;
temp.y = entidade.y - my.y;
temp.z = entidade.z - my.z;
vec_to_angle(my.pan,temp);
...
}
///////////////////////////////////////////

All works perfectly, I get all my script working if I substitute entidade.x for a vector as I said, or for player.x. I think it would be as the my synonym, but it isn't. The problem is I don't know how to get entidade's position vector. Couldn't find on the manual. I'm pretty sure the problem is here. Thanks, and sorry for the bad english.

------------------

Maybe after this problem is solved, something may be usable by WildCat.


Re: Moving Targets #3483
05/15/01 02:59
05/15/01 02:59
Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
W
WildCat Offline OP
Expert
WildCat  Offline OP
Expert
W

Joined: Jul 2000
Posts: 1,570
Windsor, CT 06095
Greetings, André,

I need the Moving Target code for an AI script to go with the Spaceflight workshop. The ship can point in any direction, not just in 2d, and fire projectiles which are non-guided.


-WildCat



Visit us at [url=http://www.vertexgames.com]Vertex Games[/url]!
Re: Moving Targets #3484
05/15/01 08:11
05/15/01 08:11

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Andre,

Not quite sure if I understand what you need...

Do you to follow entidade (or another entity) all the time?
If so just add a while(1) to the lines where you set the vec_to_angle.

if you just want the vector position in a seperate variable create the variable use the vec_set command.

If you need something different you can email me I and I can probably help you more.

Wildcat,

So you just need some code to move a target?

Brandon


Re: Moving Targets #3485
05/15/01 12:28
05/15/01 12:28

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Wildcat, I'm not sure if I can help you, but I'll post some data probably is wrong or you already know.

Basically I think this could be solved by getting the speed of player at the moment the NPC wants to fire. Then based on speed of projectil and distance to player, you would have an suposed target. If the player keeps a uniform movement, he will be hit. Also would be nice to do a trace to be shure it will not hit anything before the position the NPC think the player will be. This is a nice thing you came to, and it could be used to make different inteligences. Easy enemies would do this with some random error range, and difficult ones would do this calculating also acceleration.

I just can see it working on a very, very slow projectil. Since the player is always changing velocity and direction. And he would also noticed that was spot and would easyly flee.

Unfortunatelly my scripts at the moment are more like the guided rocket than the future prediction style.

-------------------------------------------

AcidCrow,

I'll post my code till now for my cinematic script. There are a lot of useless variables because I am also trying to implement smooth movement trought path points. Also there is a lot of room for optimizations and corrections, but my bigger problem is the fact I can't get the entidade's vector. If you would like to test it, create a entity with the action cinematica, an entity with the name "camalvo_#" and a path with the name "caminho_#" where # is the number of the group. In the entity with cinematica action, put the following skills:
Skill 1 - Time to start the # camera movement;
Skill 2 - Time to end it;
Skill 5 - How many ticks it must take to fly from one to the next point of the path;
Skill 8 - The # of the group.
You can make several groups, making always the end time of one += 1 to it's predecessor take.
I would also enjoy any comment more on the script, any criticism, and obviously, any suggestion on how to improve it. And, how usable do you think this idea is? I thought it would be nice for non-programers. Eventually, I plan to make the cinematics follow an event, other than level load. The lines in red is where I think may be something wrong. I ask you to substitue the entidade.xyz part for distancia2.xyz just for testing porpouse. See? It works if I give a specific vector.

Thanks in advance,

--------------------------------------------------------------------------------

////////////////////////////////////////////////////////////
// Início do código de cinemáticas plug N play.
////////////////////////////////////////////////////////////

VAR crono = 1;
VAR ponto_anterior[3];
VAR ponto_atual1[3];
VAR ponto_atual2[3];
VAR ponto_proximo[3];
VAR distancia[3];
VAR distancia2[3] = 604,0,330;
VAR qpptemp = 1;
VAR cronometro_var = 0;

STRING caminho_num = " ";
STRING camalvo_num = " ";
STRING cine_numstr = " ";
STRING mensagem = " ";

SYNONYM entidade { type entity; }

FUNCTION cronometro () {
WHILE (1) {
cronometro_var += 1;
WAITT(1);
}
}


ACTION cinematica
{
WHILE (cronometro_var < MY.skill1) {waitt(1);}
loucas_cameras();
}

// Lembrar de transformar muitas das variáveis em SKILL
// para não tê-las correndo globalmente.
FUNCTION loucas_cameras () {

exclusive_global;
// Transforma a entidade num fantasma invisível
MY.invisible = ON;
MY.passable = ON;

DEFINE inico = MY.skill1; // Quando começa o take em ticks desde o começo do nível
DEFINE fim = MY.skill2; // Quando termina, em ticks após o começo do nível
DEFINE qpp = MY.skill5; // Define quantos intervalos deve levar de um ponto a outro do caminho
DEFINE cine_num = MY.skill8; // # para definir o conjunto Câmera, Caminho e Alvo

to_string cine_numstr, cine_num;

// DEFINE qual caminho e qual alvo usar para a entidade através de STRINGS
str_cpy(caminho_num,"caminho_");
str_cat(caminho_num,cine_numstr);
str_cpy(camalvo_num,"camalvo_");
str_cat(camalvo_num,cine_numstr);

entidade = syn_for_name(camalvo_num);

msg.visible = on;
msg.string = camalvo_num;

ent_path(caminho_num); // Localiza o caminho correspondente

ent_waypoint(ponto_anterior.x,1);

ent_nextpoint(ponto_atual1.x);
MY.x = ponto_atual1.x;
MY.y = ponto_atual1.y;
MY.z = ponto_atual1.z;

ent_nextpoint(ponto_atual2.x);

crono = inico;
while (crono < fim)
{

ent_nextpoint(ponto_proximo.x);

// Percorre a distância de um ponto ao outro em tantas etapas (my.skill5)
WHILE (qpptemp <= qpp)
{
distancia.x = (ponto_atual2.x - ponto_atual1.x) / qpp;
distancia.y = (ponto_atual2.y - ponto_atual1.y) / qpp;
distancia.z = (ponto_atual2.z - ponto_atual1.z) / qpp;
move (my, nullvector, distancia);

temp.X = entidade.x - MY.X;
temp.Y = entidade.y - MY.Y;
temp.Z = entidade.z - MY.Z;
vec_to_angle(my.pan,temp.x);

CAMERA.x = MY.x;
CAMERA.y = MY.y;
CAMERA.z = MY.z;
CAMERA.pan = MY.pan;
CAMERA.tilt = MY.tilt;

qpptemp += 1;
crono += 1;
waitt(1);
}

// Redefine dados necessários, e prepara dados já computados para o próximo ponto

qpptemp = 1;

MY.x = ponto_atual2.x;
MY.y = ponto_atual2.y;
MY.z = ponto_atual2.z;

vec_set(ponto_anterior,ponto_atual1);
vec_set(ponto_atual1,ponto_atual2);
vec_set(ponto_atual2,ponto_proximo);
WAIT(1);
}
}

////////////////////////////////////////////////////////////
// Fim do código de cinemáticas plug N play.
////////////////////////////////////////////////////////////

--------------------------------------------------------------------------------



Moderated by  HeelX, Spirit 

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