[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Melee problem

Melee problem

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Melee problem

Postby shadowtails » Tue Sep 26, 2006 2:16 pm

I need some help about melee function.
When q2berserk attack on player and do melee attack he is so far to hit player.I try touch function but it is a huge bug for play.Can somebody help please?
Here is the code:

/*
==============================================================================

QUAKE 2 BERSERK
==============================================================================
*/

$cd /raid/quake/id1/models/berserk
$origin 0 -6 24
$base base
$skin skin

$frame stand1 stand2 stand3 stand4 stand5

$frame standb1 standb2 standb3 standb4 standb5 standb6 standb7 standb8 standb9 standb10
$frame standb11 standb12 standb13 standb14 standb15 standb16 standb17 standb18 standb19 standb20

$frame walkc1 walkc2 walkc3 walkc4 walkc5 walkc6 walkc7 walkc8
$frame walkc9 walkc10 walkc11

$frame run1 run2 run3 run4 run5 run6

$frame att_a1 att_a2 att_a3 att_a4 att_a5 att_a6 att_a7 att_a8
$frame att_a9 att_a10 att_a11 att_a12 att_a13

$frame slam1 slam2 slam3 slam4 slam5 slam6 slam7 slam8
$frame slam9 slam10 slam11 slam12 slam13 slam14 slam15 slam16
$frame slam17 slam18 slam19 slam20 slam21 slam22 slam23

$frame painc1 painc2 painc3 painc4

$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8
$frame painb9 painb10 painb11 painb12 painb13 painb14 painb15 painb16
$frame painb17 painb18 painb19 painb20

$frame death1 death2 death3 death4 death5 death6 death7 death8
$frame death9 death10 death11 death12 death13

$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8


void() berserk_stand1 =[ $stand1, berserk_stand2 ] {ai_stand();};
void() berserk_stand2 =[ $stand2, berserk_stand3 ] {ai_stand();};
void() berserk_stand3 =[ $stand3, berserk_stand4 ] {ai_stand();};
void() berserk_stand4 =[ $stand4, berserk_stand5 ] {ai_stand();};
void() berserk_stand5 =[ $stand5, berserk_stand6 ] {ai_stand();};
void() berserk_stand6 =[ $stand5, berserk_stand7 ] {ai_stand();};
void() berserk_stand7 =[ $stand5, berserk_stand8 ] {ai_stand();};
void() berserk_stand8 =[ $stand5, berserk_stand9 ] {ai_stand();};
void() berserk_stand9 =[ $stand5, berserk_stand10 ] {ai_stand();};
void() berserk_stand10 =[ $stand5, berserk_stand11 ] {ai_stand();};
void() berserk_stand11 =[ $stand5, berserk_stand12 ] {ai_stand();};
void() berserk_stand12 =[ $stand5, berserk_stand13 ] {ai_stand();};
void() berserk_stand13 =[ $stand5, berserk_stand14 ] {ai_stand();};
void() berserk_stand14 =[ $stand5, berserk_stand15 ] {ai_stand();};
void() berserk_stand15 =[ $stand5, berserk_stand16 ] {ai_stand();};
void() berserk_stand16 =[ $stand5, berserk_stand17 ] {ai_stand();};
void() berserk_stand17 =[ $stand5, berserk_stand18 ] {ai_stand();};
void() berserk_stand18 =[ $stand5, berserk_stand19 ] {ai_stand();};
void() berserk_stand19 =[ $stand5, berserk_stand20 ] {ai_stand();};
void() berserk_stand20 =[ $stand5, berserk_stand21 ] {ai_stand();};
void() berserk_stand21 =[ $standb1, berserk_stand22 ] {ai_stand();};
void() berserk_stand22 =[ $standb2, berserk_stand23 ] {ai_stand();};
void() berserk_stand23 =[ $standb3, berserk_stand24 ] {ai_stand();};
void() berserk_stand24 =[ $standb4, berserk_stand25 ] {ai_stand();};
void() berserk_stand25 =[ $standb5, berserk_stand26 ] {ai_stand();};
void() berserk_stand26 =[ $standb6, berserk_stand27 ] {ai_stand();};
void() berserk_stand27 =[ $standb7, berserk_stand28 ] {ai_stand();};
void() berserk_stand28 =[ $standb8, berserk_stand29 ] {ai_stand();};
void() berserk_stand29 =[ $standb9, berserk_stand30 ] {ai_stand();};
void() berserk_stand30 =[ $standb10, berserk_stand31 ] {ai_stand();};
void() berserk_stand31 =[ $standb11, berserk_stand32 ] {ai_stand();};
void() berserk_stand32 =[ $standb12, berserk_stand33 ] {ai_stand();};
void() berserk_stand33 =[ $standb13, berserk_stand34 ] {ai_stand();};
void() berserk_stand34 =[ $standb14, berserk_stand35 ] {ai_stand();};
void() berserk_stand35 =[ $standb15, berserk_stand36 ] {ai_stand();};
void() berserk_stand36 =[ $standb16, berserk_stand37 ] {ai_stand();};
void() berserk_stand37 =[ $standb17, berserk_stand38 ] {ai_stand();};
void() berserk_stand38 =[ $standb18, berserk_stand39 ] {ai_stand();};
void() berserk_stand39 =[ $standb19, berserk_stand40 ] {ai_stand();};
void() berserk_stand40 =[ $standb20, berserk_stand1 ] {ai_stand();};


void() berserk_walk01 =[ $walkc1, berserk_walk02 ] {
if (random() < 0.2)
sound (self, CHAN_VOICE, "berserk/idle.wav", 1, ATTN_IDLE);
ai_walk(9);};
void() berserk_walk02 =[ $walkc2, berserk_walk03 ] {ai_walk(6);};
void() berserk_walk03 =[ $walkc3, berserk_walk04 ] {ai_walk(5);};
void() berserk_walk04 =[ $walkc4, berserk_walk05 ] {ai_walk(6);};
void() berserk_walk05 =[ $walkc5, berserk_walk06 ] {ai_walk(6);};
void() berserk_walk06 =[ $walkc6, berserk_walk07 ] {ai_walk(8);};
void() berserk_walk07 =[ $walkc7, berserk_walk08 ] {ai_walk(7);};
void() berserk_walk08 =[ $walkc8, berserk_walk09 ] {ai_walk(6);};
void() berserk_walk09 =[ $walkc9, berserk_walk10 ] {ai_walk(4);};
void() berserk_walk10 =[ $walkc10, berserk_walk11 ] {ai_walk(4);};
void() berserk_walk11 =[ $walkc11, berserk_walk01 ] {ai_walk(4);};

void() berserk_run1 =[ $run1, berserk_run2 ] {ai_run(21);sound (self, CHAN_VOICE, "berserk/idle2.wav", 1, ATTN_IDLE);};
void() berserk_run2 =[ $run2, berserk_run3 ] {ai_run(11);};
void() berserk_run3 =[ $run3, berserk_run4 ] {ai_run(21);};
void() berserk_run4 =[ $run4, berserk_run5 ] {ai_run(2);};
void() berserk_run5 =[ $run5, berserk_run6 ] {ai_run(18);};
void() berserk_run6 =[ $run6, berserk_run1 ] {ai_run(19);};

void() berserk_pain1 =[ $painc1, berserk_pain2 ] {ai_pain();};
void() berserk_pain2 =[ $painc2, berserk_pain3 ] {ai_pain();};
void() berserk_pain3 =[ $painc3, berserk_pain4 ] {ai_pain();};
void() berserk_pain4 =[ $painc4, berserk_run1 ] {ai_pain();};

void() berserk_painb1 =[ $painb1, berserk_painb2 ] {ai_pain();};
void() berserk_painb2 =[ $painb2, berserk_painb3 ] {ai_pain();};
void() berserk_painb3 =[ $painb3, berserk_painb4 ] {ai_pain();};
void() berserk_painb4 =[ $painb4, berserk_painb5 ] {ai_pain();};
void() berserk_painb5 =[ $painb5, berserk_painb6 ] {ai_pain();};
void() berserk_painb6 =[ $painb6, berserk_painb7 ] {ai_pain();};
void() berserk_painb7 =[ $painb7, berserk_painb8 ] {ai_pain();};
void() berserk_painb8 =[ $painb8, berserk_painb9 ] {ai_pain();};
void() berserk_painb9 =[ $painb9, berserk_painb10 ] {ai_pain();};
void() berserk_painb10 =[ $painb10, berserk_painb11 ] {ai_pain();};
void() berserk_painb11 =[ $painb11, berserk_painb12 ] {ai_pain();};
void() berserk_painb12 =[ $painb12, berserk_painb13 ] {ai_pain();};
void() berserk_painb13 =[ $painb13, berserk_painb14 ] {ai_pain();};
void() berserk_painb14 =[ $painb14, berserk_painb15 ] {ai_pain();};
void() berserk_painb15 =[ $painb15, berserk_painb16 ] {ai_pain();};
void() berserk_painb16 =[ $painb16, berserk_painb17 ] {ai_pain();};
void() berserk_painb17 =[ $painb17, berserk_painb18 ] {ai_pain();};
void() berserk_painb18 =[ $painb18, berserk_painb19 ] {ai_pain();};
void() berserk_painb19 =[ $painb19, berserk_painb20 ] {ai_pain();};
void() berserk_painb20 =[ $painb20, berserk_run1 ] {ai_pain();};


void(entity attacker, float damage) berserk_pain =
{
local float r;

r = random ();
if (self.pain_finished > time)
return;


if (r < 0.5)
sound (self, CHAN_VOICE, "berserk/pain1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, "berserk/pain2.wav", 1, ATTN_NORM);

if (r < 0.2)
{
self.pain_finished = time + 3.0;
berserk_painb1 ();
}
else if (r < 0.4)
{
self.pain_finished = time + 1.0;
berserk_pain1 ();
}

};


void() berserk_die1 =[ $death1, berserk_die2 ] {ai_back();};
void() berserk_die2 =[ $death2, berserk_die3 ] {ai_back();};
void() berserk_die3 =[ $death3, berserk_die4 ]
{self.solid = SOLID_NOT;ai_back(0);};
void() berserk_die4 =[ $death4, berserk_die5 ] {ai_back();};
void() berserk_die5 =[ $death5, berserk_die6 ] {ai_back();};
void() berserk_die6 =[ $death6, berserk_die7 ] {ai_back();};
void() berserk_die7 =[ $death7, berserk_die8 ] {ai_back();};
void() berserk_die8 =[ $death8, berserk_die9 ] {ai_back();};
void() berserk_die9 =[ $death9, berserk_die10 ] {ai_back();};
void() berserk_die10 =[ $death10, berserk_die11 ] {ai_back();};
void() berserk_die11 =[ $death11, berserk_die12 ]
{self.solid = SOLID_NOT;ai_back(0);};
void() berserk_die12 =[ $death12, berserk_die13 ] {ai_back();};
void() berserk_die13 =[ $death13, berserk_die13 ] {ai_back();};


void() berserk_dieb1 =[ $deathc1, berserk_dieb2 ] {ai_back();};
void() berserk_dieb2 =[ $deathc2, berserk_dieb3 ] {ai_back();};
void() berserk_dieb3 =[ $deathc3, berserk_dieb4 ]
{self.solid = SOLID_NOT;ai_back(0);};
void() berserk_dieb4 =[ $deathc4, berserk_dieb5 ] {ai_back();};
void() berserk_dieb5 =[ $deathc5, berserk_dieb6 ] {ai_back();};
void() berserk_dieb6 =[ $deathc6, berserk_dieb7 ] {ai_back();};
void() berserk_dieb7 =[ $deathc7, berserk_dieb8 ] {ai_back();};
void() berserk_dieb8 =[ $deathc8, berserk_dieb8 ] {ai_back();};


void() berserk_die =
{
// check for gib
if (self.health < -35)
{
sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
ThrowHead ("progs/h_gunner.mdl", self.health);
ThrowGib ("progs/gib1.mdl", self.health);
ThrowGib ("progs/gib2.mdl", self.health);
ThrowGib ("progs/gib3.mdl", self.health);
return;
}

// regular death
sound (self, CHAN_VOICE, "berserk/death1.wav", 1, ATTN_NORM);
if (random() < 0.5)
berserk_die1 ();
else
berserk_dieb1 ();
};


void(float side) berserk_melee =
{
local float ldmg;
local vector delta;

ai_face ();
walkmove (self.ideal_yaw, 6); // allow a little closing

delta = self.enemy.origin - self.origin;

if (vlen(delta) > 10)
return;
if (!CanDamage (self.enemy, self))
return;

sound (self, CHAN_WEAPON, "q2ogre/melee.wav", 1, ATTN_NORM);
ldmg = 10 + 5*random();
T_Damage (self.enemy, self, self, ldmg);

makevectors (self.angles);

};

void() berserk_atk1 =[ $att_a1, berserk_atk2 ] {ai_face();};
void() berserk_atk2 =[ $att_a2, berserk_atk3 ] {ai_face();};
void() berserk_atk3 =[ $att_a3, berserk_atk4 ] {ai_face();};
void() berserk_atk4 =[ $att_a4, berserk_atk5 ] {ai_face();};
void() berserk_atk5 =[ $att_a5, berserk_atk6 ] {ai_face();};
void() berserk_atk6 =[ $att_a6, berserk_atk7 ] {berserk_melee();};
void() berserk_atk7 =[ $att_a7, berserk_atk8 ] {ai_face();};
void() berserk_atk8 =[ $att_a8, berserk_atk9 ] {ai_face();};
void() berserk_atk9 =[ $att_a9, berserk_atk10 ] {ai_face();};
void() berserk_atk10 =[ $att_a10, berserk_atk11 ] {ai_face();};
void() berserk_atk11 =[ $att_a11, berserk_atk12 ] {ai_face();};
void() berserk_atk12 =[ $att_a12, berserk_atk13 ] {ai_face();};
void() berserk_atk13 =[ $att_a13, berserk_run1 ] {ai_face();};

void() berserk_atkb1 =[ $slam1, berserk_atkb2 ] {ai_face();};
void() berserk_atkb2 =[ $slam2, berserk_atkb3 ] {ai_face();};
void() berserk_atkb3 =[ $slam3, berserk_atkb4 ] {ai_face();};
void() berserk_atkb4 =[ $slam4, berserk_atkb5 ] {berserk_melee();};
void() berserk_atkb5 =[ $slam5, berserk_atkb6 ] {ai_face();};
void() berserk_atkb6 =[ $slam6, berserk_atkb7 ] {ai_face();};
void() berserk_atkb7 =[ $slam7, berserk_atkb8 ] {ai_face();};
void() berserk_atkb8 =[ $slam8, berserk_atkb9 ] {ai_face();};
void() berserk_atkb9 =[ $slam9, berserk_atkb10 ] {ai_face();};
void() berserk_atkb10 =[ $slam10, berserk_atkb11 ] {ai_face();};
void() berserk_atkb11 =[ $slam11, berserk_atkb12 ] {ai_face();};
void() berserk_atkb12 =[ $slam12, berserk_atkb13 ] {ai_face();};
void() berserk_atkb13 =[ $slam13, berserk_atkb14 ] {ai_face();};
void() berserk_atkb14 =[ $slam14, berserk_atkb15 ] {ai_face();};
void() berserk_atkb15 =[ $slam15, berserk_atkb16 ] {ai_face();};
void() berserk_atkb16 =[ $slam16, berserk_atkb17 ] {ai_face();};
void() berserk_atkb17 =[ $slam17, berserk_atkb18 ] {ai_face();};
void() berserk_atkb18 =[ $slam18, berserk_atkb19 ] {ai_face();};
void() berserk_atkb19 =[ $slam19, berserk_atkb20 ] {ai_face();};
void() berserk_atkb20 =[ $slam20, berserk_atkb21 ] {ai_face();};
void() berserk_atkb21 =[ $slam21, berserk_atkb22 ] {ai_face();};
void() berserk_atkb22 =[ $slam22, berserk_atkb23 ] {ai_face();};
void() berserk_atkb23 =[ $slam23, berserk_run1 ] {ai_face();};


void() berserk_attack =
{
local float dist;

dist = vlen ( ( self.enemy.origin - self.origin ) );

ai_face();

if ( dist > 10 )
berserk_atk1 ();
else
{
berserk_run1();
}

};
/*QUAKED monster_berserk (1 0 0) (-16 -16 -24) (16 16 40) Ambush
*/
void() monster_berserk =
{
if (deathmatch)
{
remove(self);
return;
}
precache_model ("progs/berserk.mdl");
precache_model ("progs/h_gunner.mdl");
precache_model ("progs/gib1.mdl");
precache_model ("progs/gib2.mdl");
precache_model ("progs/gib3.mdl");

precache_sound ("berserk/infatck1.wav");
precache_sound ("berserk/infatck3.wav");
precache_sound ("berserk/death1.wav");
precache_sound ("berserk/idle.wav");
precache_sound ("berserk/idle2.wav");
precache_sound ("berserk/pain1.wav");
precache_sound ("berserk/pain2.wav");
precache_sound ("berserk/sattck1.wav");
precache_sound ("berserk/sight1.wav");
precache_sound ("berserk/melee.wav");

precache_sound ("player/udeath.wav"); // gib death


self.solid = SOLID_SLIDEBOX;
self.movetype = MOVETYPE_STEP;

setmodel (self, "progs/berserk.mdl");

setsize (self, '-16 -16 -24', '16 16 40');
self.health = 300;

self.th_stand = berserk_stand1;
self.th_walk = berserk_walk01;
self.th_run = berserk_run1;
self.th_melee = berserk_attack;
self.th_pain = berserk_pain;
self.th_die = berserk_die;

walkmonster_start ();
};
shadowtails
 
Posts: 11
Joined: Sun Jul 30, 2006 7:16 am

Postby Preach » Tue Sep 26, 2006 3:30 pm

if (vlen(delta) > 10)

looks like the problem. You're measuring the distance between the origins of the monster and player, not their closest surfaces. The player is surrounded by a hitbox that's 32x32x56 units in size, and your monster has one that's 32x32x64. The origin is centered in that box(horizontally anyway), so even when they are touching, the origins will be at least 32 units apart(and at most root(2)*32 apart). Set the tolerance to a higher value like

if (vlen(delta) > 70)
and it should work.
Preach
 
Posts: 122
Joined: Thu Nov 25, 2004 7:20 pm

Postby shadowtails » Tue Sep 26, 2006 3:44 pm

I have already do this but it doesn´t work.Toget it work i must add
void() berserk_atk1 =[ $att_a1, berserk_atk2 ] {ai_forward(8);};
but this animations is not with move.
shadowtails
 
Posts: 11
Joined: Sun Jul 30, 2006 7:16 am

Postby Sajt » Wed Sep 27, 2006 7:57 am

F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 3 guests