2 registered members (7th_zorro, dr_panther),
724
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Expert
|
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
OP
Newbie
|
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: Damocles]
#181184
02/01/08 21:19
02/01/08 21:19
|
Joined: Oct 2007
Posts: 34
Morph
OP
Newbie
|
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]
#181187
02/03/08 00:24
02/03/08 00:24
|
Joined: Jan 2006
Posts: 2,157 Connecticut, USA
Blink
Expert
|
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
Expert
|
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
Expert
|
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
Expert
|
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."
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|