Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
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
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: Simple enemy... [Re: kasimir] #181181
02/01/08 17:24
02/01/08 17:24
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I cannot spot a mistake right now, but here is the whole code looking a bit more nicely:
Code:


action enemy_fight // attached to the enemy
{
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints

while (my.healthpoints > 0) // as long as I'm alive
{
if (vec_dist (my.x, player.x) < 200 && player.healthpoints > 0) // the player approaches the enemy
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac
enemy_distance.x = 5 * time;
enemy_distance.y = 0;
enemy_distance.z = 0;
ent_move(enemy_distance, nullvector);
ent_cycle("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time; // "walk" animation speed

if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, player.x) < 50) // if the player comes closer than 50 quants attack him
{
my.skill20 = 0; // reset "attack" frames

while (my.skill20 < 100)
{
ent_vertex(my.sword_tip, 291); // sword tip vertex coords - get the value in Med
ent_vertex(my.sword_base, 306); // sword base vertex coords - get the value in Med
trace_mode = ignore_me + ignore_passable;
trace (my.sword_base, my.sword_tip); // trace between these sword positions

if (result != 0) // hit something, could be the player or another enemy
{
if (you != null) {you.healthpoints -= 4 * time;}
}

ent_cycle("attack", my.skill20); // play attack frames animation
my.skill20 += 5 * time; // "attack" animation speed

wait (1);
}

waitt (6); // slows down the enemy and reduces the number of traces per second
}
}
else // the player is farther than 200 quants away
{
ent_cycle("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}

wait (1);
}

while (my.skill22 < 80) // the enemy is dead
{
ent_cycle("death", my.skill22); // play death frames animation
my.skill22 += 1 * time; // "death" animation speed
wait (1);
}

my.passable = on; // the corpse can't be hit by the sword from now on
}



Re: Simple enemy... [Re: Xarthor] #181182
02/01/08 18:43
02/01/08 18:43
Joined: Oct 2007
Posts: 34
Morph Offline OP
Newbie
Morph  Offline OP
Newbie

Joined: Oct 2007
Posts: 34
hi, i clear the bracket and modified the code in some cases, is equal but more nicely...and i have other error lol, (sorry for the much questions but i am begginer), look the update code:

(the fields in red colour are the updates)

Code:
  
var player_distance; // moves the player
var enemy_distance; // moves the enemy
var distance;

define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18

entity* enemy;

action enemy_fight // attached to the enemy
{
distance = vec_dist (my.x, player.x);
enemy = me; // I'm the enemy

enemy.healthpoints = 100; // and I have 100 healthpoints
while(!player) { wait(1); } // wait until the player exists
{
if (distance < 200) // the player approaches the enemy
{
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac :)
enemy_distance.x = 5 * time;
enemy_distance.y = 0;
enemy_distance.z = 0;
ent_move(enemy_distance, nullvector);
ent_cycle("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time; // "walk" animation speed
if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, player.x) < 50) // if the player comes closer than 50 quants attack him
{
my.skill20 = 0; // reset "attack" frames
while (my.skill20 < 100)
{
ent_vertex(my.sword_tip, 291); // sword tip vertex coords - get the value in Med
ent_vertex(my.sword_base, 306); // sword base vertex coords - get the value in Med
trace_mode = ignore_me + ignore_passable;
trace (my.sword_base, my.sword_tip); // trace between these sword positions
if (result != 0) // hit something, could be the player or another enemy
{

if (you != null) {you.healthpoints -= 4 * time;}

}
ent_cycle("attack", my.skill20); // play attack frames animation
my.skill20 += 5 * time; // "attack" animation speed
wait (1);
}
waitt (6); // slows down the enemy and reduces the number of traces per second
}
}
else // the player is farther than 200 quants away
{
ent_cycle("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
wait (1);

while (my.skill22 < 80) // the enemy is dead
{
ent_cycle("death", my.skill22); // play death frames animation
my.skill22 += 1 * time; // "death" animation speed
wait (1);
}

my.passable = on; // the corpse can't be hit by the sword from now on
}





Good, put me error in ejecution: "Empty pointer in enemy_fight: distance=vec_dist(my.x,player.x)"

Help me please. bye

Last edited by Morph; 02/01/08 18:48.

Begginer in 3D Game Studio
Re: Simple enemy... [Re: Xarthor] #181183
02/01/08 20:21
02/01/08 20:21
Joined: Jan 2003
Posts: 4,305
Damocles Offline
Expert
Damocles  Offline
Expert

Joined: Jan 2003
Posts: 4,305
the player is not initialised yet

make a wait at the beginning:

action enemy_fight // attached to the enemy
{
wait(1);



or:

action enemy_fight // attached to the enemy
{
while(player==null){wait(1);}

Re: Simple enemy... [Re: Damocles] #181184
02/01/08 21:19
02/01/08 21:19
Joined: Oct 2007
Posts: 34
Morph Offline OP
Newbie
Morph  Offline OP
Newbie

Joined: Oct 2007
Posts: 34
Hi Democles, look, the error is solved, now compile and run and the error not visible but the enemy... not move . What is the problem now? the enemy would that attack the player at the 50 quants...but the enemy NOT MOVE. Help me again please, is important.

Last edited by Morph; 02/01/08 21:20.

Begginer in 3D Game Studio
Re: Simple enemy... [Re: Morph] #181185
02/01/08 21:31
02/01/08 21:31
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
did you set the pointer to your player???

action player_move
{
player = me;
...

Re: Simple enemy... [Re: kasimir] #181186
02/01/08 23:58
02/01/08 23:58
Joined: Oct 2007
Posts: 34
Morph Offline OP
Newbie
Morph  Offline OP
Newbie

Joined: Oct 2007
Posts: 34
Thanks you all!!!!!!!!!! Problem solved! thank you kasimir!!


Begginer in 3D Game Studio
Re: Simple enemy... [Re: Morph] #181187
02/03/08 00:24
02/03/08 00:24
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
@Xarthor:
just a question, i was playing around with your code a bit, and changed a few things to see if it would attack the template plbiped01_entity. the code ran with no errors, but when the level started, i got an error saying "invalid arguements in enemy_fight: ent_animate(@2, my.skill21)", then a crash afterwards saying the same thing. what did i miss?


My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
Re: Simple enemy... [Re: Blink] #181188
02/03/08 00:46
02/03/08 00:46
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
here's the modification:
Code:
var enemy_distance; // moves the enemy
var distance;
define sword_base = skill12; // using skill12, 13, 14 to store the sword_base coords
define sword_tip = skill15; // using skill15, 16, 17 to store the sword_tip coords
define healthpoints = skill18; // just another name for skill18
entity* enemy;
action enemy_fight // attached to the enemy
{
while(plBiped01_entity==null){wait(1);}
distance = vec_dist (my.x, plBiped01_entity.x);
enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints
while(!plBiped01_entity) { wait(1); } // wait until the player exists
{
if (distance < 200) // the player approaches the enemy
{
vec_set(temp, plBiped01_entity.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0; // I'm a maniac :)
enemy_distance.x = 5 * time_step;
enemy_distance.y = 0;
enemy_distance.z = 0;
ent_move(enemy_distance, nullvector);
ent_animate("walk", my.skill19); // play walk frames animation
my.skill19 += 5 * time_step; // "walk" animation speed
if (my.skill19 > 100) {my.skill19 = 0;} // loop animation
if (vec_dist (my.x, plBiped01_entity.x) < 50) // if the player comes closer than 50 quants attack him
{
my.skill20 = 0; // reset "attack" frames
while (my.skill20 < 100)
{
ent_vertex(my.sword_tip, 291); // sword tip vertex coords - get the value in Med
ent_vertex(my.sword_base, 306); // sword base vertex coords - get the value in Med
trace_mode = ignore_me + ignore_passable;
trace (my.sword_base, my.sword_tip); // trace between these sword positions
if (result != 0) // hit something, could be the player or another enemy
{
if (you != null) {you.healthpoints -= 4 * time_step;
} }
ent_animate("attack", my.skill20); // play attack frames animation
my.skill20 += 5 * time_step; // "attack" animation speed
wait (1);
}
wait (6); // slows down the enemy and reduces the number of traces per second
}
}
else // the player is farther than 200 quants away
{
ent_animate("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time_step; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
wait (1);

while (my.skill22 < 80) // the enemy is dead
{
ent_animate("death", my.skill22); // play death frames animation
my.skill22 += 1 * time_step; // "death" animation speed
wait (1);
}
my.passable = on; // the corpse can't be hit by the sword from now on
}




My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
Re: Simple enemy... [Re: Blink] #181189
02/03/08 09:42
02/03/08 09:42
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
You have to be carefull with "ent_animate". The ent_animate instruction expects an entity pointer as first argument:
Quote:


ent_animate(ENTITY* entity,STRING* scene,var percent,var mode)





Thus you need to change all your ent_animate instructions:
Simply add a "my," in the instruction.
Example:
ent_animate(me,"stand",my.skill21,ANM_CYCLE);

Re: Simple enemy... [Re: Xarthor] #181190
02/03/08 19:54
02/03/08 19:54
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
thanks a lot Xarthor, but now i have another issue. the level runs with no errors, but the enemy is dead when i approach it. what should i do?


My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
Page 2 of 3 1 2 3

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