Gamestudio Links
Zorro Links
Newest Posts
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
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, degenerate_762), 1,430 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: Simple enemy... [Re: Blink] #181191
02/03/08 22:10
02/03/08 22:10
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
There is a mistake in the code.
I'm not sure why the compiler does not report an error:
Code:

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
{


Can you see it?
Do you see it now:
Code:

while(!plBiped01_entity) { wait(1); } // wait until the player exists
{


It should be:
Code:

while(!plBiped01_entity) { wait(1); } // wait until the player exists
while(my.healthpoints > 0)
{



Furthermore you may replace these lines:
Code:

enemy = me; // I'm the enemy
enemy.healthpoints = 100; // and I have 100 healthpoints


With this:
Code:

my.healthpoints = 100;


The enemy = my; stuff makes only sense if you have on enemy at a time.
But its useless if you use many enemies.

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

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
no errors or arguements anymore, and the enemy is alive, but he doesnt respond at all when i run into him, matter of fact, he is passable. also, he doesnt die, i shot him over a hundred times, but no affect. here is the code with the corrections.

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);
my.healthpoints = 100;
while(!plBiped01_entity) { wait(1); } // wait until the player exists
while(my.healthpoints > 0)
{
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(me,"walk", my.skill19, ANM_CYCLE); // 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(me,"attack", my.skill20, ANM_CYCLE); // 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(me,"stand", my.skill21, ANM_CYCLE); // 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(me,"death", my.skill22, ANM_CYCLE); // 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] #181193
02/04/08 00:15
02/04/08 00:15
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Hi, Blink
I think maybe where you got my.passable = on;
should be in the while loop.

Code:

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




Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus
Re: Simple enemy... [Re: Nidhogg] #181194
02/04/08 03:08
02/04/08 03:08
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
still no change, thanks anyway.


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] #181195
02/04/08 08:05
02/04/08 08:05
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
There was some weird bracket stuff going on.
I rewrote and cleaned up the code a bit, now you should also be able to use it on many enemies:
Code:


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


action enemy_fight
{
var move_dist[3];
var distance;

my.healthpoints = 100;

c_setminmax(my);
wait(1);

while(plBiped01_entity == null) { wait(1); }

while(my.healthpoints > 0)
{
distance = vec_dist(my.x, plBiped01_entity.x);

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;

move_dist.x = 5 * time_step;
move_dist.y = 0;
move_dist.z = 0;
c_move(my,move_dist,nullvector,IGNORE_PASSABLE);

ent_animate(my, "walk", my.skill19, ANM_CYCLE); // play walk frames animation
my.skill19 = cycle(my.skill19+5*time_step,0,101); // "walk" animation speed + loop animation

if(distance < 50) // if the player comes closer than 50 quants attack him
{
my.skill20 = 0; // reset "attack" frames

while(my.skill20 < 100)
{
vec_for_vertex(my.sword_base,my,306);
vec_for_vertex(my.sword_tip,my,291);

c_trace(my.sword_base,my.sword_tip,IGNORE_ME|IGNORE_PASSABLE);

if(you)
{
you.healthpoints -= 4 * time_step;
}

ent_animate(my,"attack",my.skill20,ANM_CYCLE); // play attack frames animation
my.skill20 += 5 * time_step; // "attack" animation speed

wait(1);
}

wait(6);
}
}
else // the player is farther than 200 quants away
{
ent_animate(my,"stand",my.skill21,ANM_CYCLE); // play stand frames animation
my.skill21 = cycle(my.skill21+2*time_step,0,101); // "stand" animation speed + loop animation
}

wait(1);
}

// enemy was killed:
while(my.skill22 < 80)
{
ent_animate(me,"death", my.skill22, ANM_CYCLE); // 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
}



But be aware: This code does not include that the enemy takes damage (reacts to a certain event), thus your weapon code needs to handle this.
I'm not sure how the templates work though.

Re: Simple enemy... [Re: Xarthor] #181196
02/04/08 22:17
02/04/08 22:17
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
well, it works sort of...i couldnt kill him, but he attacks, sort of, and he walks and stands fine. am i forgetting to add something to the code? maybe something i have to add to the plbiped code so the plbiped weapons will affect the enemy model and vice versa? what do you think Xarthor?


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] #181197
02/05/08 09:11
02/05/08 09:11
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I think you need to add something to the enemy code.
However this is based up on the weapon code you use.
If your weapons use the "ACTIVATE_SHOOT" flag you simply need an event function for the enemy which reduces his health points when his event is event_shoot:
Code:

function enemy_events()
{
if(event_type == event_shoot)
{
my.healthpoints -= 10;
}
}

action enemy_fight
{
var move_dist[3];
var distance;

my.enable_shoot = on;
my.event = enemy_events;


my.healthpoints = 100;
//rest of the code



Re: Simple enemy... [Re: Xarthor] #181198
02/05/08 12:23
02/05/08 12:23
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
works perfectly! thanks for your help. after i tweak it a little, i will post it for the community. you are a genius!


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 3 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