Advertisement
Guest User

RPK47 script

a guest
Jan 17th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.95 KB | None | 0 0
  1. //########## RPK47
  2. datablock AudioProfile(RPK47WhizSound){filename="./Sounds/whiz.wav";description=AudioClosest3d;preload=true;};
  3.  
  4. datablock AudioProfile(RPK47DeploySound){filename="./Sounds/equip.wav";description=AudioClosest3d;preload=true;};
  5.  
  6. datablock AudioProfile(RPK47HitSound){filename="./Add-Ons/Weapon_Gun/bulletHit.wav";description=AudioClosest3d;preload=true;};
  7.  
  8. datablock AudioProfile(RPK47MetalHitSound){filename="./Add-Ons/Weapon_Gun/bulletHit.wav";description=AudioClosest3d;preload=true;};
  9.  
  10. datablock AudioProfile(RPK47FireSound){filename="./Sounds/RPK47fire.wav";description=AudioClose3d;preload=true;};
  11.  
  12. datablock AudioProfile(RPK47ClickSound){filename="./Sounds/empty.wav";description=AudioClosest3d;preload=true;};
  13.  
  14. datablock AudioProfile(RPK47Reload1Sound){filename="./Sounds/RPK47Reload1.wav";description=AudioClosest3d;preload=true;};
  15.  
  16. datablock AudioProfile(RPK47Reload2Sound){filename="./Sounds/RPK47Reload2.wav";description=AudioClosest3d;preload=true;};
  17. //
  18. datablock AudioProfile(RPK47CockSound){filename="./Sounds/RPK47Cock.wav";description=AudioClosest3d;preload=true;};
  19.  
  20. datablock ParticleData(RPK47bulletExplosionParticle){dragCoefficient=8;gravityCoefficient=0;inheritedVelFactor=0.2;constantAcceleration=0;lifetimeMS=1000;lifetimeVarianceMS=0;textureName="base/data/particles/cloud";spinSpeed=10;spinRandomMin=-50;spinRandomMax=50;colors[0]="0.4 0.4 0.4 0.5";colors[1]="0.2 0.2 0.2 0";sizes[0]=0.5;sizes[1]=2;useInvAlpha=true;};
  21.  
  22. datablock ParticleEmitterData(RPK47bulletExplosionEmitter){uiName="";ejectionPeriodMS=8;periodVarianceMS=0;ejectionVelocity=2;velocityVariance=1;ejectionOffset=0;thetaMin=89;thetaMax=90;phiReferenceVel=0;phiVariance=360;overrideAdvance=false;particles="RPK47bulletExplosionParticle";};
  23.  
  24. datablock ParticleData(RPK47bulletDebrisExplosionParticle){dragCoefficient=0;gravityCoefficient=5;inheritedVelFactor=0.2;constantAcceleration=0;lifetimeMS=1000;lifetimeVarianceMS=500;textureName="base/data/particles/chunk";spinSpeed=10;spinRandomMin=-50;spinRandomMax=50;colors[0]="0.2 0.2 0.2 1";colors[1]="0.2 0.2 0.2 0";sizes[0]=0.2;sizes[1]=0.2;useInvAlpha=true;};
  25.  
  26. datablock ParticleEmitterData(RPK47bulletDebrisExplosionEmitter){uiName="";ejectionPeriodMS=3;periodVarianceMS=0;ejectionVelocity=16;velocityVariance=8;ejectionOffset=0;thetaMin=0;thetaMax=30;phiReferenceVel=0;phiVariance=360;overrideAdvance=false;particles="RPK47bulletDebrisExplosionParticle";};
  27.  
  28. datablock ParticleData(RPK47bulletExplosionSmokeParticle : RPK47bulletExplosionParticle){dragCoefficient=6;gravityCoefficient=0.2;inheritedVelFactor=0;lifetimeMS=1400;lifetimeVarianceMS=200;textureName="base/data/particles/cloud";colors[0]="0.6 0.6 0.6 1";colors[1]="0.6 0.6 0.6 0.2";colors[2]="0.4 0.4 0.4 0";sizes[0]=0.5;sizes[1]=0.6;sizes[2]=5;times[0]=0;times[1]=0.1;times[2]=1;useInvAlpha=true;};
  29.  
  30. datablock ParticleEmitterData(RPK47bulletExplosionSmokeEmitter : RPK47bulletExplosionEmitter){uiName="";ejectionPeriodMS=8;ejectionVelocity=9;velocityVariance=8;thetaMin=0;thetaMax=30;overrideAdvance=false;particles="RPK47bulletExplosionSmokeParticle";};
  31.  
  32. datablock ExplosionData(RPK47bulletExplosion){lifeTimeMS=50;emitter[0]=RPK47bulletExplosionSmokeEmitter;emitter[1]=RPK47bulletDebrisExplosionEmitter;faceViewer=true;explosionScale="1 1 1";shakeCamera=true;camShakeFreq="2 2 2";camShakeAmp="1 1 1";camShakeDuration=0.5;camShakeRadius=1;};
  33.  
  34. datablock ExplosionData(RPK47RecoilExplosion){lifeTimeMS=1;explosionScale="1 1 1";shakeCamera=true;camShakeFreq="1.5 1.5 1.5";camShakeAmp="0.6 0.3 0.3";camShakeDuration=0.6;camShakeRadius=1;};
  35.  
  36. datablock ProjectileData(RPK47Recoil){uiName="";explosion=RPK47RecoilExplosion;muzzleVelocity=0;velInheritFactor=1;lifetime=1;fadeDelay=1;explodeOnDeath=true;};
  37.  
  38. datablock ParticleData(RPK47FlashParticle : RPK47bulletExplosionParticle){dragCoefficient=0;inheritedVelFactor=1;lifetimeMS=30;textureName="base/data/particles/cloud";spinSpeed=50;spinRandomMin=-500;spinRandomMax=500;colors[0]="1 0.5 0 1";colors[1]="1 0.8 0.6 1";colors[2]="1 0.6 0.3 0";sizes[0]=0.1;sizes[1]=0.5;sizes[2]=0;times[9]=0;times[1]=0.3;times[2]=1;useInvAlpha=false;};
  39.  
  40. datablock ParticleEmitterData(RPK47FlashEmitter : RPK47bulletExplosionEmitter){ejectionPeriodMS=3;ejectionVelocity=50;velocityVariance=0;thetaMin=0;thetaMax=10;particles="RPK47FlashParticle";uiName="";};
  41.  
  42. datablock DebrisData(RPK47ShellDebris){shapeFile="./Models/modernShell.dts";lifetime=2;minSpinSpeed=-400;maxSpinSpeed=200;elasticity=0.5;friction=0.2;numBounces=3;staticOnMaxBounce=true;snapOnMaxBounce=false;fade=true;gravModifier=2;};
  43.  
  44. datablock ParticleData(RPK47TrailParticle)
  45. {
  46. dragCoefficient = 3.0;
  47. windCoefficient = 0.0;
  48. gravityCoefficient = 0.0;
  49. inheritedVelFactor = 0.0;
  50. constantAcceleration = 0.0;
  51. lifetimeMS = 120;
  52. lifetimeVarianceMS = 0;
  53. spinSpeed = 10.0;
  54. spinRandomMin = -50.0;
  55. spinRandomMax = 50.0;
  56. useInvAlpha = false;
  57. animateTexture = false;
  58. //framesPerSec = 1;
  59.  
  60. textureName = "base/data/particles/dot";
  61. //animTexName = "~/data/particles/dot";
  62.  
  63. // Interpolation variables
  64. colors[0] = "1 1 0 1";
  65. colors[1] = "1 1 0.4 1";
  66. colors[2] = "1 1 1 1";
  67. sizes[0] = 0.2;
  68. sizes[1] = 0.15;
  69. sizes[2] = 0.0;
  70. times[0] = 0.0;
  71. times[1] = 0.5;
  72. times[2] = 1.0;
  73. };
  74.  
  75. datablock ParticleEmitterData(RPK47Tracer)
  76. {
  77. ejectionPeriodMS = 2;
  78. periodVarianceMS = 0;
  79.  
  80. ejectionVelocity = 0; //0.25;
  81. velocityVariance = 0; //0.10;
  82.  
  83. ejectionOffset = 0;
  84.  
  85. thetaMin = 0.0;
  86. thetaMax = 30.0;
  87.  
  88. particles = RPK47TrailParticle;
  89.  
  90. useEmitterColors = true;
  91. };
  92.  
  93. AddDamageType("RPK47",'<bitmap:Add-ons/Weapon_Engineer/CI_RPK47>%1','%2<bitmap:Add-ons/Weapon_Engineer/CI_RPK47> %1',0.2,1);
  94.  
  95. datablock ProjectileData(RPK47Projectile){uiName="";
  96. projectileShapeName="./Models/modernBullet.dts";
  97. directDamage=48;
  98. directDamageType=$DamageType::RPK47;
  99. radiusDamageType=$DamageType::RPK47;brickExplosionRadius=0;
  100. brickExplosionImpact=true;
  101. brickExplosionForce=30;brickExplosionMaxVolume=1;
  102. brickExplosionMaxVolumeFloating=2;
  103. impactImpulse=60;
  104. explosion=RPK47bulletExplosion;
  105. particleEmitter = "RPK47Tracer";
  106. muzzleVelocity=500;
  107. verInheritFactor=1;
  108. lifetime=4000;
  109. fadeDelay=2000;
  110. bounceElasticity=0.5;
  111. bounceFriction=0.2;
  112. isBallistic=true;
  113. gravityMod=0.20;
  114. sound=RPK47WhizSound;
  115.  
  116. };
  117.  
  118. datablock ItemData(RPK47Item){uiName="RPK47";iconName="./RPK47";
  119.  
  120. image=RPK47Image;category=Weapon;className=Weapon;shapeFile="./Models/RPK47Display.dts";
  121. mass=1;
  122. density=0.2;
  123. elasticity=0;
  124. friction=0.6;
  125. emap=true;
  126. doColorShift=true;
  127. colorShiftColor="1 1 1 1";
  128. canDrop=true;RPK47reload=1;RPK47maxmag=45;};
  129. datablock shapeBaseImageData(RPK47Image){shapeFile="./Models/RPK47.dts";
  130. emap=true;
  131. correctMuzzleVector=true;className="WeaponImage";
  132. item=RPK47Item;
  133. ammo="";
  134. projectile=RPK47Projectile;
  135. projectileType=Projectile;
  136. casing=RPK47ShellDebris;
  137. shellExitDir="1 0.5 0.5";
  138. shellExitVariance=10;
  139. shellVelocity=6;
  140. melee=false;
  141. doReaction=false;
  142. armReady=true;
  143. doColorShift=true;
  144. colorShiftColor="1 1 1 1";
  145.  
  146. //#########################################################################################
  147. //#-Sequences- #
  148. //# #
  149. //# fire / fire the weapon #
  150. //# reload / reloads the weapon -clipIn and clipOut combined- #
  151. //# use / When you equip the weapon -I added this- #
  152. //# #
  153. //#########################################################################################
  154.  
  155. offset = "0 0.25 0"; //-Left +Right, -Back +Front, -Down +Up
  156.  
  157. stateName[0]="Activate";
  158. stateTimeoutValue[0]=0.6;
  159. stateTransitionOnTimeout[0]="AmmoCheck";
  160. stateSequence[0]="use";
  161. stateSound[0]=RPK47DeploySound;
  162.  
  163. stateName[1]="Ready";
  164. stateTransitionOnTriggerDown[1]="Fire1";
  165. stateAllowImageChange[1]=true;
  166. stateTransitionOnNoAmmo[1]="Empty";
  167.  
  168. stateName[2]="Fire1";
  169. stateTransitionOnTimeout[2]="AmmoCheck";
  170. stateTimeoutValue[2]="0.09";
  171. stateFire[2]=true;
  172. stateAllowImageChange[2]=false;
  173. stateWaitForTimeout[2]=true;
  174. stateEmitter[2]=RPK47FlashEmitter;
  175. stateEmitterTime[2]=0.05;
  176. stateEmitterNode[2]="muzzlePoint";
  177. stateSound[2]=RPK47FireSound;
  178. stateScript[2]="onFire1";
  179. stateEjectShell[2]=true;
  180. stateSequence[2]="Fire";
  181.  
  182. stateName[3]="Fire2";
  183. stateTransitionOnTimeout[3]="AmmoCheck";
  184. stateTimeoutValue[3]="0.23";
  185. stateFire[3]=true;
  186. stateAllowImageChange[3]=false;
  187. stateWaitForTimeout[3]=true;
  188. stateEmitter[3]=RPK47FlashEmitter;
  189. stateEmitterTime[3]=0.05;
  190. stateEmitterNode[3]="muzzlePoint";
  191. stateSound[3]=RPK47FireSound;
  192. stateScript[3]="onFire2";
  193. stateEjectShell[3]=true;
  194. stateSequence[3]="Fire";
  195.  
  196. stateName[4]="AmmoCheck";
  197. stateTransitionOnTimeout[4]="Ready";
  198. stateAllowImageChange[4]=true;
  199. stateScript[4]="onAmmoCheck";
  200.  
  201. stateName[5]="Reload";
  202. stateTimeoutValue[5]=0.5;
  203. stateSequence[5]="Reload1";
  204. stateTransitionOnTimeout[5]="Reload2";
  205. stateWaitForTimeout[5]=true;
  206. stateSound[5]=RPK47Reload1Sound;
  207. stateAllowImageChange[5]=true;
  208.  
  209. stateName[9]="Reload2";
  210. stateTimeoutValue[9]=1.0;
  211. stateSequence[9]="Reload2";
  212. stateTransitionOnTimeout[9]="Cock";
  213. stateWaitForTimeout[9]=true;
  214. stateSound[9]=RPK47Reload2Sound;
  215. stateAllowImageChange[9]=true;
  216.  
  217. stateName[10]="Cock";
  218. stateTimeoutValue[10]=1.0;
  219. stateSequence[10]="Cock";
  220. stateTransitionOnTimeout[10]="Done";
  221. stateWaitForTimeout[10]=true;
  222. stateSound[10]=RPK47CockSound;
  223. stateAllowImageChange[10]=true;
  224.  
  225. stateName[6]="Done";
  226. stateTransitionOnTimeout[6]="Ready";
  227. stateTimeoutValue[6]=0.1;
  228. stateAllowImageChange[6]=true;
  229. stateScript[6]="onReload";stateName[7]="Empty";
  230.  
  231. stateTransitionOnTriggerDown[7]="EmptyFire";
  232. stateAllowImageChange[7]=true;
  233. stateTransitionOnAmmo[7]="Reload";
  234.  
  235. stateName[8]="EmptyFire";
  236. stateTransitionOnTriggerUp[8]="Ready";
  237. stateTimeoutValue[8]="0.15";
  238. stateAllowImageChange[8]=false;
  239. stateWaitForTimeout[8]=true;
  240. stateSound[8]=RPK47ClickSound;
  241.  
  242. };
  243.  
  244. datablock shapeBaseImageData(RPK47ImageScoped : RPK47Image)
  245. {
  246. offset = "-0.0 0.0 0.0"; //-Left +Right, -Back +Front, -Down +Up
  247. eyeOffset="0.0 0.0 -0.0"; //-Left +Right, -Back +Front, -Down +Up
  248.  
  249.  
  250. stateName[0]="Activate";
  251. stateTimeoutValue[0]=0.2;
  252. stateTransitionOnTimeout[0]="AmmoCheck";
  253. //stateSequence[0]="Sight";
  254.  
  255. stateName[1]="Ready";
  256. stateTransitionOnTriggerDown[1]="Fire1";
  257. stateAllowImageChange[1]=true;
  258. stateTransitionOnNoAmmo[1]="Empty";
  259. stateSequence[1]="Ready";
  260.  
  261. stateName[2]="Fire1";
  262. stateTransitionOnTimeout[2]="AmmoCheck";
  263. stateTimeoutValue[2]="0.1";
  264. stateFire[2]=true;
  265. stateAllowImageChange[2]=false;
  266. stateWaitForTimeout[2]=true;
  267. stateEmitter[2]=RPK47FlashEmitter;
  268. stateEmitterTime[2]=0.10;
  269. stateEmitterNode[2]="muzzlePoint";
  270. stateSound[2]=RPK47FireSound;
  271. stateScript[2]="onFire1";
  272. stateEjectShell[2]=true;
  273. stateSequence[2]="Fire";
  274.  
  275. stateName[3]="Fire2";
  276. stateTransitionOnTimeout[3]="AmmoCheck";
  277. stateTimeoutValue[3]="0.25";
  278. stateFire[3]=true;
  279. stateAllowImageChange[3]=false;
  280. stateWaitForTimeout[3]=true;
  281. stateEmitter[3]=RPK47FlashEmitter;
  282. stateEmitterTime[3]=0.05;
  283. stateEmitterNode[3]="muzzlePoint";
  284. stateSound[3]=RPK47FireSound;
  285. stateScript[3]="onFire2";
  286. stateEjectShell[3]=true;
  287. stateSequence[3]="Fire";
  288.  
  289. stateName[4]="AmmoCheck";
  290. stateTransitionOnTimeout[4]="Ready";
  291. stateAllowImageChange[4]=true;
  292. stateScript[4]="onAmmoCheck";
  293.  
  294. stateName[5]="Reload";
  295. stateTimeoutValue[5]=0.5;
  296. stateSequence[5]="Reload";
  297. stateTransitionOnTimeout[5]="Reload2";
  298. stateWaitForTimeout[5]=true;
  299. stateSound[5]=RPK47Reload1Sound;
  300. stateAllowImageChange[5]=true;
  301. stateSequence[5]="Reload1";
  302.  
  303. stateName[10]="Reload2";
  304. stateTimeoutValue[10]=1.0;
  305. stateSequence[10]="Reload2";
  306. stateTransitionOnTimeout[10]="Cock";
  307. stateWaitForTimeout[10]=true;
  308. stateSound[10]=RPK47Reload2Sound;
  309. stateAllowImageChange[10]=true;
  310.  
  311. stateName[11]="Cock";
  312. stateTimeoutValue[11]=1.0;
  313. stateSequence[11]="Cock";
  314. stateTransitionOnTimeout[11]="Done";
  315. stateWaitForTimeout[11]=true;
  316. stateSound[11]=RPK47CockSound;
  317. stateAllowImageChange[11]=true;
  318.  
  319. stateName[6]="Done";
  320. stateTransitionOnTimeout[6]="Ready";
  321. stateTimeoutValue[6]=0.1;
  322. stateAllowImageChange[6]=true;
  323. stateScript[6]="onReload";
  324.  
  325. stateName[7]="Empty";
  326. stateTransitionOnTriggerDown[7]="EmptyFire";
  327. stateAllowImageChange[7]=true;
  328. stateTransitionOnAmmo[7]="Reload";
  329. stateName[8]="EmptyFire";
  330. stateTransitionOnTriggerUp[8]="Ready";
  331. stateTimeoutValue[8]="0.15";
  332. stateAllowImageChange[8]=false;
  333. stateWaitForTimeout[8]=true;
  334. stateSound[8]=RPK47ClickSound;
  335.  
  336. stateName[9]="ReadyWeap";
  337. stateSequence[9]="Ready";
  338. stateTimeoutValue[9]=0.95;
  339. stateSound[9]=RPK47DeploySound;
  340. stateTransitionOnTimeout[9]="Ready";
  341.  
  342. };
  343.  
  344. function RPK47Image::onAmmoCheck(%this,%obj,%slot)
  345. {
  346. if(%obj.toolMag[%obj.currTool]<1)
  347. {
  348. %obj.toolMag[%obj.currTool]=0;
  349.  
  350. }
  351. if(%obj.toolMag[%obj.currTool]>%this.item.RPK47maxmag)
  352.  
  353. {
  354. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  355.  
  356. }
  357. if(%obj.toolMag[%obj.currTool]<1)
  358.  
  359. {
  360.  
  361. %obj.toolMag[%obj.currTool]=0;%obj.setImageAmmo(0,0);
  362.  
  363. }
  364. }
  365. function RPK47Image::onReload(%this,%obj,%slot)
  366.  
  367. {
  368. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;%obj.setImageAmmo(0,1);
  369.  
  370. }
  371. function RPK47Image::onFire1(%this,%obj,%slot)
  372.  
  373. {
  374. %obj.toolMag[%obj.currTool]-=1;if(%obj.toolMag[%obj.currTool]<1)
  375.  
  376. {
  377. %obj.toolMag[%obj.currTool]=0;%obj.setImageAmmo(0,0);
  378.  
  379. }
  380. RPK47Fire(%this,%obj,%slot,0.0015,1,0.02);
  381.  
  382. }
  383. function RPK47Image::onFire2(%this,%obj,%slot)
  384. {
  385. %obj.toolMag[%obj.currTool]-=1;
  386.  
  387. if(%obj.toolMag[%obj.currTool]<1)
  388. {
  389. %obj.toolMag[%obj.currTool]=0;%obj.setImageAmmo(0,0);
  390.  
  391. }
  392. RPK47Fire(%this,%obj,%slot,0.0030,1,0.04);
  393. }
  394. function RPK47Image::onMount(%this,%obj,%slot)
  395.  
  396. {
  397. if(%obj.toolMag[%obj.currTool]$="")
  398. {
  399.  
  400. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  401. }
  402.  
  403. parent::onMount(%this,%obj,%slot);
  404.  
  405. %obj.hideNode("LHand");
  406. %obj.hideNode("RHand");
  407. %obj.hideNode("LHook");
  408. %obj.hideNode("RHook");
  409. }
  410. function RPK47Image::onUnMount(%this,%obj,%slot)
  411.  
  412. {
  413. parent::onUnMount(%this,%obj,%slot);
  414. %obj.unhideNode("ALL");
  415.  
  416. if(isObject(%obj.client))
  417. {
  418. %obj.client.applyBodyParts();
  419. %obj.client.applyBodyColors();
  420. }
  421. else{applyDefaultCharacterPrefs(%obj);
  422.  
  423. }
  424.  
  425. %obj.client.setControlCameraFov(90);
  426.  
  427. }
  428. function RPK47ImageScoped::onAmmoCheck(%this,%obj,%slot)
  429.  
  430. {
  431. if(%obj.toolMag[%obj.currTool]<1)
  432.  
  433. {
  434. %obj.toolMag[%obj.currTool]=0;
  435.  
  436. }
  437. if(%obj.toolMag[%obj.currTool]>%this.item.RPK47maxmag)
  438.  
  439. {
  440. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  441.  
  442. }
  443. if(%obj.toolMag[%obj.currTool]<1)
  444.  
  445. {
  446. %obj.toolMag[%obj.currTool]=0;
  447. %obj.setImageAmmo(0,0);
  448.  
  449. }
  450. }
  451. function RPK47ImageScoped::onReload(%this,%obj,%slot)
  452.  
  453. {
  454. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  455. %obj.setImageAmmo(0,1);
  456.  
  457. }
  458. function RPK47ImageScoped::onFire1(%this,%obj,%slot)
  459.  
  460. {
  461. %obj.toolMag[%obj.currTool]-=1;
  462.  
  463. if(%obj.toolMag[%obj.currTool]<1)
  464.  
  465. {
  466. %obj.toolMag[%obj.currTool]=0;
  467. %obj.setImageAmmo(0,0);
  468.  
  469. }
  470. RPK47Fire(%this,%obj,%slot,0.0015,1,0.02);
  471.  
  472. }
  473. function RPK47ImageScoped::onFire2(%this,%obj,%slot)
  474.  
  475. {
  476. %obj.toolMag[%obj.currTool]-=1;
  477.  
  478. if(%obj.toolMag[%obj.currTool]<1)
  479.  
  480. {
  481. %obj.toolMag[%obj.currTool]=0;
  482. %obj.setImageAmmo(0,0);
  483.  
  484. }
  485. RPK47Fire(%this,%obj,%slot,0.0030,1,0.04);
  486.  
  487. }
  488.  
  489. function RPK47ImageScoped::onUnMount(%this,%obj,%slot)
  490.  
  491. {
  492. parent::onUnMount(%this,%obj,%slot);
  493.  
  494. %obj.unhideNode("ALL");
  495.  
  496. if(isObject(%obj.client))
  497.  
  498. {
  499. %obj.client.applyBodyParts();
  500. %obj.client.applyBodyColors();
  501.  
  502. }
  503. else{applyDefaultCharacterPrefs(%obj);
  504.  
  505. }
  506. %obj.client.setControlCameraFov(90);
  507.  
  508. }
  509. function RPK47Projectile::onCollision(%this,%obj,%col,%fade,%pos,%norm)
  510.  
  511. {
  512. if(%col.getClassName()$="WheeledVehicle"||%col.getClassName()$="FlyingVehicle")serverPlay3D(RPK47MetalHitSound,%obj.getTransform());
  513.  
  514.  
  515. else{serverPlay3D(RPK47HitSound,%obj.getTransform());
  516.  
  517. }
  518. parent::onCollision(%this,%obj,%col,%fade,%pos,%norm);
  519.  
  520. }
  521. function RPK47Fire(%this,%obj,%slot,%spread,%shellcount,%recoil)
  522.  
  523.  
  524. {
  525. if(%obj.isCrouched()==1){%spread=%spread-0.00001;%recoil=%recoil/2;
  526.  
  527. }
  528. if(vectorLen(%obj.getVelocity()) >= 0.1 && !isObject(%obj.getObjectMount()))
  529.  
  530. {
  531. %spread=%spread+0.0001;}%vector=%obj.getMuzzleVector(%slot);%p=new Projectile()
  532.  
  533. {
  534. dataBlock=RPK47Recoil;initialVelocity=%obj.getVelocity();
  535.  
  536. initialPosition=%obj.getEyePoint();
  537. sourceObject=%obj;sourceSlot=%slot;client=%obj.client;};
  538. for(%shell=0;%shell<%shellcount;
  539. %shell++){%x=(getRandom()-0.5)*5.415926*%spread;
  540. %y=(getRandom()-0.5)*5.415926*%spread;
  541. %z=(getRandom()-0.5)*5.415926*%spread;
  542. %p=new Projectile(){dataBlock=RPK47Projectile;
  543. initialVelocity=MatrixMulVector(MatrixCreateFromEuler(%x@" "@%y@" "@%z),VectorScale(%obj.getMuzzleVector(%slot),RPK47Projectile.muzzleVelocity));
  544. initialPosition=%obj.getMuzzlePoint(%slot);
  545. sourceObject=%obj;sourceSlot=%slot;
  546. client=%obj.client;};
  547. MissionCleanup.add(%p);
  548.  
  549. }
  550. if(isObject(%obj.getObjectMount()))
  551.  
  552. {
  553. return %p;}%a=%obj.getTransform();
  554.  
  555. %rnd=getRandom(1);if(%rnd==1)
  556.  
  557. {
  558. %recoil=%recoil*-1;
  559.  
  560. }
  561. %obj.setTransform(getWord(%a,0)@" "@getWord(%a,1)@" "@getWord(%a,2)@" "@getWord(%a,3)@" "@getWord(%a,4)@" "@getWord(%a,5)@" "@getWord(%a,6)+%recoil);
  562.  
  563. return %p;}package RPK47
  564.  
  565. {
  566. function GameConnection::onDeath(%this,%killerPlayer,%killer,%damageType,%damageLoc)
  567.  
  568. {
  569. %this.player.client.setControlCameraFov(90);
  570.  
  571. parent::onDeath(%this,%killerPlayer,%killer,%damageType,%damageLoc);
  572.  
  573. }
  574. function Armor::onTrigger(%this,%player,%slot,%val){if(isObject(%player.getMountedImage(0)))
  575.  
  576. {
  577. %item=%player.getMountedImage(0).getName();if((%item $= "RPK47Image" || %item $= "RPK47ImageScoped") && %slot $= 4 && %val)
  578.  
  579. {
  580. if(%item$="RPK47Image"){%player.mountImage(RPK47ImageScoped,0);
  581.  
  582. %player.client.setControlCameraFov(80);
  583. }
  584. if(%item$="RPK47ImageScoped")
  585.  
  586. {
  587. %player.mountImage(RPK47Image,0);
  588.  
  589. %player.client.setControlCameraFov(90);
  590.  
  591. }
  592. }
  593. else{parent::onTrigger(%this,%player,%slot,%val);
  594.  
  595. }
  596. }
  597. else{parent::onTrigger(%this,%player,%slot,%val);
  598.  
  599. }
  600. }
  601. function Player::pickUp(%this,%item)
  602.  
  603. {
  604. %data=%item.dataBlock;
  605. %mag=%item.mag;
  606. %status=parent::pickUp(%this,%item);
  607.  
  608. if(!%status==1)
  609.  
  610. {
  611. return %status;}
  612. %slot=-1;
  613.  
  614. for(%i=0;%i<%this.dataBlock.maxTools;%i++)
  615.  
  616.  
  617. if(isObject(%this.tool[%i])&&%this.tool[%i].getID()==%data.getID()){%slot=%i;break;
  618. }
  619.  
  620. if(%slot == -1)
  621.  
  622. {
  623. return %val;
  624.  
  625. }
  626. if(%mag $= "")
  627.  
  628. {
  629. %this.toolMag[%slot]=%data.RPK47maxmag;
  630.  
  631. }
  632. else%this.toolMag[%slot]=%mag;
  633.  
  634. }
  635. function serverCmdDropTool(%client,%slot)
  636.  
  637. {
  638. if(!isObject(%client.player))
  639.  
  640. {
  641. return parent::serverCmdDropTool(%client,%slot);
  642.  
  643. }
  644. $weaponMag=%client.player.toolMag[%client.player.currTool];
  645.  
  646. %client.player.toolMag[%client.player.currTool]="";
  647.  
  648. return parent::serverCmdDropTool(%client,%slot);
  649.  
  650. }
  651. function ItemData::onAdd(%this,%obj){if($weaponMag!$="")
  652.  
  653. {
  654. %obj.mag=$weaponMag;$weaponMag="";
  655.  
  656. }
  657. parent::onAdd(%this,%obj);
  658.  
  659. }
  660. function serverCmdLight(%client)
  661.  
  662. {
  663. %player=%client.player;
  664.  
  665. %image=%player.getMountedImage(0);
  666.  
  667. if(%image.item.RPK47reload)
  668.  
  669. {
  670. if(%player.getImageState(0)$="Ready"||%player.getImageState(0)$="Empty")
  671.  
  672. {
  673. if(%player.toolMag[%player.currTool]<%image.item.RPK47maxmag)
  674.  
  675. {
  676. %player.setImageAmmo(0,0);
  677.  
  678. %player.Schedule(50,setImageAmmo,0,1);
  679.  
  680. }
  681. else{parent::serverCmdLight(%client);
  682.  
  683. }
  684. }
  685. return;}parent::serverCmdLight(%client);
  686.  
  687. }
  688. }
  689. ;activatePackage(RPK47);
  690.  
  691. function RPK47Image::onUnMount(%this,%obj,%slot)
  692.  
  693. {
  694. parent::onUnMount(%this,%obj,%slot);
  695.  
  696. %obj.unhideNode("ALL");
  697. crossHair.setBitmap("base/client/ui/crosshair.png");
  698.  
  699. if(isObject(%obj.client))
  700.  
  701. {
  702. %obj.client.applyBodyParts();
  703. %obj.client.applyBodyColors();
  704.  
  705. }
  706. else{applyDefaultCharacterPrefs(%obj);
  707.  
  708. }
  709. %obj.client.setControlCameraFov(90);
  710.  
  711. }
  712. function RPK47ImageScoped::onUnMount(%this,%obj,%slot)
  713.  
  714. {
  715. parent::onUnMount(%this,%obj,%slot);
  716.  
  717. %obj.unhideNode("ALL");
  718. crossHair.setBitmap("base/client/ui/crosshair.png");
  719.  
  720. if(isObject(%obj.client))
  721.  
  722. {
  723. %obj.client.applyBodyParts();
  724. %obj.client.applyBodyColors();
  725.  
  726. }
  727. else{applyDefaultCharacterPrefs(%obj);
  728.  
  729. }
  730. %obj.client.setControlCameraFov(90);
  731.  
  732. }
  733.  
  734. function RPK47ImageScoped::onMount(%this,%obj,%slot)
  735. {
  736. if(%obj.toolMag[%obj.currTool]$="")
  737. {
  738. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  739. }
  740.  
  741.  
  742. crossHair.setBitmap("base/client/ui/crosshair.png");
  743.  
  744.  
  745. parent::onMount(%this,%obj,%slot);
  746.  
  747. %obj.hideNode("LHand");
  748. %obj.hideNode("RHand");
  749. %obj.hideNode("LHook");
  750. %obj.hideNode("RHook");
  751.  
  752. }
  753.  
  754. function RPK47Image::onMount(%this,%obj,%slot)
  755. {
  756. if(%obj.toolMag[%obj.currTool]$="")
  757. {
  758. %obj.toolMag[%obj.currTool]=%this.item.RPK47maxmag;
  759. }
  760.  
  761.  
  762. crossHair.setBitmap("base/client/ui/crosshair.png");
  763.  
  764.  
  765. parent::onMount(%this,%obj,%slot);
  766.  
  767. %obj.hideNode("LHand");
  768. %obj.hideNode("RHand");
  769. %obj.hideNode("LHook");
  770. %obj.hideNode("RHook");
  771.  
  772. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement