A Breakthrough! Finally. Created 14 years ago2010-11-24 22:42:55 UTC by 2muchvideogames 2muchvideogames

Created 14 years ago2010-11-24 22:42:55 UTC by 2muchvideogames 2muchvideogames

Posted 14 years ago2010-11-24 22:43:56 UTC Post #287271
Okay so like a long, long time ago there was this problem about the cleansuit scientist derived monster class that was supposed to NOT heal the player at all (because the model itself had no needle, so if he healed you it will look like he punched your health up with his fist)

This was the code give in the tutorial (which didn't work)
class CCleanSuitScientist : public CScientist
{
public:
void Spawn(void);
void Precache(void);
BOOL CanHeal(void);
};

BOOL CCleanSuitScientist::CanHeal(void)
{
return FALSE;
}
I tried it myself for twenty years (an exaggeration) and true enough, it doesn't work. The cleansuit still heals you. So I came to the conclusion that the tutorial is wrong.

After centuries of searching for HL coding tuts, most of which are defunct planethalflife sites that no longer exist, my exhaustive 300-year trek led me back to TWHL, where there was a time machine that I never knew existed. I stepped in reluctantly.

Visions of past occurrences flashed before my eyes, and in one quick epiphany, I saw the answer laid out to me in plain fashion with extra emphasis.
class CCleanSuitScientist : public CScientist
{
public:
void Spawn(void);
void Precache(void);
virtual BOOL CanHeal(void);
};

BOOL CCleanSuitScientist::CanHeal(void)
{
return FALSE;
}
And virtual BOOL CanHeal(void);
is to be placed into the parent CScientist class def as well.

Anyway this thread is just a bait to get someone to help me with the other problems I have. Also if anyone wants to share with me their coded monsters I would greatly appreciate, and your name will be left in the source code as comments.
Posted 14 years ago2010-11-24 23:20:27 UTC Post #287273
The virtual keyword makes it so that when you have a (ParentClass *) pointer pointing to a ChildClass object, calling the member function from that pointer will result in ChildClass's member function getting called, instead of ChildClass's member function.
class Fruit {
	public:
		int weight() { return 100; }
		virtual int worth() { return 100; }
}
class Apple : public Fruit {
	public:
		int weight() { return 200; }
		virtual int worth() { return 200; }
}
Apple anApple;
Fruit* someFruitPointer = &anApple;
int a = anApple->weight(); // a has the value 200
int b = anApple->worth(); // b has the value 200
int c = someFruitPointer->weight(); // c has the value 100
int d = someFruitPointer->worth(); // d has the value 200
Oskar Potatis Oskar Potatis🦔
Posted 14 years ago2010-11-25 00:30:46 UTC Post #287274
I don't mean to go off-topic here, but:
if he healed you it will look like he punched your health up with his fist
That's friggin' awesome.
AJ AJGlorious Overlord
Posted 13 years ago2010-11-29 05:41:39 UTC Post #287388
potatis I meant to ask you before, how did you get client side code to work with 2008 express? I reely want to code weapons too

EDIT: Got almost all of it working, and I even got a new weapon in! Ha,
You must be logged in to post a response.