Here's one I made, if it helps. The only differences I see are the precache
macro, the ifndef guard and that I put my link macro in my cpp file.

my header file
------------------

#ifndef _H_BLOODBOWL_PICKUP
#define _H_BLOODBOWL_PICKUP

#include "items.h"

class CBloodBowlManaBig : public CItem
{
public:
DECLARE_CLASS( CBloodBowlManaBig, CItem );

void Spawn( void );
void Precache( void );
void ItemTouch( CBaseEntity *pOther );
int GetManaChange( void ) const;
private:
int m_ManaChange;
};

#endif


my cpp
------------

#include "cbase.h"
#include "arena_pickups.h"
// ...

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

LINK_ENTITY_TO_CLASS( arena_item_mana, CBloodBowlManaBig );
PRECACHE_REGISTER( arena_item_mana );


void CBloodBowlManaBig::Spawn( void )
{
Precache();
SetModel( "models/healthvial.mdl" );
...
BaseClass::Spawn();
}

void CBloodBowlManaBig::Precache( void )
{
PrecacheModel("models/props_junk/glassbottle01a.mdl");

PrecacheScriptSound( "HealthKit.Touch" );
}

void CBloodBowlManaBig::ItemTouch( CBaseEntity *pEntity )
{
...

BaseClass::ItemTouch( pEntity );
}

int CBloodBowlManaBig::GetManaChange() const
{
...
}



On 4 September 2014 08:23, iv michael <[email protected]> wrote:

> So I'm trying to create really simple items in game just to test.
> Basically I copied the code from item_suit.cpp into 2 files (header and
> cpp), changed some names and behaviour in MyTouch method. During load I get
> an error in utils.cpp :
>
> void CEntityFactoryDictionary::InstallFactory( IEntityFactory *pFactory,
> const char *pClassName )
> {
>         Assert( FindFactory( pClassName ) == NULL );  // ASSERT FAILS when
> pClassName = item_kevlar
>         m_Factories.Insert( pClassName, pFactory );
> }
>
> Apparenlty factory cant find a constructor to create an instance (if I
> understand it correctly). There is code of my item..
>
> -----------------------------------------------------------header-----------
> class CItemKevlar : public CItem
> {
> public:
>         DECLARE_CLASS(CItemKevlar, CItem);
>
>         void Spawn(void);
>         void Precache(void);
>         bool MyTouch(CBasePlayer *pPlayer);
>         int itemNumber(void) { return ACTION_ITEM_KEVLAR; };
>         bool isSpecificItem(int);
> };
>
> LINK_ENTITY_TO_CLASS(item_kevlar, CItemKevlar); // here is factory method
> called. interesting thing
>                                                                     //that
> the string "item_kelvar"  or "item_suit" can be found only here.
>                                                                     //so I
> have no idea why it cant be found
> -----------------------------------------------------------
> and in cpp file there is just code of this functions (again, basically
> it's just a copy of item_suit).
> How should I fix it?
>
> regards, Michael
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders

Reply via email to