Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.66 KB | None | 0 0
  1. //========================================================================
  2. //
  3. // DOOMBRINGER : CSQC code
  4. //
  5. // Copyright (C) 2015 - 2018 Kristian Kaell
  6. // Copyright (C) 2015 Andrew Apted
  7. //
  8. // This code is free software; you can redistribute it and/or modify
  9. // it under the terms of the GNU GPL (General Public License); either
  10. // version 2 of the License, or (at your option) any later version.
  11. //
  12. //========================================================================
  13.  
  14.  
  15. /* Player entity handling */
  16.  
  17. float torso_first_bone = 5;
  18. float torso_last_bone = 73;
  19.  
  20. float last_time;
  21. float current_viewzoom;
  22. float view_quality = 1;
  23.  
  24. .float torso_frame;
  25. .float torso_lerpfrac;
  26. .float torso_frame1time;
  27. .float torso_frame2;
  28. .float torso_frame2time;
  29. .float back_bone;
  30. .float back_bone2;
  31.  
  32. .float fx_time;
  33. .float fx_flags;
  34.  
  35. .vector fx_dest;
  36.  
  37. .float fx_owner; // numeric value of engine-drawn ent, can only use with getentity()
  38.  
  39. .float fx_enemy;
  40. .float team;
  41. .float deadflag;
  42.  
  43. .float fx_along;
  44.  
  45. float autocvar_cl_playeravatar;
  46. string autocvar_cl_playercountry;
  47. float autocvar_cl_forcemodels;
  48. float autocvar_cl_forceskins;
  49. float autocvar_cl_forcecolors;
  50. float autocvar_cl_forceglow;
  51. float autocvar_cl_forcecorpsecolor;
  52. float autocvar_snd_clientsndvol;
  53. float autocvar_snd_warningsndvol;
  54. float autocvar_cl_playerdetailreduction;
  55. float surface;
  56.  
  57. string autocvar_enemymodel;
  58. float autocvar_enemyskin;
  59. float autocvar_enemycolor;
  60. float autocvar_corpsecolor;
  61. string autocvar_enemyglow;
  62. string autocvar_glow;
  63. float localteam;
  64. float teamcolor;
  65. float teamskin;
  66.  
  67. vector view_origin, view_forward, view_right, view_up;
  68.  
  69. // detect changes in 'enemymodel' cvar, load new model on changes
  70. string enemymodel;
  71. string teammodel;
  72. string zs_enemymodel_latch;
  73. string zs_defaultmodel_latch;
  74.  
  75. void CheckClientCountry(float force_send);
  76. void CheckClientAvatar(float force_send);
  77.  
  78.  
  79. void startanim(entity e, float f)
  80. {
  81. e.frame2 = e.frame;
  82. e.frame2time = e.frame1time;
  83. e.lerpfrac = 1.0;
  84. e.frame = f;
  85. //e.frame1time = time;
  86. }
  87.  
  88. float fexists(string f)
  89. {
  90. float fh = fopen(f, FILE_READ);
  91. if (fh < 0) return false;
  92. fclose(fh);
  93. return true;
  94. }
  95.  
  96. // FEATURE: LOD from Xonotic
  97. .float lodmodelindex0;
  98. .float lodmodelindex1;
  99. .float lodmodelindex2;
  100. void CSQCPlayer_LOD_Apply(entity this)
  101. {
  102. // LOD model loading
  103. if(this.lodmodelindex0 != this.modelindex)
  104. {
  105. string modelname = this.model;
  106. string s;
  107.  
  108. vector mi = this.mins;
  109. vector ma = this.maxs;
  110.  
  111. // set modelindex
  112. this.lodmodelindex0 = this.modelindex;
  113. this.lodmodelindex1 = this.modelindex;
  114. this.lodmodelindex2 = this.modelindex;
  115.  
  116. // FIXME: this only supports 3-letter extensions
  117. s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
  118. if(fexists(s))
  119. {
  120. precache_model(s);
  121. setmodel(this, s);
  122. if(this.modelindex)
  123. this.lodmodelindex1 = this.modelindex;
  124. }
  125.  
  126. s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
  127. if(fexists(s))
  128. {
  129. precache_model(s);
  130. setmodel(this, s);
  131. if(this.modelindex)
  132. this.lodmodelindex2 = this.modelindex;
  133. }
  134.  
  135. setmodel(this, modelname); // make everything normal again
  136. setsize(this, mi, ma);
  137. }
  138.  
  139. // apply LOD
  140. if(autocvar_cl_playerdetailreduction <= 0)
  141. {
  142. if(autocvar_cl_playerdetailreduction <= -2)
  143. this.modelindex = this.lodmodelindex2;
  144. else if(autocvar_cl_playerdetailreduction <= -1)
  145. this.modelindex = this.lodmodelindex1;
  146. else
  147. this.modelindex = this.lodmodelindex0;
  148. }
  149. else
  150. {
  151. float distance = vlen(this.origin - view_origin);
  152. float f = (distance * current_viewzoom + 100.0) * autocvar_cl_playerdetailreduction;
  153. f *= 1.0 / bound(0.01, view_quality, 1);
  154. if(f > 2048)
  155. this.modelindex = this.lodmodelindex2;
  156. else if(f > 768)
  157. this.modelindex = this.lodmodelindex1;
  158. else
  159. this.modelindex = this.lodmodelindex0;
  160. }
  161. }
  162.  
  163.  
  164. void PL_TorsoAnim(entity e, float animframe)
  165. {
  166. e.torso_frame2 = e.torso_frame;
  167. e.torso_frame2time = e.torso_frame1time;
  168. e.torso_lerpfrac = 1.0;
  169. e.torso_frame = animframe;
  170. e.torso_frame1time = time;
  171. }
  172.  
  173. void PL_UpdateWeapon(entity player)
  174. {
  175.  
  176. if(player == world)
  177. return;
  178.  
  179. /* if(!player)
  180. remove(player.pl_extweap);
  181.  
  182. if not(player.pl_extweap)
  183. return;*/
  184.  
  185. local string name = "";
  186. local string hand = "Weapon_R";
  187. float tag_found;
  188. //print(va("DEBUG: Tag found1: %d\n", player.weapon));
  189. if (player.deadflag > 0 || player.weapon == WEAPON_FISTS)
  190. {
  191. // nothing if spectating or dead
  192. setmodel(player.pl_extweap, "null");
  193. PL_TorsoAnim (player, PLANIM_hold_fists);
  194. return;
  195. }
  196. //print(va("DEBUG: Tag found2: %d\n", player.weapon));
  197.  
  198. switch (player.weapon)
  199. {
  200.  
  201. case WEAPON_BOLTER:
  202. name = "models/weapons/w_bolter.obj";
  203. hand = "Weapon_R";
  204. PL_TorsoAnim (player, PLANIM_hold_bolter);
  205. break;
  206.  
  207. case WEAPON_SHOTGUN:
  208. name = "models/weapons/w_sg.obj";
  209. hand = "Weapon_R";
  210. PL_TorsoAnim (player, PLANIM_hold_shotgun);
  211. break;
  212.  
  213. case WEAPON_SUPER_SHOTGUN:
  214. name = "models/weapons/w_ssg.obj";
  215. hand = "Weapon_R";
  216. PL_TorsoAnim (player, PLANIM_hold_superbolter);
  217. break;
  218.  
  219. case WEAPON_GOTLUNG:
  220. name = "models/weapons/w_gotlung.obj";
  221. hand = "Weapon_L";
  222. PL_TorsoAnim (player, PLANIM_hold_chaingun);
  223. break;
  224.  
  225. case WEAPON_GRENADE:
  226. name = "models/weapons/v_gl.obj";
  227. hand = "Weapon_L";
  228. PL_TorsoAnim (player, PLANIM_hold_grenade);
  229. break;
  230.  
  231. case WEAPON_ROCKET:
  232. name = "models/weapons/v_rl.obj";
  233. hand = "Weapon_L";
  234. PL_TorsoAnim (player, PLANIM_hold_rocket);
  235. break;
  236.  
  237. case WEAPON_TESLA:
  238. name = "models/weapons/v_shaft.obj";
  239. hand = "Weapon_R";
  240. PL_TorsoAnim (player, PLANIM_hold_tesla);
  241. break;
  242.  
  243. case WEAPON_RAILGUN:
  244. name = "models/weapons/v_rail.obj";
  245. hand = "Weapon_R";
  246. PL_TorsoAnim (player, PLANIM_hold_railgun);
  247. break;
  248.  
  249. }
  250. eprint(player);
  251. // print(va("DEBUG: Tag found3: %d\n", player.weapon));
  252. //print ("DEBUG: Gettagindex: Weapon\n");
  253. if(player.skeletonindex)
  254. if((tag_found = gettagindex(player, hand)))
  255. {
  256. //print(va("DEBUG: Tag found4: %d\n", tag_found));
  257. //if (self.pl_extweap.weapon != name)
  258. //{
  259. //print(va("DEBUG: Tag found5: %d\n", tag_found));
  260.  
  261.  
  262. //self.pl_extweap.weapon = name;
  263. setmodel(player.pl_extweap, name);
  264. //print(va("DEBUG: WeapExt model: %s\n", self.pl_extweap.model));
  265. //print(va("DEBUG: WeapExt hand: %s\n", hand));
  266. setattachment(player.pl_extweap, player, hand);
  267. //eprint(player);
  268. //}
  269. }
  270. else
  271. setmodel(player.pl_extweap, "null");
  272. }
  273.  
  274. void PL_WeaponModel_Create(entity player)
  275. {
  276. //if (player != world)
  277. if (!player.pl_extweap)
  278. {
  279. player.pl_extweap = spawn();
  280. print("DEBUG: Spawned Ext Weapon:\n");
  281. eprint(player);
  282.  
  283. //PL_WeaponModel_Init(self.pl_extweap);
  284.  
  285. player.pl_extweap.drawmask = MASK_ENGINE;
  286. player.pl_extweap.renderflags = 0;
  287.  
  288.  
  289. setorigin(player.pl_extweap, '0 0 0');
  290. setsize (player.pl_extweap, '0 0 0', '0 0 0');
  291. player.pl_extweap.angles = '0 0 0';
  292. player.pl_extweap.scale = 0.60;
  293.  
  294. player.pl_extweap.model = "";
  295. setattachment(player.pl_extweap, player, "");//Weapon_R, Weapon_L
  296. // eprint(player);
  297. PL_UpdateWeapon(player);
  298. }
  299. }
  300.  
  301. void player_predraw()
  302. {
  303.  
  304. if ( self.fx_owner == player_localentnum )
  305. {
  306.  
  307. self.movetype = MOVETYPE_WALK;
  308. // Prepare rollback
  309. vector vOldOrigin = self.origin;
  310. vector vOldVelocity = self.velocity;
  311. float fOldPMoveFlags = self.pmove_flags;
  312.  
  313. local float i;
  314. // Apply physics for every single input-frame that has not yet been
  315. // acknowledged by the server (servercommandframe = last acknowledged frame)
  316. for ( i = servercommandframe + 1; i <= clientcommandframe; i++ ) {
  317. getinputstate( i );
  318. // runstandardplayerphysics( self );
  319. }
  320.  
  321. vPlayerVelocity = self.velocity;
  322. //addentity( self );
  323.  
  324. print("Walking round?\n");
  325.  
  326. // Time to roll back
  327. self.origin = vOldOrigin;
  328. setorigin( self, self.origin );
  329. self.velocity = vOldVelocity;
  330. self.pmove_flags = fOldPMoveFlags;
  331. self.movetype = MOVETYPE_NONE;
  332.  
  333. }
  334.  
  335. self.lerpfrac = max(0, self.lerpfrac - frametime * 10);
  336. self.torso_lerpfrac = max(0, self.torso_lerpfrac - frametime * 10);
  337.  
  338. local float frametime = time - last_time;
  339. last_time = time;
  340.  
  341. if (intermission == 1)
  342. return;
  343.  
  344. /*if (frametime <= 0)
  345. return;*/
  346.  
  347. if (frametime > 0.1)
  348. frametime = 0.1;
  349.  
  350. //self.drawmask = 0;
  351.  
  352. if (! self.modelindex)
  353. return;
  354.  
  355. // never draw for the same client (unless chase-cam is on)
  356. if (self.fx_owner == player_localentnum && !chase_active)
  357. {
  358. self.renderflags = RF_EXTERNALMODEL;
  359. self.pl_extweap.renderflags = RF_EXTERNALMODEL;//FIXME : Make pl_extmodel show in mirrors.
  360. }
  361. else
  362. {
  363. self.renderflags = 0;
  364. self.pl_extweap.renderflags = 0;
  365. }
  366.  
  367.  
  368. self.drawmask = MASK_ENGINE;
  369.  
  370. //self.origin = getentityvec(self.fx_owner, E_ORIGINANDVECTORS);
  371.  
  372. local float old_yangles = self.angles_y;
  373.  
  374. self.angles = csqc_calcangles(v_forward, v_up);
  375.  
  376. //Save the forward looking direction.
  377. local float torso_aim = self.angles_y;
  378.  
  379. //Limit how far up or down the spine will bend
  380. if (self.angles_x > 70)
  381. self.angles_x = 70;
  382. else if (self.angles_x < -70)
  383. self.angles_x = -70;
  384.  
  385.  
  386. //print(va("%f\n", self.w_direction));
  387. //print(va("angles %f\n", old_yangles));
  388.  
  389.  
  390. if (self.w_direction < 130 && self.w_direction > 50)
  391. self.w_direction = (self.w_direction - 50)/2;
  392. else if (self.w_direction > -130 && self.w_direction < -50)
  393. self.w_direction = (self.w_direction + 50)/2;
  394. else if (self.w_direction <= -120)
  395. self.w_direction = self.w_direction + 180;
  396. else if (self.w_direction >= 120)
  397. self.w_direction = self.w_direction - 180;
  398. else if (self.w_direction > 50 || self.w_direction < -50)
  399. self.w_direction = self.w_olddir;
  400.  
  401. self.w_olddir = self.w_direction;
  402.  
  403. self.angles_y = self.angles_y + self.w_direction;
  404.  
  405. /*if (old_yangles > self.angles_y+100 || old_yangles < self.angles_y - 100)
  406. {
  407. print(va("w_angles%f\n", self.angles_y));
  408. print(va("old_angles %f\n", old_yangles));
  409. }*/
  410.  
  411. //Blend rotation of the legs.
  412. if ((old_yangles > 270 && self.angles_y < 90) || (old_yangles < 90 && self.angles_y > 270))
  413. {
  414. if (old_yangles > self.angles_y) //Old angle is over 270 degrees
  415. {
  416. self.angles_y = self.angles_y - ((old_yangles-360-self.angles_y)/10);
  417. //print("Turn Right\n");
  418. }
  419. else if (old_yangles < self.angles_y) //New angle is over 270
  420. {
  421. self.angles_y = self.angles_y - ((old_yangles+360-self.angles_y)/10);
  422. //print("Turn Left\n");
  423. }
  424. }
  425. else
  426. self.angles_y = old_yangles - ((old_yangles-self.angles_y)/10);
  427.  
  428.  
  429. // build skeleteon for leg animation
  430.  
  431. skel_build(self.skeletonindex, self, self.modelindex, 0 /* retain */,
  432. 1, 999 /* <-- all bones */ );
  433.  
  434. // if not mixing LEG + TORSO animations, do nothing else here
  435. if (self.torso_frame < 0)
  436. return;
  437.  
  438. /* MIX IT */
  439.  
  440. local float save_frame = self.frame;
  441. local float save_time = self.frame1time;
  442. local float save_lerpfrac = self.lerpfrac;
  443.  
  444. local float save_frame2 = self.frame2;
  445. local float save_time2 = self.frame2time;
  446.  
  447. self.frame = self.torso_frame;
  448. self.frame1time = self.torso_frame1time;
  449. self.lerpfrac = self.torso_lerpfrac;
  450. self.frame2 = self.torso_frame2;
  451. self.frame2time = self.torso_frame2time;
  452.  
  453.  
  454. skel_build(self.skeletonindex, self, self.modelindex, 0 /* retain */,
  455. torso_first_bone, torso_last_bone /* <-- torso bones */ );
  456.  
  457. self.frame = save_frame;
  458. self.frame1time = save_time;
  459. self.lerpfrac = save_lerpfrac;
  460. self.frame2 = save_frame2;
  461. self.frame2time = save_time2;
  462. //print(va("frame %d %d %d %d lerpfrac * %d %d %f\n", self.frame, self.frame2, self.frame3, self.frame4, self.lerpfrac, self.lerpfrac3, self.lerpfrac4));
  463.  
  464.  
  465.  
  466. local float back = skel_find_bone(self.skeletonindex, "Bip002 Spine1");
  467.  
  468. local vector org = skel_get_bonerel(self.skeletonindex, back);
  469. local vector ang = skel_get_boneabs(self.skeletonindex, back);
  470. ang_y = ang_y-self.angles_x-5;
  471. ang_x = 0;
  472.  
  473. //Make the torso always face forward.
  474. torso_aim = torso_aim - self.angles_y;
  475. ang_z = ang_z+torso_aim;
  476.  
  477.  
  478. makevectors(ang);
  479. skel_set_bone(self.skeletonindex, back, org);
  480. /*
  481.  
  482. back = skel_find_bone(self.skeletonindex, "Bip002 Spine2");
  483.  
  484. org = skel_get_bonerel(self.skeletonindex, back);
  485. ang = skel_get_boneabs(self.skeletonindex, back);
  486. ang_y = ang_y-(self.angles_x/2)-5;
  487. makevectors(ang);
  488. skel_set_bone(self.skeletonindex, back, org);*/
  489.  
  490. //print(va("%f\n", self.angles_x));
  491. //print(va("%f\n", org_y));
  492. //print(va("%f\n", self.angles_z));
  493.  
  494. self.angles_x = 0;
  495. //self.angles_z = self.w_direction;
  496. // Pred_PlayerUpdated(self);
  497.  
  498. PL_WeaponModel_Create(self);
  499.  
  500. }
  501.  
  502.  
  503.  
  504. void Ent_Remove_Player()
  505. {
  506. print("DEBUG: Ent_Remove_Player\n");
  507.  
  508.  
  509. //Free Skeleton
  510. if (self.skeletonindex)
  511. {
  512. skel_delete(self.skeletonindex);
  513. self.skeletonindex = 0;
  514. //print("DEBUG: Skeleton freed\n");
  515. }
  516.  
  517. remove(self.pl_extweap);
  518. remove(self);
  519.  
  520. }
  521.  
  522.  
  523.  
  524. void Ent_Update_Player(float is_new)
  525. {
  526.  
  527.  
  528. self.origin_x = ReadCoord();
  529. self.origin_y = ReadCoord();
  530. self.origin_z = ReadCoord();
  531. self.angles_x = ReadCoord();
  532. self.angles_y = ReadCoord();
  533. self.angles_z = ReadCoord();
  534. self.velocity_x = ReadShort();
  535. self.velocity_y = ReadShort();
  536. self.velocity_z = ReadShort();
  537. self.flags = ReadLong();
  538.  
  539. setsize( self, '-16 -16 -24', '16 16 32' );
  540. setorigin( self, self.origin );
  541.  
  542. //print(va("DEBUG: Ent_Update_Player: is_new %d\n", is_new));
  543. //print(va("frame %d %d %d %d lerpfrac * %d %d %f\n", self.frame, self.frame2, self.frame3, self.frame4, self.lerpfrac, self.lerpfrac3, self.lerpfrac4));
  544. /* this MUST mirror the SendEntity_Player in game code */
  545.  
  546. local float sendflags = ReadShort();
  547.  
  548. //print(va("DEBUG: Ent_Update_Player: sendflags %d\n", sendflags));
  549.  
  550. if (sendflags & SENDFLAG_MODEL)
  551. {
  552. setmodel(self, ReadString());
  553. self.fx_owner = ReadEntity();
  554. self.team = ReadByte();
  555.  
  556. //player = ftoe(self.fx_owner);
  557. //print(va ("DEBUG: Player model is %s\n", self.model));
  558. }
  559.  
  560. if (sendflags & SENDFLAG_FRAME)
  561. {
  562. local float legs_frame = ReadByte();
  563.  
  564. startanim(self, legs_frame);
  565.  
  566. //Don't update frametime for running/walking animations
  567. if (legs_frame < PLANIM_turn || legs_frame > PLANIM_runB)
  568. self.frame1time = time;
  569. }
  570.  
  571. if (sendflags & SENDFLAG_TORSO)
  572. {
  573. self.torso_frame2 = self.torso_frame;
  574. self.torso_frame2time = self.torso_frame1time;
  575. self.torso_lerpfrac = 1.0;
  576. self.torso_frame = ReadByte();
  577. self.torso_frame1time = time;
  578. //print(va("DEBUG: Anim found: %d\n", self.torso_frame));
  579. }
  580.  
  581. if (sendflags & SENDFLAG_SKIN)
  582. {
  583. self.skin = ReadByte();
  584. }
  585.  
  586. if (sendflags & SENDFLAG_COLORS)
  587. {
  588. self.colormap = ReadByte() | 1024;
  589. //print(va ("DEBUG: Player color is %d\n", self.colormap));
  590. }
  591.  
  592. if (sendflags & SENDFLAG_WEAPON)
  593. {
  594. self.weapon = ReadByte();
  595. PL_UpdateWeapon(self);
  596. //print(va("DEBUG: Weapon found: %d\n", self.weapon));
  597. //eprint(self);
  598. }
  599.  
  600. if (sendflags & SENDFLAG_DEAD)
  601. {
  602. self.deadflag = ReadByte();
  603. //print(va ("DEBUG: Player is dead? %d\n", self.deadflag));
  604. local entity plweap = self.pl_extweap;
  605. remove(plweap);
  606. }
  607.  
  608. if (sendflags & SENDFLAG_ANGLES)
  609. {
  610. self.w_direction = ReadShort();
  611. //print(va ("DEBUG: Player is dead? %d\n", self.deadflag));
  612. }
  613.  
  614. if (is_new || !self.skeletonindex)
  615. {
  616. // print(va("DEBUG: Ent_Update_Player: is_new_skeleton %d\n", is_new));
  617. self.classname = "player";
  618. self.solid = SOLID_SLIDEBOX;
  619. self.predraw = player_predraw;
  620.  
  621. self.skeletonindex = skel_create(self.modelindex);
  622. self.drawmask = MASK_ENGINE;
  623.  
  624. /*if (self.skeletonindex)
  625. self.back_bone = skel_find_bone(self.skeletonindex, "Bip002 Spine");*/
  626. }
  627.  
  628. //is it a spectator? Then no need to do any of this.
  629. if (self.team == 0)
  630. return;
  631.  
  632. //Check what is yours
  633. if (self.fx_owner == player_localentnum)
  634. {
  635. localteam = self.team;
  636. teamskin = self.skin;
  637. teamcolor = self.colormap;
  638. teammodel = self.model;
  639.  
  640. if(self.deadflag == 1)
  641. localcmd("set _togglezoom +; -button4\n"); //Make sure you don't respawn with togglezoom on.
  642.  
  643. }
  644.  
  645. surface = cvar("r_showsurfaces");
  646.  
  647. /*if(!self.modelindex)
  648. {
  649. setmodel(self, zs_defaultmodel_latch);
  650. }*/
  651.  
  652.  
  653. if (((self.fx_owner != player_localentnum && self.team != localteam) || ((zs_gametype == "ffa" || zs_gametype == "duel") && self.fx_owner != player_localentnum)) && self.team != 0)
  654. {
  655.  
  656. if ((autocvar_cl_forcemodels) && ((self.model != "models/gore/gib_db_head.obj" && self.deadflag > 0) || (self.deadflag == 0)))
  657. {
  658. enemymodel = strcat("models/player/", autocvar_enemymodel, "/player.iqm");
  659. setmodel(self, enemymodel);
  660. self.skeletonindex = skel_create(self.modelindex);
  661. }
  662. else if (self.model == "models/gore/gib_db_head.obj" && self.deadflag > 0)
  663. return;
  664.  
  665.  
  666. if (autocvar_cl_forceskins && surface == 0)
  667. self.skin = autocvar_enemyskin;
  668. else if(!autocvar_cl_forceskins && zs_gametype == "tdm")
  669. self.skin = 2;
  670.  
  671. if(self.deadflag > 0 && autocvar_cl_forcecorpsecolor)
  672. {
  673. self.colormap = autocvar_corpsecolor;
  674. self.skin = 2;
  675. self.glowmod = '0 0 0';
  676. return;
  677. }
  678. else
  679. {
  680.  
  681. if (autocvar_cl_forcecolors)
  682. self.colormap = autocvar_enemycolor;
  683. else if(!autocvar_cl_forcecolors && self.team == 1 && zs_gametype == "tdm")
  684. self.colormap = 198;
  685. else if(!autocvar_cl_forcecolors && self.team == 2 && zs_gametype == "tdm")
  686. self.colormap = 35;
  687.  
  688. if (autocvar_cl_forceglow)
  689. self.glowmod = stov(autocvar_enemyglow);
  690. else
  691. self.glowmod = '1 1 1';
  692. }
  693.  
  694. }
  695.  
  696. // Friends adjustments
  697. if ((self.fx_owner != player_localentnum && self.team == localteam && zs_gametype != "ffa" && zs_gametype != "duel" && self.team != 0))
  698. {
  699.  
  700. if ((autocvar_cl_forcemodels) && ((self.model != "models/gore/gib_db_head.obj" && self.deadflag > 0) || (self.deadflag == 0)))
  701. setmodel(self, teammodel);
  702. else if (self.model == "models/gore/gib_db_head.obj" && self.deadflag > 0)
  703. return;
  704.  
  705. if (autocvar_cl_forceskins && surface == 0)
  706. self.skin = teamskin;
  707. else if(autocvar_cl_forceskins && surface > 0)
  708. self.skin = 6;
  709. else if(!autocvar_cl_forceskins && zs_gametype == "tdm")
  710. self.skin = 2;
  711.  
  712. if(self.deadflag > 0 && autocvar_cl_forcecorpsecolor)
  713. {
  714. self.colormap = autocvar_corpsecolor;
  715. self.glowmod = '0 0 0';
  716. return;
  717. }
  718. else
  719. {
  720.  
  721. if (autocvar_cl_forcecolors)
  722. self.colormap = teamcolor;
  723. else if(!autocvar_cl_forcecolors && self.team == 1 && zs_gametype == "tdm")
  724. self.colormap = 198;
  725. else if(!autocvar_cl_forcecolors && self.team == 2 && zs_gametype == "tdm")
  726. self.colormap = 35;
  727.  
  728. if (autocvar_cl_forceglow)
  729. self.glowmod = stov(autocvar_glow);
  730. else
  731. self.glowmod = '1 1 1';
  732.  
  733. }
  734.  
  735. //print(va("teammember got skin %d\n", self.skin));
  736. }
  737.  
  738.  
  739. }
  740.  
  741.  
  742. //------------------------------------------------------------------------
  743.  
  744.  
  745. void TempEnt_WClientSound()
  746. {
  747. local float kind = ReadByte();
  748. // print(va("DEBUG: Extra: %f\n", extra));
  749.  
  750. local vector org = ReadVector();
  751.  
  752. local string snd_name = "";
  753. local float attn = ATTN_NORM;
  754.  
  755. switch (kind)
  756. {
  757. case 1:
  758. snd_name = "";
  759.  
  760.  
  761. default:
  762. print(va("^1Unknown client sound #%d\n", kind));
  763. return;
  764. }
  765.  
  766. pointsound(org, snd_name, autocvar_snd_clientsndvol, attn);
  767.  
  768. }
  769.  
  770. void TempEnt_ClientSound()
  771. {
  772. local float kind = ReadByte();
  773. local float extra = ReadByte();
  774. local float extra2 = ReadByte();
  775. // print(va("DEBUG: Extra: %f\n", extra));
  776.  
  777. local float ent_num = ReadEntity();
  778. local vector org = ReadVector();
  779.  
  780. local string snd_name = "";
  781. local float attn = ATTN_NORM;
  782.  
  783. switch (kind)
  784. {
  785. case CSOUND_FOOTSTEP:
  786. {
  787. local float r = rand_int(6);
  788. local string mat = "normal";
  789.  
  790. /* if (extra == )
  791. else*/ if (ent_num != player_localentnum && extra2 != localteam)
  792. {
  793. mat = "metal";
  794. snd_name = va("sound/player/default/step_%s_%d.wav", mat, r);
  795. pointsound(org, snd_name, autocvar_snd_clientsndvol, attn);
  796. }
  797. else if (ent_num != player_localentnum && extra2 == localteam)
  798. {
  799. snd_name = va("sound/player/default/step_%s_%d.wav", mat, r);
  800. pointsound(org, snd_name, autocvar_snd_clientsndvol, attn);
  801. }
  802. else
  803. {
  804. snd_name = va("sound/player/default/step_%s_%d.wav", mat, r);
  805. sound(world,CHAN_AUTO, snd_name, autocvar_snd_clientsndvol, ATTN_NONE);
  806. }
  807. return;
  808. }
  809.  
  810. case CSOUND_AMWARNING:
  811. {
  812. if (ent_num != player_localentnum)
  813. return;
  814.  
  815. snd_name = va("sound/hud/ammo_warning.wav");
  816. sound(world, CHAN_AUTO, snd_name, autocvar_snd_warningsndvol, ATTN_NONE);
  817. return;
  818. }
  819.  
  820. default:
  821. print(va("^1Unknown client sound #%d\n", kind));
  822. return;
  823. }
  824.  
  825.  
  826. }
  827.  
  828.  
  829. //--- editor settings ---
  830. // vi:ts=4:sw=4:expandtab
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement