Forum

if zombie touches the player?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

if zombie touches the player?

Postby ThePlasticBling » Sun Oct 31, 2010 5:26 am

i tried this:

Code: Select all
void () attacked
{     
   precache_model ("progs/zombie.mdl");
   if (self.touch = "zombie.mdl");
};


but i need some help. im kind of new to quakec
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby Mexicouger » Sun Oct 31, 2010 7:19 am

I can already see a few Problems.

First off, You tried precacheing a model in an ordinary function. You can only do a precache when Something is spawned.
void () attacked
{
precache_model ("progs/zombie.mdl");
if (self.touch = "zombie.mdl");
};

2nd of all, you forgot the equal sign after attacked
void () attacked =

Third, You didn't give the if statement anything to do, and you only did one equal sign. When doing an if statement, and showing equality, you must do 2 equal signs.
if (self.touch == "zombie.mdl");
{} //Do nothing

And the next problem is you did "zombie.mdl". That does absolutely nothing. This whole function does not work.

Sorry. :?
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ThePlasticBling » Sun Oct 31, 2010 1:29 pm

can you please show me an example of what will work? thanx
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby Mexicouger » Sun Oct 31, 2010 6:03 pm

So what do you want to happen if self touches a zombie? An explosion?

And who are you referring to? Do you mean if the Zombie touches something or the Player touches something? I know you are new and all, But you must portray your goal in a more detailed manner.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ThePlasticBling » Sun Oct 31, 2010 6:14 pm

k sorry. I want to make it so when the zombie and player touch each other, or collide, the player loses half health. and this is kind of off topic but i want to make it so in 5 seconds, the players health goes back to full.
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby Mexicouger » Sun Oct 31, 2010 7:51 pm

ThePlasticBling wrote:k sorry. I want to make it so when the zombie and player touch each other, or collide, the player loses half health. and this is kind of off topic but i want to make it so in 5 seconds, the players health goes back to full.


Hmm, Well here might be something:

void() zomb_touch =
{
if (other.classname != "player") //if it isn't the player, than stop the function
return;
other.health -= 50; //Adjustable health
};


void() monster_zombie =
{
if (deathmatch)
{
remove(self);
return;
}

precache_model ("progs/zombie.mdl");
precache_model ("progs/h_zombie.mdl");
precache_model ("progs/zom_gib.mdl");

precache_sound ("zombie/z_idle.wav");
precache_sound ("zombie/z_idle1.wav");
precache_sound ("zombie/z_shot1.wav");
precache_sound ("zombie/z_gib.wav");
precache_sound ("zombie/z_pain.wav");
precache_sound ("zombie/z_pain1.wav");
precache_sound ("zombie/z_fall.wav");
precache_sound ("zombie/z_miss.wav");
precache_sound ("zombie/z_hit.wav");
precache_sound ("zombie/idle_w2.wav");

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

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

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

self.th_stand = zombie_stand1;
self.th_walk = zombie_walk1;
self.th_run = zombie_run1;
self.th_pain = zombie_pain;
self.th_die = zombie_die;
self.th_missile = zombie_missile;
self.touch = zomb_touch;

if (self.spawnflags & SPAWN_CRUCIFIED)
{
self.movetype = MOVETYPE_NONE;
zombie_cruc1 ();
}
else
walkmonster_start();
};


Code is not tested.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ThePlasticBling » Sun Oct 31, 2010 9:36 pm

it didnt work. do you think it would be easier to make the zombie just melee? so basically, overall, i just want the zombie to melee instead of throw grenades. I have half of it accomplished because the zombie walks at you instead of throwing grenades. but now i need the zombie to hit you when it gets close enough.
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby Mexicouger » Sun Oct 31, 2010 9:41 pm

ThePlasticBling wrote:it didnt work. do you think it would be easier to make the zombie just melee? so basically, overall, i just want the zombie to melee instead of throw grenades. I have half of it accomplished because the zombie walks at you instead of throwing grenades. but now i need the zombie to hit you when it gets close enough.


You have to have melee animations ya know.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby ThePlasticBling » Sun Oct 31, 2010 10:27 pm

yeah i know but i need a code to accomplish this. any ideas?
ThePlasticBling
 
Posts: 51
Joined: Fri Jun 04, 2010 10:18 pm

Postby DusterdooSmock » Mon Nov 01, 2010 4:12 am

ThePlasticBling wrote:yeah i know but i need a code to accomplish this. any ideas?


I suggest you do some BASIC C tutorials, or get a book on C before you dive head-first into something that you have no idea about what you are doing, because really, even someone who has a tiny bit of a grasp on coding would be able to figure this out...
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby frag.machine » Mon Nov 01, 2010 12:12 pm

ThePlasticBling wrote:yeah i know but i need a code to accomplish this. any ideas?


As said by others in other thread, welcome. :D

My suggestion to you is: try to learn a bit about QuakeC. There are a good ammount of resources available in this site, either language specs, tutorials, examples and a cool community of modders.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby OneManClan » Tue Nov 02, 2010 7:38 pm

As well as the awesome tutorials here on inside3d, check out coffees tutorials, and a bunch of stuff at quaddicted.

You can also do a search on this forum; as a newb, I've gotten some really good answers to basic, fundamental questions.
OneManClan
 
Posts: 243
Joined: Sat Feb 28, 2009 2:38 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest