Coding a simple scientist Created 15 years ago2009-02-02 22:50:19 UTC by =NH= Yodalman =NH= Yodalman

Created 15 years ago2009-02-02 22:50:19 UTC by =NH= Yodalman =NH= Yodalman

Posted 15 years ago2009-02-02 22:50:19 UTC Post #262281
It probably wouldn't even be able to move if i actually got it working!

[quote]#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "talkmonster.h"
#include "schedule.h"
#include "defaultai.h"
#include "scripted.h"
#include "animation.h"
#include "soundent.h"

class CLab : public CBaseMonster
{
public:
[blue]void[/blue] Spawn( [blue]void[/blue] );
[blue]int[/blue]  Classify ( [blue]void[/blue] );
void CLab :: spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/scientist.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
pev->solid			= SOLID_SLIDEBOX;
pev->movetype		= MOVETYPE_STEP;
m_bloodColor		= BLOOD_COLOR_RED;
pev->health			= gSkillData.scientistHealth;
pev->view_ofs		= Vector ( 0, 0, 50 );[green]// position of the eyes relative to monster's origin.[/green]
m_flFieldOfView		= VIEW_FIELD_WIDE; [green]// NOTE: we need a wide field of view so scientists will notice player and say hello[/green]
m_MonsterState		= MONSTERSTATE_NONE;
pev->skin = 0;
MonsterInit();
}

void CLab :: Precache( void )
{
PRECACHE_MODEL("models/scientist.mdl");
}[/quote]

The error:
-------------------Configuration: hl - Win32 Profile-------------------
Compiling...
blaster.cpp
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(39) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

blaster.obj - 1 error(s), 0 warning(s)
Now, it's pretty obvious i didn't have the correct brackets here: [quote]{
public:
void Spawn( void );
int  Classify ( void );
void CLab :: spawn( void )[/quote]

But it i add the closing bracket there, this will happen.

[quote]-------------------Configuration: hl - Win32 Profile-------------------
Compiling...
blaster.cpp
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(19) : error C2628: 'CLab' followed by 'void' is illegal (did you forget a ';'?)
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(19) : error C2039: 'spawn' : is not a member of 'CLab'
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(13) : see declaration of 'CLab'
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(21) : error C2065: 'Precache' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(22) : error C2065: 'pev' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(24) : error C2227: left of '->solid' must point to class/struct/union
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(25) : error C2227: left of '->movetype' must point to class/struct/union
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(26) : error C2065: 'm_bloodColor' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(27) : error C2227: left of '->health' must point to class/struct/union
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(28) : error C2227: left of '->view_ofs' must point to class/struct/union
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(29) : error C2065: 'm_flFieldOfView' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(30) : error C2065: 'm_MonsterState' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(31) : error C2227: left of '->skin' must point to class/struct/union
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(32) : error C2065: 'MonsterInit' : undeclared identifier
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(36) : error C2509: 'Precache' : member function not declared in 'CLab'
C:\Sierra\Half-Life\SDK\Single-Player Source\dlls\blaster.cpp(13) : see declaration of 'CLab'
Error executing cl.exe.

blaster.obj - 14 error(s), 0 warning(s)[/quote]
Posted 15 years ago2009-02-03 04:57:52 UTC Post #262290
class CLab : public CBaseMonster
{
public:
void Spawn( void );
int Classify ( void );
}

void CLab :: [b][u]S[/u][/b]pawn( void )
{
...
C++ is case-sensitive.
Penguinboy PenguinboyHaha, I died again!
Posted 15 years ago2009-02-03 06:19:06 UTC Post #262294
It sure is.

You could check out botmans tutorials on the scientist from 99, i dont know how relevant they are in these days since i remember hearing about a SDK update, but i havent messed with the code yet so i cant really say so.

Linky: http://botman.planethalflife.gamespy.com/balfourroad/index.shtml
Posted 15 years ago2009-02-03 17:20:31 UTC Post #262300
Thanks pengy, I'll test in a bit.

I'm rather new to this >_>

EDIT: Damn that coding tut, why didn't it tell me about ANYTHING being case sensitive :tired:

EDIT: got it, just copied some code from scientist, it compiled without error, and it linked without conflict.

My new code, i hope it works:
[quote]#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "talkmonster.h"
#include "schedule.h"
#include "defaultai.h"
#include "scripted.h"
#include "animation.h"
#include "soundent.h"

class CLab : public CBaseMonster
{
public:
void spawn( void );
void Precache( void );
static	TYPEDESCRIPTION m_SaveData[];
};

LINK_ENTITY_TO_CLASS( monster_scientist2, CLab );

void CLab :: spawn( void )
{
SET_MODEL(ENT(pev), "models/scientist.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED;
pev->health = gSkillData.scientistHealth;
pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin.
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello
m_MonsterState = MONSTERSTATE_NONE;
pev->skin = 0;
MonsterInit();
}

void CLab :: Precache( void )
{
PRECACHE_MODEL("models/scientist.mdl");
}[/quote]

By the way, the mod's name is interest mod x3
Posted 15 years ago2009-02-03 18:20:33 UTC Post #262304
Looks solid, couldnt find any errors in it, good luck with your mod!
Posted 15 years ago2009-02-03 18:28:06 UTC Post #262305
So, what special thing is your new scientist supposed to do? (I don't speak C# or C++ as of yet.)
Notewell NotewellGIASFELFEBREHBER
Posted 15 years ago2009-02-03 18:36:13 UTC Post #262307
Well, it doesn't do anything, it's the first code that i copied off of the scientist without having conflict while linking because they have the same code.

EDIT: In other words, It's just a model, you can't shoot it, kill it or enytheng, pretty much a test.
Posted 15 years ago2009-02-03 19:25:50 UTC Post #262310
EDIT: Damn that coding tut, why didn't it tell me about ANYTHING being case sensitive tired - :tired:
Probably because that tutorial assumes you already know that. It's pretty standard stuff.

Don't worry, I didn't know those things either, 6 years ago. ;)
You must be logged in to post a response.