NPC_spawn.cpp 121 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352
  1. //b_spawn.cpp
  2. //added by MCG
  3. // leave this line at the top for all NPC_xxxx.cpp files...
  4. #include "g_headers.h"
  5. #include "Q3_Interface.h"
  6. #include "b_local.h"
  7. #include "anims.h"
  8. #include "g_functions.h"
  9. #include "wp_saber.h"
  10. #include "g_vehicles.h"
  11. extern qboolean G_CheckInSolid (gentity_t *self, qboolean fix);
  12. extern void ClientUserinfoChanged( int clientNum );
  13. extern qboolean SpotWouldTelefrag2( gentity_t *mover, vec3_t dest );
  14. extern void Jedi_Cloak( gentity_t *self );
  15. extern void Saboteur_Cloak( gentity_t *self );
  16. //extern void FX_BorgTeleport( vec3_t org );
  17. extern void G_MatchPlayerWeapon( gentity_t *ent );
  18. extern void Q3_SetParm (int entID, int parmNum, const char *parmValue);
  19. //extern void CG_ShimmeryThing_Spawner( vec3_t start, vec3_t end, float radius, qboolean taper, int duration );
  20. //extern void NPC_StasisSpawnEffect( gentity_t *ent );
  21. extern void PM_SetTorsoAnimTimer( gentity_t *ent, int *torsoAnimTimer, int time );
  22. extern void PM_SetLegsAnimTimer( gentity_t *ent, int *legsAnimTimer, int time );
  23. extern int WP_SaberInitBladeData( gentity_t *ent );
  24. extern void ST_ClearTimers( gentity_t *ent );
  25. extern void Jedi_ClearTimers( gentity_t *ent );
  26. extern void Howler_ClearTimers( gentity_t *self );
  27. #define NSF_DROP_TO_FLOOR 16
  28. //void HirogenAlpha_Precache( void );
  29. /*
  30. -------------------------
  31. NPC_PainFunc
  32. -------------------------
  33. */
  34. painFunc_t NPC_PainFunc( gentity_t *ent )
  35. {
  36. painFunc_t func;
  37. if ( ent->client->ps.weapon == WP_SABER )
  38. {
  39. func = painF_NPC_Jedi_Pain;
  40. }
  41. else
  42. {
  43. // team no longer indicates race/species, use NPC_class to determine different npc types
  44. /*
  45. switch ( ent->client->playerTeam )
  46. {
  47. default:
  48. func = painF_NPC_Pain;
  49. break;
  50. }
  51. */
  52. switch( ent->client->NPC_class )
  53. {
  54. // troopers get special pain
  55. case CLASS_SABOTEUR:
  56. case CLASS_STORMTROOPER:
  57. case CLASS_SWAMPTROOPER:
  58. case CLASS_NOGHRI:
  59. func = painF_NPC_ST_Pain;
  60. break;
  61. case CLASS_SEEKER:
  62. func = painF_NPC_Seeker_Pain;
  63. break;
  64. case CLASS_REMOTE:
  65. func = painF_NPC_Remote_Pain;
  66. break;
  67. case CLASS_MINEMONSTER:
  68. func = painF_NPC_MineMonster_Pain;
  69. break;
  70. case CLASS_HOWLER:
  71. func = painF_NPC_Howler_Pain;
  72. break;
  73. case CLASS_RANCOR:
  74. func = painF_NPC_Rancor_Pain;
  75. break;
  76. case CLASS_WAMPA:
  77. func = painF_NPC_Wampa_Pain;
  78. break;
  79. case CLASS_SAND_CREATURE:
  80. func = painF_NPC_SandCreature_Pain;
  81. break;
  82. // all other droids, did I miss any?
  83. case CLASS_GONK:
  84. case CLASS_R2D2:
  85. case CLASS_R5D2:
  86. case CLASS_MOUSE:
  87. case CLASS_PROTOCOL:
  88. case CLASS_INTERROGATOR:
  89. func = painF_NPC_Droid_Pain;
  90. break;
  91. case CLASS_PROBE:
  92. func = painF_NPC_Probe_Pain;
  93. break;
  94. case CLASS_SENTRY:
  95. func = painF_NPC_Sentry_Pain;
  96. break;
  97. case CLASS_MARK1:
  98. func = painF_NPC_Mark1_Pain;
  99. break;
  100. case CLASS_MARK2:
  101. func = painF_NPC_Mark2_Pain;
  102. break;
  103. case CLASS_ATST:
  104. func = painF_NPC_ATST_Pain;
  105. break;
  106. case CLASS_GALAKMECH:
  107. func = painF_NPC_GM_Pain;
  108. break;
  109. // everyone else gets the normal pain func
  110. default:
  111. func = painF_NPC_Pain;
  112. break;
  113. }
  114. }
  115. return func;
  116. }
  117. /*
  118. -------------------------
  119. NPC_TouchFunc
  120. -------------------------
  121. */
  122. touchFunc_t NPC_TouchFunc( gentity_t *ent )
  123. {
  124. return touchF_NPC_Touch;
  125. }
  126. /*
  127. -------------------------
  128. NPC_SetMiscDefaultData
  129. -------------------------
  130. */
  131. void G_ClassSetDontFlee( gentity_t *self )
  132. {
  133. if ( !self || !self->client || !self->NPC )
  134. {
  135. return;
  136. }
  137. switch ( self->client->NPC_class )
  138. {
  139. case CLASS_ATST:
  140. case CLASS_CLAW:
  141. case CLASS_DESANN:
  142. case CLASS_FISH:
  143. case CLASS_FLIER2:
  144. case CLASS_GALAK:
  145. case CLASS_GLIDER:
  146. case CLASS_RANCOR:
  147. case CLASS_SAND_CREATURE:
  148. case CLASS_INTERROGATOR: // droid
  149. case CLASS_JAN:
  150. case CLASS_JEDI:
  151. case CLASS_KYLE:
  152. case CLASS_LANDO:
  153. case CLASS_LIZARD:
  154. case CLASS_LUKE:
  155. case CLASS_MARK1: // droid
  156. case CLASS_MARK2: // droid
  157. case CLASS_GALAKMECH: // droid
  158. case CLASS_MONMOTHA:
  159. case CLASS_MORGANKATARN:
  160. case CLASS_MURJJ:
  161. case CLASS_PROBE: // droid
  162. case CLASS_REBORN:
  163. case CLASS_REELO:
  164. case CLASS_REMOTE:
  165. case CLASS_SEEKER: // droid
  166. case CLASS_SENTRY:
  167. case CLASS_SHADOWTROOPER:
  168. case CLASS_SWAMP:
  169. case CLASS_TAVION:
  170. case CLASS_ALORA:
  171. case CLASS_BOBAFETT:
  172. case CLASS_SABER_DROID:
  173. case CLASS_ASSASSIN_DROID:
  174. case CLASS_PLAYER:
  175. case CLASS_VEHICLE:
  176. self->NPC->scriptFlags |= SCF_DONT_FLEE;
  177. break;
  178. }
  179. if ( (self->NPC->aiFlags&NPCAI_BOSS_CHARACTER) )
  180. {
  181. self->NPC->scriptFlags |= SCF_DONT_FLEE;
  182. }
  183. if ( (self->NPC->aiFlags&NPCAI_SUBBOSS_CHARACTER) )
  184. {
  185. self->NPC->scriptFlags |= SCF_DONT_FLEE;
  186. }
  187. if ( (self->NPC->aiFlags&NPCAI_ROSH) )
  188. {
  189. self->NPC->scriptFlags |= SCF_DONT_FLEE;
  190. }
  191. if ( (self->NPC->aiFlags&NPCAI_HEAL_ROSH) )
  192. {
  193. self->NPC->scriptFlags |= SCF_DONT_FLEE;
  194. }
  195. }
  196. extern void Vehicle_Register(gentity_t *ent);
  197. extern void RT_FlyStart( gentity_t *self );
  198. extern void SandCreature_ClearTimers( gentity_t *ent );
  199. void NPC_SetMiscDefaultData( gentity_t *ent )
  200. {
  201. if ( ent->spawnflags & SFB_CINEMATIC )
  202. {//if a cinematic guy, default us to wait bState
  203. ent->NPC->behaviorState = BS_CINEMATIC;
  204. }
  205. if ( ent->client->NPC_class == CLASS_RANCOR )
  206. {
  207. if ( Q_stricmp( "mutant_rancor", ent->NPC_type ) == 0 )
  208. {
  209. ent->spawnflags |= 1;//just so I know it's a mutant rancor as opposed to a normal one
  210. ent->NPC->aiFlags |= NPCAI_NAV_THROUGH_BREAKABLES;
  211. ent->mass = 2000;
  212. }
  213. else
  214. {
  215. ent->NPC->aiFlags |= NPCAI_NAV_THROUGH_BREAKABLES;
  216. ent->mass = 1000;
  217. }
  218. ent->flags |= FL_NO_KNOCKBACK;
  219. }
  220. else if ( ent->client->NPC_class == CLASS_SAND_CREATURE )
  221. {//???
  222. ent->clipmask = CONTENTS_SOLID|CONTENTS_MONSTERCLIP;//it can go through others
  223. ent->contents = 0;//can't be hit?
  224. ent->takedamage = qfalse;//can't be killed
  225. ent->flags |= FL_NO_KNOCKBACK;
  226. SandCreature_ClearTimers( ent );
  227. }
  228. else if ( ent->client->NPC_class == CLASS_BOBAFETT )
  229. {//set some stuff, precache
  230. ent->client->ps.forcePowersKnown |= ( 1 << FP_LEVITATION );
  231. ent->client->ps.forcePowerLevel[FP_LEVITATION] = FORCE_LEVEL_3;
  232. ent->client->ps.forcePower = 100;
  233. ent->NPC->scriptFlags |= (SCF_NAV_CAN_FLY|SCF_FLY_WITH_JET|SCF_NAV_CAN_JUMP);
  234. NPC->flags |= FL_UNDYING; // Can't Kill Boba
  235. }
  236. else if ( ent->client->NPC_class == CLASS_ROCKETTROOPER )
  237. {//set some stuff, precache
  238. ent->client->ps.forcePowersKnown |= ( 1 << FP_LEVITATION );
  239. ent->client->ps.forcePowerLevel[FP_LEVITATION] = FORCE_LEVEL_3;
  240. ent->client->ps.forcePower = 100;
  241. ent->NPC->scriptFlags |= (SCF_NAV_CAN_FLY|SCF_FLY_WITH_JET|SCF_NAV_CAN_JUMP);//no groups, no combat points!
  242. if ( Q_stricmp( "rockettrooper2Officer", ent->NPC_type ) == 0 )
  243. {//start in the air, use spotlight
  244. //ent->NPC->scriptFlags |= SCF_NO_GROUPS;
  245. ent->NPC->scriptFlags &= ~SCF_FLY_WITH_JET;
  246. RT_FlyStart( ent );
  247. NPC_SetMoveGoal( ent, ent->currentOrigin, 16, qfalse, -1, NULL );
  248. VectorCopy( ent->currentOrigin, ent->pos1 );
  249. }
  250. if ( (ent->spawnflags&2) )
  251. {//spotlight
  252. ent->client->ps.eFlags |= EF_SPOTLIGHT;
  253. }
  254. }
  255. else if (ent->client->NPC_class == CLASS_SABER_DROID)
  256. {
  257. ent->flags |= FL_NO_KNOCKBACK;
  258. }
  259. else if ( ent->client->NPC_class == CLASS_SABOTEUR )
  260. {//can cloak
  261. ent->NPC->aiFlags |= NPCAI_SHIELDS;//give them the ability to cloak
  262. if ( (ent->spawnflags&16) )
  263. {//start cloaked
  264. Saboteur_Cloak( ent );
  265. }
  266. }
  267. else if ( ent->client->NPC_class == CLASS_ASSASSIN_DROID )
  268. {
  269. ent->client->ps.stats[STAT_ARMOR] = 250; // start with full armor
  270. if (ent->s.weapon==WP_BLASTER)
  271. {
  272. ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  273. }
  274. ent->flags |= (FL_NO_KNOCKBACK);
  275. }
  276. if (ent->spawnflags&4096)
  277. {
  278. ent->NPC->scriptFlags |= SCF_NO_GROUPS;//don't use combat points or group AI
  279. }
  280. if ( Q_stricmp( "DKothos", ent->NPC_type ) == 0
  281. || Q_stricmp( "VKothos", ent->NPC_type ) == 0 )
  282. {
  283. ent->NPC->scriptFlags |= SCF_DONT_FIRE;
  284. ent->NPC->aiFlags |= NPCAI_HEAL_ROSH;
  285. ent->count = 100;
  286. }
  287. else if ( Q_stricmp( "rosh_dark", ent->NPC_type ) == 0 )
  288. {
  289. ent->NPC->aiFlags |= NPCAI_ROSH;
  290. }
  291. if ( Q_stricmpn( ent->NPC_type, "hazardtrooper", 13 ) == 0 )
  292. {//hazard trooper
  293. ent->NPC->scriptFlags |= SCF_NO_GROUPS;//don't use combat points or group AI
  294. ent->flags |= (FL_SHIELDED|FL_NO_KNOCKBACK);//low-level shots bounce off, no knockback
  295. }
  296. if ( !Q_stricmp( "Yoda", ent->NPC_type ) )
  297. {//FIXME: extern this into NPC.cfg?
  298. ent->NPC->scriptFlags |= SCF_NO_FORCE;//force powers don't work on him
  299. ent->NPC->aiFlags |= NPCAI_BOSS_CHARACTER;
  300. }
  301. if ( !Q_stricmp( "emperor", ent->NPC_type )
  302. || !Q_stricmp( "cultist_grip", ent->NPC_type )
  303. || !Q_stricmp( "cultist_drain", ent->NPC_type )
  304. || !Q_stricmp( "cultist_lightning", ent->NPC_type ))
  305. {//FIXME: extern this into NPC.cfg?
  306. ent->NPC->scriptFlags |= SCF_DONT_FIRE;//so he uses only force powers
  307. }
  308. if (!Q_stricmp( "Rax", ent->NPC_type ) )
  309. {
  310. ent->NPC->scriptFlags |= SCF_DONT_FLEE;
  311. }
  312. if ( !Q_stricmp( "cultist_destroyer", ent->NPC_type ) )
  313. {
  314. ent->splashDamage = 1000;
  315. ent->splashRadius = 384;
  316. //FIXME: precache these!
  317. ent->fxID = G_EffectIndex( "force/destruction_exp" );
  318. ent->NPC->scriptFlags |= (SCF_DONT_FLEE|SCF_IGNORE_ALERTS);
  319. ent->NPC->ignorePain = qtrue;
  320. }
  321. if ( Q_stricmp( "chewie", ent->NPC_type ) )
  322. {
  323. //in case chewie ever loses his gun...
  324. ent->NPC->aiFlags |= NPCAI_HEAVY_MELEE;
  325. }
  326. //==================
  327. if ( ent->client->ps.saber[0].type != SABER_NONE
  328. && (!(ent->NPC->aiFlags&NPCAI_MATCHPLAYERWEAPON)||!ent->weaponModel[0]) )
  329. {//if I'm equipped with a saber, initialize it (them)
  330. ent->client->ps.SaberDeactivate();
  331. ent->client->ps.SetSaberLength( 0 );
  332. WP_SaberInitBladeData( ent );
  333. if ( ent->client->ps.weapon == WP_SABER )
  334. {//this is our current weapon, add the models now
  335. WP_SaberAddG2SaberModels( ent );
  336. }
  337. Jedi_ClearTimers( ent );
  338. }
  339. if ( ent->client->ps.forcePowersKnown != 0 )
  340. {
  341. WP_InitForcePowers( ent );
  342. if (ent->client->ps.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_0)
  343. {
  344. ent->NPC->scriptFlags |= SCF_NAV_CAN_JUMP; // anyone who has any force jump can jump
  345. }
  346. }
  347. if ( ent->client->NPC_class == CLASS_HOWLER )
  348. {
  349. Howler_ClearTimers( ent );
  350. ent->NPC->scriptFlags |= SCF_NO_FALLTODEATH;
  351. ent->flags |= FL_NO_IMPACT_DMG;
  352. ent->NPC->scriptFlags |= SCF_NAV_CAN_JUMP; // These jokers can jump
  353. }
  354. if ( ent->client->NPC_class == CLASS_DESANN
  355. || ent->client->NPC_class == CLASS_TAVION
  356. || ent->client->NPC_class == CLASS_LUKE
  357. || ent->client->NPC_class == CLASS_KYLE
  358. || Q_stricmp("tavion_scepter", ent->NPC_type ) == 0
  359. || Q_stricmp("alora_dual", ent->NPC_type ) == 0 )
  360. {
  361. ent->NPC->aiFlags |= NPCAI_BOSS_CHARACTER;
  362. }
  363. else if ( Q_stricmp( "alora", ent->NPC_type ) == 0
  364. || Q_stricmp( "rosh_dark", ent->NPC_type ) == 0 )
  365. {
  366. ent->NPC->aiFlags |= NPCAI_SUBBOSS_CHARACTER;
  367. }
  368. if ( ent->client->NPC_class == CLASS_TUSKEN )
  369. {
  370. if ( g_spskill->integer > 1 )
  371. {//on hard, tusken raiders are faster than you
  372. ent->NPC->stats.runSpeed = 280;
  373. ent->NPC->stats.walkSpeed = 65;
  374. }
  375. }
  376. //***I'm not sure whether I should leave this as a TEAM_ switch, I think NPC_class may be more appropriate - dmv
  377. switch(ent->client->playerTeam)
  378. {
  379. case TEAM_PLAYER:
  380. //ent->flags |= FL_NO_KNOCKBACK;
  381. if ( ent->client->NPC_class == CLASS_SEEKER )
  382. {
  383. ent->NPC->defaultBehavior = BS_DEFAULT;
  384. ent->client->ps.gravity = 0;
  385. ent->svFlags |= SVF_CUSTOM_GRAVITY;
  386. ent->client->moveType = MT_FLYSWIM;
  387. ent->count = 30; // SEEKER shot ammo count
  388. return;
  389. }
  390. else if ( ent->client->NPC_class == CLASS_JEDI
  391. || ent->client->NPC_class == CLASS_KYLE
  392. || ent->client->NPC_class == CLASS_LUKE )
  393. {//good jedi
  394. ent->client->enemyTeam = TEAM_ENEMY;
  395. if ( ent->spawnflags & JSF_AMBUSH )
  396. {//ambusher
  397. ent->NPC->scriptFlags |= SCF_IGNORE_ALERTS;
  398. ent->client->noclip = true;//hang
  399. }
  400. }
  401. else
  402. {
  403. if (ent->client->ps.weapon != WP_NONE
  404. && ent->client->ps.weapon != WP_SABER //sabers done above
  405. && (!(ent->NPC->aiFlags&NPCAI_MATCHPLAYERWEAPON)||!ent->weaponModel[0]) )//they do this themselves
  406. {
  407. G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl, ent->handRBolt, 0 );
  408. }
  409. switch ( ent->client->ps.weapon )
  410. {
  411. case WP_BRYAR_PISTOL://FIXME: new weapon: imp blaster pistol
  412. case WP_BLASTER_PISTOL:
  413. case WP_DISRUPTOR:
  414. case WP_BOWCASTER:
  415. case WP_REPEATER:
  416. case WP_DEMP2:
  417. case WP_FLECHETTE:
  418. case WP_ROCKET_LAUNCHER:
  419. case WP_CONCUSSION:
  420. default:
  421. break;
  422. case WP_THERMAL:
  423. case WP_BLASTER:
  424. //FIXME: health in NPCs.cfg, and not all blaster users are stormtroopers
  425. //ent->health = 25;
  426. //FIXME: not necc. a ST
  427. ST_ClearTimers( ent );
  428. if ( ent->NPC->rank >= RANK_LT || ent->client->ps.weapon == WP_THERMAL )
  429. {//officers, grenade-throwers use alt-fire
  430. //ent->health = 50;
  431. //ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  432. }
  433. break;
  434. }
  435. }
  436. if ( ent->client->NPC_class == CLASS_PLAYER
  437. || ent->client->NPC_class == CLASS_VEHICLE
  438. || (ent->spawnflags & SFB_CINEMATIC) )
  439. {
  440. ent->NPC->defaultBehavior = BS_CINEMATIC;
  441. }
  442. else
  443. {
  444. ent->NPC->defaultBehavior = BS_FOLLOW_LEADER;
  445. ent->client->leader = &g_entities[0];//player
  446. }
  447. break;
  448. case TEAM_NEUTRAL:
  449. if ( Q_stricmp( ent->NPC_type, "gonk" ) == 0 )
  450. {
  451. // I guess we generically make them player usable
  452. ent->svFlags |= SVF_PLAYER_USABLE;
  453. // Not even sure if we want to give different levels of batteries? ...Or even that these are the values we'd want to use.
  454. switch ( g_spskill->integer )
  455. {
  456. case 0: // EASY
  457. ent->client->ps.batteryCharge = MAX_BATTERIES * 0.8f;
  458. break;
  459. case 1: // MEDIUM
  460. ent->client->ps.batteryCharge = MAX_BATTERIES * 0.75f;
  461. break;
  462. default :
  463. case 2: // HARD
  464. ent->client->ps.batteryCharge = MAX_BATTERIES * 0.5f;
  465. break;
  466. }
  467. }
  468. break;
  469. case TEAM_ENEMY:
  470. {
  471. ent->NPC->defaultBehavior = BS_DEFAULT;
  472. if ( ent->client->NPC_class == CLASS_SHADOWTROOPER
  473. && Q_stricmpn("shadowtrooper", ent->NPC_type, 13 ) == 0 )
  474. {//FIXME: a spawnflag?
  475. Jedi_Cloak( ent );
  476. }
  477. if( ent->client->NPC_class == CLASS_TAVION ||
  478. ent->client->NPC_class == CLASS_ALORA ||
  479. (ent->client->NPC_class == CLASS_REBORN && ent->client->ps.weapon == WP_SABER) ||
  480. ent->client->NPC_class == CLASS_DESANN ||
  481. ent->client->NPC_class == CLASS_SHADOWTROOPER )
  482. {
  483. ent->client->enemyTeam = TEAM_PLAYER;
  484. if ( ent->spawnflags & JSF_AMBUSH )
  485. {//ambusher
  486. ent->NPC->scriptFlags |= SCF_IGNORE_ALERTS;
  487. ent->client->noclip = true;//hang
  488. }
  489. }
  490. else if( ent->client->NPC_class == CLASS_PROBE || ent->client->NPC_class == CLASS_REMOTE ||
  491. ent->client->NPC_class == CLASS_INTERROGATOR || ent->client->NPC_class == CLASS_SENTRY)
  492. {
  493. ent->NPC->defaultBehavior = BS_DEFAULT;
  494. ent->client->ps.gravity = 0;
  495. ent->svFlags |= SVF_CUSTOM_GRAVITY;
  496. ent->client->moveType = MT_FLYSWIM;
  497. }
  498. else
  499. {
  500. if ( ent->client->ps.weapon != WP_NONE
  501. && ent->client->ps.weapon != WP_SABER//sabers done above
  502. && (!(ent->NPC->aiFlags&NPCAI_MATCHPLAYERWEAPON)||!ent->weaponModel[0]) )//they do this themselves
  503. {
  504. G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl, ent->handRBolt, 0 );
  505. }
  506. switch ( ent->client->ps.weapon )
  507. {
  508. case WP_BRYAR_PISTOL:
  509. break;
  510. case WP_BLASTER_PISTOL:
  511. NPCInfo->scriptFlags |= SCF_PILOT;
  512. if ( ent->client->NPC_class == CLASS_REBORN
  513. && ent->NPC->rank >= RANK_LT_COMM
  514. && (!(ent->NPC->aiFlags&NPCAI_MATCHPLAYERWEAPON)||!ent->weaponModel[0]) )//they do this themselves
  515. {//dual blaster pistols, so add the left-hand one, too
  516. G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl, ent->handLBolt, 1 );
  517. }
  518. break;
  519. case WP_DISRUPTOR:
  520. //Sniper
  521. //ent->NPC->scriptFlags |= SCF_ALT_FIRE;//FIXME: use primary fire sometimes? Up close? Different class of NPC?
  522. break;
  523. case WP_BOWCASTER:
  524. NPCInfo->scriptFlags |= SCF_PILOT;
  525. break;
  526. case WP_REPEATER:
  527. NPCInfo->scriptFlags |= SCF_PILOT;
  528. //machine-gunner
  529. break;
  530. case WP_DEMP2:
  531. break;
  532. case WP_FLECHETTE:
  533. NPCInfo->scriptFlags |= SCF_PILOT;
  534. //shotgunner
  535. if ( !Q_stricmp( "stofficeralt", ent->NPC_type ) )
  536. {
  537. //ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  538. }
  539. break;
  540. case WP_ROCKET_LAUNCHER:
  541. break;
  542. case WP_CONCUSSION:
  543. break;
  544. case WP_THERMAL:
  545. //Gran, use main, bouncy fire
  546. // ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  547. break;
  548. case WP_MELEE:
  549. break;
  550. case WP_NOGHRI_STICK:
  551. break;
  552. default:
  553. case WP_BLASTER:
  554. //FIXME: health in NPCs.cfg, and not all blaster users are stormtroopers
  555. //FIXME: not necc. a ST
  556. NPCInfo->scriptFlags |= SCF_PILOT;
  557. ST_ClearTimers( ent );
  558. if ( ent->NPC->rank >= RANK_COMMANDER )
  559. {//commanders use alt-fire
  560. //ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  561. }
  562. if ( !Q_stricmp( "rodian2", ent->NPC_type ) )
  563. {
  564. //ent->NPC->scriptFlags |= SCF_ALT_FIRE;
  565. }
  566. break;
  567. }
  568. }
  569. }
  570. break;
  571. default:
  572. ent->NPC->defaultBehavior = BS_DEFAULT;
  573. if ( ent->client->ps.weapon != WP_NONE
  574. && ent->client->ps.weapon != WP_MELEE
  575. && ent->client->ps.weapon != WP_SABER//sabers done above
  576. && (!(ent->NPC->aiFlags&NPCAI_MATCHPLAYERWEAPON)||!ent->weaponModel[0]) )//they do this themselves
  577. {
  578. G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl, ent->handRBolt, 0 );
  579. }
  580. break;
  581. }
  582. if ( ent->client->NPC_class == CLASS_ATST || ent->client->NPC_class == CLASS_MARK1 ) // chris/steve/kevin requested that the mark1 be shielded also
  583. {
  584. ent->flags |= (FL_SHIELDED|FL_NO_KNOCKBACK);
  585. }
  586. // Set CAN FLY Flag for Navigation On The Following Classes
  587. //----------------------------------------------------------
  588. if (ent->client->NPC_class==CLASS_PROBE ||
  589. ent->client->NPC_class==CLASS_REMOTE ||
  590. ent->client->NPC_class==CLASS_SEEKER ||
  591. ent->client->NPC_class==CLASS_SENTRY ||
  592. ent->client->NPC_class==CLASS_GLIDER ||
  593. ent->client->NPC_class==CLASS_IMPWORKER ||
  594. ent->client->NPC_class==CLASS_BOBAFETT ||
  595. ent->client->NPC_class==CLASS_ROCKETTROOPER
  596. )
  597. {
  598. ent->NPC->scriptFlags |= SCF_NAV_CAN_FLY;
  599. }
  600. if (ent->client->NPC_class==CLASS_VEHICLE)
  601. {
  602. Vehicle_Register(ent);
  603. }
  604. if ( ent->client->ps.stats[STAT_WEAPONS]&(1<<WP_SCEPTER) )
  605. {
  606. if ( !ent->weaponModel[1] )
  607. {//we have the scepter, so put it in our left hand if we don't already have a second weapon
  608. G_CreateG2AttachedWeaponModel( ent, weaponData[WP_SCEPTER].weaponMdl, ent->handLBolt, 1 );
  609. }
  610. ent->genericBolt1 = gi.G2API_AddBolt(&ent->ghoul2[ent->weaponModel[1]], "*flash");
  611. }
  612. if ( ent->client->ps.saber[0].type == SABER_SITH_SWORD )
  613. {
  614. ent->genericBolt1 = gi.G2API_AddBolt(&ent->ghoul2[ent->weaponModel[0]], "*flash");
  615. G_PlayEffect( G_EffectIndex( "scepter/sword.efx" ), ent->weaponModel[0], ent->genericBolt1, ent->s.number, ent->currentOrigin, qtrue, qtrue );
  616. //how many times can she recharge?
  617. ent->count = g_spskill->integer*2;
  618. //To make sure she can do it at least once
  619. ent->flags |= FL_UNDYING;
  620. }
  621. if ( ent->client->ps.weapon == WP_NOGHRI_STICK
  622. && ent->weaponModel[0] )
  623. {
  624. ent->genericBolt1 = gi.G2API_AddBolt(&ent->ghoul2[ent->weaponModel[0]], "*flash");
  625. }
  626. G_ClassSetDontFlee( ent );
  627. }
  628. /*
  629. -------------------------
  630. NPC_WeaponsForTeam
  631. -------------------------
  632. */
  633. int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type )
  634. {
  635. //*** not sure how to handle this, should I pass in class instead of team and go from there? - dmv
  636. switch(team)
  637. {
  638. // no longer exists
  639. // case TEAM_BORG:
  640. // break;
  641. // case TEAM_HIROGEN:
  642. // if( Q_stricmp( "hirogenalpha", NPC_type ) == 0 )
  643. // return ( 1 << WP_BLASTER);
  644. //Falls through
  645. // case TEAM_KLINGON:
  646. //NOTENOTE: Falls through
  647. // case TEAM_IMPERIAL:
  648. case TEAM_ENEMY:
  649. if ( Q_stricmp( "tavion", NPC_type ) == 0 ||
  650. Q_stricmpn( "reborn", NPC_type, 6 ) == 0 ||
  651. Q_stricmp( "desann", NPC_type ) == 0 ||
  652. Q_stricmpn( "shadowtrooper", NPC_type, 13 ) == 0 )
  653. return ( 1 << WP_SABER);
  654. // return ( 1 << WP_IMPERIAL_BLADE);
  655. //NOTENOTE: Falls through if not a knife user
  656. // case TEAM_SCAVENGERS:
  657. // case TEAM_MALON:
  658. //FIXME: default weapon in npc config?
  659. if ( Q_stricmpn( "stofficer", NPC_type, 9 ) == 0 )
  660. {
  661. return ( 1 << WP_FLECHETTE);
  662. }
  663. if ( Q_stricmp( "stcommander", NPC_type ) == 0 )
  664. {
  665. return ( 1 << WP_REPEATER);
  666. }
  667. if ( Q_stricmp( "swamptrooper", NPC_type ) == 0 )
  668. {
  669. return ( 1 << WP_FLECHETTE);
  670. }
  671. if ( Q_stricmp( "swamptrooper2", NPC_type ) == 0 )
  672. {
  673. return ( 1 << WP_REPEATER);
  674. }
  675. if ( Q_stricmp( "rockettrooper", NPC_type ) == 0 )
  676. {
  677. return ( 1 << WP_ROCKET_LAUNCHER);
  678. }
  679. if ( Q_stricmpn( "shadowtrooper", NPC_type, 13 ) == 0 )
  680. {
  681. return ( 1 << WP_SABER);//|( 1 << WP_RAPID_CONCUSSION)?
  682. }
  683. if ( Q_stricmp( "imperial", NPC_type ) == 0 )
  684. {
  685. return ( 1 << WP_BLASTER_PISTOL);
  686. }
  687. if ( Q_stricmpn( "impworker", NPC_type, 9 ) == 0 )
  688. {
  689. return ( 1 << WP_BLASTER_PISTOL);
  690. }
  691. if ( Q_stricmp( "stormpilot", NPC_type ) == 0 )
  692. {
  693. return ( 1 << WP_BLASTER_PISTOL);
  694. }
  695. if ( Q_stricmp( "galak", NPC_type ) == 0 )
  696. {
  697. return ( 1 << WP_BLASTER);
  698. }
  699. if ( Q_stricmp( "galak_mech", NPC_type ) == 0 )
  700. {
  701. return ( 1 << WP_REPEATER);
  702. }
  703. if ( Q_stricmpn( "ugnaught", NPC_type, 8 ) == 0 )
  704. {
  705. return WP_NONE;
  706. }
  707. if ( Q_stricmp( "granshooter", NPC_type ) == 0 )
  708. {
  709. return ( 1 << WP_BLASTER);
  710. }
  711. if ( Q_stricmp( "granboxer", NPC_type ) == 0 )
  712. {
  713. return ( 1 << WP_MELEE);
  714. }
  715. if ( Q_stricmpn( "gran", NPC_type, 4 ) == 0 )
  716. {
  717. return (( 1 << WP_THERMAL)|( 1 << WP_MELEE));
  718. }
  719. if ( Q_stricmp( "rodian", NPC_type ) == 0 )
  720. {
  721. return ( 1 << WP_DISRUPTOR);
  722. }
  723. if ( Q_stricmp( "rodian2", NPC_type ) == 0 )
  724. {
  725. return ( 1 << WP_BLASTER);
  726. }
  727. if (( Q_stricmp( "interrogator",NPC_type) == 0) || ( Q_stricmp( "sentry",NPC_type) == 0) || (Q_stricmpn( "protocol",NPC_type,8) == 0) )
  728. {
  729. return WP_NONE;
  730. }
  731. if ( Q_stricmpn( "weequay", NPC_type, 7 ) == 0 )
  732. {
  733. return ( 1 << WP_BOWCASTER);//|( 1 << WP_STAFF )(FIXME: new weap?)
  734. }
  735. if ( Q_stricmp( "impofficer", NPC_type ) == 0 )
  736. {
  737. return ( 1 << WP_BLASTER);
  738. }
  739. if ( Q_stricmp( "impcommander", NPC_type ) == 0 )
  740. {
  741. return ( 1 << WP_BLASTER);
  742. }
  743. if (( Q_stricmp( "probe", NPC_type ) == 0 ) || ( Q_stricmp( "seeker", NPC_type ) == 0 ))
  744. {
  745. return ( 1 << WP_BOT_LASER);
  746. }
  747. if ( Q_stricmpn( "remote", NPC_type, 6 ) == 0 )
  748. {
  749. return ( 1 << WP_BOT_LASER );
  750. }
  751. if ( Q_stricmp( "trandoshan", NPC_type ) == 0 )
  752. {
  753. return (1<<WP_REPEATER);
  754. }
  755. if ( Q_stricmp( "atst", NPC_type ) == 0 )
  756. {
  757. return (( 1 << WP_ATST_MAIN)|( 1 << WP_ATST_SIDE));
  758. }
  759. if ( Q_stricmp( "mark1", NPC_type ) == 0 )
  760. {
  761. return ( 1 << WP_BOT_LASER);
  762. }
  763. if ( Q_stricmp( "mark2", NPC_type ) == 0 )
  764. {
  765. return ( 1 << WP_BOT_LASER);
  766. }
  767. if ( Q_stricmp( "minemonster", NPC_type ) == 0 )
  768. {
  769. return (( 1 << WP_MELEE));
  770. }
  771. if ( Q_stricmp( "howler", NPC_type ) == 0 )
  772. {
  773. return (( 1 << WP_MELEE));
  774. }
  775. //Stormtroopers, etc.
  776. return ( 1 << WP_BLASTER);
  777. break;
  778. case TEAM_PLAYER:
  779. // if(spawnflags & SFB_TRICORDER)
  780. // return ( 1 << WP_TRICORDER);
  781. if(spawnflags & SFB_RIFLEMAN)
  782. return ( 1 << WP_REPEATER);
  783. if(spawnflags & SFB_PHASER)
  784. return ( 1 << WP_BLASTER_PISTOL);
  785. if ( Q_stricmpn( "jedi", NPC_type, 4 ) == 0 || Q_stricmp( "luke", NPC_type ) == 0 )
  786. return ( 1 << WP_SABER);
  787. if ( Q_stricmpn( "prisoner", NPC_type, 8 ) == 0
  788. || Q_stricmpn( "elder", NPC_type, 5 ) == 0 )
  789. {
  790. return WP_NONE;
  791. }
  792. if ( Q_stricmpn( "bespincop", NPC_type, 9 ) == 0 )
  793. {
  794. return ( 1 << WP_BLASTER_PISTOL);
  795. }
  796. if ( Q_stricmp( "MonMothma", NPC_type ) == 0 )
  797. {
  798. return WP_NONE;
  799. }
  800. //rebel
  801. return ( 1 << WP_BLASTER);
  802. break;
  803. case TEAM_NEUTRAL:
  804. if ( Q_stricmp( "mark1", NPC_type ) == 0 )
  805. {
  806. return WP_NONE;
  807. }
  808. if ( Q_stricmp( "mark2", NPC_type ) == 0 )
  809. {
  810. return WP_NONE;
  811. }
  812. if ( Q_stricmpn( "ugnaught", NPC_type, 8 ) == 0 )
  813. {
  814. return WP_NONE;
  815. }
  816. if ( Q_stricmp( "bartender", NPC_type ) == 0 )
  817. {
  818. return WP_NONE;
  819. }
  820. if ( Q_stricmp( "morgankatarn", NPC_type ) == 0 )
  821. {
  822. return WP_NONE;
  823. }
  824. break;
  825. // these no longer exist
  826. // case TEAM_FORGE:
  827. // return ( 1 << WP_MELEE);
  828. // break;
  829. // case TEAM_STASIS:
  830. // return ( 1 << WP_MELEE);
  831. // break;
  832. // case TEAM_PARASITE:
  833. // break;
  834. // case TEAM_8472:
  835. // break;
  836. default:
  837. break;
  838. }
  839. return WP_NONE;
  840. }
  841. extern void ChangeWeapon( gentity_t *ent, int newWeapon );
  842. /*
  843. -------------------------
  844. NPC_SetWeapons
  845. -------------------------
  846. */
  847. void NPC_SetWeapons( gentity_t *ent )
  848. {
  849. int bestWeap = WP_NONE;
  850. int weapons = NPC_WeaponsForTeam( ent->client->playerTeam, ent->spawnflags, ent->NPC_type );
  851. ent->client->ps.stats[STAT_WEAPONS] = 0;
  852. for ( int curWeap = WP_SABER; curWeap < WP_NUM_WEAPONS; curWeap++ )
  853. {
  854. if ( (weapons & ( 1 << curWeap )) )
  855. {
  856. ent->client->ps.stats[STAT_WEAPONS] |= ( 1 << curWeap );
  857. RegisterItem( FindItemForWeapon( (weapon_t)(curWeap) ) ); //precache the weapon
  858. ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[curWeap].ammoIndex] = 100;//FIXME: max ammo
  859. if ( bestWeap == WP_SABER )
  860. {
  861. // still want to register other weapons -- force saber to be best weap
  862. continue;
  863. }
  864. if ( curWeap == WP_MELEE )
  865. {
  866. if ( bestWeap == WP_NONE )
  867. {// We'll only consider giving Melee since we haven't found anything better yet.
  868. bestWeap = curWeap;
  869. }
  870. }
  871. else if ( curWeap > bestWeap || bestWeap == WP_MELEE )
  872. {
  873. // This will never override saber as best weap. Also will override WP_MELEE if something better comes later in the list
  874. bestWeap = curWeap;
  875. }
  876. }
  877. }
  878. ent->client->ps.weapon = bestWeap;
  879. }
  880. /*
  881. -------------------------
  882. NPC_SpawnEffect
  883. NOTE: Make sure any effects called here have their models, tga's and sounds precached in
  884. CG_RegisterNPCEffects in cg_player.cpp
  885. -------------------------
  886. */
  887. static void NPC_SpawnEffect (gentity_t *ent)
  888. {
  889. }
  890. //--------------------------------------------------------------
  891. // NPC_SetFX_SpawnStates
  892. //
  893. // Set up any special parms for spawn effects
  894. //--------------------------------------------------------------
  895. void NPC_SetFX_SpawnStates( gentity_t *ent )
  896. {
  897. ent->client->ps.gravity = g_gravity->value;
  898. }
  899. //--------------------------------------------------------------
  900. extern qboolean stop_icarus;
  901. void NPC_Begin (gentity_t *ent)
  902. {
  903. vec3_t spawn_origin, spawn_angles;
  904. gclient_t *client;
  905. usercmd_t ucmd;
  906. gentity_t *spawnPoint = NULL;
  907. memset( &ucmd, 0, sizeof( ucmd ) );
  908. if ( !(ent->spawnflags & SFB_NOTSOLID) )
  909. {//No NPCs should telefrag
  910. if ( Q_stricmp( ent->NPC_type, "nullDriver") == 0 )
  911. {//FIXME: should be a better way to check this
  912. }
  913. else if( SpotWouldTelefrag( ent, TEAM_FREE ) )//(team_t)(ent->client->playerTeam)
  914. {
  915. if ( ent->wait < 0 )
  916. {//remove yourself
  917. Quake3Game()->DebugPrint( IGameInterface::WL_ERROR, "NPC %s could not spawn, firing target3 (%s) and removing self\n", ent->targetname, ent->target3 );
  918. //Fire off our target3
  919. G_UseTargets2( ent, ent, ent->target3 );
  920. //Kill us
  921. ent->e_ThinkFunc = thinkF_G_FreeEntity;
  922. ent->nextthink = level.time + 100;
  923. }
  924. else
  925. {
  926. Quake3Game()->DebugPrint( IGameInterface::WL_ERROR, "NPC %s at (%5.0f %5.0f %5.0f) couldn't spawn, waiting %4.2f secs to try again\n",
  927. ent->targetname, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2], ent->wait/1000.0f );
  928. ent->e_ThinkFunc = thinkF_NPC_Begin;
  929. ent->nextthink = level.time + ent->wait;//try again in half a second
  930. }
  931. return;
  932. }
  933. }
  934. //Spawn effect
  935. NPC_SpawnEffect( ent );
  936. VectorCopy( ent->client->ps.origin, spawn_origin);
  937. VectorCopy( ent->s.angles, spawn_angles);
  938. spawn_angles[YAW] = ent->NPC->desiredYaw;
  939. client = ent->client;
  940. // increment the spawncount so the client will detect the respawn
  941. client->ps.persistant[PERS_SPAWN_COUNT]++;
  942. client->airOutTime = level.time + 12000;
  943. client->ps.clientNum = ent->s.number;
  944. // clear entity values
  945. if ( ent->health ) // Was health supplied in map
  946. {
  947. ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->health;
  948. }
  949. else if ( ent->NPC->stats.health ) // Was health supplied in NPC.cfg?
  950. {
  951. if ( ent->client->NPC_class != CLASS_REBORN
  952. && ent->client->NPC_class != CLASS_SHADOWTROOPER
  953. //&& ent->client->NPC_class != CLASS_TAVION
  954. //&& ent->client->NPC_class != CLASS_DESANN
  955. && ent->client->NPC_class != CLASS_JEDI )
  956. {// up everyone except jedi
  957. if ( !Q_stricmp("tavion_sith_sword", ent->NPC_type )
  958. || !Q_stricmp("tavion_scepter", ent->NPC_type )
  959. || !Q_stricmp("kyle_boss", ent->NPC_type )
  960. || !Q_stricmp("alora_dual", ent->NPC_type )
  961. || !Q_stricmp("alora_boss", ent->NPC_type ) )
  962. {//bosses are a bit different
  963. ent->NPC->stats.health = ceil((float)ent->NPC->stats.health*0.75f + ((float)ent->NPC->stats.health/4.0f*g_spskill->value)); // 75% on easy, 100% on medium, 125% on hard
  964. }
  965. else
  966. {
  967. ent->NPC->stats.health += ent->NPC->stats.health/4 * g_spskill->integer; // 100% on easy, 125% on medium, 150% on hard
  968. }
  969. }
  970. ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->NPC->stats.health;
  971. }
  972. else
  973. {
  974. ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = 100;
  975. }
  976. if ( !Q_stricmp( "rodian", ent->NPC_type ) )
  977. {//sniper
  978. //NOTE: this will get overridden by any aim settings in their spawnscripts
  979. switch ( g_spskill->integer )
  980. {
  981. case 0:
  982. ent->NPC->stats.aim = 1;
  983. break;
  984. case 1:
  985. ent->NPC->stats.aim = Q_irand( 2, 3 );
  986. break;
  987. case 2:
  988. ent->NPC->stats.aim = Q_irand( 3, 4 );
  989. break;
  990. }
  991. }
  992. else if ( ent->client->NPC_class == CLASS_STORMTROOPER
  993. || ent->client->NPC_class == CLASS_SWAMPTROOPER
  994. || ent->client->NPC_class == CLASS_IMPWORKER
  995. || !Q_stricmp( "rodian2", ent->NPC_type ) )
  996. {//tweak yawspeed for these NPCs based on difficulty
  997. switch ( g_spskill->integer )
  998. {
  999. case 0:
  1000. ent->NPC->stats.yawSpeed *= 0.75f;
  1001. if ( ent->client->NPC_class == CLASS_IMPWORKER )
  1002. {
  1003. ent->NPC->stats.aim -= Q_irand( 3, 6 );
  1004. }
  1005. break;
  1006. case 1:
  1007. if ( ent->client->NPC_class == CLASS_IMPWORKER )
  1008. {
  1009. ent->NPC->stats.aim -= Q_irand( 2, 4 );
  1010. }
  1011. break;
  1012. case 2:
  1013. ent->NPC->stats.yawSpeed *= 1.5f;
  1014. if ( ent->client->NPC_class == CLASS_IMPWORKER )
  1015. {
  1016. ent->NPC->stats.aim -= Q_irand( 0, 2 );
  1017. }
  1018. break;
  1019. }
  1020. }
  1021. else if ( ent->client->NPC_class == CLASS_REBORN
  1022. || ent->client->NPC_class == CLASS_SHADOWTROOPER )
  1023. {
  1024. switch ( g_spskill->integer )
  1025. {
  1026. case 1:
  1027. ent->NPC->stats.yawSpeed *= 1.25f;
  1028. break;
  1029. case 2:
  1030. ent->NPC->stats.yawSpeed *= 1.5f;
  1031. break;
  1032. }
  1033. }
  1034. ent->s.groundEntityNum = ENTITYNUM_NONE;
  1035. ent->mass = 10;
  1036. ent->takedamage = qtrue;
  1037. /*ent->inuse = qtrue;
  1038. SetInUse(ent);
  1039. ent->m_iIcarusID = -1; // ICARUS_INVALID
  1040. */
  1041. assert(ent->inuse);
  1042. assert(ent->m_iIcarusID==IIcarusInterface::ICARUS_INVALID);
  1043. // CRITICAL NOTE! This was already done somewhere else and it was overwriting the previous value!!!
  1044. if ( !ent->classname || Q_stricmp( ent->classname, "noclass" ) == 0 )
  1045. ent->classname = "NPC";
  1046. // if ( ent->client->race == RACE_HOLOGRAM )
  1047. // {//can shoot through holograms, but not walk through them
  1048. // ent->contents = CONTENTS_PLAYERCLIP|CONTENTS_MONSTERCLIP|CONTENTS_ITEM;//contents_corspe to make them show up in ID and use traces
  1049. // ent->clipmask = MASK_NPCSOLID;
  1050. // } else
  1051. if(!(ent->spawnflags & SFB_NOTSOLID))
  1052. {
  1053. ent->contents = CONTENTS_BODY;
  1054. ent->clipmask = MASK_NPCSOLID;
  1055. }
  1056. else
  1057. {
  1058. ent->contents = 0;
  1059. ent->clipmask = MASK_NPCSOLID&~CONTENTS_BODY;
  1060. }
  1061. if(!ent->client->moveType)//Static?
  1062. {
  1063. ent->client->moveType = MT_RUNJUMP;
  1064. }
  1065. ent->e_DieFunc = dieF_player_die;
  1066. ent->waterlevel = 0;
  1067. ent->watertype = 0;
  1068. //visible to player and NPCs
  1069. if ( ent->client->NPC_class != CLASS_R2D2 &&
  1070. ent->client->NPC_class != CLASS_R5D2 &&
  1071. ent->client->NPC_class != CLASS_MOUSE &&
  1072. ent->client->NPC_class != CLASS_GONK &&
  1073. ent->client->NPC_class != CLASS_PROTOCOL )
  1074. {
  1075. ent->flags &= ~FL_NOTARGET;
  1076. }
  1077. ent->s.eFlags &= ~EF_NODRAW;
  1078. NPC_SetFX_SpawnStates( ent );
  1079. client->ps.friction = 6;
  1080. if ( ent->client->ps.weapon == WP_NONE )
  1081. {//not set by the NPCs.cfg
  1082. NPC_SetWeapons(ent);
  1083. }
  1084. //select the weapon
  1085. ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[ent->client->ps.weapon].ammoIndex];
  1086. ent->client->ps.weaponstate = WEAPON_IDLE;
  1087. ChangeWeapon( ent, ent->client->ps.weapon );
  1088. VectorCopy( spawn_origin, client->ps.origin );
  1089. // the respawned flag will be cleared after the attack and jump keys come up
  1090. client->ps.pm_flags |= PMF_RESPAWNED;
  1091. // clear entity state values
  1092. ent->s.eType = ET_PLAYER;
  1093. // ent->s.skinNum = ent - g_entities - 1; // used as index to get custom models
  1094. VectorCopy (spawn_origin, ent->s.origin);
  1095. // ent->s.origin[2] += 1; // make sure off ground
  1096. SetClientViewAngle( ent, spawn_angles );
  1097. client->renderInfo.lookTarget = ENTITYNUM_NONE;
  1098. //clear IK grabbing stuff
  1099. client->ps.heldClient = client->ps.heldByClient = ENTITYNUM_NONE;
  1100. if(!(ent->spawnflags & 64))
  1101. {
  1102. if ( Q_stricmp( ent->NPC_type, "nullDriver") == 0 )
  1103. {//FIXME: should be a better way to check this
  1104. }
  1105. else
  1106. {
  1107. G_KillBox( ent );
  1108. }
  1109. gi.linkentity (ent);
  1110. }
  1111. // don't allow full run speed for a bit
  1112. client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
  1113. client->ps.pm_time = 100;
  1114. client->respawnTime = level.time;
  1115. client->latched_buttons = 0;
  1116. if ( ent->client->NPC_class != CLASS_VEHICLE )
  1117. {
  1118. // set default animations
  1119. NPC_SetAnim( ent, SETANIM_BOTH, BOTH_STAND1, SETANIM_FLAG_NORMAL );
  1120. }
  1121. if( spawnPoint )
  1122. {
  1123. // fire the targets of the spawn point
  1124. G_UseTargets( spawnPoint, ent );
  1125. }
  1126. //ICARUS include
  1127. // NOTE! Does this need to be called here? It seems to be getting called twice...
  1128. // Once before the level starts, then once again when the entity is spawned!
  1129. Quake3Game()->InitEntity( ent );
  1130. //==NPC initialization
  1131. SetNPCGlobals( ent );
  1132. ent->enemy = NPCInfo->eventualGoal;
  1133. NPCInfo->timeOfDeath = 0;
  1134. NPCInfo->shotTime = 0;
  1135. NPC_ClearGoal();
  1136. NPC_ChangeWeapon( ent->client->ps.weapon );
  1137. //==Final NPC initialization
  1138. ent->e_PainFunc = NPC_PainFunc( ent ); //painF_NPC_Pain;
  1139. ent->e_TouchFunc = NPC_TouchFunc( ent ); //touchF_NPC_Touch;
  1140. // ent->NPC->side = 1;
  1141. ent->client->ps.ping = ent->NPC->stats.reactions * 50;
  1142. //MCG - Begin: NPC hacks
  1143. //FIXME: Set the team correctly
  1144. ent->client->ps.persistant[PERS_TEAM] = ent->client->playerTeam;
  1145. ent->e_UseFunc = useF_NPC_Use;
  1146. ent->e_ThinkFunc = thinkF_NPC_Think;
  1147. ent->nextthink = level.time + FRAMETIME + Q_irand(0, 100);
  1148. NPC_SetMiscDefaultData( ent );
  1149. if ( ent->health <= 0 )
  1150. {
  1151. //ORIGINAL ID: health will count down towards max_health
  1152. ent->health = client->ps.stats[STAT_HEALTH] = ent->max_health;
  1153. }
  1154. else
  1155. {
  1156. client->ps.stats[STAT_HEALTH] = ent->max_health = ent->health;
  1157. }
  1158. ChangeWeapon( ent, ent->client->ps.weapon );//yes, again... sigh
  1159. if ( !(ent->spawnflags & SFB_STARTINSOLID) )
  1160. {//Not okay to start in solid
  1161. G_CheckInSolid( ent, qtrue );
  1162. }
  1163. VectorClear( ent->NPC->lastClearOrigin );
  1164. //Run a script if you have one assigned to you
  1165. if ( G_ActivateBehavior( ent, BSET_SPAWN ) )
  1166. {
  1167. if( ent->m_iIcarusID != IIcarusInterface::ICARUS_INVALID/*ent->taskManager*/ && !stop_icarus )
  1168. {
  1169. IIcarusInterface::GetIcarus()->Update( ent->m_iIcarusID );
  1170. }
  1171. }
  1172. VectorCopy( ent->currentOrigin, ent->client->renderInfo.eyePoint );
  1173. // run a client frame to drop exactly to the floor,
  1174. // initialize animations and other things
  1175. memset( &ucmd, 0, sizeof( ucmd ) );
  1176. _VectorCopy( client->pers.cmd_angles, ucmd.angles );
  1177. ent->client->ps.groundEntityNum = ENTITYNUM_NONE;
  1178. if ( ent->NPC->aiFlags & NPCAI_MATCHPLAYERWEAPON )
  1179. {
  1180. G_MatchPlayerWeapon( ent );
  1181. }
  1182. ClientThink( ent->s.number, &ucmd );
  1183. gi.linkentity( ent );
  1184. if ( ent->client->playerTeam == TEAM_ENEMY || ent->client->playerTeam == TEAM_FREE )
  1185. {//valid enemy spawned
  1186. if ( !(ent->spawnflags&SFB_CINEMATIC) && ent->NPC->behaviorState != BS_CINEMATIC )
  1187. {//not a cinematic enemy
  1188. if ( g_entities[0].client )
  1189. {
  1190. g_entities[0].client->sess.missionStats.enemiesSpawned++;
  1191. }
  1192. }
  1193. }
  1194. }
  1195. /*
  1196. -------------------------
  1197. NPC_StasisSpawn_Go
  1198. -------------------------
  1199. */
  1200. /*
  1201. qboolean NPC_StasisSpawn_Go( gentity_t *ent )
  1202. {
  1203. //Setup an owner pointer if we need it
  1204. if VALIDSTRING( ent->ownername )
  1205. {
  1206. ent->owner = G_Find( NULL, FOFS( targetname ), ent->ownername );
  1207. if ( ( ent->owner ) && ( ent->owner->health <= 0 ) )
  1208. {//our spawner thing is broken
  1209. if ( ent->target2 && ent->target2[0] )
  1210. {
  1211. //Fire off our target2
  1212. G_UseTargets2( ent, ent, ent->target2 );
  1213. //Kill us
  1214. ent->e_ThinkFunc = thinkF_G_FreeEntity;
  1215. ent->nextthink = level.time + 100;
  1216. }
  1217. else
  1218. {
  1219. //Try to spawn again in one second
  1220. ent->e_ThinkFunc = thinkF_NPC_Spawn_Go;
  1221. ent->nextthink = level.time + 1000;
  1222. }
  1223. return qfalse;
  1224. }
  1225. }
  1226. //Test for an entity blocking the spawn
  1227. trace_t tr;
  1228. gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, ent->currentOrigin, ent->s.number, MASK_NPCSOLID );
  1229. //Can't have anything in the way
  1230. if ( tr.allsolid || tr.startsolid )
  1231. {
  1232. ent->nextthink = level.time + 1000;
  1233. return qfalse;
  1234. }
  1235. return qtrue;
  1236. }
  1237. */
  1238. void NPC_DefaultScriptFlags( gentity_t *ent )
  1239. {
  1240. if ( !ent || !ent->NPC )
  1241. {
  1242. return;
  1243. }
  1244. //Set up default script flags
  1245. ent->NPC->scriptFlags = (SCF_CHASE_ENEMIES|SCF_LOOK_FOR_ENEMIES);
  1246. }
  1247. #define MAX_SAFESPAWN_ENTS 4
  1248. bool NPC_SafeSpawn( gentity_t *ent, float safeRadius )
  1249. {
  1250. gentity_t *radiusEnts[ MAX_SAFESPAWN_ENTS ];
  1251. vec3_t safeMins, safeMaxs;
  1252. float distance = 999999;
  1253. int numEnts = 0;
  1254. float safeRadiusSquared = safeRadius*safeRadius;
  1255. if (!ent)
  1256. {
  1257. return false;
  1258. }
  1259. //Setup the bbox to search in
  1260. for ( int i = 0; i < 3; i++ )
  1261. {
  1262. safeMins[i] = ent->currentOrigin[i] - safeRadius;
  1263. safeMaxs[i] = ent->currentOrigin[i] + safeRadius;
  1264. }
  1265. //Get a number of entities in a given space
  1266. numEnts = gi.EntitiesInBox( safeMins, safeMaxs, radiusEnts, MAX_SAFESPAWN_ENTS );
  1267. for ( i = 0; i < numEnts; i++ )
  1268. {
  1269. //Don't consider self
  1270. if ( radiusEnts[i] == ent )
  1271. continue;
  1272. if (radiusEnts[i]->NPC && (radiusEnts[i]->health == 0))
  1273. {
  1274. // ignore dead guys
  1275. continue;
  1276. }
  1277. distance = DistanceSquared( ent->currentOrigin, radiusEnts[i]->currentOrigin );
  1278. //Found one too close to us
  1279. if ( distance < safeRadiusSquared )
  1280. {
  1281. return false;
  1282. }
  1283. }
  1284. return true;
  1285. }
  1286. /*
  1287. -------------------------
  1288. NPC_Spawn_Go
  1289. -------------------------
  1290. */
  1291. gentity_t *NPC_Spawn_Do( gentity_t *ent, qboolean fullSpawnNow )
  1292. {
  1293. gentity_t *newent;
  1294. int index;
  1295. vec3_t saveOrg;
  1296. /* //Do extra code for stasis spawners
  1297. if ( Q_stricmp( ent->classname, "NPC_Stasis" ) == 0 )
  1298. {
  1299. if ( NPC_StasisSpawn_Go( ent ) == qfalse )
  1300. return;
  1301. }
  1302. */
  1303. // 4/18/03 kef -- don't let guys spawn into other guys
  1304. if (ent->spawnflags & 4096)
  1305. {
  1306. if (!NPC_SafeSpawn(ent, 64))
  1307. {
  1308. return NULL;
  1309. }
  1310. }
  1311. //Test for drop to floor
  1312. if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1313. {
  1314. trace_t tr;
  1315. vec3_t bottom;
  1316. VectorCopy( ent->currentOrigin, saveOrg );
  1317. VectorCopy( ent->currentOrigin, bottom );
  1318. bottom[2] = MIN_WORLD_COORD;
  1319. gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, bottom, ent->s.number, MASK_NPCSOLID );
  1320. if ( !tr.allsolid && !tr.startsolid && tr.fraction < 1.0 )
  1321. {
  1322. G_SetOrigin( ent, tr.endpos );
  1323. }
  1324. }
  1325. //Check the spawner's count
  1326. if( ent->count != -1 )
  1327. {
  1328. ent->count--;
  1329. if( ent->count <= 0 )
  1330. {
  1331. ent->e_UseFunc = useF_NULL;//never again
  1332. //will be removed below
  1333. }
  1334. }
  1335. newent = G_Spawn();
  1336. if ( newent == NULL )
  1337. {
  1338. gi.Printf ( S_COLOR_RED"ERROR: NPC G_Spawn failed\n" );
  1339. if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1340. {
  1341. G_SetOrigin( ent, saveOrg );
  1342. }
  1343. return NULL;
  1344. }
  1345. newent->client = (gclient_s *)gi.Malloc(sizeof(gclient_s), TAG_G_ALLOC, qtrue);
  1346. newent->svFlags |= SVF_NPC;
  1347. if ( ent->NPC_type == NULL )
  1348. {
  1349. ent->NPC_type = "random";
  1350. newent->NPC_type = "random";
  1351. }
  1352. else
  1353. {
  1354. newent->NPC_type = strlwr( G_NewString( ent->NPC_type ) ); //get my own copy so i can free it when i die
  1355. }
  1356. newent->NPC = (gNPC_t*) gi.Malloc(sizeof(gNPC_t), TAG_G_ALLOC, qtrue);
  1357. newent->NPC->tempGoal = G_Spawn();
  1358. newent->NPC->tempGoal->classname = "NPC_goal";
  1359. newent->NPC->tempGoal->owner = newent;
  1360. newent->NPC->tempGoal->svFlags |= SVF_NOCLIENT;
  1361. //==NPC_Connect( newent, net_name );===================================
  1362. if ( ent->svFlags & SVF_NO_BASIC_SOUNDS )
  1363. {
  1364. newent->svFlags |= SVF_NO_BASIC_SOUNDS;
  1365. }
  1366. if ( ent->svFlags & SVF_NO_COMBAT_SOUNDS )
  1367. {
  1368. newent->svFlags |= SVF_NO_COMBAT_SOUNDS;
  1369. }
  1370. if ( ent->svFlags & SVF_NO_EXTRA_SOUNDS )
  1371. {
  1372. newent->svFlags |= SVF_NO_EXTRA_SOUNDS;
  1373. }
  1374. if ( ent->message )
  1375. {//has a key
  1376. newent->message = G_NewString(ent->message);//copy the key name
  1377. newent->flags |= FL_NO_KNOCKBACK;//don't fall off ledges
  1378. }
  1379. // If this is a vehicle we need to see what kind it is so we properlly allocate it.
  1380. if ( Q_stricmp( ent->classname, "NPC_Vehicle" ) == 0 )
  1381. {
  1382. // Get the vehicle entry index.
  1383. int iVehIndex = BG_VehicleGetIndex( newent->NPC_type );
  1384. if ( iVehIndex == -1 )
  1385. {
  1386. Com_Printf( S_COLOR_RED"ERROR: Attempting to Spawn an unrecognized Vehicle! - %s\n", newent->NPC_type );
  1387. G_FreeEntity( newent );
  1388. if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1389. {
  1390. G_SetOrigin( ent, saveOrg );
  1391. }
  1392. return NULL;
  1393. }
  1394. newent->soundSet = G_NewString(ent->soundSet);//get my own copy so i can free it when i die
  1395. // NOTE: If you change/add any of these, update NPC_Spawn_f for the new vehicle you
  1396. // want to be able to spawn in manually.
  1397. // See what kind of vehicle this is and allocate it properly.
  1398. switch( g_vehicleInfo[iVehIndex].type )
  1399. {
  1400. case VH_ANIMAL:
  1401. // Create the animal (making sure all it's data is initialized).
  1402. G_CreateAnimalNPC( &newent->m_pVehicle, newent->NPC_type );
  1403. break;
  1404. case VH_SPEEDER:
  1405. // Create the speeder (making sure all it's data is initialized).
  1406. G_CreateSpeederNPC( &newent->m_pVehicle, newent->NPC_type );
  1407. break;
  1408. case VH_FIGHTER:
  1409. // Create the fighter (making sure all it's data is initialized).
  1410. G_CreateFighterNPC( &newent->m_pVehicle, newent->NPC_type );
  1411. break;
  1412. case VH_WALKER:
  1413. // Create the animal (making sure all it's data is initialized).
  1414. G_CreateWalkerNPC( &newent->m_pVehicle, newent->NPC_type );
  1415. break;
  1416. default:
  1417. Com_Printf( S_COLOR_RED"ERROR: Attempting to Spawn an unrecognized Vehicle Type! - %s\n", newent->NPC_type );
  1418. G_FreeEntity( newent );
  1419. if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1420. {
  1421. G_SetOrigin( ent, saveOrg );
  1422. }
  1423. return NULL;
  1424. }
  1425. //grab this from the spawner
  1426. if ( (ent->spawnflags&1) )
  1427. {//wants to explode when not in vis of player
  1428. newent->endFrame = ent->endFrame;
  1429. }
  1430. // Setup the vehicle.
  1431. newent->m_pVehicle->m_pParentEntity = newent;
  1432. newent->m_pVehicle->m_pVehicleInfo->Initialize( newent->m_pVehicle );
  1433. newent->client->NPC_class = CLASS_VEHICLE;
  1434. }
  1435. else
  1436. {
  1437. newent->client->ps.weapon = WP_NONE;//init for later check in NPC_Begin
  1438. }
  1439. newent->classname = "NPC";
  1440. VectorCopy(ent->s.origin, newent->s.origin);
  1441. VectorCopy(ent->s.origin, newent->client->ps.origin);
  1442. VectorCopy(ent->s.origin, newent->currentOrigin);
  1443. G_SetOrigin(newent, ent->s.origin);//just to be sure!
  1444. //NOTE: on vehicles, anything in the .npc file will STOMP data on the NPC that's set by the vehicle
  1445. if ( !NPC_ParseParms( ent->NPC_type, newent ) )
  1446. {
  1447. gi.Printf ( S_COLOR_RED "ERROR: Couldn't spawn NPC %s\n", ent->NPC_type );
  1448. G_FreeEntity( newent );
  1449. if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1450. {
  1451. G_SetOrigin( ent, saveOrg );
  1452. }
  1453. return NULL;
  1454. }
  1455. if ( ent->NPC_type )
  1456. {
  1457. if ( !Q_stricmp( ent->NPC_type, "player" ) )
  1458. {// Or check NPC_type against player's NPC_type?
  1459. newent->NPC->aiFlags |= NPCAI_MATCHPLAYERWEAPON;
  1460. }
  1461. else if ( !Q_stricmp( ent->NPC_type, "test" ) )
  1462. {
  1463. int n;
  1464. for ( n = 0; n < 1 ; n++)
  1465. {
  1466. if ( !(g_entities[n].svFlags & SVF_NPC) && g_entities[n].client)
  1467. {
  1468. VectorCopy(g_entities[n].s.origin, newent->s.origin);
  1469. newent->client->playerTeam = g_entities[n].client->playerTeam;
  1470. break;
  1471. }
  1472. }
  1473. newent->NPC->defaultBehavior = newent->NPC->behaviorState = BS_WAIT;
  1474. // newent->svFlags |= SVF_NOPUSH;
  1475. }
  1476. }
  1477. //=====================================================================
  1478. //set the info we want
  1479. newent->health = ent->health;
  1480. newent->wait = ent->wait;
  1481. //copy strings so we can safely free them
  1482. newent->script_targetname = G_NewString(ent->NPC_targetname);
  1483. newent->targetname = G_NewString(ent->NPC_targetname);
  1484. newent->target = G_NewString(ent->NPC_target);//death
  1485. newent->target2 = G_NewString(ent->target2);//knocked out death
  1486. newent->target3 = G_NewString(ent->target3);//???
  1487. newent->target4 = G_NewString(ent->target4);//ffire death
  1488. newent->paintarget = G_NewString(ent->paintarget);
  1489. newent->opentarget = G_NewString(ent->opentarget);
  1490. newent->radius = ent->radius;
  1491. newent->NPC->eventualGoal = ent->enemy;
  1492. for( index = BSET_FIRST; index < NUM_BSETS; index++)
  1493. {
  1494. if ( ent->behaviorSet[index] )
  1495. {
  1496. newent->behaviorSet[index] = ent->behaviorSet[index];
  1497. }
  1498. }
  1499. VectorCopy(ent->s.angles, newent->s.angles);
  1500. VectorCopy(ent->s.angles, newent->currentAngles);
  1501. VectorCopy(ent->s.angles, newent->client->ps.viewangles);
  1502. newent->NPC->desiredYaw =ent->s.angles[YAW];
  1503. //gi.linkentity(newent); //check: don't need this here?
  1504. newent->spawnflags = ent->spawnflags;
  1505. //==New stuff=====================================================================
  1506. newent->s.eType = ET_PLAYER;
  1507. //FIXME: Call CopyParms
  1508. if ( ent->parms )
  1509. {
  1510. for ( int parmNum = 0; parmNum < MAX_PARMS; parmNum++ )
  1511. {
  1512. if ( ent->parms->parm[parmNum] && ent->parms->parm[parmNum][0] )
  1513. {
  1514. Q3_SetParm( newent->s.number, parmNum, ent->parms->parm[parmNum] );
  1515. }
  1516. }
  1517. }
  1518. //FIXME: copy cameraGroup, store mine in message or other string field
  1519. //set origin
  1520. newent->s.pos.trType = TR_INTERPOLATE;
  1521. newent->s.pos.trTime = level.time;
  1522. VectorCopy( newent->currentOrigin, newent->s.pos.trBase );
  1523. VectorClear( newent->s.pos.trDelta );
  1524. newent->s.pos.trDuration = 0;
  1525. //set angles
  1526. newent->s.apos.trType = TR_INTERPOLATE;
  1527. newent->s.apos.trTime = level.time;
  1528. VectorCopy( newent->currentOrigin, newent->s.apos.trBase );
  1529. VectorClear( newent->s.apos.trDelta );
  1530. newent->s.apos.trDuration = 0;
  1531. newent->NPC->combatPoint = -1;
  1532. newent->NPC->aiFlags |= ent->bounceCount;//ai flags
  1533. newent->flags |= FL_NOTARGET;//So he's ignored until he's fully spawned
  1534. newent->s.eFlags |= EF_NODRAW;//So he's ignored until he's fully spawned
  1535. if ( fullSpawnNow )
  1536. {
  1537. newent->owner = ent->owner;
  1538. }
  1539. else
  1540. {
  1541. newent->e_ThinkFunc = thinkF_NPC_Begin;
  1542. newent->nextthink = level.time + FRAMETIME;
  1543. }
  1544. NPC_DefaultScriptFlags( newent );
  1545. gi.linkentity (newent);
  1546. if(ent->e_UseFunc == useF_NULL)
  1547. {
  1548. if( ent->target )
  1549. {//use any target we're pointed at
  1550. G_UseTargets ( ent, ent );
  1551. }
  1552. if(ent->closetarget)
  1553. {//last guy should fire this target when he dies
  1554. if (newent->target)
  1555. {//zap
  1556. gi.Free(newent->target);
  1557. }
  1558. newent->target = G_NewString(ent->closetarget);
  1559. }
  1560. G_FreeEntity( ent );//bye!
  1561. }
  1562. else if ( ent->spawnflags & NSF_DROP_TO_FLOOR )
  1563. {
  1564. G_SetOrigin( ent, saveOrg );
  1565. }
  1566. if ( fullSpawnNow )
  1567. {
  1568. NPC_Begin( newent );
  1569. }
  1570. return newent;
  1571. }
  1572. void NPC_Spawn_Go( gentity_t *ent )
  1573. {
  1574. NPC_Spawn_Do( ent, qfalse );
  1575. }
  1576. /*
  1577. -------------------------
  1578. NPC_StasisSpawnEffect
  1579. -------------------------
  1580. */
  1581. /*
  1582. void NPC_StasisSpawnEffect( gentity_t *ent )
  1583. {
  1584. vec3_t start, end, forward;
  1585. qboolean taper;
  1586. //Floor or wall?
  1587. if ( ent->spawnflags & 1 )
  1588. {
  1589. AngleVectors( ent->s.angles, forward, NULL, NULL );
  1590. VectorMA( ent->currentOrigin, 24, forward, end );
  1591. VectorMA( ent->currentOrigin, -20, forward, start );
  1592. start[2] += 64;
  1593. taper = qtrue;
  1594. }
  1595. else
  1596. {
  1597. VectorCopy( ent->currentOrigin, start );
  1598. VectorCopy( start, end );
  1599. end[2] += 48;
  1600. taper = qfalse;
  1601. }
  1602. //Add the effect
  1603. // CG_ShimmeryThing_Spawner( start, end, 32, qtrue, 1000 );
  1604. }
  1605. */
  1606. /*
  1607. -------------------------
  1608. NPC_ShySpawn
  1609. -------------------------
  1610. */
  1611. #define SHY_THINK_TIME 1000
  1612. #define SHY_SPAWN_DISTANCE 128
  1613. #define SHY_SPAWN_DISTANCE_SQR ( SHY_SPAWN_DISTANCE * SHY_SPAWN_DISTANCE )
  1614. void NPC_ShySpawn( gentity_t *ent )
  1615. {
  1616. ent->nextthink = level.time + SHY_THINK_TIME;
  1617. ent->e_ThinkFunc = thinkF_NPC_ShySpawn;
  1618. if ( DistanceSquared( g_entities[0].currentOrigin, ent->currentOrigin ) <= SHY_SPAWN_DISTANCE_SQR )
  1619. return;
  1620. if ( (InFOV( ent, &g_entities[0], 80, 64 )) ) // FIXME: hardcoded fov
  1621. if ( (NPC_ClearLOS( &g_entities[0], ent->currentOrigin )) )
  1622. return;
  1623. // 4/18/03 kef -- don't let guys spawn into other guys
  1624. if (ent->spawnflags & 4096)
  1625. {
  1626. if (!NPC_SafeSpawn(ent, 64))
  1627. {
  1628. return;
  1629. }
  1630. }
  1631. ent->e_ThinkFunc = thinkF_NULL;
  1632. ent->nextthink = 0;
  1633. NPC_Spawn_Go( ent );
  1634. }
  1635. /*
  1636. -------------------------
  1637. NPC_Spawn
  1638. -------------------------
  1639. */
  1640. void NPC_Spawn ( gentity_t *ent, gentity_t *other, gentity_t *activator )
  1641. {
  1642. //delay before spawning NPC
  1643. if (other->spawnflags&32)
  1644. {
  1645. ent->enemy = activator;
  1646. }
  1647. if( ent->delay )
  1648. {
  1649. /* //Stasis does an extra step
  1650. if ( Q_stricmp( ent->classname, "NPC_Stasis" ) == 0 )
  1651. {
  1652. if ( NPC_StasisSpawn_Go( ent ) == qfalse )
  1653. return;
  1654. }
  1655. */
  1656. if ( ent->spawnflags & 2048 ) // SHY
  1657. ent->e_ThinkFunc = thinkF_NPC_ShySpawn;
  1658. else
  1659. ent->e_ThinkFunc = thinkF_NPC_Spawn_Go;
  1660. ent->nextthink = level.time + ent->delay;
  1661. }
  1662. else
  1663. {
  1664. if ( ent->spawnflags & 2048 ) // SHY
  1665. NPC_ShySpawn( ent );
  1666. else
  1667. NPC_Spawn_Go( ent );
  1668. }
  1669. }
  1670. /*QUAKED NPC_spawner (1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY SAFE
  1671. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  1672. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1673. NOTSOLID - Starts not solid
  1674. STARTINSOLID - Don't try to fix if spawn in solid
  1675. SHY - Spawner is shy
  1676. SAFE - Won't spawn if an entity is within 64 units
  1677. NPC_type - name of NPC (in npcs.cfg) to spawn in
  1678. targetname - name this NPC goes by for targetting
  1679. target - NPC will fire this when it spawns it's last NPC (should this be when the last NPC it spawned dies?)
  1680. target2 - Fired by stasis spawners when they try to spawn while their spawner model is broken
  1681. target3 - Fired by spawner if they try to spawn and are blocked and have a wait < 0 (removes them)
  1682. If targeted, will only spawn a NPC when triggered
  1683. count - how many NPCs to spawn (only if targetted) default = 1
  1684. delay - how long to wait to spawn after used
  1685. wait - if trying to spawn and blocked, how many seconds to wait before trying again (default = 0.5, < 0 = never try again and fire target2)
  1686. NPC_targetname - NPC's targetname AND script_targetname
  1687. NPC_target - NPC's target to fire when killed
  1688. NPC_target2 - NPC's target to fire when knocked out
  1689. NPC_target4 - NPC's target to fire when killed by friendly fire
  1690. NPC_type - type of NPC ("Borg" (default), "Xian", etc)
  1691. health - starting health (default = 100)
  1692. "noBasicSounds" - set to 1 to prevent loading and usage of basic sounds (pain, death, etc)
  1693. "noCombatSounds" - set to 1 to prevent loading and usage of combat sounds (anger, victory, etc.)
  1694. "noExtraSounds" - set to 1 to prevent loading and usage of "extra" sounds (chasing the enemy - detecting them, flanking them... also jedi combat sounds)
  1695. spawnscript - default script to run once spawned (none by default)
  1696. usescript - default script to run when used (none by default)
  1697. awakescript - default script to run once awoken (none by default)
  1698. angerscript - default script to run once angered (none by default)
  1699. painscript - default script to run when hit (none by default)
  1700. fleescript - default script to run when hit and below 50% health (none by default)
  1701. deathscript - default script to run when killed (none by default)
  1702. These strings can be used to activate behaviors instead of scripts - these are checked
  1703. first and so no scripts should be names with these names:
  1704. default - 0: whatever
  1705. idle - 1: Stand around, do abolutely nothing
  1706. roam - 2: Roam around, collect stuff
  1707. walk - 3: Crouch-Walk toward their goals
  1708. run - 4: Run toward their goals
  1709. standshoot - 5: Stay in one spot and shoot- duck when neccesary
  1710. standguard - 6: Wait around for an enemy
  1711. patrol - 7: Follow a path, looking for enemies
  1712. huntkill - 8: Track down enemies and kill them
  1713. evade - 9: Run from enemies
  1714. evadeshoot - 10: Run from enemies, shoot them if they hit you
  1715. runshoot - 11: Run to your goal and shoot enemy when possible
  1716. defend - 12: Defend an entity or spot?
  1717. snipe - 13: Stay hidden, shoot enemy only when have perfect shot and back turned
  1718. combat - 14: Attack, evade, use cover, move about, etc. Full combat AI - id NPC code
  1719. medic - 15: Go for lowest health buddy, hide and heal him.
  1720. takecover - 16: Find nearest cover from enemies
  1721. getammo - 17: Go get some ammo
  1722. advancefight - 18: Go somewhere and fight along the way
  1723. face - 19: turn until facing desired angles
  1724. wait - 20: do nothing
  1725. formation - 21: Maintain a formation
  1726. crouch - 22: Crouch-walk toward their goals
  1727. delay - after spawned or triggered, how many seconds to wait to spawn the NPC
  1728. */
  1729. //void NPC_PrecacheModels ( char *NPCName );
  1730. extern qboolean spawning; // the G_Spawn*() functions are valid (only turned on during one function)
  1731. extern void NPC_PrecacheByClassName(const char*);
  1732. void SP_NPC_spawner( gentity_t *self)
  1733. {
  1734. extern void NPC_PrecacheAnimationCFG( const char *NPC_type );
  1735. float fDelay;
  1736. //register/precache the models needed for this NPC, not anymore
  1737. //self->classname = "NPC_spawner";
  1738. if(!self->count)
  1739. {
  1740. self->count = 1;
  1741. }
  1742. //NOTE: bounceCount is transferred to the spawned NPC's NPC->aiFlags
  1743. self->bounceCount = 0;
  1744. {
  1745. static int garbage;
  1746. //Stop loading of certain extra sounds
  1747. if ( G_SpawnInt( "noBasicSounds", "0", &garbage ) )
  1748. {
  1749. self->svFlags |= SVF_NO_BASIC_SOUNDS;
  1750. }
  1751. if ( G_SpawnInt( "noCombatSounds", "0", &garbage ) )
  1752. {
  1753. self->svFlags |= SVF_NO_COMBAT_SOUNDS;
  1754. }
  1755. if ( G_SpawnInt( "noExtraSounds", "0", &garbage ) )
  1756. {
  1757. self->svFlags |= SVF_NO_EXTRA_SOUNDS;
  1758. }
  1759. if ( G_SpawnInt( "nodelay", "0", &garbage ) )
  1760. {
  1761. self->bounceCount |= NPCAI_NO_JEDI_DELAY;
  1762. }
  1763. }
  1764. if ( !self->wait )
  1765. {
  1766. self->wait = 500;
  1767. }
  1768. else
  1769. {
  1770. self->wait *= 1000;//1 = 1 msec, 1000 = 1 sec
  1771. }
  1772. G_SpawnFloat( "delay", "0", &fDelay );
  1773. if ( fDelay )
  1774. {
  1775. self->delay = ceil(1000.0f*fDelay);//1 = 1 msec, 1000 = 1 sec
  1776. }
  1777. if ( self->delay > 0 )
  1778. {
  1779. self->svFlags |= SVF_NPC_PRECACHE;
  1780. }
  1781. //We have to load the animation.cfg now because spawnscripts are going to want to set anims and we need to know their length and if they're valid
  1782. NPC_PrecacheAnimationCFG( self->NPC_type );
  1783. if ( self->targetname )
  1784. {//Wait for triggering
  1785. self->e_UseFunc = useF_NPC_Spawn;
  1786. self->svFlags |= SVF_NPC_PRECACHE;//FIXME: precache my weapons somehow?
  1787. //NPC_PrecacheModels( self->NPC_type );
  1788. }
  1789. else
  1790. {
  1791. //NOTE: auto-spawners never check for shy spawning
  1792. if ( spawning )
  1793. {//in entity spawn stage - map starting up
  1794. self->e_ThinkFunc = thinkF_NPC_Spawn_Go;
  1795. self->nextthink = level.time + START_TIME_REMOVE_ENTS + 50;
  1796. }
  1797. else
  1798. {//else spawn right now
  1799. NPC_Spawn( self, self, self );
  1800. }
  1801. }
  1802. if (!(self->svFlags&SVF_NPC_PRECACHE))
  1803. {
  1804. NPC_PrecacheByClassName(self->NPC_type);
  1805. }
  1806. //FIXME: store cameraGroup somewhere else and apply to spawned NPCs' cameraGroup
  1807. //Or just don't include NPC_spawners in cameraGroupings
  1808. if ( self->message )
  1809. {//may drop a key, precache the key model and pickup sound
  1810. G_SoundIndex( "sound/weapons/key_pkup.wav" );
  1811. if ( !Q_stricmp( "goodie", self->message ) )
  1812. {
  1813. RegisterItem( FindItemForInventory( INV_GOODIE_KEY ) );
  1814. }
  1815. else
  1816. {
  1817. RegisterItem( FindItemForInventory( INV_SECURITY_KEY ) );
  1818. }
  1819. }
  1820. }
  1821. //=============================================================================================
  1822. //VEHICLES
  1823. //=============================================================================================
  1824. /*QUAKED NPC_Vehicle (1 0 0) (-16 -16 -24) (16 16 32) NO_VIS_DIE x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY SAFE
  1825. set NPC_type to vehicle name in vehicles.dat
  1826. NO_VIS_DIE - die after certain amount of time of not having a LOS to the Player (default time is 10 seconds, change by setting "noVisTime")
  1827. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1828. NOTSOLID - Starts not solid
  1829. STARTINSOLID - Don't try to fix if spawn in solid
  1830. SHY - Spawner is shy
  1831. SAFE - Won't spawn if an entity is within 64 units
  1832. "noVisTime" - how long to wait after spawning/last being seen by the player beforw blowing ourselves up (default is 10 seconds)
  1833. "skin" - which skin to set "red" for example - If no skin it is random
  1834. */
  1835. void NPC_VehicleSpawnUse( gentity_t *self, gentity_t *other, gentity_t *activator )
  1836. {
  1837. G_VehicleSpawn( self );
  1838. }
  1839. void SP_NPC_Vehicle( gentity_t *self)
  1840. {
  1841. if ( !self->NPC_type )
  1842. {
  1843. self->NPC_type = "swoop";
  1844. }
  1845. if ( !self->classname )
  1846. {
  1847. self->classname = "NPC_Vehicle";
  1848. }
  1849. G_SetOrigin( self, self->s.origin );
  1850. G_SetAngles( self, self->s.angles );
  1851. G_SpawnString("skin", "", &self->soundSet);
  1852. //grab this from the spawner
  1853. if ( (self->spawnflags&1) )
  1854. {//wants to explode when not in vis of player
  1855. if ( !self->endFrame )
  1856. {
  1857. self->endFrame = NO_PILOT_DIE_TIME;
  1858. }
  1859. }
  1860. if ( self->targetname )
  1861. {
  1862. self->svFlags |= SVF_NPC_PRECACHE; // Precache The Bike when all other npcs are precached
  1863. self->e_UseFunc = useF_NPC_VehicleSpawnUse;
  1864. //we're not spawning until later, so precache us now
  1865. BG_VehicleGetIndex( self->NPC_type );
  1866. }
  1867. else
  1868. {
  1869. G_VehicleSpawn( self );
  1870. }
  1871. }
  1872. //=============================================================================================
  1873. //CHARACTERS
  1874. //=============================================================================================
  1875. /*QUAKED NPC_Player (1 0 0) (-16 -16 -24) (16 16 32) x RIFLEMAN PHASER TRICORDER DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1876. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1877. NOTSOLID - Starts not solid
  1878. STARTINSOLID - Don't try to fix if spawn in solid
  1879. SHY - Spawner is shy
  1880. */
  1881. void SP_NPC_Player( gentity_t *self)
  1882. {
  1883. self->NPC_type = "Player";
  1884. SP_NPC_spawner( self );
  1885. }
  1886. /*QUAKED NPC_Kyle (1 0 0) (-16 -16 -24) (16 16 32) BOSS x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1887. BOSS - Uses Boss AI
  1888. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1889. NOTSOLID - Starts not solid
  1890. STARTINSOLID - Don't try to fix if spawn in solid
  1891. SHY - Spawner is shy
  1892. */
  1893. void SP_NPC_Kyle( gentity_t *self)
  1894. {
  1895. if ( (self->spawnflags&1) )
  1896. {
  1897. self->NPC_type = "Kyle_boss";
  1898. }
  1899. else
  1900. {
  1901. self->NPC_type = "Kyle";
  1902. }
  1903. SP_NPC_spawner( self );
  1904. }
  1905. /*QUAKED NPC_Lando(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1906. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  1907. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1908. NOTSOLID - Starts not solid
  1909. STARTINSOLID - Don't try to fix if spawn in solid
  1910. SHY - Spawner is shy
  1911. */
  1912. void SP_NPC_Lando( gentity_t *self)
  1913. {
  1914. self->NPC_type = "Lando";
  1915. SP_NPC_spawner( self );
  1916. }
  1917. /*QUAKED NPC_Jan(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1918. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  1919. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1920. NOTSOLID - Starts not solid
  1921. STARTINSOLID - Don't try to fix if spawn in solid
  1922. SHY - Spawner is shy
  1923. */
  1924. void SP_NPC_Jan( gentity_t *self)
  1925. {
  1926. self->NPC_type = "Jan";
  1927. SP_NPC_spawner( self );
  1928. }
  1929. /*QUAKED NPC_Luke(1 0 0) (-16 -16 -24) (16 16 40) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  1930. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  1931. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1932. NOTSOLID - Starts not solid
  1933. STARTINSOLID - Don't try to fix if spawn in solid
  1934. SHY - Spawner is shy
  1935. */
  1936. void SP_NPC_Luke( gentity_t *self)
  1937. {
  1938. self->NPC_type = "Luke";
  1939. SP_NPC_spawner( self );
  1940. }
  1941. /*QUAKED NPC_MonMothma(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1942. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  1943. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1944. NOTSOLID - Starts not solid
  1945. STARTINSOLID - Don't try to fix if spawn in solid
  1946. SHY - Spawner is shy
  1947. */
  1948. void SP_NPC_MonMothma( gentity_t *self)
  1949. {
  1950. self->NPC_type = "MonMothma";
  1951. SP_NPC_spawner( self );
  1952. }
  1953. /*QUAKED NPC_Rosh_Penin (1 0 0) (-16 -16 -24) (16 16 32) DARKSIDE NOFORCE x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  1954. Good Rosh
  1955. DARKSIDE - Evil Rosh
  1956. NOFORCE - Can't jump, starts with no saber
  1957. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1958. NOTSOLID - Starts not solid
  1959. STARTINSOLID - Don't try to fix if spawn in solid
  1960. SHY - Spawner is shy
  1961. */
  1962. void SP_NPC_Rosh_Penin( gentity_t *self)
  1963. {
  1964. if ( (self->spawnflags&1) )
  1965. {
  1966. self->NPC_type = "rosh_dark";
  1967. }
  1968. else if ( (self->spawnflags&2) )
  1969. {
  1970. self->NPC_type = "rosh_penin_noforce";
  1971. }
  1972. else
  1973. {
  1974. self->NPC_type = "rosh_penin";
  1975. }
  1976. SP_NPC_spawner( self );
  1977. }
  1978. /*QUAKED NPC_Tavion (1 0 0) (-16 -16 -24) (16 16 32) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  1979. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  1980. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1981. NOTSOLID - Starts not solid
  1982. STARTINSOLID - Don't try to fix if spawn in solid
  1983. SHY - Spawner is shy
  1984. */
  1985. void SP_NPC_Tavion( gentity_t *self)
  1986. {
  1987. self->NPC_type = "Tavion";
  1988. SP_NPC_spawner( self );
  1989. }
  1990. /*QUAKED NPC_Tavion_New (1 0 0) (-16 -16 -24) (16 16 32) SCEPTER SITH_SWORD x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  1991. Has a red lightsaber and force powers, uses her saber style from JK2
  1992. SCEPTER - Has a red lightsaber and force powers, Ragnos' Scepter in left hand, uses dual saber style and occasionally attacks with Scepter
  1993. SITH_SWORD - Has Ragnos' Sith Sword in right hand and force powers, uses strong style
  1994. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  1995. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  1996. NOTSOLID - Starts not solid
  1997. STARTINSOLID - Don't try to fix if spawn in solid
  1998. SHY - Spawner is shy
  1999. */
  2000. void SP_NPC_Tavion_New( gentity_t *self)
  2001. {
  2002. if ( (self->spawnflags&1) )
  2003. {
  2004. self->NPC_type = "tavion_scepter";
  2005. }
  2006. else if ( (self->spawnflags&2) )
  2007. {
  2008. self->NPC_type = "tavion_sith_sword";
  2009. }
  2010. else
  2011. {
  2012. self->NPC_type = "tavion_new";
  2013. }
  2014. SP_NPC_spawner( self );
  2015. }
  2016. /*QUAKED NPC_Alora (1 0 0) (-16 -16 -24) (16 16 32) DUAL x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2017. Lightsaber and level 2 force powers, 300 health
  2018. DUAL - Dual sabers and level 3 force powers, 500 health
  2019. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2020. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2021. NOTSOLID - Starts not solid
  2022. STARTINSOLID - Don't try to fix if spawn in solid
  2023. SHY - Spawner is shy
  2024. */
  2025. void SP_NPC_Alora( gentity_t *self)
  2026. {
  2027. if ( (self->spawnflags&1) )
  2028. {
  2029. self->NPC_type = "alora_dual";
  2030. }
  2031. else
  2032. {
  2033. self->NPC_type = "alora";
  2034. }
  2035. SP_NPC_spawner( self );
  2036. }
  2037. /*QUAKED NPC_Reelo(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2038. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2039. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2040. NOTSOLID - Starts not solid
  2041. STARTINSOLID - Don't try to fix if spawn in solid
  2042. SHY - Spawner is shy
  2043. */
  2044. void SP_NPC_Reelo( gentity_t *self)
  2045. {
  2046. self->NPC_type = "Reelo";
  2047. SP_NPC_spawner( self );
  2048. }
  2049. /*QUAKED NPC_Galak(1 0 0) (-16 -16 -24) (16 16 40) MECH x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2050. MECH - will be the armored Galak
  2051. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2052. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2053. NOTSOLID - Starts not solid
  2054. STARTINSOLID - Don't try to fix if spawn in solid
  2055. SHY - Spawner is shy
  2056. */
  2057. void SP_NPC_Galak( gentity_t *self)
  2058. {
  2059. }
  2060. /*QUAKED NPC_Desann(1 0 0) (-16 -16 -24) (16 16 40) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2061. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2062. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2063. NOTSOLID - Starts not solid
  2064. STARTINSOLID - Don't try to fix if spawn in solid
  2065. SHY - Spawner is shy
  2066. */
  2067. void SP_NPC_Desann( gentity_t *self)
  2068. {
  2069. self->NPC_type = "Desann";
  2070. SP_NPC_spawner( self );
  2071. }
  2072. /*QUAKED NPC_Rax(1 0 0) (-16 -16 -24) (16 16 40) FUN x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2073. FUN - Makes him magically the funnest thing ever in any game ever made. (actually does nothing, it'll just be fun by the power of suggestion).
  2074. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2075. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2076. NOTSOLID - Starts not solid
  2077. STARTINSOLID - Don't try to fix if spawn in solid
  2078. SHY - Spawner is shy
  2079. */
  2080. void SP_NPC_Rax( gentity_t *self )
  2081. {
  2082. self->NPC_type = "Rax";
  2083. SP_NPC_spawner( self );
  2084. }
  2085. /*QUAKED NPC_BobaFett(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2086. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2087. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2088. NOTSOLID - Starts not solid
  2089. STARTINSOLID - Don't try to fix if spawn in solid
  2090. SHY - Spawner is shy
  2091. */
  2092. void SP_NPC_BobaFett( gentity_t *self )
  2093. {
  2094. self->NPC_type = "Boba_Fett";
  2095. SP_NPC_spawner( self );
  2096. }
  2097. /*QUAKED NPC_Ragnos(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2098. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2099. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2100. NOTSOLID - Starts not solid
  2101. STARTINSOLID - Don't try to fix if spawn in solid
  2102. SHY - Spawner is shy
  2103. */
  2104. void SP_NPC_Ragnos( gentity_t *self )
  2105. {
  2106. self->NPC_type = "Ragnos";
  2107. SP_NPC_spawner( self );
  2108. }
  2109. /*QUAKED NPC_Lannik_Racto(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2110. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2111. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2112. NOTSOLID - Starts not solid
  2113. STARTINSOLID - Don't try to fix if spawn in solid
  2114. SHY - Spawner is shy
  2115. */
  2116. void SP_NPC_Lannik_Racto( gentity_t *self )
  2117. {
  2118. self->NPC_type = "lannik_racto";
  2119. SP_NPC_spawner( self );
  2120. }
  2121. /*QUAKED NPC_Kothos(1 0 0) (-16 -16 -24) (16 16 40) VIL x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2122. VIL - spawns Vil Kothos instead of Dasariah (can anyone tell them apart anyway...?)
  2123. Force only... will (eventually) be set up to re-inforce their leader (use SET_LEADER) by healing them, recharging them, keeping the player away, etc.
  2124. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2125. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2126. NOTSOLID - Starts not solid
  2127. STARTINSOLID - Don't try to fix if spawn in solid
  2128. SHY - Spawner is shy
  2129. */
  2130. void SP_NPC_Kothos( gentity_t *self )
  2131. {
  2132. if ( (self->spawnflags&1) )
  2133. {
  2134. self->NPC_type = "VKothos";
  2135. }
  2136. else
  2137. {
  2138. self->NPC_type = "DKothos";
  2139. }
  2140. SP_NPC_spawner( self );
  2141. }
  2142. /*QUAKED NPC_Chewbacca(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2143. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2144. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2145. NOTSOLID - Starts not solid
  2146. STARTINSOLID - Don't try to fix if spawn in solid
  2147. SHY - Spawner is shy
  2148. */
  2149. void SP_NPC_Chewbacca( gentity_t *self )
  2150. {
  2151. self->NPC_type = "Chewie";
  2152. SP_NPC_spawner( self );
  2153. }
  2154. /*QUAKED NPC_Bartender(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2155. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2156. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2157. NOTSOLID - Starts not solid
  2158. STARTINSOLID - Don't try to fix if spawn in solid
  2159. SHY - Spawner is shy
  2160. */
  2161. void SP_NPC_Bartender( gentity_t *self)
  2162. {
  2163. self->NPC_type = "Bartender";
  2164. SP_NPC_spawner( self );
  2165. }
  2166. /*QUAKED NPC_MorganKatarn(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2167. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2168. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2169. NOTSOLID - Starts not solid
  2170. STARTINSOLID - Don't try to fix if spawn in solid
  2171. SHY - Spawner is shy
  2172. */
  2173. void SP_NPC_MorganKatarn( gentity_t *self)
  2174. {
  2175. self->NPC_type = "MorganKatarn";
  2176. SP_NPC_spawner( self );
  2177. }
  2178. //=============================================================================================
  2179. //ALLIES
  2180. //=============================================================================================
  2181. /*QUAKED NPC_Jedi(1 0 0) (-16 -16 -24) (16 16 40) TRAINER MASTER RANDOM x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2182. TRAINER - Special Jedi- instructor
  2183. MASTER - Special Jedi- master
  2184. RANDOM - creates a random Jedi student using the available player models/skins (excludes the current model of the player)
  2185. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2186. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2187. NOTSOLID - Starts not solid
  2188. STARTINSOLID - Don't try to fix if spawn in solid
  2189. SHY - Spawner is shy
  2190. Ally Jedi NPC Buddy - tags along with player
  2191. */
  2192. static char *randomJedis[] = {
  2193. "jedi_hf1",
  2194. "jedi_rm1",
  2195. "jedi_zf1",
  2196. "jedi_hm1",
  2197. "jedi_tf1",
  2198. "jedi_kdm1",
  2199. };
  2200. extern cvar_t *g_char_model;
  2201. void SP_NPC_Jedi( gentity_t *self)
  2202. {
  2203. if(!self->NPC_type)
  2204. {
  2205. if ( self->spawnflags & 4 ) // Random jedi student
  2206. {
  2207. static unsigned long jediSequence = 0;
  2208. int myIdx;
  2209. for (myIdx = 0; myIdx < 6; ++myIdx)
  2210. if (strstr(randomJedis[myIdx], g_char_model->string))
  2211. break;
  2212. // Sanity check, if player doesn't have a jedi_xx model right now:
  2213. if (myIdx == 6)
  2214. myIdx = 0;
  2215. // Get one of the three after ours:
  2216. int idx = (myIdx + (jediSequence % 3) + 1) % 6;
  2217. jediSequence++;
  2218. self->NPC_type = randomJedis[idx];
  2219. }
  2220. else if ( self->spawnflags & 2 )
  2221. {
  2222. self->NPC_type = "jedimaster";
  2223. }
  2224. else if ( self->spawnflags & 1 )
  2225. {
  2226. self->NPC_type = "jeditrainer";
  2227. }
  2228. else
  2229. {
  2230. /*
  2231. if ( !Q_irand( 0, 2 ) )
  2232. {
  2233. self->NPC_type = "JediF";
  2234. }
  2235. else
  2236. */if ( Q_irand( 0, 1 ) )
  2237. {
  2238. self->NPC_type = "Jedi";
  2239. }
  2240. else
  2241. {
  2242. self->NPC_type = "Jedi2";
  2243. }
  2244. }
  2245. }
  2246. SP_NPC_spawner( self );
  2247. }
  2248. /*QUAKED NPC_Prisoner(1 0 0) (-16 -16 -24) (16 16 40) ELDER x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2249. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2250. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2251. NOTSOLID - Starts not solid
  2252. STARTINSOLID - Don't try to fix if spawn in solid
  2253. SHY - Spawner is shy
  2254. */
  2255. void SP_NPC_Prisoner( gentity_t *self)
  2256. {
  2257. if(!self->NPC_type)
  2258. {
  2259. if ( (self->spawnflags&1) )
  2260. {
  2261. if ( Q_irand( 0, 1 ) )
  2262. {
  2263. self->NPC_type = "elder";
  2264. }
  2265. else
  2266. {
  2267. self->NPC_type = "elder2";
  2268. }
  2269. }
  2270. else
  2271. {
  2272. if ( Q_irand( 0, 1 ) )
  2273. {
  2274. self->NPC_type = "Prisoner";
  2275. }
  2276. else
  2277. {
  2278. self->NPC_type = "Prisoner2";
  2279. }
  2280. }
  2281. }
  2282. SP_NPC_spawner( self );
  2283. }
  2284. /*QUAKED NPC_Merchant(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2285. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2286. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2287. NOTSOLID - Starts not solid
  2288. STARTINSOLID - Don't try to fix if spawn in solid
  2289. SHY - Spawner is shy
  2290. */
  2291. void SP_NPC_Merchant( gentity_t *self)
  2292. {
  2293. self->NPC_type = "merchant";
  2294. SP_NPC_spawner( self );
  2295. }
  2296. /*QUAKED NPC_Rebel(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2297. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2298. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2299. NOTSOLID - Starts not solid
  2300. STARTINSOLID - Don't try to fix if spawn in solid
  2301. SHY - Spawner is shy
  2302. */
  2303. void SP_NPC_Rebel( gentity_t *self)
  2304. {
  2305. if(!self->NPC_type)
  2306. {
  2307. self->NPC_type = "Rebel";
  2308. }
  2309. SP_NPC_spawner( self );
  2310. }
  2311. //=============================================================================================
  2312. //ENEMIES
  2313. //=============================================================================================
  2314. /*QUAKED NPC_Human_Merc(1 0 0) (-16 -16 -24) (16 16 40) BOWCASTER REPEATER FLECHETTE CONCUSSION DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2315. 100 health, blaster rifle
  2316. BOWCASTER - Starts with a Bowcaster
  2317. REPEATER - Starts with a Repeater
  2318. FLECHETTE - Starts with a Flechette gun
  2319. CONCUSSION - Starts with a Concussion Rifle
  2320. If you want them to start with any other kind of weapon, make a spawnscript for them that sets their weapon.
  2321. "message" - turns on his key surface. This is the name of the key you get when you walk over his body. This must match the "message" field of the func_security_panel you want this key to open. Set to "goodie" to have him carrying a goodie key that player can use to operate doors with "GOODIE" spawnflag. NOTE: this overrides all the weapon spawnflags
  2322. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2323. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2324. NOTSOLID - Starts not solid
  2325. STARTINSOLID - Don't try to fix if spawn in solid
  2326. SHY - Spawner is shy
  2327. */
  2328. void SP_NPC_Human_Merc( gentity_t *self)
  2329. {
  2330. if ( !self->NPC_type )
  2331. {
  2332. if ( self->message )
  2333. {
  2334. self->NPC_type = "human_merc_key";
  2335. }
  2336. else if ( (self->spawnflags&1) )
  2337. {
  2338. self->NPC_type = "human_merc_bow";
  2339. }
  2340. else if ( (self->spawnflags&2) )
  2341. {
  2342. self->NPC_type = "human_merc_rep";
  2343. }
  2344. else if ( (self->spawnflags&4) )
  2345. {
  2346. self->NPC_type = "human_merc_flc";
  2347. }
  2348. else if ( (self->spawnflags&8) )
  2349. {
  2350. self->NPC_type = "human_merc_cnc";
  2351. }
  2352. else
  2353. {
  2354. self->NPC_type = "human_merc";
  2355. }
  2356. }
  2357. SP_NPC_spawner( self );
  2358. }
  2359. //TROOPERS=============================================================================
  2360. /*QUAKED NPC_Stormtrooper(1 0 0) (-16 -16 -24) (16 16 40) OFFICER COMMANDER ALTOFFICER ROCKET DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY COMMANDO
  2361. 30 health, blaster
  2362. OFFICER - 60 health, flechette
  2363. COMMANDER - 60 health, heavy repeater
  2364. ALTOFFICER - 60 health, alt-fire flechette (grenades)
  2365. ROCKET - 60 health, rocket launcher
  2366. COMMANDO - Causes character to use Hazard Trooper (move in formation AI)
  2367. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2368. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2369. NOTSOLID - Starts not solid
  2370. STARTINSOLID - Don't try to fix if spawn in solid
  2371. SHY - Spawner is shy
  2372. */
  2373. void SP_NPC_Stormtrooper( gentity_t *self)
  2374. {
  2375. if ( self->spawnflags & 8 )
  2376. {//rocketer
  2377. self->NPC_type = "rockettrooper";
  2378. }
  2379. else if ( self->spawnflags & 4 )
  2380. {//alt-officer
  2381. self->NPC_type = "stofficeralt";
  2382. }
  2383. else if ( self->spawnflags & 2 )
  2384. {//commander
  2385. self->NPC_type = "stcommander";
  2386. }
  2387. else if ( self->spawnflags & 1 )
  2388. {//officer
  2389. self->NPC_type = "stofficer";
  2390. }
  2391. else
  2392. {//regular trooper
  2393. if ( Q_irand( 0, 1 ) )
  2394. {
  2395. self->NPC_type = "StormTrooper";
  2396. }
  2397. else
  2398. {
  2399. self->NPC_type = "StormTrooper2";
  2400. }
  2401. }
  2402. SP_NPC_spawner( self );
  2403. }
  2404. void SP_NPC_StormtrooperOfficer( gentity_t *self)
  2405. {
  2406. self->spawnflags |= 1;
  2407. SP_NPC_Stormtrooper( self );
  2408. }
  2409. /*QUAKED NPC_Snowtrooper(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2410. 30 health, blaster
  2411. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2412. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2413. NOTSOLID - Starts not solid
  2414. STARTINSOLID - Don't try to fix if spawn in solid
  2415. SHY - Spawner is shy
  2416. */
  2417. void SP_NPC_Snowtrooper( gentity_t *self)
  2418. {
  2419. self->NPC_type = "snowtrooper";
  2420. SP_NPC_spawner( self );
  2421. }
  2422. /*QUAKED NPC_Tie_Pilot(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2423. 30 health, blaster
  2424. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2425. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2426. NOTSOLID - Starts not solid
  2427. STARTINSOLID - Don't try to fix if spawn in solid
  2428. SHY - Spawner is shy
  2429. */
  2430. void SP_NPC_Tie_Pilot( gentity_t *self)
  2431. {
  2432. self->NPC_type = "stormpilot";
  2433. SP_NPC_spawner( self );
  2434. }
  2435. /*QUAKED NPC_RocketTrooper(1 0 0) (-16 -16 -24) (16 16 40) OFFICER SPOTLIGHT x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2436. 200 health, flies, rockets
  2437. OFFICER - starts flying, uses concussion rifle instead of rockets
  2438. SPOTLIGHT - uses a shoulder-mounted spotlight
  2439. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2440. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2441. NOTSOLID - Starts not solid
  2442. STARTINSOLID - Don't try to fix if spawn in solid
  2443. SHY - Spawner is shy
  2444. */
  2445. void SP_NPC_RocketTrooper( gentity_t *self)
  2446. {
  2447. if ( !self->NPC_type )
  2448. {
  2449. if ( (self->spawnflags&1) )
  2450. {
  2451. self->NPC_type = "rockettrooper2Officer";
  2452. }
  2453. else
  2454. {
  2455. self->NPC_type = "rockettrooper2";
  2456. }
  2457. }
  2458. SP_NPC_spawner( self );
  2459. }
  2460. /*QUAKED NPC_HazardTrooper(1 0 0) (-16 -16 -24) (16 16 40) OFFICER CONCUSSION x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2461. 250 health, repeater
  2462. OFFICER - 400 health, flechette
  2463. CONCUSSION - 400 health, concussion rifle
  2464. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2465. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2466. NOTSOLID - Starts not solid
  2467. STARTINSOLID - Don't try to fix if spawn in solid
  2468. SHY - Spawner is shy
  2469. */
  2470. void SP_NPC_HazardTrooper( gentity_t *self)
  2471. {
  2472. if ( !self->NPC_type )
  2473. {
  2474. if ( (self->spawnflags&1) )
  2475. {
  2476. self->NPC_type = "hazardtrooperofficer";
  2477. }
  2478. else if ( (self->spawnflags&2) )
  2479. {
  2480. self->NPC_type = "hazardtrooperconcussion";
  2481. }
  2482. else
  2483. {
  2484. self->NPC_type = "hazardtrooper";
  2485. }
  2486. }
  2487. SP_NPC_spawner( self );
  2488. }
  2489. //OTHERS=============================================================================
  2490. /*QUAKED NPC_Ugnaught(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2491. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2492. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2493. NOTSOLID - Starts not solid
  2494. STARTINSOLID - Don't try to fix if spawn in solid
  2495. SHY - Spawner is shy
  2496. */
  2497. void SP_NPC_Ugnaught( gentity_t *self)
  2498. {
  2499. if ( !self->NPC_type )
  2500. {
  2501. if ( Q_irand( 0, 1 ) )
  2502. {
  2503. self->NPC_type = "Ugnaught";
  2504. }
  2505. else
  2506. {
  2507. self->NPC_type = "Ugnaught2";
  2508. }
  2509. }
  2510. SP_NPC_spawner( self );
  2511. }
  2512. /*QUAKED NPC_Jawa(1 0 0) (-16 -16 -24) (16 16 40) ARMED x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2513. ARMED - starts with the Jawa gun in-hand
  2514. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2515. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2516. NOTSOLID - Starts not solid
  2517. STARTINSOLID - Don't try to fix if spawn in solid
  2518. SHY - Spawner is shy
  2519. */
  2520. void SP_NPC_Jawa( gentity_t *self)
  2521. {
  2522. if ( !self->NPC_type )
  2523. {
  2524. if ( (self->spawnflags&1) )
  2525. {
  2526. self->NPC_type = "jawa_armed";
  2527. }
  2528. else
  2529. {
  2530. self->NPC_type = "jawa";
  2531. }
  2532. }
  2533. SP_NPC_spawner( self );
  2534. }
  2535. /*QUAKED NPC_Gran(1 0 0) (-16 -16 -24) (16 16 40) SHOOTER BOXER x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2536. Uses grenade
  2537. SHOOTER - uses blaster instead of
  2538. BOXER - uses fists only
  2539. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2540. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2541. NOTSOLID - Starts not solid
  2542. STARTINSOLID - Don't try to fix if spawn in solid
  2543. SHY - Spawner is shy
  2544. */
  2545. void SP_NPC_Gran( gentity_t *self)
  2546. {
  2547. if ( !self->NPC_type )
  2548. {
  2549. if ( self->spawnflags & 1 )
  2550. {
  2551. self->NPC_type = "granshooter";
  2552. }
  2553. else if ( self->spawnflags & 2 )
  2554. {
  2555. self->NPC_type = "granboxer";
  2556. }
  2557. else
  2558. {
  2559. if ( Q_irand( 0, 1 ) )
  2560. {
  2561. self->NPC_type = "gran";
  2562. }
  2563. else
  2564. {
  2565. self->NPC_type = "gran2";
  2566. }
  2567. }
  2568. }
  2569. SP_NPC_spawner( self );
  2570. }
  2571. /*QUAKED NPC_Rodian(1 0 0) (-16 -16 -24) (16 16 40) BLASTER NO_HIDE x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2572. BLASTER uses a blaster instead of sniper rifle, different skin
  2573. NO_HIDE (only applicable with snipers) does not duck and hide between shots
  2574. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2575. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2576. NOTSOLID - Starts not solid
  2577. STARTINSOLID - Don't try to fix if spawn in solid
  2578. SHY - Spawner is shy
  2579. */
  2580. void SP_NPC_Rodian( gentity_t *self)
  2581. {
  2582. if ( !self->NPC_type )
  2583. {
  2584. if ( self->spawnflags&1 )
  2585. {
  2586. self->NPC_type = "rodian2";
  2587. }
  2588. else
  2589. {
  2590. self->NPC_type = "rodian";
  2591. }
  2592. }
  2593. SP_NPC_spawner( self );
  2594. }
  2595. /*QUAKED NPC_Weequay(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2596. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2597. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2598. NOTSOLID - Starts not solid
  2599. STARTINSOLID - Don't try to fix if spawn in solid
  2600. SHY - Spawner is shy
  2601. */
  2602. void SP_NPC_Weequay( gentity_t *self)
  2603. {
  2604. if ( !self->NPC_type )
  2605. {
  2606. switch ( Q_irand( 0, 3 ) )
  2607. {
  2608. case 0:
  2609. self->NPC_type = "Weequay";
  2610. break;
  2611. case 1:
  2612. self->NPC_type = "Weequay2";
  2613. break;
  2614. case 2:
  2615. self->NPC_type = "Weequay3";
  2616. break;
  2617. case 3:
  2618. self->NPC_type = "Weequay4";
  2619. break;
  2620. }
  2621. }
  2622. SP_NPC_spawner( self );
  2623. }
  2624. /*QUAKED NPC_Trandoshan(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2625. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2626. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2627. NOTSOLID - Starts not solid
  2628. STARTINSOLID - Don't try to fix if spawn in solid
  2629. SHY - Spawner is shy
  2630. */
  2631. void SP_NPC_Trandoshan( gentity_t *self)
  2632. {
  2633. if ( !self->NPC_type )
  2634. {
  2635. self->NPC_type = "Trandoshan";
  2636. }
  2637. SP_NPC_spawner( self );
  2638. }
  2639. /*QUAKED NPC_Tusken(1 0 0) (-16 -16 -24) (16 16 40) SNIPER x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2640. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2641. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2642. NOTSOLID - Starts not solid
  2643. STARTINSOLID - Don't try to fix if spawn in solid
  2644. SHY - Spawner is shy
  2645. */
  2646. void SP_NPC_Tusken( gentity_t *self)
  2647. {
  2648. if ( !self->NPC_type )
  2649. {
  2650. if ( (self->spawnflags&1) )
  2651. {
  2652. self->NPC_type = "tuskensniper";
  2653. }
  2654. else
  2655. {
  2656. self->NPC_type = "tusken";
  2657. }
  2658. }
  2659. SP_NPC_spawner( self );
  2660. }
  2661. /*QUAKED NPC_Noghri(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2662. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2663. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2664. NOTSOLID - Starts not solid
  2665. STARTINSOLID - Don't try to fix if spawn in solid
  2666. SHY - Spawner is shy
  2667. */
  2668. void SP_NPC_Noghri( gentity_t *self)
  2669. {
  2670. if ( !self->NPC_type )
  2671. {
  2672. self->NPC_type = "noghri";
  2673. }
  2674. SP_NPC_spawner( self );
  2675. }
  2676. /*QUAKED NPC_SwampTrooper(1 0 0) (-16 -16 -24) (16 16 40) REPEATER x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2677. REPEATER - Swaptrooper who uses the repeater
  2678. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2679. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2680. NOTSOLID - Starts not solid
  2681. STARTINSOLID - Don't try to fix if spawn in solid
  2682. SHY - Spawner is shy
  2683. */
  2684. void SP_NPC_SwampTrooper( gentity_t *self)
  2685. {
  2686. if ( !self->NPC_type )
  2687. {
  2688. if ( self->spawnflags & 1 )
  2689. {
  2690. self->NPC_type = "SwampTrooper2";
  2691. }
  2692. else
  2693. {
  2694. self->NPC_type = "SwampTrooper";
  2695. }
  2696. }
  2697. SP_NPC_spawner( self );
  2698. }
  2699. /*QUAKED NPC_Imperial(1 0 0) (-16 -16 -24) (16 16 40) OFFICER COMMANDER x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2700. Greyshirt grunt, uses blaster pistol, 20 health.
  2701. OFFICER - Brownshirt Officer, uses blaster rifle, 40 health
  2702. COMMANDER - Blackshirt Commander, uses rapid-fire blaster rifle, 80 healt
  2703. "message" - if a COMMANDER, turns on his key surface. This is the name of the key you get when you walk over his body. This must match the "message" field of the func_security_panel you want this key to open. Set to "goodie" to have him carrying a goodie key that player can use to operate doors with "GOODIE" spawnflag.
  2704. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2705. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2706. NOTSOLID - Starts not solid
  2707. STARTINSOLID - Don't try to fix if spawn in solid
  2708. SHY - Spawner is shy
  2709. */
  2710. void SP_NPC_Imperial( gentity_t *self)
  2711. {
  2712. if ( !self->NPC_type )
  2713. {
  2714. if ( self->spawnflags & 1 )
  2715. {
  2716. self->NPC_type = "ImpOfficer";
  2717. }
  2718. else if ( self->spawnflags & 2 )
  2719. {
  2720. self->NPC_type = "ImpCommander";
  2721. }
  2722. else
  2723. {
  2724. self->NPC_type = "Imperial";
  2725. }
  2726. }
  2727. SP_NPC_spawner( self );
  2728. }
  2729. /*QUAKED NPC_ImpWorker(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2730. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2731. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2732. NOTSOLID - Starts not solid
  2733. STARTINSOLID - Don't try to fix if spawn in solid
  2734. SHY - Spawner is shy
  2735. */
  2736. void SP_NPC_ImpWorker( gentity_t *self)
  2737. {
  2738. self->NPC_type = "ImpWorker";
  2739. SP_NPC_spawner( self );
  2740. }
  2741. /*QUAKED NPC_BespinCop(1 0 0) (-16 -16 -24) (16 16 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  2742. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  2743. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2744. NOTSOLID - Starts not solid
  2745. STARTINSOLID - Don't try to fix if spawn in solid
  2746. SHY - Spawner is shy
  2747. */
  2748. void SP_NPC_BespinCop( gentity_t *self)
  2749. {
  2750. if ( !self->NPC_type )
  2751. {
  2752. if ( !Q_irand( 0, 1 ) )
  2753. {
  2754. self->NPC_type = "BespinCop";
  2755. }
  2756. else
  2757. {
  2758. self->NPC_type = "BespinCop2";
  2759. }
  2760. }
  2761. SP_NPC_spawner( self );
  2762. }
  2763. /*QUAKED NPC_Reborn(1 0 0) (-16 -16 -24) (16 16 40) FORCE FENCER ACROBAT BOSS CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2764. Default Reborn is A poor lightsaber fighter, acrobatic and uses no force powers. 40 health.
  2765. FORCE - Uses force powers but is not the best lightsaber fighter and not acrobatic. 75 health.
  2766. FENCER - A good lightsaber fighter, but not acrobatic and uses no force powers. 100 health.
  2767. ACROBAT - quite acrobatic, but not the best lightsaber fighter and uses no force powers. 100 health.
  2768. BOSS - quite acrobatic, good lightsaber fighter and uses force powers. 150 health.
  2769. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2770. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2771. NOTSOLID - Starts not solid
  2772. STARTINSOLID - Don't try to fix if spawn in solid
  2773. SHY - Spawner is shy
  2774. nodelay - set to "1" to make the Reborn not stand around and taunt the player before attacking
  2775. */
  2776. void SP_NPC_Reborn( gentity_t *self)
  2777. {
  2778. if ( !self->NPC_type )
  2779. {
  2780. if ( self->spawnflags & 1 )
  2781. {
  2782. self->NPC_type = "rebornforceuser";
  2783. }
  2784. else if ( self->spawnflags & 2 )
  2785. {
  2786. self->NPC_type = "rebornfencer";
  2787. }
  2788. else if ( self->spawnflags & 4 )
  2789. {
  2790. self->NPC_type = "rebornacrobat";
  2791. }
  2792. else if ( self->spawnflags & 8 )
  2793. {
  2794. self->NPC_type = "rebornboss";
  2795. }
  2796. else
  2797. {
  2798. self->NPC_type = "reborn";
  2799. }
  2800. }
  2801. SP_NPC_spawner( self );
  2802. }
  2803. /*QUAKED NPC_Reborn_New(1 0 0) (-16 -16 -24) (16 16 40) DUAL STAFF WEAK MASTER CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2804. Reborn is an excellent lightsaber fighter, acrobatic and uses force powers. Full-length red saber, 200 health.
  2805. DUAL - Use 2 shorter sabers
  2806. STAFF - Uses a saber staff
  2807. WEAK - Is a bit less tough
  2808. MASTER - Is SUPER tough
  2809. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2810. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2811. NOTSOLID - Starts not solid
  2812. STARTINSOLID - Don't try to fix if spawn in solid
  2813. SHY - Spawner is shy
  2814. nodelay - set to "1" to make the Reborn not stand around and taunt the player before attacking
  2815. */
  2816. void SP_NPC_Reborn_New( gentity_t *self)
  2817. {
  2818. if ( !self->NPC_type )
  2819. {
  2820. if ( (self->spawnflags&8) )
  2821. {//tougher guys
  2822. if ( (self->spawnflags&1) )
  2823. {
  2824. self->NPC_type = "RebornMasterDual";
  2825. }
  2826. else if ( (self->spawnflags&2) )
  2827. {
  2828. self->NPC_type = "RebornMasterStaff";
  2829. }
  2830. else
  2831. {
  2832. self->NPC_type = "RebornMaster";
  2833. }
  2834. }
  2835. else if ( (self->spawnflags&4) )
  2836. {//weaker guys
  2837. if ( (self->spawnflags&1) )
  2838. {
  2839. self->NPC_type = "reborn_dual2";
  2840. }
  2841. else if ( (self->spawnflags&2) )
  2842. {
  2843. self->NPC_type = "reborn_staff2";
  2844. }
  2845. else
  2846. {
  2847. self->NPC_type = "reborn_new2";
  2848. }
  2849. }
  2850. else
  2851. {
  2852. if ( (self->spawnflags&1) )
  2853. {
  2854. self->NPC_type = "reborn_dual";
  2855. }
  2856. else if ( (self->spawnflags&2) )
  2857. {
  2858. self->NPC_type = "reborn_staff";
  2859. }
  2860. else
  2861. {
  2862. self->NPC_type = "reborn_new";
  2863. }
  2864. }
  2865. }
  2866. SP_NPC_spawner( self );
  2867. }
  2868. /*QUAKED NPC_Cultist_Saber(1 0 0) (-16 -16 -24) (16 16 40) MED STRONG ALL THROW CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2869. Uses a saber and no force powers. 100 health.
  2870. default fencer uses fast style - weak, but can attack rapidly. Good defense.
  2871. MED - Uses medium style - average speed and attack strength, average defense.
  2872. STRONG - Uses strong style, slower than others, but can do a lot of damage with one blow. Weak defense.
  2873. ALL - Knows all 3 styles, switches between them, good defense.
  2874. THROW - can throw their saber (level 2) - reduces their defense some (can use this spawnflag alone or in combination with any *one* of the previous 3 spawnflags)
  2875. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2876. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2877. NOTSOLID - Starts not solid
  2878. STARTINSOLID - Don't try to fix if spawn in solid
  2879. SHY - Spawner is shy
  2880. nodelay - set to "1" to make the Cultist not stand around and taunt the player before attacking
  2881. */
  2882. void SP_NPC_Cultist_Saber( gentity_t *self)
  2883. {
  2884. if ( !self->NPC_type )
  2885. {
  2886. if ( (self->spawnflags&1) )
  2887. {
  2888. if ( (self->spawnflags&8) )
  2889. {
  2890. self->NPC_type = "cultist_saber_med_throw";
  2891. }
  2892. else
  2893. {
  2894. self->NPC_type = "cultist_saber_med";
  2895. }
  2896. }
  2897. else if ( (self->spawnflags&2) )
  2898. {
  2899. if ( (self->spawnflags&8) )
  2900. {
  2901. self->NPC_type = "cultist_saber_strong_throw";
  2902. }
  2903. else
  2904. {
  2905. self->NPC_type = "cultist_saber_strong";
  2906. }
  2907. }
  2908. else if ( (self->spawnflags&2) )
  2909. {
  2910. if ( (self->spawnflags&8) )
  2911. {
  2912. self->NPC_type = "cultist_saber_all_throw";
  2913. }
  2914. else
  2915. {
  2916. self->NPC_type = "cultist_saber_all";
  2917. }
  2918. }
  2919. else
  2920. {
  2921. if ( (self->spawnflags&8) )
  2922. {
  2923. self->NPC_type = "cultist_saber_throw";
  2924. }
  2925. else
  2926. {
  2927. self->NPC_type = "cultist_saber";
  2928. }
  2929. }
  2930. }
  2931. SP_NPC_spawner( self );
  2932. }
  2933. /*QUAKED NPC_Cultist_Saber_Powers(1 0 0) (-16 -16 -24) (16 16 40) MED STRONG ALL THROW CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2934. Uses a saber and has a couple low-level powers. 150 health.
  2935. default fencer uses fast style - weak, but can attack rapidly. Good defense.
  2936. MED - Uses medium style - average speed and attack strength, average defense.
  2937. STRONG - Uses strong style, slower than others, but can do a lot of damage with one blow. Weak defense.
  2938. ALL - Knows all 3 styles, switches between them, good defense.
  2939. THROW - can throw their saber (level 2) - reduces their defense some (can use this spawnflag alone or in combination with any *one* of the previous 3 spawnflags)
  2940. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  2941. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  2942. NOTSOLID - Starts not solid
  2943. STARTINSOLID - Don't try to fix if spawn in solid
  2944. SHY - Spawner is shy
  2945. nodelay - set to "1" to make the Cultist not stand around and taunt the player before attacking
  2946. */
  2947. void SP_NPC_Cultist_Saber_Powers( gentity_t *self)
  2948. {
  2949. if ( !self->NPC_type )
  2950. {
  2951. if ( (self->spawnflags&1) )
  2952. {
  2953. if ( (self->spawnflags&8) )
  2954. {
  2955. self->NPC_type = "cultist_saber_med_throw2";
  2956. }
  2957. else
  2958. {
  2959. self->NPC_type = "cultist_saber_med2";
  2960. }
  2961. }
  2962. else if ( (self->spawnflags&2) )
  2963. {
  2964. if ( (self->spawnflags&8) )
  2965. {
  2966. self->NPC_type = "cultist_saber_strong_throw2";
  2967. }
  2968. else
  2969. {
  2970. self->NPC_type = "cultist_saber_strong2";
  2971. }
  2972. }
  2973. else if ( (self->spawnflags&2) )
  2974. {
  2975. if ( (self->spawnflags&8) )
  2976. {
  2977. self->NPC_type = "cultist_saber_all_throw2";
  2978. }
  2979. else
  2980. {
  2981. self->NPC_type = "cultist_saber_all2";
  2982. }
  2983. }
  2984. else
  2985. {
  2986. if ( (self->spawnflags&8) )
  2987. {
  2988. self->NPC_type = "cultist_saber_throw";
  2989. }
  2990. else
  2991. {
  2992. self->NPC_type = "cultist_saber2";
  2993. }
  2994. }
  2995. }
  2996. SP_NPC_spawner( self );
  2997. }
  2998. /*QUAKED NPC_Cultist(1 0 0) (-16 -16 -24) (16 16 40) SABER GRIP LIGHTNING DRAIN CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  2999. Cultist uses a blaster and force powers. 40 health.
  3000. SABER - Uses a saber and no force powers
  3001. GRIP - Uses no weapon and grip, push and pull
  3002. LIGHTNING - Uses no weapon and lightning and push
  3003. DRAIN - Uses no weapons and drain and push
  3004. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  3005. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3006. NOTSOLID - Starts not solid
  3007. STARTINSOLID - Don't try to fix if spawn in solid
  3008. SHY - Spawner is shy
  3009. nodelay - set to "1" to make the Cultist not stand around and taunt the player before attacking
  3010. */
  3011. void SP_NPC_Cultist( gentity_t *self)
  3012. {
  3013. if ( !self->NPC_type )
  3014. {
  3015. if ( (self->spawnflags&1) )
  3016. {
  3017. self->NPC_type = NULL;
  3018. self->spawnflags = 0;//fast, no throw
  3019. switch ( Q_irand( 0, 2 ) )
  3020. {
  3021. case 0://medium
  3022. self->spawnflags |= 1;
  3023. break;
  3024. case 1://strong
  3025. self->spawnflags |= 2;
  3026. break;
  3027. case 2://all
  3028. self->spawnflags |= 4;
  3029. break;
  3030. }
  3031. if ( Q_irand( 0, 1 ) )
  3032. {//throw
  3033. self->spawnflags |= 8;
  3034. }
  3035. SP_NPC_Cultist_Saber( self );
  3036. return;
  3037. }
  3038. else if ( (self->spawnflags&2) )
  3039. {
  3040. self->NPC_type = "cultist_grip";
  3041. }
  3042. else if ( (self->spawnflags&4) )
  3043. {
  3044. self->NPC_type = "cultist_lightning";
  3045. }
  3046. else if ( (self->spawnflags&8) )
  3047. {
  3048. self->NPC_type = "cultist_drain";
  3049. }
  3050. else
  3051. {
  3052. self->NPC_type = "cultist";
  3053. }
  3054. }
  3055. SP_NPC_spawner( self );
  3056. }
  3057. /*QUAKED NPC_Cultist_Commando(1 0 0) (-16 -16 -24) (16 16 40) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  3058. Cultist uses dual blaster pistols and force powers. 40 health.
  3059. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  3060. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3061. NOTSOLID - Starts not solid
  3062. STARTINSOLID - Don't try to fix if spawn in solid
  3063. SHY - Spawner is shy
  3064. nodelay - set to "1" to make the Cultist not stand around and taunt the player before attacking
  3065. */
  3066. void SP_NPC_Cultist_Commando( gentity_t *self)
  3067. {
  3068. if ( !self->NPC_type )
  3069. {
  3070. self->NPC_type = "cultistcommando";
  3071. }
  3072. SP_NPC_spawner( self );
  3073. }
  3074. /*QUAKED NPC_Cultist_Destroyer(1 0 0) (-16 -16 -24) (16 16 40) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  3075. Cultist has no weapons, runs up to you chanting & building up a Force Destruction blast - when gets to you, screams & explodes
  3076. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  3077. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3078. NOTSOLID - Starts not solid
  3079. STARTINSOLID - Don't try to fix if spawn in solid
  3080. SHY - Spawner is shy
  3081. */
  3082. void SP_NPC_Cultist_Destroyer( gentity_t *self)
  3083. {
  3084. self->NPC_type = "cultist_destroyer";
  3085. SP_NPC_spawner( self );
  3086. }
  3087. /*QUAKED NPC_ShadowTrooper(1 0 0) (-16 -16 -24) (16 16 40) x x x x CEILING CINEMATIC NOTSOLID STARTINSOLID SHY
  3088. CEILING - Sticks to the ceiling until he sees an enemy or takes pain
  3089. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3090. NOTSOLID - Starts not solid
  3091. STARTINSOLID - Don't try to fix if spawn in solid
  3092. SHY - Spawner is shy
  3093. nodelay - set to "1" to make the Cultist not stand around and taunt the player before attacking
  3094. */
  3095. void SP_NPC_ShadowTrooper( gentity_t *self)
  3096. {
  3097. if(!self->NPC_type)
  3098. {
  3099. if ( !Q_irand( 0, 1 ) )
  3100. {
  3101. self->NPC_type = "ShadowTrooper";
  3102. }
  3103. else
  3104. {
  3105. self->NPC_type = "ShadowTrooper2";
  3106. }
  3107. }
  3108. SP_NPC_spawner( self );
  3109. }
  3110. /*QUAKED NPC_Saboteur(1 0 0) (-16 -16 -24) (16 16 40) SNIPER PISTOL x x CLOAKED CINEMATIC NOTSOLID STARTINSOLID SHY
  3111. Has a blaster rifle, can cloak and roll
  3112. SNIPER - Has a sniper rifle, no acrobatics, but can dodge
  3113. PISTOL - Just has a pistol, can roll
  3114. COMMANDO - Has 2 pistols and can roll & dodge
  3115. CLOAKED - Starts cloaked
  3116. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3117. NOTSOLID - Starts not solid
  3118. STARTINSOLID - Don't try to fix if spawn in solid
  3119. SHY - Spawner is shy
  3120. */
  3121. void SP_NPC_Saboteur( gentity_t *self)
  3122. {
  3123. if ( !self->NPC_type )
  3124. {
  3125. if ( (self->spawnflags&1) )
  3126. {
  3127. self->NPC_type = "saboteursniper";
  3128. }
  3129. else if ( (self->spawnflags&2) )
  3130. {
  3131. self->NPC_type = "saboteurpistol";
  3132. }
  3133. else if ( (self->spawnflags&4) )
  3134. {
  3135. self->NPC_type = "saboteurcommando";
  3136. }
  3137. else
  3138. {
  3139. self->NPC_type = "saboteur";
  3140. }
  3141. }
  3142. SP_NPC_spawner( self );
  3143. }
  3144. //=============================================================================================
  3145. //MONSTERS
  3146. //=============================================================================================
  3147. /*QUAKED NPC_Monster_Murjj (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3148. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3149. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3150. NOTSOLID - Starts not solid
  3151. STARTINSOLID - Don't try to fix if spawn in solid
  3152. SHY - Spawner is shy
  3153. */
  3154. void SP_NPC_Monster_Murjj( gentity_t *self)
  3155. {
  3156. self->NPC_type = "Murjj";
  3157. SP_NPC_spawner( self );
  3158. }
  3159. /*QUAKED NPC_Monster_Swamp (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3160. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3161. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3162. NOTSOLID - Starts not solid
  3163. STARTINSOLID - Don't try to fix if spawn in solid
  3164. SHY - Spawner is shy
  3165. */
  3166. void SP_NPC_Monster_Swamp( gentity_t *self)
  3167. {
  3168. self->NPC_type = "Swamp";
  3169. SP_NPC_spawner( self );
  3170. }
  3171. /*QUAKED NPC_Monster_Howler (1 0 0) (-16 -16 -24) (16 16 8) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3172. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3173. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3174. NOTSOLID - Starts not solid
  3175. STARTINSOLID - Don't try to fix if spawn in solid
  3176. SHY - Spawner is shy
  3177. */
  3178. void SP_NPC_Monster_Howler( gentity_t *self)
  3179. {
  3180. self->NPC_type = "howler";
  3181. SP_NPC_spawner( self );
  3182. }
  3183. /*QUAKED NPC_Monster_Rancor (1 0 0) (-30 -30 -24) (30 30 136) MUTANT FASTKILL x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3184. 2000 health, picks people up and eats them
  3185. MUTANT - Bigger, meaner, nastier, Frencher. Breath attack, pound attack.
  3186. FASTKILL - Kills NPCs faster
  3187. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3188. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3189. NOTSOLID - Starts not solid
  3190. STARTINSOLID - Don't try to fix if spawn in solid
  3191. SHY - Spawner is shy
  3192. */
  3193. void SP_NPC_Monster_Rancor( gentity_t *self)
  3194. {
  3195. if ( (self->spawnflags&1) )
  3196. {
  3197. self->NPC_type = "mutant_rancor";
  3198. }
  3199. else
  3200. {
  3201. self->NPC_type = "rancor";
  3202. }
  3203. SP_NPC_spawner( self );
  3204. }
  3205. /*QUAKED NPC_Monster_Mutant_Rancor (1 0 0) (-60 -60 -24) (60 60 360) x FASTKILL x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3206. Bigger, meaner, nastier, Frencher. Breath attack, pound attack.
  3207. FASTKILL - Kills NPCs faster
  3208. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3209. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3210. NOTSOLID - Starts not solid
  3211. STARTINSOLID - Don't try to fix if spawn in solid
  3212. SHY - Spawner is shy
  3213. */
  3214. void SP_NPC_Monster_Mutant_Rancor( gentity_t *self)
  3215. {
  3216. self->NPC_type = "mutant_rancor";
  3217. SP_NPC_spawner( self );
  3218. }
  3219. /*QUAKED NPC_Monster_Wampa (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3220. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3221. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3222. NOTSOLID - Starts not solid
  3223. STARTINSOLID - Don't try to fix if spawn in solid
  3224. SHY - Spawner is shy
  3225. */
  3226. void SP_NPC_Monster_Wampa( gentity_t *self)
  3227. {
  3228. self->NPC_type = "wampa";
  3229. SP_NPC_spawner( self );
  3230. }
  3231. /*QUAKED NPC_MineMonster (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3232. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3233. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3234. NOTSOLID - Starts not solid
  3235. STARTINSOLID - Don't try to fix if spawn in solid
  3236. SHY - Spawner is shy
  3237. */
  3238. void SP_NPC_MineMonster( gentity_t *self)
  3239. {
  3240. self->NPC_type = "minemonster";
  3241. SP_NPC_spawner( self );
  3242. }
  3243. /*QUAKED NPC_Monster_Claw (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3244. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3245. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3246. NOTSOLID - Starts not solid
  3247. STARTINSOLID - Don't try to fix if spawn in solid
  3248. SHY - Spawner is shy
  3249. */
  3250. void SP_NPC_Monster_Claw( gentity_t *self)
  3251. {
  3252. self->NPC_type = "Claw";
  3253. SP_NPC_spawner( self );
  3254. }
  3255. /*QUAKED NPC_Monster_Glider (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3256. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3257. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3258. NOTSOLID - Starts not solid
  3259. STARTINSOLID - Don't try to fix if spawn in solid
  3260. SHY - Spawner is shy
  3261. */
  3262. void SP_NPC_Monster_Glider( gentity_t *self)
  3263. {
  3264. self->NPC_type = "Glider";
  3265. SP_NPC_spawner( self );
  3266. }
  3267. /*QUAKED NPC_Monster_Flier2 (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3268. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3269. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3270. NOTSOLID - Starts not solid
  3271. STARTINSOLID - Don't try to fix if spawn in solid
  3272. SHY - Spawner is shy
  3273. */
  3274. void SP_NPC_Monster_Flier2( gentity_t *self)
  3275. {
  3276. self->NPC_type = "Flier2";
  3277. SP_NPC_spawner( self );
  3278. }
  3279. /*QUAKED NPC_Monster_Lizard (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3280. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3281. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3282. NOTSOLID - Starts not solid
  3283. STARTINSOLID - Don't try to fix if spawn in solid
  3284. SHY - Spawner is shy
  3285. */
  3286. void SP_NPC_Monster_Lizard( gentity_t *self)
  3287. {
  3288. self->NPC_type = "Lizard";
  3289. SP_NPC_spawner( self );
  3290. }
  3291. /*QUAKED NPC_Monster_Fish (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3292. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3293. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3294. NOTSOLID - Starts not solid
  3295. STARTINSOLID - Don't try to fix if spawn in solid
  3296. SHY - Spawner is shy
  3297. */
  3298. void SP_NPC_Monster_Fish( gentity_t *self)
  3299. {
  3300. self->NPC_type = "Fish";
  3301. SP_NPC_spawner( self );
  3302. }
  3303. /*QUAKED NPC_Monster_Sand_Creature (1 0 0) (-24 -24 -24) (24 24 0) FAST x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3304. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3305. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3306. NOTSOLID - Starts not solid
  3307. STARTINSOLID - Don't try to fix if spawn in solid
  3308. SHY - Spawner is shy
  3309. turfrange - if set, they will not go beyond this dist from their spawn position
  3310. */
  3311. void SP_NPC_Monster_Sand_Creature( gentity_t *self)
  3312. {
  3313. if ( (self->spawnflags&1) )
  3314. {
  3315. self->NPC_type = "sand_creature_fast";
  3316. }
  3317. else
  3318. {
  3319. self->NPC_type = "sand_creature";
  3320. }
  3321. SP_NPC_spawner( self );
  3322. }
  3323. //=============================================================================================
  3324. //DROIDS
  3325. //=============================================================================================
  3326. /*QUAKED NPC_Droid_Interrogator (1 0 0) (-12 -12 -24) (12 12 0) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3327. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3328. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3329. NOTSOLID - Starts not solid
  3330. STARTINSOLID - Don't try to fix if spawn in solid
  3331. SHY - Spawner is shy
  3332. */
  3333. void SP_NPC_Droid_Interrogator( gentity_t *self)
  3334. {
  3335. self->NPC_type = "interrogator";
  3336. SP_NPC_spawner( self );
  3337. }
  3338. /*QUAKED NPC_Droid_Probe (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3339. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3340. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3341. NOTSOLID - Starts not solid
  3342. STARTINSOLID - Don't try to fix if spawn in solid
  3343. SHY - Spawner is shy
  3344. Imperial Probe Droid - the multilegged floating droid that Han and Chewie shot on the ice planet Hoth
  3345. */
  3346. void SP_NPC_Droid_Probe( gentity_t *self)
  3347. {
  3348. self->NPC_type = "probe";
  3349. SP_NPC_spawner( self );
  3350. }
  3351. /*QUAKED NPC_Droid_Mark1 (1 0 0) (-36 -36 -24) (36 36 80) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3352. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3353. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3354. NOTSOLID - Starts not solid
  3355. STARTINSOLID - Don't try to fix if spawn in solid
  3356. SHY - Spawner is shy
  3357. Big walking droid
  3358. */
  3359. void SP_NPC_Droid_Mark1( gentity_t *self)
  3360. {
  3361. self->NPC_type = "mark1";
  3362. SP_NPC_spawner( self );
  3363. }
  3364. /*QUAKED NPC_Droid_Mark2 (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3365. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3366. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3367. NOTSOLID - Starts not solid
  3368. STARTINSOLID - Don't try to fix if spawn in solid
  3369. SHY - Spawner is shy
  3370. Small rolling droid with one gun.
  3371. */
  3372. void SP_NPC_Droid_Mark2( gentity_t *self)
  3373. {
  3374. self->NPC_type = "mark2";
  3375. SP_NPC_spawner( self );
  3376. }
  3377. /*QUAKED NPC_Droid_ATST (1 0 0) (-40 -40 -24) (40 40 248) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3378. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3379. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3380. NOTSOLID - Starts not solid
  3381. STARTINSOLID - Don't try to fix if spawn in solid
  3382. SHY - Spawner is shy
  3383. */
  3384. void SP_NPC_Droid_ATST( gentity_t *self)
  3385. {
  3386. self->NPC_type = "atst";
  3387. SP_NPC_spawner( self );
  3388. }
  3389. /*QUAKED NPC_Droid_Remote (1 0 0) (-4 -4 -24) (4 4 8) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3390. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3391. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3392. NOTSOLID - Starts not solid
  3393. STARTINSOLID - Don't try to fix if spawn in solid
  3394. SHY - Spawner is shy
  3395. Remote Droid - the floating round droid used by Obi Wan to train Luke about the force while on the Millenium Falcon.
  3396. */
  3397. void SP_NPC_Droid_Remote( gentity_t *self)
  3398. {
  3399. self->NPC_type = "remote_sp";
  3400. SP_NPC_spawner( self );
  3401. }
  3402. /*QUAKED NPC_Droid_Seeker (1 0 0) (-4 -4 -24) (4 4 8) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3403. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3404. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3405. NOTSOLID - Starts not solid
  3406. STARTINSOLID - Don't try to fix if spawn in solid
  3407. SHY - Spawner is shy
  3408. Seeker Droid - floating round droids that shadow troopers spawn
  3409. */
  3410. void SP_NPC_Droid_Seeker( gentity_t *self)
  3411. {
  3412. self->NPC_type = "seeker";
  3413. SP_NPC_spawner( self );
  3414. }
  3415. /*QUAKED NPC_Droid_Sentry (1 0 0) (-24 -24 -24) (24 24 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3416. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3417. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3418. NOTSOLID - Starts not solid
  3419. STARTINSOLID - Don't try to fix if spawn in solid
  3420. SHY - Spawner is shy
  3421. Sentry Droid - Large, armored floating Imperial droids with 3 forward-facing gun turrets
  3422. */
  3423. void SP_NPC_Droid_Sentry( gentity_t *self)
  3424. {
  3425. self->NPC_type = "sentry";
  3426. SP_NPC_spawner( self );
  3427. }
  3428. /*QUAKED NPC_Droid_Gonk (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3429. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3430. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3431. NOTSOLID - Starts not solid
  3432. STARTINSOLID - Don't try to fix if spawn in solid
  3433. SHY - Spawner is shy
  3434. Gonk Droid - the droid that looks like a walking ice machine. Was in the Jawa land crawler, walking around talking to itself.
  3435. NOTARGET by default
  3436. */
  3437. void SP_NPC_Droid_Gonk( gentity_t *self)
  3438. {
  3439. self->NPC_type = "gonk";
  3440. SP_NPC_spawner( self );
  3441. }
  3442. /*QUAKED NPC_Droid_Mouse (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3443. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3444. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3445. NOTSOLID - Starts not solid
  3446. STARTINSOLID - Don't try to fix if spawn in solid
  3447. SHY - Spawner is shy
  3448. Mouse Droid - small, box shaped droid, first seen on the Death Star. Chewie yelled at it and it backed up and ran away.
  3449. NOTARGET by default
  3450. */
  3451. void SP_NPC_Droid_Mouse( gentity_t *self)
  3452. {
  3453. self->NPC_type = "mouse";
  3454. SP_NPC_spawner( self );
  3455. }
  3456. /*QUAKED NPC_Droid_R2D2 (1 0 0) (-12 -12 -24) (12 12 40) IMPERIAL x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3457. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3458. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3459. NOTSOLID - Starts not solid
  3460. STARTINSOLID - Don't try to fix if spawn in solid
  3461. SHY - Spawner is shy
  3462. R2D2 Droid - you probably know this one already.
  3463. NOTARGET by default
  3464. */
  3465. void SP_NPC_Droid_R2D2( gentity_t *self)
  3466. {
  3467. if ( self->spawnflags&1 )
  3468. {//imperial skin
  3469. self->NPC_type = "r2d2_imp";
  3470. }
  3471. else
  3472. {
  3473. self->NPC_type = "r2d2";
  3474. }
  3475. SP_NPC_spawner( self );
  3476. }
  3477. /*QUAKED NPC_Droid_R5D2 (1 0 0) (-12 -12 -24) (12 12 40) IMPERIAL ALWAYSDIE x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3478. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3479. ALWAYSDIE - won't go into spinning zombie AI when at low health.
  3480. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3481. NOTSOLID - Starts not solid
  3482. STARTINSOLID - Don't try to fix if spawn in solid
  3483. SHY - Spawner is shy
  3484. R5D2 Droid - the droid originally chosen by Uncle Owen until it blew a bad motivator, and they took R2D2 instead.
  3485. NOTARGET by default
  3486. */
  3487. void SP_NPC_Droid_R5D2( gentity_t *self)
  3488. {
  3489. if ( self->spawnflags&1 )
  3490. {//imperial skin
  3491. self->NPC_type = "r5d2_imp";
  3492. }
  3493. else
  3494. {
  3495. self->NPC_type = "r5d2";
  3496. }
  3497. SP_NPC_spawner( self );
  3498. }
  3499. /*QUAKED NPC_Droid_Protocol (1 0 0) (-12 -12 -24) (12 12 40) IMPERIAL x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3500. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3501. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3502. NOTSOLID - Starts not solid
  3503. STARTINSOLID - Don't try to fix if spawn in solid
  3504. SHY - Spawner is shy
  3505. NOTARGET by default
  3506. */
  3507. void SP_NPC_Droid_Protocol( gentity_t *self)
  3508. {
  3509. if ( self->spawnflags&1 )
  3510. {//imperial skin
  3511. self->NPC_type = "protocol_imp";
  3512. }
  3513. else
  3514. {
  3515. self->NPC_type = "protocol";
  3516. }
  3517. SP_NPC_spawner( self );
  3518. }
  3519. /*QUAKED NPC_Droid_Assassin (1 0 0) (-12 -12 -24) (12 12 40) x x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3520. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3521. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3522. NOTSOLID - Starts not solid
  3523. STARTINSOLID - Don't try to fix if spawn in solid
  3524. SHY - Spawner is shy
  3525. */
  3526. void SP_NPC_Droid_Assassin( gentity_t *self)
  3527. {
  3528. if ( !self->NPC_type )
  3529. {
  3530. self->NPC_type = "assassin_droid";
  3531. }
  3532. SP_NPC_spawner( self );
  3533. }
  3534. /*QUAKED NPC_Droid_Saber (1 0 0) (-12 -12 -24) (12 12 40) TRAINING x x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY
  3535. DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it
  3536. CINEMATIC - Will spawn with no default AI (BS_CINEMATIC)
  3537. NOTSOLID - Starts not solid
  3538. STARTINSOLID - Don't try to fix if spawn in solid
  3539. SHY - Spawner is shy
  3540. */
  3541. void SP_NPC_Droid_Saber( gentity_t *self)
  3542. {
  3543. if ( !self->NPC_type )
  3544. {
  3545. if ( (self->spawnflags&1) )
  3546. {
  3547. self->NPC_type = "saber_droid_training";
  3548. }
  3549. else
  3550. {
  3551. self->NPC_type = "saber_droid";
  3552. }
  3553. }
  3554. SP_NPC_spawner( self );
  3555. }
  3556. //NPC console commands
  3557. /*
  3558. NPC_Spawn_f
  3559. */
  3560. static void NPC_Spawn_f(void)
  3561. {
  3562. gentity_t *NPCspawner = G_Spawn();
  3563. vec3_t forward, end;
  3564. trace_t trace;
  3565. qboolean isVehicle = qfalse;
  3566. if(!NPCspawner)
  3567. {
  3568. gi.Printf( S_COLOR_RED"NPC_Spawn Error: Out of entities!\n" );
  3569. return;
  3570. }
  3571. NPCspawner->e_ThinkFunc = thinkF_G_FreeEntity;
  3572. NPCspawner->nextthink = level.time + FRAMETIME;
  3573. char *npc_type = gi.argv( 2 );
  3574. if (!npc_type )
  3575. {
  3576. gi.Printf( S_COLOR_RED"Error, expected:\n NPC spawn [NPC type (from NCPCs.cfg)]\n" );
  3577. return;
  3578. }
  3579. if ( !Q_stricmp( "vehicle", npc_type ) )
  3580. {//spawning a vehicle
  3581. isVehicle = qtrue;
  3582. npc_type = gi.argv( 3 );
  3583. if (!npc_type )
  3584. {
  3585. gi.Printf( S_COLOR_RED"Error, expected:\n NPC spawn vehicle [NPC type (from NCPCs.cfg)]\n" );
  3586. return;
  3587. }
  3588. }
  3589. //Spawn it at spot of first player
  3590. //FIXME: will gib them!
  3591. AngleVectors(g_entities[0].client->ps.viewangles, forward, NULL, NULL);
  3592. VectorNormalize(forward);
  3593. VectorMA(g_entities[0].currentOrigin, 64, forward, end);
  3594. gi.trace(&trace, g_entities[0].currentOrigin, NULL, NULL, end, 0, MASK_SOLID);
  3595. VectorCopy(trace.endpos, end);
  3596. end[2] -= 24;
  3597. gi.trace(&trace, trace.endpos, NULL, NULL, end, 0, MASK_SOLID);
  3598. VectorCopy(trace.endpos, end);
  3599. end[2] += 24;
  3600. G_SetOrigin(NPCspawner, end);
  3601. VectorCopy(NPCspawner->currentOrigin, NPCspawner->s.origin);
  3602. //set the yaw so that they face away from player
  3603. NPCspawner->s.angles[1] = g_entities[0].client->ps.viewangles[1];
  3604. gi.linkentity(NPCspawner);
  3605. NPCspawner->NPC_type = strlwr( G_NewString( npc_type ) );
  3606. NPCspawner->NPC_targetname = G_NewString(gi.argv( 3 ));
  3607. NPCspawner->count = 1;
  3608. NPCspawner->delay = 0;
  3609. NPCspawner->wait = 500;
  3610. //NPCspawner->spawnflags |= SFB_NOTSOLID;
  3611. //NPCspawner->playerTeam = TEAM_FREE;
  3612. //NPCspawner->behaviorSet[BSET_SPAWN] = "common/guard";
  3613. if ( isVehicle )
  3614. {//must let NPC spawn func know this is a vehicle we're trying to spawn
  3615. NPCspawner->classname = "NPC_Vehicle";
  3616. }
  3617. NPC_PrecacheByClassName(NPCspawner->NPC_type);
  3618. if ( !Q_stricmp( "kyle_boss", NPCspawner->NPC_type ))
  3619. {//bah
  3620. NPCspawner->spawnflags |= 1;
  3621. }
  3622. if ( !Q_stricmp( "key", NPCspawner->NPC_type ))
  3623. {//bah
  3624. NPCspawner->message = "key";
  3625. NPCspawner->NPC_type = "imperial";
  3626. }
  3627. if ( !Q_stricmp( "jedi_random", NPCspawner->NPC_type ) )
  3628. {//special case, for testing
  3629. NPCspawner->NPC_type = NULL;
  3630. NPCspawner->spawnflags |= 4;
  3631. SP_NPC_Jedi( NPCspawner );
  3632. }
  3633. else
  3634. {
  3635. NPC_Spawn( NPCspawner, NPCspawner, NPCspawner );
  3636. }
  3637. }
  3638. /*
  3639. NPC_Kill_f
  3640. */
  3641. void NPC_Kill_f( void )
  3642. {
  3643. int n;
  3644. gentity_t *player;
  3645. char *name;
  3646. team_t killTeam = TEAM_FREE;
  3647. qboolean killNonSF = qfalse;
  3648. name = gi.argv( 2 );
  3649. if ( !*name || !name[0] )
  3650. {
  3651. gi.Printf( S_COLOR_RED"Error, Expected:\n");
  3652. gi.Printf( S_COLOR_RED"NPC kill '[NPC targetname]' - kills NPCs with certain targetname\n" );
  3653. gi.Printf( S_COLOR_RED"or\n" );
  3654. gi.Printf( S_COLOR_RED"NPC kill 'all' - kills all NPCs\n" );
  3655. gi.Printf( S_COLOR_RED"or\n" );
  3656. gi.Printf( S_COLOR_RED"NPC team '[teamname]' - kills all NPCs of a certain team ('nonally' is all but your allies)\n" );
  3657. return;
  3658. }
  3659. if ( Q_stricmp( "team", name ) == 0 )
  3660. {
  3661. name = gi.argv( 3 );
  3662. if ( !*name || !name[0] )
  3663. {
  3664. gi.Printf( S_COLOR_RED"NPC_Kill Error: 'npc kill team' requires a team name!\n" );
  3665. gi.Printf( S_COLOR_RED"Valid team names are:\n");
  3666. for ( n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
  3667. {
  3668. gi.Printf( S_COLOR_RED"%s\n", GetStringForID( TeamTable, n ) );
  3669. }
  3670. gi.Printf( S_COLOR_RED"nonally - kills all but your teammates\n" );
  3671. return;
  3672. }
  3673. if ( Q_stricmp( "nonally", name ) == 0 )
  3674. {
  3675. killNonSF = qtrue;
  3676. }
  3677. else
  3678. {
  3679. killTeam = (team_t)GetIDForString( TeamTable, name );
  3680. if ( killTeam == -1 )
  3681. {
  3682. gi.Printf( S_COLOR_RED"NPC_Kill Error: team '%s' not recognized\n", name );
  3683. gi.Printf( S_COLOR_RED"Valid team names are:\n");
  3684. for ( n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
  3685. {
  3686. gi.Printf( S_COLOR_RED"%s\n", GetStringForID( TeamTable, n ) );
  3687. }
  3688. gi.Printf( S_COLOR_RED"nonally - kills all but your teammates\n" );
  3689. return;
  3690. }
  3691. }
  3692. }
  3693. for ( n = 1; n < ENTITYNUM_MAX_NORMAL; n++)
  3694. {
  3695. player = &g_entities[n];
  3696. if (!player->inuse) {
  3697. continue;
  3698. }
  3699. if ( killNonSF )
  3700. {
  3701. if ( player )
  3702. {
  3703. if ( player->client )
  3704. {
  3705. if ( player->client->playerTeam != TEAM_PLAYER )
  3706. {
  3707. gi.Printf( S_COLOR_GREEN"Killing NPC %s named %s\n", player->NPC_type, player->targetname );
  3708. /*
  3709. if ( (player->flags&FL_UNDYING) )
  3710. {
  3711. G_Damage( player, NULL, NULL, NULL, NULL, player->health+10000, 0, MOD_UNKNOWN );
  3712. }
  3713. else
  3714. */
  3715. {
  3716. player->health = 0;
  3717. GEntity_DieFunc(player, player, player, player->max_health, MOD_UNKNOWN);
  3718. }
  3719. }
  3720. }
  3721. else if ( player->NPC_type && player->classname && player->classname[0] && Q_stricmp( "NPC_starfleet", player->classname ) != 0 )
  3722. {//A spawner, remove it
  3723. gi.Printf( S_COLOR_GREEN"Removing NPC spawner %s with NPC named %s\n", player->NPC_type, player->NPC_targetname );
  3724. G_FreeEntity( player );
  3725. //FIXME: G_UseTargets2(player, player, player->NPC_target & player->target);?
  3726. }
  3727. }
  3728. }
  3729. else if ( player && player->NPC && player->client )
  3730. {
  3731. if ( killTeam != TEAM_FREE )
  3732. {
  3733. if ( player->client->playerTeam == killTeam )
  3734. {
  3735. gi.Printf( S_COLOR_GREEN"Killing NPC %s named %s\n", player->NPC_type, player->targetname );
  3736. /*
  3737. if ( (player->flags&FL_UNDYING) )
  3738. {
  3739. G_Damage( player, NULL, NULL, NULL, NULL, player->health+10000, 0, MOD_UNKNOWN );
  3740. }
  3741. else
  3742. */
  3743. {
  3744. player->health = 0;
  3745. GEntity_DieFunc(player, player, player, player->max_health, MOD_UNKNOWN);
  3746. }
  3747. }
  3748. }
  3749. else if( (player->targetname && Q_stricmp( name, player->targetname ) == 0)
  3750. || Q_stricmp( name, "all" ) == 0 )
  3751. {
  3752. gi.Printf( S_COLOR_GREEN"Killing NPC %s named %s\n", player->NPC_type, player->targetname );
  3753. player->client->ps.stats[STAT_HEALTH] = 0;
  3754. /*
  3755. if ( (player->flags&FL_UNDYING) )
  3756. {
  3757. G_Damage( player, NULL, NULL, NULL, NULL, player->health+10000, 0, MOD_UNKNOWN );
  3758. }
  3759. else
  3760. */
  3761. {
  3762. player->health = 0;
  3763. GEntity_DieFunc(player, player, player, 100, MOD_UNKNOWN);
  3764. }
  3765. }
  3766. }
  3767. else if ( player && (player->svFlags&SVF_NPC_PRECACHE) )
  3768. {//a spawner
  3769. if( (player->targetname && Q_stricmp( name, player->targetname ) == 0)
  3770. || Q_stricmp( name, "all" ) == 0 )
  3771. {
  3772. gi.Printf( S_COLOR_GREEN"Removing NPC spawner %s named %s\n", player->NPC_type, player->targetname );
  3773. G_FreeEntity( player );
  3774. }
  3775. }
  3776. }
  3777. }
  3778. void NPC_PrintScore( gentity_t *ent )
  3779. {
  3780. gi.Printf( "%s: %d\n", ent->targetname, ent->client->ps.persistant[PERS_SCORE] );
  3781. }
  3782. /*
  3783. Svcmd_NPC_f
  3784. parse and dispatch bot commands
  3785. */
  3786. qboolean showBBoxes = qfalse;
  3787. void Svcmd_NPC_f( void )
  3788. {
  3789. char *cmd;
  3790. cmd = gi.argv( 1 );
  3791. if ( !*cmd )
  3792. {
  3793. gi.Printf( "Valid NPC commands are:\n" );
  3794. gi.Printf( " spawn [NPC type (from *.npc files)]\n" );
  3795. gi.Printf( " spawn vehicle [NPC type (from *.npc files, only for NPCs that are CLASS_VEHICLE and have a .veh file)]\n" );
  3796. gi.Printf( " kill [NPC targetname] or [all(kills all NPCs)] or 'team [teamname]'\n" );
  3797. gi.Printf( " showbounds (draws exact bounding boxes of NPCs)\n" );
  3798. gi.Printf( " score [NPC targetname] (prints number of kills per NPC)\n" );
  3799. }
  3800. else if ( Q_stricmp( cmd, "spawn" ) == 0 )
  3801. {
  3802. NPC_Spawn_f();
  3803. }
  3804. else if ( Q_stricmp( cmd, "kill" ) == 0 )
  3805. {
  3806. NPC_Kill_f();
  3807. }
  3808. else if ( Q_stricmp( cmd, "showbounds" ) == 0 )
  3809. {//Toggle on and off
  3810. showBBoxes = showBBoxes ? qfalse : qtrue;
  3811. }
  3812. else if ( Q_stricmp ( cmd, "score" ) == 0 )
  3813. {
  3814. char *cmd2 = gi.argv(2);
  3815. gentity_t *ent = NULL;
  3816. if ( !cmd2 || !cmd2[0] )
  3817. {//Show the score for all NPCs
  3818. gi.Printf( "SCORE LIST:\n" );
  3819. for ( int i = 0; i < ENTITYNUM_WORLD; i++ )
  3820. {
  3821. ent = &g_entities[i];
  3822. if ( !ent || !ent->client )
  3823. {
  3824. continue;
  3825. }
  3826. NPC_PrintScore( ent );
  3827. }
  3828. }
  3829. else
  3830. {
  3831. if ( (ent = G_Find( NULL, FOFS(targetname), cmd2 )) != NULL && ent->client )
  3832. {
  3833. NPC_PrintScore( ent );
  3834. }
  3835. else
  3836. {
  3837. gi.Printf( "ERROR: NPC score - no such NPC %s\n", cmd2 );
  3838. }
  3839. }
  3840. }
  3841. }