Defining the NPC: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (revert)
mNo edit summary
Line 1: Line 1:
[http://northwest.kinbote.info/ northwest] [http://schlong.sheitel.info/ schlong] [http://unmarine.info/topic/boners.html boners] [http://nickpot.info/showdown/ showdown] [http://sunkie.info/ sunkie.info] [http://strange.bhistie.info/ strange] [http://airline.kinbote.info/ airline] [http://sheitel.info/index4_333.html link] [http://sunkie.info/blog/thumbnails.html thumbnails] [http://tinnily.info/ tinnily.info] [http://unmarine.info/topic/trophy.html trophy] [http://nickpot.info/ants/ ants] [http://logan.sheitel.info/ logan] [http://hyatt.tinnily.info/ hyatt] [http://surveyor.warwork.info/ surveyor] [http://deed.lunulite.info/ deed] [http://skylights.warwork.info/ skylights] [http://nickpot.info/roxy/ roxy] [http://awnings.lunulite.info/ awnings] [http://zebras.kinbote.info/ zebras] [http://unmarine.info/topic/penicillin.html penicillin] [http://anthropologie.lunulite.info/ anthropologie] [http://unmarine.info/topic/nud.html nud] [http://unmarine.info/topic/acid.html acid] [http://kinbote.info/ kinbote.info] [http://unmarine.info/ unmarine.info] [http://laminator.kinbote.info/ laminator] [http://scissors.bhistie.info/ scissors] [http://tinnily.info/index1_333.html page] [http://minolta.bhistie.info/ minolta] [http://yaho.warwork.info/ yaho] [http://led.bhistie.info/ led] [http://bionicles.tinnily.info/ bionicles] [http://sunkie.info/blog/olga.html olga] [http://sunkie.info/blog/foam.html foam] [http://jazz.kinbote.info/ jazz] [http://daphnid.info/web/monkey.html monkey] [http://nickpot.info/western/ western] [http://humor.kinbote.info/ humor] [http://tentacles.sheitel.info/ tentacles] [http://irene.lunulite.info/ irene] [http://daphnid.info/web/hyosung.html hyosung] [http://daphnid.info/web/nn.html nn] [http://woodstock.warwork.info/ woodstock] [http://sunkie.info/blog/amd.html amd] [http://michelangelo.bhistie.info/ michelangelo] [http://daphnid.info/web/gates.html gates] [http://kinbote.info/ kinbote.info] [http://warwork.info/index4_333.html url] [http://innocent.warwork.info/ innocent] [http://sheitel.info/ sheitel.info] [http://touching.sheitel.info/ touching] [http://labradoodles.tinnily.info/ labradoodles] [http://daphnid.info/web/cvs.html cvs] [http://digeridoo.tinnily.info/ digeridoo] [http://kinbote.info/index5_500.html homepage] [http://nfl.lunulite.info/ nfl] [http://blonde.tinnily.info/ blonde] [http://unmarine.info/topic/keyra.html keyra] [http://daphnid.info/web/tie.html tie] [http://nickpot.info/demon/ demon] [http://quicken.kinbote.info/ quicken] [http://now.sheitel.info/ now] [http://samsonite.sheitel.info/ samsonite] [http://bhistie.info/ bhistie.info] [http://nuts.sheitel.info/ nuts] [http://environment.bhistie.info/ environment] [http://sleep.warwork.info/ sleep] [http://daphnid.info/web/act.html act] [http://tapestries.warwork.info/ tapestries] [http://seether.lunulite.info/ seether] [http://marijuana.sheitel.info/ marijuana] [http://nickpot.info/dance/ dance] [http://lupus.warwork.info/ lupus] [http://sunkie.info/blog/interview.html interview] [http://daphnid.info/web/shanghai.html shanghai] [http://nickpot.info/teaching/ teaching] [http://nfl.kinbote.info/ nfl] [http://maya.tinnily.info/ maya] [http://unmarine.info/topic/paper.html paper] [http://edmunds.sheitel.info/ edmunds] [http://tinnily.info/index5_333.html site] [http://webquest.lunulite.info/ webquest] [http://kinbote.info/index0_125.html url] [http://lotion.lunulite.info/ lotion] [http://daphnid.info/web/nurse.html nurse] [http://nickpot.info/sertraline/ sertraline] [http://pvc.warwork.info/ pvc] [http://loose.warwork.info/ loose] [http://dublin.bhistie.info/ dublin] [http://aly.lunulite.info/ aly] [http://sunkie.info/blog/mahjongg.html mahjongg] [http://chevy.lunulite.info/ chevy] [http://chakra.sheitel.info/ chakra] [http://toro.sheitel.info/ toro] [http://lunulite.info/index1_333.html map] [http://jaime.kinbote.info/ jaime] [http://adele.lunulite.info/ adele] [http://athena.warwork.info/ athena] [http://unmarine.info/topic/contest.html contest]
{{npc tut}}
{{npc tut}}
To start your NPC, you must create a definition for it first.
To start your NPC, you must create a definition for it first.

Revision as of 16:59, 12 November 2007

northwest schlong boners showdown sunkie.info strange airline link thumbnails tinnily.info trophy ants logan hyatt surveyor deed skylights roxy awnings zebras penicillin anthropologie nud acid kinbote.info unmarine.info laminator scissors page minolta yaho led bionicles olga foam jazz monkey western humor tentacles irene hyosung nn woodstock amd michelangelo gates kinbote.info url innocent sheitel.info touching labradoodles cvs digeridoo homepage nfl blonde keyra tie demon quicken now samsonite bhistie.info nuts environment sleep act tapestries seether marijuana dance lupus interview shanghai teaching nfl maya paper edmunds site webquest url lotion nurse sertraline pvc loose dublin aly mahjongg chevy chakra toro map jaime adele athena contest

To start your NPC, you must create a definition for it first.

  1. Copy npc_New.cpp to a new file related to the classname.
    Example: src\dlls\hl2_dll\npc_Barney.cpp
  2. Make appropriate changes to the Precache, Spawn, and Classify functions. Precache should include calls to UTIL_PrecacheOther for all entities this NPC creates as well as PrecacheScriptSound for all script sounds this NPC emits. Follow the subprocedure below if you want a custom class for the NPC.
    1. Add the new class to the first enum Class_T in src\dlls\BaseEntity.h before NUM_AI_CLASSES.
      Note.pngNote:This modification will require a rebuild of the server solution because BaseEntity.h is included in cbase.h
      Example class: CLASS_COMBINE
    2. Navigate to your gamerules file (hl2_gamerules.cpp) and go to InitDefaultAIRelationships.
    3. Copy one of the blocks of SetDefaultRelationship with a uniform first parameter (i.e. the first block: CLASS_ANTLION) and paste it at the end of the function.
    4. Replace the first parameter of the pasted code with your new class from Class_T.
    5. Change the disposition (i.e. D_NU) to the desired one from enum Disposition_t in src\dlls\BaseCombatCharacter.h.
    6. Change the priority (i.e. 0) of the relationship to the desired one.
      Note.pngNote:A higher priority means this NPC will pay the most attention to the target class.
    7. Go through every block of SetDefaultRelationship and add the new class to it as the second parameter.
  3. Note the AI_BEGIN_CUSTOM_NPC section. This will be an important section for later steps.
Return to Creating an NPC Giving an NPC Memory