plugin/"bolt-on" entities (NPC's specifically)

Got problems with your models? Struggling with textures? Get help with your custom assets.

plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Sat Sep 17, 2011 12:01 am

So I've been fiddling with custom entities for a few days and I'm a little overwhelmed. The VDC only provided half the info and google made it all sound irrelevant. I'm trying to create an NPC that anyone can download and plug straight into their mod, much like a custom prop. Props have the advantage of being able to just change their world model and any model is compatible with any mod (generally). Entities seem to need to be hardcoded into the mod? Is that right?

Exactly what I'm trying to do is this: I have made a new model for the headcrab, which is rigged to the old rig and uses all the same animations, it's all good in HLMV. I want to make a new entity (a straight clone of npc_headcrab with new models and sounds) that anyone can download and put in their map or mod. I don't want to just replace the model for the old headcrab.

How do I go about this? Should I be looking at VPKs or GCFs? If anyone can point me in the general direction that would be super.
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby LordDz on Sat Sep 17, 2011 1:07 am

Make it as a prefab, then anyone can change the npc_whateverthefuckyerusing to npc_whatevertheyfeellikeusing ?
User avatar
LordDz
May Contain Skills
May Contain Skills
 
Joined: Mon Sep 01, 2008 12:28 pm
Location: Hammer Crash Logs

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Sat Sep 17, 2011 7:23 am

I'm not sure I follow, wouldn't that still require the entity to be compiled, and therefore still hardcoded? I mean, a prefab doesn't extract the entities it uses and save them elsewhere, it just stores a bunch of internal pointers to assets, right?
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Gary on Sat Sep 17, 2011 12:56 pm

Interesting fact, all zombies are in one cpp file. You can declare multiple entities.

You should also able to copy the head crab ai from a new file... Cant say how, I would have to learn first.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Sat Sep 17, 2011 1:24 pm

Yeah all the headcrabs share the same cpp file too. it already includes all the ai in the script, all I have done is changed the linking model file and the entity name, leaving all the local variables and private declarations as "headcrab" just in case it messes something up in a reference file. But in order to compile I have to compile the entire mod, and there must be some files somewhere that I am missing. Is there a way to compile just the one file without compiling the mod? I feel like I'm going around in circles here, I need to sleep...
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby zombie@computer on Sat Sep 17, 2011 6:08 pm

Code: Select all
class MyNewHeadcrap : public CHeadcrab
{
public:
     MyNewHeadcrap()
     {
            Precache();
            SetModel("models/MyNewHeadcrap.mdl" );
     }
     void Precache()
     {
           PrecacheModel( "models/MyNewHeadcrap.mdl" );
     }
};

all there is to it.

not sure if this works in plugins, ive never touched plugins nor ever will.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Sun Sep 18, 2011 2:29 am

Thanks for the advice, but I can't get it to work. I'm getting the "failed to create unknown entity type" console error. I have added a new class in the npc_headcrab.h file (copying from Cbaseheadcrab) and copied the relevant entries in the npc_headcrab.cpp file as well. I worked through my errors and have an error free compile, but the entity isn't being created. Shouldn't this output a file of some sort? Like a combinecrab.mdl file? I noticed that there is a headcrab.obj file, which I thought was just a model source file but it appears to be updated whenever I compile the code. Here's what I have modified in the files so far:

npc_headcrab.cpp:
Code: Select all

void Ccombinecrab::Precache( void )
{
   PrecacheModel( "models/m4m/combinecrab.mdl" );

   PrecacheScriptSound( "NPC_HeadCrab.Gib" );
   PrecacheScriptSound( "NPC_HeadCrab.Idle" );
   PrecacheScriptSound( "NPC_HeadCrab.Alert" );
   PrecacheScriptSound( "NPC_HeadCrab.Pain" );
   PrecacheScriptSound( "NPC_HeadCrab.Die" );
   PrecacheScriptSound( "NPC_HeadCrab.Attack" );
   PrecacheScriptSound( "NPC_HeadCrab.Bite" );
   PrecacheScriptSound( "NPC_Headcrab.BurrowIn" );
   PrecacheScriptSound( "NPC_Headcrab.BurrowOut" );

   BaseClass::Precache();
}

void Ccombinecrab::Spawn( void )
{
   Precache();
   SetModel( "models/m4m/combinecrab.mdl" );

   BaseClass::Spawn();

   m_iHealth = sk_headcrab_health.GetFloat();
   m_flBurrowTime = 0.0f;
   m_bCrawlFromCanister = false;
   m_bMidJump = false;

   NPCInit();
   HeadcrabInit();
}

Activity Ccombinecrab::NPC_TranslateActivity( Activity eNewActivity )
{
   if ( eNewActivity == ACT_WALK )
      return ACT_RUN;

   return BaseClass::NPC_TranslateActivity( eNewActivity );
}


void Ccombinecrab::IdleSound( void )
{
   EmitSound( "NPC_HeadCrab.Idle" );
}

void Ccombinecrab::AlertSound( void )
{
   EmitSound( "NPC_HeadCrab.Alert" );
}

void Ccombinecrab::PainSound( const CTakeDamageInfo &info )
{
   if( IsOnFire() && random->RandomInt( 0, HEADCRAB_BURN_SOUND_FREQUENCY ) > 0 )
   {
      // Don't squeak every think when burning.
      return;
   }

   EmitSound( "NPC_HeadCrab.Pain" );
}

void Ccombinecrab::DeathSound( const CTakeDamageInfo &info )
{
   EmitSound( "NPC_HeadCrab.Die" );
}

void Ccombinecrab::TelegraphSound( void )
{
   //FIXME: Need a real one
   EmitSound( "NPC_HeadCrab.Alert" );
}

void Ccombinecrab::AttackSound( void )
{
   EmitSound( "NPC_Headcrab.Attack" );
}

void Ccombinecrab::BiteSound( void )
{
   EmitSound( "NPC_HeadCrab.Bite" );
}

LINK_ENTITY_TO_CLASS( npc_combinecrab, Ccombinecrab );

float Ccombinecrab::MaxYawSpeed ( void )
{
   switch ( GetActivity() )
   {
   case ACT_IDLE:         
      return 30;

   case ACT_RUN:         
   case ACT_WALK:         
      return 20;

   case ACT_TURN_LEFT:
   case ACT_TURN_RIGHT:
      return 15;

   case ACT_RANGE_ATTACK1:
      {
         const Task_t *pCurTask = GetTask();
         if ( pCurTask && pCurTask->iTask == TASK_HEADCRAB_JUMP_FROM_CANISTER )
            return 15;
      }
      return 30;

   default:
      return 30;
   }

   return BaseClass::MaxYawSpeed();
}



npc_headcrab.h:
Code: Select all
class Ccombinecrab : public CBaseHeadcrab
{
   DECLARE_CLASS( Ccombinecrab, CBaseHeadcrab );

public:
   void Precache( void );
   void Spawn( void );

   float   MaxYawSpeed( void );
   Activity NPC_TranslateActivity( Activity eNewActivity );

   void   BiteSound( void );
   void   PainSound( const CTakeDamageInfo &info );
   void   DeathSound( const CTakeDamageInfo &info );
   void   IdleSound( void );
   void   AlertSound( void );
   void   AttackSound( void );
   void   TelegraphSound( void );
};


Mymod.fgd:
Code: Select all
@include "base.fgd"
 
@PointClass base(Targetname) studio("models/m4m/combinecrab.mdl")= npc_combinecrab :  "combinecrab"
[
]


thanks for helping me this far, at least.
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Gary on Sun Sep 18, 2011 2:50 am

Where are you declaring the entity name?

Oh and obj, while known as a model format, just stands for object in VS.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Sun Sep 18, 2011 4:40 am

Do you mean this line?
Code: Select all
LINK_ENTITY_TO_CLASS( npc_combinecrab, Ccombinecrab );


That's the only real mention of an entity name outside of the .fgd. I assumed it would appear after all of the entries about the class, but the fastheadcrab has it's MaxYawSpeed after the LINK_ENTITY, so I stayed with that order.

And about the .obj, I assume that must be the file that contains some information about the headcrab and variants then? Because it updates on each compile, but I can't read the contents of it, and can't import it into blender either.
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Gary on Sun Sep 18, 2011 12:23 pm

Ignore the obj thing, it's just something the compiler makes during the build.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Jordash on Mon Sep 19, 2011 7:43 am

why do you think the code would output a model? I can't seem to follow the logic pattern there...

The naming of the npc in the cpp file is the important one, the fdg is only for hammer. If you want to test your code use the 'npc_create npc_*' console command. Also, since you seem to be basing the code off the original headcrab, you don't need to have all the sounds and stuff mentioned again, they default to the original headcrab's if you don't mention them.

Also make sure the code is being copied, you need your client.dll and server.dll files to be in which ever mod you are playing.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Thu May 16, 2013 7:41 am

I can't believe it was two years since I tried to do this. Since I made that steampunk turret model I want to include that as its own entity so I guess I'll give this another go.

By "Shouldn't this output a file of some sort?" I think I meant shouldn't it be an entity of its own within my mod? For instance the turret in portal is a turret_floor entity. If I was to clone it and change the models/sounds then I would want to create a turret_gentry entity. Once I added in the code and recompiled my mod I was hoping the combinecrab entity would show up in my entity list within hammer. Is this not how it works?

Also is there a way to extract the entity and all its logic and provide it as a download for other people to put in their mods or do they have to code in the entity in the same way I do, and I just provide the assets?
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby [Steve] on Thu May 16, 2013 8:22 pm

Hammer loads its entity list independently from your client/server dll's , from an Fgd file
https://developer.valvesoftware.com/wiki/FGD

so to place a custom ent in hammer you need to add it to one of the Fgd's or make your own and add it to those loaded by hammer.

However if you just want to test your new custom ent ingame without having to add it to a map , then just use the ent_Create console command.
If you would like me to go into further detail i don't mind writing a tutorial on how to create a new turret entity and add it to your fgd.

Also if all your wanting to do is a model swap then you don't need to create a new ent. in hammer you can edit the model key value and have a stock ent use a different model (this seems to work on most ents , tho some it doesn't).
User avatar
[Steve]
Interlopers Staff
Interlopers Staff
 
Joined: Fri Mar 06, 2009 11:25 pm

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby Stormy on Thu May 16, 2013 10:10 pm

To be honest I hadn't looked at the entity in hammer to see if I could swap out the model. What about sound files? The turret uses custom sounds I assume I'll have to make a new entity for that.
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: plugin/"bolt-on" entities (NPC's specifically)

Postby [Steve] on Sat May 18, 2013 11:16 pm

yeah custom ent would be the best way to go for new sounds.
User avatar
[Steve]
Interlopers Staff
Interlopers Staff
 
Joined: Fri Mar 06, 2009 11:25 pm

Return to Custom Asset Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]