Inside3D!
     

Quake Amphibian
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Sat Aug 22, 2009 1:53 am    Post subject: Quake Amphibian Reply with quote

I know it isn't a usual subject but I'm trying it out.
I made two models, one with the normal stand,walk, attack , pain and death functions.
And another one with the swim, atack, pain and death functions.
So they both behave as a land monster and the other one as a water monster.

I compared these two in one qc file, and made them go apart with an extra function.
This function is added as a "harpo_to_harpo" and a Harpo_to_harpi" function.
It took a while before I could make the qc running, but for sofar I have it made.
The both are running apart in Quake except for the fact I have to make a decision to make them glide into eachother.

Now I'm chewing on the last and hardest part as I realize I can make the monster get into the water and make it swim (I hope),
but I'm aware it will be really hard to get it out of it.
So Now I'm in the FIGHT.QC, added a new HarpCheckAttack and I lost my maths on the last part...


To keep it short I will only post the last part to make clear how this function is specified.
Code:
void() harpo_to_harpi =
{
self.th_stand = h_stand1;
self.th_walk = h_walk1;
self.th_run = h_run1;
self.th_die = harpi_die;
self.th_pain = harpi_pain;
self.th_missile = h_attack1;
self.th_melee = h_faint1;
self.flags = self.flags - (self.flags & FL_SWIM);
};

void() monster_harpi =
{
if (deathmatch)
{
remove(self);
return;
}
precache_model2 ("progs/harpi.mdl");
precache_model2 ("progs/pioen.mdl");
precache_model2 ("progs/h_model.mdl");

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

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

setsize (self, '-16 -16 -24', '16 16 24');
self.health = 25;
harpo_to_harpi ();
walkmonster_start ();
};

void() harpi_to_harpo =
{
self.th_stand = h_dwell1;
self.th_walk = h_swim1;
self.th_run = h_crawl1;
self.th_die = h_die1;
self.th_pain = harpo_pain;
self.th_melee = h_harp1;
self.flags = self.flags | FL_SWIM;
};

void() monster_harpo =
{
if (deathmatch)
{
remove(self);
return;
}
precache_model2 ("progs/harpo.mdl");
precache_model2 ("progs/pioen.mdl");

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

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

setsize (self, '-16 -16 -24', '16 16 24');
self.health = 25;
harpi_to_harpo ();
swimmonster_start();
};

I added the
self.flags = self.flags - (self.flags &|FL_ SWIM)]
for the land model and the
self.flags = self.flags | FL_SWIM;
for the water model.

To get a function for making the engine know when the model is on land and when it is in water I thought to make a CHeck_Attack function in the FIGHT.QC.
So I added a line in the AI.QC to the CheckAnyAttack and added

if(self.classname == "monster_harpio")
return HarpCheckAttack();


Now I am on the last part of the FIGHT.QC and I realize it might be possible to get the monster into the water and swim (I hope) but I might not get it out of it.
But it is this last part I can't get filled in.
I made a regular CheckAttack and started at the top with something like


float() HarpCheckAttack =
{
local vector spot1, spot2;
local entity targ;
local float chance;

targ = self.enemy;

// see if any entities are in the way of the shot
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;

traceline (spot1, spot2, FALSE, self);

if(self.th_stand = harpo_stand1) //if not swimming
{
if (self.waterlevel == 3)
harpo_to_harpi();
return TRUE;
}
// else
// {
// if( /*insert decision making code for standing up here*/)
// harpi_to_harpo();
// }

if (trace_inopen && trace_inwater)
return FALSE; // sight line crossed contents

if (trace_ent != targ)
return FALSE; // don't have a clear shot
etc


The FIGHT.QC keeps giving the error "harpo_stand1 not defined"
and I can't find a way to get the right thread.

I know it is a rather long thread to post, but I'm wrenching myself so long with it I wondered if someone had a clue to it.
Maybe it just ain'rt possible and I'm looking for something that doesn't fit in the Quake engine, but I was curious.

Thanks.
Back to top
View user's profile Send private message Visit poster's website
jim



Joined: 05 Aug 2005
Posts: 400
Location: In The Sun

PostPosted: Thu Aug 27, 2009 1:58 am    Post subject: Reply with quote

I made monsters that were able to swim and walk on land. I didn't make them two different entities.. but seems like I didn't back up my files properly...

Well, have you defined harpo_stand1 anywhere? In your harpo_to_harpi you're using h_stand1, so maybe you should use that in the later parts of the code too?
_________________
zbang!
Back to top
View user's profile Send private message Visit poster's website
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Fri Aug 28, 2009 11:25 pm    Post subject: Reply with quote

Quote:
Well, have you defined harpo_stand1 anywhere? In your harpo_to_harpi you're using h_stand1, so maybe you should use that in the later parts of the code too?


I used the following statement to define the code as in the harpio.qc
for the stand to swim I have the :

void() h_jive1 =[ $djive1, h_jive2 ] {harpi_to_harpo();};

and for the swim to stand I use the code:

void() h_mour1 =[ $mour1, h_mour2 ] {harpo_to_harpi();};

So I wondered how to make the FIGH.QC right untill I suceeded in:

if(self.th_stand = h_stand1)
return TRUE;

{
if (h_mour1 )
harpo_to_harpi();
return TRUE;
}
if(self.th_stand = h_dwell1)
return TRUE;
{
if( h_jive1)
harpi_to_harpo();
}


If I use this progs.dat I get a walking monster, but it doesn't turn into a swim mode.
Back to top
View user's profile Send private message Visit poster's website
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Sat Aug 29, 2009 9:48 pm    Post subject: Reply with quote

couldnt you just... when it goes from walking to swimming switch its move type to that of a flying/swimming type?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Sun Aug 30, 2009 12:35 am    Post subject: Reply with quote

ceriux wrote:
couldnt you just... when it goes from walking to swimming switch its move type to that of a flying/swimming type?


I'm not sure. As far as I know the monster stats as in the th_walk scenes go with one definition.
Or the monster is a walk_monster_start or it is a swim_monster_start.
I can't make a walking monster swim, as it th_walk definition is declared already.
Back to top
View user's profile Send private message Visit poster's website
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Sun Aug 30, 2009 1:27 am    Post subject: Reply with quote

There's not that much that I can see unique with swimmonster_start_go().

Try stripping the monster of FL_SWIM flag, and switching it's stand / walk / run frames via the .th_stand, .th_walk, and .th_run, etc. to whatever it's water / land frames should be.

Additional note Edit:

You're making an error in your if statements. Use == not = unless you want it to be set right there on the spot.

To clarify: = Sets stuff, == compares them.

Also, you can't use framemacros (unless this is inside the file they're defined in, or you redefine them in whatever file your doing this in, which is space hoggy.) or void definitions that way either. If you need to determine if your in a certain frame, you'll have to do something like if(self.frame == X) where X is whatever frame your looking for.
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Tue Sep 01, 2009 8:14 pm    Post subject: Reply with quote

Thanks for your reply in this for me sticky problem, Dr.Shadowborg.

So if I have it right the fight.qc has to be something like:

if(self.th_stand == h_stand1)
return TRUE;

{
if (self.frame=h_mour1 )
harpo_to_harpi();
return TRUE;
}
if(self.th_stand == h_dwell1)
return TRUE;
{
if(self.frame= h_jive1)
harpi_to_harpo();
}
Back to top
View user's profile Send private message Visit poster's website
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Tue Sep 01, 2009 8:42 pm    Post subject: Reply with quote

That looks more or less right, just bear in mind stuff like h_mour1, h_jive1, etc. won't work unless you actually define those framemacros inside fight.qc.
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Wed Sep 02, 2009 12:33 am    Post subject: Reply with quote

Dr. Shadowborg wrote:
That looks more or less right, just bear in mind stuff like h_mour1, h_jive1, etc. won't work unless you actually define those framemacros inside fight.qc.


Indeed, I had to make a new statement for the h_mour1 and h_jive1.

As I try to compile I'm rejected with the:
>fight.qc:434:type mismatch for =<
reffering to the
if (self.frame=h_mour1 )
Back to top
View user's profile Send private message Visit poster's website
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Wed Sep 02, 2009 1:05 am    Post subject: Reply with quote

Madfox wrote:

Indeed, I had to make a new statement for the h_mour1 and h_jive1.

As I try to compile I'm rejected with the:
>fight.qc:434:type mismatch for =<
reffering to the
if (self.frame=h_mour1 )

Just means that you need to use the actual raw frame number instead. Wink
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Thu Sep 24, 2009 2:22 am    Post subject: jonas and the amphibian Reply with quote

Well I did some homework and concluded I had to combine the two models to one.
Then, with a little help from preach, I could change the fight qc for the part it reachs the water.
From there it turns into a swimming model and hunts the player down.

Now I have come to the point it has to change its animation from swimming back to walking on land.
And I believe it is a hard question, because I was told that
once a monster is FL_SWIM, it will never move to a place which is not underwater.

I'm not a coder so I really don't know if the Quake engine is capable to do such a thing.
As example here is the code from the harpio.qc
Carefull... it is quiet a lot

Code:

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

$frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8
$frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 walk10 walk11
$frame walk12 walk13
$frame run1 run2 run3 run4 run5 run6
$frame painc1 painc2 painc3 painc4 painc5 painc6 painc7
$frame paind1 paind2 paind3 paind4 paind5 paind6 paind7 paind8 paind9 paind10
$frame paind11 paind12 paind13
$frame attack1 attack2 attack3 attack4 attack5 attack6 attack7
$frame attack8 attack9 attack10 attack11
$frame faint1 faint2 faint3 faint4 faint5 faint6 faint7 faint8 faint9 faint10 
$frame faint11 faint12 faint13
$frame death1 death2 death3 death4 death5 death6 death7 death8 death9 death10
$frame death11 death12 death13 death14 death15
$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8 deatha9
$frame deatha10 deatha11 deatha12 deatha13
$frame djive1 djive2 djive3 djive4 djive5 djive6 djive7 djive8 djive9 djive10

$frame wrap1 wrap2 wrap3 wrap4 wrap5 wrap6 wrap7 wrap8 wrap9 wrap10 wrap11 wrap12
$frame swim1 swim2 swim3 swim4 swim5 swim6 swim7 swim8 swim9 swim10 swim11 swim12
$frame shoot1 shoot2 shoot3 shoot4 shoot5 shoot6 shoot7 shoot8 shoot9 shoot10
$frame shoot11 shoot12
$frame pain1 pain2 pain3 pain4 pain5 pain6
$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 painb10
$frame painb11 painb12 painb13 painb14
$frame die1 die2 die3 die4 die5 die6 die7 die8 die9 die10 die11 die12 die13 
$frame mour1 mour2 mour3 mour4 mour5 mour6 mour7 mour8 mour9 mour10

void() harpi_to_harpo;
void() harpo_to_harpi;
void() h_pain1;
void() h_painb1;

void() harpio_Touch =
{
   local vector org;
   
   if (other == self.owner)
      return;      // don't explode on owner

   if (pointcontents(self.origin) == CONTENT_SKY)
   {
      remove(self);
      return;
   }
   
   sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
   org = self.origin - 8*normalize(self.velocity);

   if (other.health)
   {
      SpawnBlood (org, self.velocity*0.2, 15);
      T_Damage (other, self, self.owner, 15);
   }
   else
   {
      WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST, TE_GUNSHOT);
      WriteCoord (MSG_BROADCAST, org_x);
      WriteCoord (MSG_BROADCAST, org_y);
      WriteCoord (MSG_BROADCAST, org_z);
   }
   
   remove(self);   
};

void(vector org, vector vec) Launchharpio =
{
//   local   vector   vec;
      
   if (self.classname == "monster_enforcer")
      sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);

   vec = normalize(vec);
   
   newmis = spawn();
   newmis.owner = self;
   newmis.movetype = MOVETYPE_FLY;
   newmis.solid = SOLID_BBOX;
   newmis.effects = EF_DIMLIGHT;

   setmodel (newmis, "progs/pioen.mdl");
   setsize (newmis, '0 0 0', '0 0 0');      

   setorigin (newmis, org);

   newmis.velocity = vec * 600;
   newmis.angles = vectoangles(newmis.velocity);

   newmis.nextthink = time + 5;
   newmis.think = SUB_Remove;
   newmis.touch = harpio_Touch;
};

void() harpio_fire =
{
   local vector org;

   self.effects = self.effects | EF_MUZZLEFLASH;
   makevectors (self.angles);
   
   org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 -24';

   Launchharpio(org, self.enemy.origin - self.origin);
};

void() harpio_slash =
{
local vector   delta;
local float    ldmg;

   if (!self.enemy)
      return;

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


   ai_charge(10);

   if (!CanDamage (self.enemy, self))
      return;

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

   if (vlen(delta) > 100)
      return;
      
   ldmg = 10 + 5*random();
   T_Damage (self.enemy, self, self, ldmg);

   makevectors (self.angles);
   SpawnMeatSpray (self.origin + v_forward*16, v_right*16 );

};


void() h_stand1  =[      $stand1,  h_stand2 ]      {ai_stand();};
void() h_stand2  =[      $stand2,  h_stand3 ]      {ai_stand();};
void() h_stand3  =[      $stand3,  h_stand4 ]      {ai_stand();};
void() h_stand4  =[      $stand4,  h_stand5 ]      {ai_stand();};
void() h_stand5  =[      $stand5,  h_stand6 ]      {ai_stand();};
void() h_stand6  =[      $stand6,  h_stand7 ]      {ai_stand();};
void() h_stand7  =[      $stand7,  h_stand8 ]      {ai_stand();};
void() h_stand8  =[      $stand8,  h_stand1 ]      {ai_stand();};

void() h_walk1  =[      $walk1,  h_walk2  ]   {ai_walk(6);};
void() h_walk2  =[      $walk2,  h_walk3  ]   {ai_walk(4);};
void() h_walk3  =[      $walk3,  h_walk4  ]   {ai_walk(3);};
void() h_walk4  =[      $walk4,  h_walk5  ]   {ai_walk(4);};
void() h_walk5  =[      $walk5,  h_walk6  ]   {ai_walk(6);};
void() h_walk6  =[      $walk6,  h_walk7  ]   {ai_walk(4);};
void() h_walk7  =[      $walk7,  h_walk8  ]   {ai_walk(3);};
void() h_walk8  =[      $walk8,  h_walk9  ]   {ai_walk(4);};
void() h_walk9  =[      $walk9,  h_walk10 ]   {ai_walk(6);};
void() h_walk10 =[      $walk10, h_walk11 ]   {ai_walk(4);};
void() h_walk11 =[      $walk11, h_walk12 ]   {ai_walk(3);};
void() h_walk12 =[      $walk12, h_walk13 ]   {ai_walk(4);};
void() h_walk13 =[      $walk13, h_walk1  ]   {ai_walk(4);};

void() h_run1  =[      $run1, h_run2 ] {ai_run(12);
   if (random() < 0.5)
      sound (self, CHAN_VOICE, "harpi/sight.wav", 1, ATTN_NORM);
};
void() h_run2  =[      $run2, h_run3    ] {ai_run(14);};
void() h_run3  =[      $run3, h_run4    ] {ai_run(10);};
void() h_run4  =[      $run4, h_run5    ] {ai_run(10);};
void() h_run5  =[      $run5, h_run6    ] {ai_run(6);};
void() h_run6  =[      $run6, h_run1    ] {ai_run(10);};

void() h_painc1  =[      $painc1, h_painc2    ] {};
void() h_painc2  =[      $painc2, h_painc3    ] {ai_pain(6);};
void() h_painc3  =[      $painc3, h_painc4    ] {ai_pain(6);};
void() h_painc4  =[      $painc4, h_painc5    ] {ai_pain(6);};
void() h_painc5  =[      $painc5, h_painc6    ] {ai_pain(6);};
void() h_painc6  =[      $painc6, h_painc7    ] {ai_pain(6);};
void() h_painc7  =[      $painc7, h_run1      ] {ai_pain(6);};

void() h_paind1  =[      $paind1, h_paind2 ] {};
void() h_paind2  =[      $paind2, h_paind3 ] {ai_pain(6);};
void() h_paind3  =[      $paind3, h_paind4 ] {ai_pain(6);};
void() h_paind4  =[      $paind4, h_paind5 ] {ai_pain(6);};
void() h_paind5  =[      $paind5, h_paind6 ] {ai_pain(6);};
void() h_paind6  =[      $paind6, h_paind7 ] {ai_pain(6);};
void() h_paind7  =[      $paind7, h_paind8 ] {ai_pain(6);};
void() h_paind8  =[      $paind8, h_paind9 ] {ai_pain(6);};
void() h_paind9  =[      $paind9, h_paind10 ] {ai_pain(6);};
void() h_paind10 =[      $paind10, h_paind11 ] {ai_pain(6);};
void() h_paind11 =[      $paind11, h_paind12 ] {ai_pain(6);};
void() h_paind12 =[      $paind12, h_paind13 ] {ai_pain(6);};
void() h_paind13 =[      $paind13, h_run1 ] {ai_pain(6);};

void(entity attacker, float damage)   harpio_pain =
{

   local float r;

   if (self.pain_finished > time)
      return;

   r = random();
   
   sound (self, CHAN_VOICE, "knight/khurt.wav", 1, ATTN_NORM);
   if (r < 0.85)
   {
      h_painc1 ();
      self.pain_finished = time + 1;
   }
   else
   {
      h_paind1 ();
      self.pain_finished = time + 1;
   }
};

void() h_attack1        =[      $attack1,       h_attack2 ] {ai_face();};
void() h_attack2        =[      $attack2,       h_attack3 ] {ai_face();};
void() h_attack3        =[      $attack3,       h_attack4 ] {ai_face();};
void() h_attack4        =[      $attack4,       h_attack5 ] {harpio_fire();};
void() h_attack5        =[      $attack5,       h_attack6 ] {ai_face();};
void() h_attack6        =[      $attack6,       h_attack7 ] {ai_face();};
void() h_attack7        =[      $attack7,       h_attack8 ] {ai_face();};
void() h_attack8        =[      $attack8,       h_attack9 ] {ai_face();};
void() h_attack9        =[      $attack9,       h_attack10] {ai_face();};
void() h_attack10       =[      $attack10,      h_attack11] {ai_face();};
void() h_attack11       =[      $attack11,      h_run1    ] {ai_face();};

void() h_faint1        =[      $faint1,       h_faint2 ] {ai_face();};
void() h_faint2        =[      $faint2,       h_faint3 ] {ai_face();};
void() h_faint3        =[      $faint3,       h_faint4 ] {ai_face();};
void() h_faint4        =[      $faint4,       h_faint5 ] {ai_face();};
void() h_faint5        =[      $faint5,       h_faint6 ] {ai_face();};
void() h_faint6        =[      $faint6,       h_faint7 ] {harpio_slash();ai_face();};
void() h_faint7        =[      $faint7,       h_faint8 ] {ai_face();};
void() h_faint8        =[      $faint8,       h_faint9 ] {ai_face();};
void() h_faint9        =[      $faint9,       h_faint10] {ai_face();};
void() h_faint10       =[      $faint10,      h_faint11] {ai_face();};
void() h_faint11       =[      $faint11,      h_run1    ] {ai_face();};

void() harpio_melee =
{
   if (random() > 0.3)
      h_faint1 ();
   else
      h_attack1 ();
};

void() h_death1 =[      $death1,        h_death2        ] {
sound (self, CHAN_VOICE, "player/death2.wav", 1, ATTN_NORM);
};
void() h_death2  =[      $death2,        h_death3        ] {};
void() h_death3  =[      $death3,        h_death4        ] {};
void() h_death4  =[      $death4,        h_death5        ] {};
void() h_death5  =[      $death5,        h_death6        ] {};
void() h_death6  =[      $death6,        h_death7        ] {};
void() h_death7  =[      $death7,        h_death8        ] {};
void() h_death8  =[      $death8,        h_death9        ] {};
void() h_death9  =[      $death9,        h_death10       ] {};
void() h_death10 =[      $death10,       h_death11       ] {};
void() h_death11 =[      $death11,       h_death12       ] {};
void() h_death12 =[      $death12,       h_death13       ] {};
void() h_death13 =[      $death13,       h_death14       ] {};
void() h_death14 =[      $death14,       h_death15       ] {};
void() h_death15 =[      $death15,       h_death15       ] {self.solid = SOLID_NOT;};

void() h_deatha1 =[      $deatha1,        h_deatha2        ] {
sound (self, CHAN_VOICE, "player/death2.wav", 1, ATTN_NORM);
};
void() h_deatha2  =[      $deatha2,        h_deatha3        ] {};
void() h_deatha3  =[      $deatha3,        h_deatha4        ] {};
void() h_deatha4  =[      $deatha4,        h_deatha5        ] {};
void() h_deatha5  =[      $deatha5,        h_deatha6        ] {};
void() h_deatha6  =[      $deatha6,        h_deatha7        ] {};
void() h_deatha7  =[      $deatha7,        h_deatha8        ] {};
void() h_deatha8  =[      $deatha8,        h_deatha9        ] {};
void() h_deatha9  =[      $deatha9,        h_deatha10       ] {};
void() h_deatha10 =[      $deatha10,       h_deatha11       ] {};
void() h_deatha11 =[      $deatha11,       h_deatha12       ] {};
void() h_deatha12 =[      $deatha12,       h_deatha13       ] {};
void() h_deatha13 =[      $deatha13,       h_deatha13       ] {self.solid = SOLID_NOT;};

void() harpio_die =
{
// check for gib
   if (self.health < -35)
   {
      sound (self, CHAN_VOICE, "player/death2.wav", 1, ATTN_NORM);
      ThrowHead ("progs/h_mega.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, "player/death2.wav", 1, ATTN_NORM);
   if (random() > 0.5)
      h_death1 ();
   else
      h_deatha1 ();
};


void() h_jive1    =[     $djive1,         h_jive2         ] {harpi_to_harpo();}; 
void() h_jive2    =[     $djive2,         h_jive3         ] {};
void() h_jive3    =[     $djive3,         h_jive4         ] {};
void() h_jive4    =[     $djive4,         h_jive5         ] {};
void() h_jive5    =[     $djive5,         h_jive6         ] {};
void() h_jive6    =[     $djive6,         h_jive7         ] {};
void() h_jive7    =[     $djive7,         h_jive8         ] {};
void() h_jive8    =[     $djive8,         h_jive9         ] {};
void() h_jive9    =[     $djive9,         h_jive10        ] {};
void() h_jive10   =[     $djive10,        h_swim1        ] {};

void() h_dwell1  =[      $wrap1,  h_dwell2 ]      {ai_stand();};
void() h_dwell2  =[      $wrap2,  h_dwell3 ]      {ai_stand();};
void() h_dwell3  =[      $wrap3,  h_dwell4 ]      {ai_stand();};
void() h_dwell4  =[      $wrap4,  h_dwell5 ]      {ai_stand();};
void() h_dwell5  =[      $wrap5,  h_dwell6 ]      {ai_stand();};
void() h_dwell6  =[      $wrap6,  h_dwell7 ]      {ai_stand();};
void() h_dwell7  =[      $wrap7,  h_dwell8 ]      {ai_stand();};
void() h_dwell8  =[      $wrap8,  h_dwell9 ]      {ai_stand();};
void() h_dwell9  =[      $wrap9,  h_dwell10]      {ai_stand();};
void() h_dwell10 =[      $wrap10, h_dwell11]      {ai_stand();};
void() h_dwell11 =[      $wrap11, h_dwell12]      {ai_stand();};
void() h_dwell12 =[      $wrap12, h_dwell1 ]      {ai_stand();};

void() h_swim1  =[      $wrap1, h_swim2 ] {ai_walk(12);};
void() h_swim2  =[      $wrap2, h_swim3 ] {ai_walk(12);};
void() h_swim3  =[      $wrap3, h_swim4 ] {ai_walk(12);};
void() h_swim4  =[      $wrap4, h_swim5 ] {ai_walk(12);};
void() h_swim5  =[      $wrap5, h_swim6 ] {ai_walk(12);};
void() h_swim6  =[      $wrap6, h_swim7 ] {ai_walk(12);};
void() h_swim7  =[      $wrap7, h_swim8 ] {ai_walk(12);};
void() h_swim8  =[      $wrap8, h_swim9 ] {ai_walk(12);};
void() h_swim9  =[      $wrap9, h_swim10  ] {ai_walk(12);};
void() h_swim10 =[      $wrap10, h_swim11 ] {ai_walk(12);};
void() h_swim11 =[      $wrap11, h_swim12 ] {ai_walk(12);};
void() h_swim12 =[      $wrap12, h_swim1 ] {ai_walk(12);};

void() h_crawl1  =[      $swim1, h_crawl2 ] {ai_run(12);
   if (random() < 0.5)
      sound (self, CHAN_VOICE, "harpi/idle.wav", 1, ATTN_NORM);
};
void() h_crawl2  =[      $swim2, h_crawl3 ] {ai_run(16);};
void() h_crawl3  =[      $swim3, h_crawl4 ] {ai_run(16);};
void() h_crawl4  =[      $swim4, h_crawl5 ] {ai_run(16);};
void() h_crawl5  =[      $swim5, h_crawl6 ] {ai_run(16);};
void() h_crawl6  =[      $swim6, h_crawl7 ] {ai_run(16);};
void() h_crawl7  =[      $swim7, h_crawl8 ] {ai_run(16);};
void() h_crawl8  =[      $swim8, h_crawl9 ] {ai_run(16);};
void() h_crawl9  =[      $swim9, h_crawl10 ] {ai_run(16);};
void() h_crawl10 =[      $swim10, h_crawl11 ] {ai_run(16);};
void() h_crawl11 =[      $swim11, h_crawl12 ] {ai_run(16);};
void() h_crawl12 =[      $swim12, h_crawl1 ] {ai_run(16);};

void() newharpio_Touch =
{
   local vector org;
   
   if (other == self.owner)
      return;      // don't explode on owner

   if (pointcontents(self.origin) == CONTENT_SKY)
   {
      remove(self);
      return;
   }
   
   sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
   org = self.origin - 8*normalize(self.velocity);

   if (other.health)
   {
      SpawnBlood (org, self.velocity*0.2, 15);
      T_Damage (other, self, self.owner, 15);
   }
   else
   {
      WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
      WriteByte (MSG_BROADCAST, TE_GUNSHOT);
      WriteCoord (MSG_BROADCAST, org_x);
      WriteCoord (MSG_BROADCAST, org_y);
      WriteCoord (MSG_BROADCAST, org_z);
   }
   
   remove(self);   
};

void(vector org, vector vec) newLaunchharpio =
{
//   local   vector   vec;
      
   if (self.classname == "monster_enforcer")
      sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);

   vec = normalize(vec);
   
   newmis = spawn();
   newmis.owner = self;
   newmis.movetype = MOVETYPE_FLY;
   newmis.solid = SOLID_BBOX;
   newmis.effects = EF_DIMLIGHT;

   setmodel (newmis, "progs/pioen.mdl");
   setsize (newmis, '0 0 0', '0 0 0');      

   setorigin (newmis, org);

   newmis.velocity = vec * 600;
   newmis.angles = vectoangles(newmis.velocity);

   newmis.nextthink = time + 5;
   newmis.think = SUB_Remove;
   newmis.touch = newharpio_Touch;
};

void() newharpio_fire =
{
   local vector org;

   self.effects = self.effects | EF_MUZZLEFLASH;
   makevectors (self.angles);
   
   org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 -24';

   newLaunchharpio(org, self.enemy.origin - self.origin);
};

void() h_harp1        =[      $shoot1,       h_harp2 ] {ai_charge(10);};
void() h_harp2        =[      $shoot2,       h_harp3 ] {ai_charge(10);};
void() h_harp3        =[      $shoot3,       h_harp4 ] {newharpio_fire();};
void() h_harp4        =[      $shoot4,       h_harp5 ] {ai_charge(10);};
void() h_harp5        =[      $shoot5,       h_harp6 ] {ai_charge(10);};
void() h_harp6        =[      $shoot6,       h_harp7 ] {ai_charge(10);};
void() h_harp7        =[      $shoot7,       h_harp8 ] {ai_charge(10);};
void() h_harp8        =[      $shoot8,       h_harp9 ] {ai_charge(10);};
void() h_harp9        =[      $shoot9,       h_harp10] {ai_charge(10);};
void() h_harp10       =[      $shoot10,      h_harp11] {ai_charge(10);};
void() h_harp11       =[      $shoot11,      h_harp12] {ai_charge(10);};
void() h_harp12       =[      $shoot12,      h_crawl1] {ai_charge(10);};

void(entity attacker, float damage)   newharpio_pain =
{

   local float r;

   if (self.pain_finished > time)
      return;

   r = random();
   
   sound (self, CHAN_VOICE, "knight/khurt.wav", 1, ATTN_NORM);
   if (r < 0.85)
   {
      h_pain1 ();
      self.pain_finished = time + 1;
   }
   else
   {
      h_painb1 ();
      self.pain_finished = time + 1;
   }
};

void() h_pain1  =[      $pain1, h_pain2 ] {};
void() h_pain2  =[      $pain2, h_pain3 ] {ai_pain(6);};
void() h_pain3  =[      $pain3, h_pain4 ] {ai_pain(6);};
void() h_pain4  =[      $pain4, h_pain5 ] {ai_pain(6);};
void() h_pain5  =[      $pain5, h_pain6 ] {ai_pain(6);};
void() h_pain6  =[      $pain6, h_crawl1 ] {ai_pain(6);};

void() h_painb1  =[      $painb1, h_painb2 ]    {};
void() h_painb2  =[      $painb2, h_painb3 ]    {ai_pain(6);};
void() h_painb3  =[      $painb3, h_painb4 ]    {ai_pain(6);};
void() h_painb4  =[      $painb4, h_painb5 ]    {ai_pain(6);};
void() h_painb5  =[      $painb5, h_painb6 ]    {ai_pain(6);};
void() h_painb6  =[      $painb6, h_painb7 ]    {ai_pain(6);};
void() h_painb7  =[      $painb7, h_painb8 ]    {ai_pain(6);};
void() h_painb8  =[      $painb8, h_painb9 ]    {ai_pain(6);};
void() h_painb9  =[      $painb9, h_painb10 ]   {ai_pain(6);};
void() h_painb10 =[      $painb10, h_painb11 ]  {ai_pain(6);};
void() h_painb11 =[      $painb11, h_painb12 ]  {ai_pain(6);};
void() h_painb12 =[      $painb12, h_painb13 ]  {ai_pain(6);};
void() h_painb13 =[      $painb13, h_painb14 ]  {ai_pain(6);};
void() h_painb14 =[      $painb14, h_crawl1]    {ai_pain(6);};

void() h_die1 =[      $die1,        h_die2        ] {
sound (self, CHAN_VOICE, "fish/death.wav", 1, ATTN_NORM);
};
void() h_die2  =[      $die2,        h_die3        ] {};
void() h_die3  =[      $die3,        h_die4        ] {};
void() h_die4  =[      $die4,        h_die5        ] {self.solid = SOLID_NOT;};
void() h_die5  =[      $die5,        h_die6        ] {};
void() h_die6  =[      $die6,        h_die7        ] {};
void() h_die7  =[      $die7,        h_die8        ] {};
void() h_die8  =[      $die8,        h_die9        ] {};
void() h_die9  =[      $die9,        h_die10       ] {};
void() h_die10 =[      $die10,       h_die11       ] {};
void() h_die11 =[      $die11,       h_die12       ] {};
void() h_die12 =[      $die12,       h_die13       ] {};
void() h_die13 =[      $die13,       h_die13       ] {};

void() h_mour1  =[      $mour1,       h_mour2       ] {harpo_to_harpi();};
void() h_mour2  =[      $mour2,       h_mour3       ] {};
void() h_mour3  =[      $mour3,       h_mour4       ] {};
void() h_mour4  =[      $mour4,       h_mour5       ] {};
void() h_mour5  =[      $mour5,       h_mour6       ] {};
void() h_mour6  =[      $mour6,       h_mour7       ] {};
void() h_mour7  =[      $mour7,       h_mour8       ] {};
void() h_mour8  =[      $mour8,       h_mour9       ] {};
void() h_mour9  =[      $mour9,       h_mour10      ] {};
void() h_mour10 =[      $mour10,      h_run1      ] {};

void() harpo_to_harpi =
{
   self.th_stand = h_stand1;
   self.th_walk = h_walk1;
   self.th_run = h_run1;
   self.th_die = harpio_die;
   self.th_pain = harpio_pain;
        self.th_missile = h_attack1;
   self.th_melee = h_faint1;
        self.flags = self.flags - (self.flags & FL_SWIM);
};

void() monster_harpio =
{
   if (deathmatch)
   {
      remove(self);
      return;
   }
   precache_model2 ("progs/harpio.mdl");
        precache_model2 ("progs/pioen.mdl");
        precache_model2 ("progs/h_model.mdl");
   precache_sound2 ("player/death2.wav");
   precache_sound2 ("fish/bite.wav");
   precache_sound2 ("fish/death.wav");
        precache_sound2 ("harpi/sight.wav");
   precache_sound2 ("enforcer/enfstop.wav");
        precache_sound2 ("enforcer/enfire.wav");
        precache_sound2 ("knight/khurt.wav");
   precache_sound2 ("harpi/idle.wav");

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

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

   setsize (self, '-16 -16 -24', '16 16 24');
   self.health = 25;
        harpo_to_harpi ();
        walkmonster_start ();
};

void() harpi_to_harpo =
{
   self.th_stand = h_dwell1;
   self.th_walk = h_swim1;
   self.th_run = h_crawl1;
   self.th_die = h_die1;
   self.th_pain = newharpio_pain;
//   self.th_melee = h_harp1;
        self.th_missile = h_harp1;
        self.flags = self.flags | FL_SWIM;
};



and the FIGHT.QC add on :


Code:


float() HarpCheckAttack =
{
        local vector spot1, spot2;
        local entity targ;
        local float chance;
//check we are in the water and also standing
        if (self.waterlevel > 0 && self.th_stand == h_stand1)
        {
        dprint("standing in water \n");
        h_jive1();
        return TRUE;
        }

        targ = self.enemy;

// see if any entities are in the way of the shot
        spot1 = self.origin + self.view_ofs;
        spot2 = targ.origin + targ.view_ofs;

        traceline (spot1, spot2, FALSE, self);

        if (trace_inopen && trace_inwater)
        return FALSE; // sight line crossed contents

        if (trace_ent != targ)
        return FALSE; // don't have a clear shot

// missile attack
        if (time < self.attack_finished)
        return FALSE;

        if (enemy_range == RANGE_FAR)
        return FALSE;

        if (enemy_range == RANGE_MELEE)
        chance = 0.9;
        else if (enemy_range == RANGE_NEAR)
        chance = 0.4;
        else if (enemy_range == RANGE_MID)
        chance = 0.05;
        else
        chance = 0;

        if (random () < chance)
        {
        self.th_missile ();
        SUB_AttackFinished (1 + random());
        if (random() < 0.3)
        self.lefty = !self.lefty;

        return TRUE;
        }

        return FALSE;
};



Last edited by Madfox on Thu Sep 24, 2009 9:26 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Electro



Joined: 29 Dec 2004
Posts: 241
Location: Brisbane, Australia

PostPosted: Thu Sep 24, 2009 7:23 am    Post subject: Reply with quote

code tags are broken?
_________________
Unit reporting!
http://www.bendarling.net/
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Thu Sep 24, 2009 7:45 pm    Post subject: Reply with quote

Don't you just love those smilies, standing right in the middle of the code. Proud and looking cool...
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Thu Sep 24, 2009 7:49 pm    Post subject: Reply with quote

Chip wrote:
Don't you just love those smilies, standing right in the middle of the code. Proud and looking cool...


lol yeah... he should put the code in the "[code]" tags...
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Madfox



Joined: 15 Jan 2005
Posts: 36
Location: Holland

PostPosted: Thu Sep 24, 2009 9:24 pm    Post subject: Reply with quote

Thanks for attending me spelling my name wrong.

Electro: code runs fine but includes ai.qc line 602

Code:


      if(self.classname == "monster_harpio")
                return HarpCheckAttack();
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group