Guest User

Untitled

a guest
Jul 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.29 KB | None | 0 0
  1. //ThrowingKnifeKnife.cs
  2. datablock AudioProfile(ThrowingKnifeBrickSound)
  3. {
  4. filename = "./KnifeBrick.wav";
  5. description = AudioClosest3d;
  6. preload = true;
  7. };
  8. datablock AudioProfile(ThrowingKnifePlayerSound)
  9. {
  10. filename = "./KnifePlayer.wav";
  11. description = AudioClosest3d;
  12. preload = true;
  13. };
  14. datablock AudioProfile(ThrowingKnifeSwingSound)
  15. {
  16. filename = "./KnifeSwing.wav";
  17. description = AudioClosest3d;
  18. preload = true;
  19. };
  20. datablock AudioProfile(swordDrawSound)
  21. {
  22. filename = "./swordDraw.wav";
  23. description = AudioClosest3d;
  24. preload = true;
  25. };
  26.  
  27. datablock ParticleData(ThrowingKnifeExplosionParticle)
  28. {
  29. dragCoefficient = 5;
  30. gravityCoefficient = 0.1;
  31. inheritedVelFactor = 0.2;
  32. constantAcceleration = 0.0;
  33. lifetimeMS = 500;
  34. lifetimeVarianceMS = 300;
  35. textureName = "base/data/particles/chunk";
  36. spinSpeed = 10.0;
  37. spinRandomMin = -50.0;
  38. spinRandomMax = 50.0;
  39. colors[0] = "0.9 0.9 0.6 0.9";
  40. colors[1] = "0.9 0.5 0.6 0.0";
  41. sizes[0] = 0.25;
  42. sizes[1] = 0.0;
  43. };
  44.  
  45. datablock ParticleEmitterData(ThrowingKnifeExplosionEmitter)
  46. {
  47. ejectionPeriodMS = 1;
  48. periodVarianceMS = 0;
  49. ejectionVelocity = 5;
  50. velocityVariance = 0.0;
  51. ejectionOffset = 0.0;
  52. thetaMin = 80;
  53. thetaMax = 80;
  54. phiReferenceVel = 0;
  55. phiVariance = 360;
  56. overrideAdvance = false;
  57. particles = "ThrowingKnifeExplosionParticle";
  58.  
  59. uiName = "ThrowingKnife Hit";
  60. };
  61.  
  62. datablock ExplosionData(ThrowingKnifeExplosion)
  63. {
  64. //explosionShape = "";
  65. lifeTimeMS = 500;
  66.  
  67. soundProfile = ThrowingKnifeBrickSound;
  68.  
  69. particleEmitter = ThrowingKnifeExplosionEmitter;
  70. particleDensity = 10;
  71. particleRadius = 0.2;
  72.  
  73. faceViewer = true;
  74. explosionScale = "0.5 1 1";
  75.  
  76. shakeCamera = true;
  77. camShakeFreq = "20.0 22.0 20.0";
  78. camShakeAmp = "1.0 1.0 1.0";
  79. camShakeDuration = 0.5;
  80. camShakeRadius = 10.0;
  81.  
  82. // Dynamic light
  83. lightStartRadius = 3;
  84. lightEndRadius = 0;
  85. lightStartColor = "0.6 0.2 0.0";
  86. lightEndColor = "0 0 0";
  87. };
  88.  
  89. //Stab Projectile
  90. AddDamageType("ThrowingKnife", '<bitmap:add-ons/Weapon_Throwing_Knife/CI_ThrowingKnife> %1', '%2 <bitmap:add-ons/Weapon_Throwing_Knife/CI_ThrowingKnife> %1',0.75,1);
  91. datablock ProjectileData(ThrowingKnifeStabProjectile)
  92. {
  93. shapeFile = "base/data/shapes/empty.dts";
  94. directDamage = 20;
  95. directDamageType = $DamageType::ThrowingKnife;
  96. radiusDamageType = $DamageType::ThrowingKnife;
  97.  
  98. brickExplosionRadius = 0;
  99. brickExplosionImpact = true;
  100. brickExplosionForce = 0;
  101. brickExplosionMaxVolume = 1;
  102. brickExplosionMaxVolumeFloating = 2;
  103. explosion = ThrowingKnifeExplosion;
  104.  
  105. muzzleVelocity = 50;
  106. velInheritFactor = 1;
  107.  
  108. armingDelay = 0;
  109. lifetime = 100;
  110. fadeDelay = 70;
  111. bounceElasticity = 0;
  112. bounceFriction = 0;
  113. isBallistic = true;
  114. gravityMod = 0.50;
  115.  
  116. hasLight = false;
  117. lightRadius = 3.0;
  118. lightColor = "1 0 0";
  119.  
  120. uiName = "Throwing Knife Stab";
  121. };
  122.  
  123. //Thrown projectile
  124. datablock ProjectileData(ThrowingKnifeThrowProjectile)
  125. {
  126. projectileShapeName = "./ThrowingKnifeProjectile.dts";
  127. directDamage = 100;
  128. directDamageType = $DamageType::ThrowingKnife;
  129. radiusDamageType = $DamageType::ThrowingKnife;
  130. particleEmitter = spearTrailEmitter;
  131. stickExplosion = ThrowingKnifeExplosion;
  132. bloodExplosion = ThrowingKnifeExplosion;
  133. explosion = arrowExplosion;
  134. explodeOnPlayerImpact = true;
  135. explodeOnDeath = true;
  136.  
  137. armingDelay = 8000;
  138. lifetime = 8000;
  139. fadeDelay = 8000;
  140.  
  141. isBallistic = true;
  142. bounceAngle = 180; //stick almost all the time
  143. minStickVelocity = 10;
  144. bounceElasticity = 0;
  145. bounceFriction = 1;
  146. gravityMod = 0.25;
  147. doColorShift = true;
  148. colorShiftColor = "0.471 0.471 0.471 1.000";
  149.  
  150.  
  151. hasLight = false;
  152. lightRadius = 3.0;
  153. lightColor = "0 0 1";
  154.  
  155. muzzleVelocity = 65;
  156. velInheritFactor = 1;
  157. lightColor = "0 0 0.5";
  158.  
  159. uiName = "Throwing Knife Throw";
  160. };
  161.  
  162. datablock ParticleData(spearTrailParticle)
  163. {
  164. dragCoefficient = 3.0;
  165. windCoefficient = 0.0;
  166. gravityCoefficient = 0.0;
  167. inheritedVelFactor = 0.0;
  168. constantAcceleration = 0.0;
  169. lifetimeMS = 600;
  170. lifetimeVarianceMS = 0;
  171. spinSpeed = 10.0;
  172. spinRandomMin = -50.0;
  173. spinRandomMax = 50.0;
  174. useInvAlpha = true;
  175. animateTexture = false;
  176. //framesPerSec = 1;
  177.  
  178. textureName = "base/data/particles/ring";
  179. //animTexName = " ";
  180.  
  181. // Interpolation variables
  182. colors[0] = "0.75 0.75 0.75 0.3";
  183. colors[1] = "0.75 0.75 0.75 0.2";
  184. colors[2] = "1 1 1 0.0";
  185. sizes[0] = 0.15;
  186. sizes[1] = 0.35;
  187. sizes[2] = 0.05;
  188. times[0] = 0.0;
  189. times[1] = 0.1;
  190. times[2] = 1.0;
  191. };
  192.  
  193. datablock ParticleEmitterData(spearTrailEmitter)
  194. {
  195. ejectionPeriodMS = 5;
  196. periodVarianceMS = 0;
  197.  
  198. ejectionVelocity = 0; //0.25;
  199. velocityVariance = 0; //0.10;
  200.  
  201. ejectionOffset = 0;
  202.  
  203. thetaMin = 0.0;
  204. thetaMax = 90.0;
  205.  
  206. particles = spearTrailParticle;
  207.  
  208. useEmitterColors = true;
  209. uiName = "Spear Trail";
  210. };
  211.  
  212. datablock ParticleData(arrowExplosionParticle)
  213. {
  214. dragCoefficient = 8;
  215. gravityCoefficient = -0.3;
  216. inheritedVelFactor = 0.2;
  217. constantAcceleration = 0.0;
  218. lifetimeMS = 500;
  219. lifetimeVarianceMS = 300;
  220. textureName = "base/data/particles/cloud";
  221. spinSpeed = 10.0;
  222. spinRandomMin = -50.0;
  223. spinRandomMax = 50.0;
  224. colors[0] = "0.5 0.5 0.5 0.9";
  225. colors[1] = "0.5 0.5 0.5 0.0";
  226. sizes[0] = 0.45;
  227. sizes[1] = 0.0;
  228.  
  229. useInvAlpha = true;
  230. };
  231. datablock ParticleEmitterData(arrowExplosionEmitter)
  232. {
  233. ejectionPeriodMS = 1;
  234. periodVarianceMS = 0;
  235. ejectionVelocity = 3;
  236. velocityVariance = 0.0;
  237. ejectionOffset = 0.0;
  238. thetaMin = 0;
  239. thetaMax = 180;
  240. phiReferenceVel = 0;
  241. phiVariance = 360;
  242. overrideAdvance = false;
  243. particles = "arrowExplosionParticle";
  244.  
  245. useEmitterColors = true;
  246. uiName = "Arrow Vanish";
  247. };
  248. datablock ExplosionData(arrowExplosion)
  249. {
  250. //explosionShape = "";
  251. soundProfile = "";
  252.  
  253. lifeTimeMS = 50;
  254.  
  255. emitter[0] = arrowExplosionEmitter;
  256.  
  257. faceViewer = true;
  258. explosionScale = "1 1 1";
  259.  
  260. shakeCamera = false;
  261. camShakeFreq = "10.0 11.0 10.0";
  262. camShakeAmp = "1.0 1.0 1.0";
  263. camShakeDuration = 0.5;
  264. camShakeRadius = 10.0;
  265.  
  266. // Dynamic light
  267. lightStartRadius = 0;
  268. lightEndRadius = 1;
  269. lightStartColor = "0.3 0.6 0.7";
  270. lightEndColor = "0 0 0";
  271. };
  272.  
  273.  
  274.  
  275.  
  276. //////////
  277. // item //
  278. //////////
  279. datablock ItemData(ThrowingKnifeItem)
  280. {
  281. category = "Weapon"; // Mission editor category
  282. className = "Weapon"; // For inventory system
  283.  
  284. // Basic Item Properties
  285. shapeFile = "./ThrowingKnife.dts";
  286. mass = 1;
  287. density = 0.2;
  288. elasticity = 0.2;
  289. friction = 0.6;
  290. emap = true;
  291.  
  292. //gui stuff
  293. uiName = "Throwing Knife";
  294. iconName = "./icon_ThrowingKnife";
  295. doColorShift = false;
  296. colorShiftColor = "0.471 0.471 0.471 1.000";
  297.  
  298. // Dynamic properties defined by the scripts
  299. image = ThrowingKnifeImage;
  300. canDrop = true;
  301. };
  302.  
  303. ////////////////
  304. //weapon image//
  305. ////////////////
  306. datablock ShapeBaseImageData(ThrowingKnifeImage)
  307. {
  308. // Basic Item properties
  309. shapeFile = "./ThrowingKnife.dts";
  310. emap = true;
  311.  
  312. // Specify mount point & offset for 3rd person, and eye offset
  313. // for first person rendering.
  314. mountPoint = 0;
  315. offset = "0 0 0";
  316.  
  317. // When firing from a point offset from the eye, muzzle correction
  318. // will adjust the muzzle vector to point to the eye LOS point.
  319. // Since this weapon doesn't actually fire from the muzzle point,
  320. // we need to turn this off.
  321. correctMuzzleVector = false;
  322.  
  323. eyeOffset = "0 0 0";
  324.  
  325. // Add the WeaponImage namespace as a parent, WeaponImage namespace
  326. // provides some hooks into the inventory system.
  327. className = "WeaponImage";
  328.  
  329. // Projectile && Ammo.
  330. item = ThrowingKnifeItem;
  331. ammo = " ";
  332. projectile = ThrowingKnifeStabProjectile;
  333. projectileType = Projectile;
  334.  
  335. //melee particles shoot from eye node for consistancy
  336. melee = true;
  337. doRetraction = false;
  338. //raise your arm up or not
  339. armReady = true;
  340.  
  341. //casing = " ";
  342. doColorShift = true;
  343. colorShiftColor = "0.471 0.471 0.471 1.000";
  344.  
  345. // Images have a state system which controls how the animations
  346. // are run, which sounds are played, script callbacks, etc. This
  347. // state system is downloaded to the client so that clients can
  348. // predict state changes and animate accordingly. The following
  349. // system supports basic ready->fire->reload transitions as
  350. // well as a no-ammo->dryfire idle state.
  351.  
  352. // Initial start up state
  353. stateName[0] = "Activate";
  354. stateTimeoutValue[0] = 0.5;
  355. stateTransitionOnTimeout[0] = "Ready";
  356. stateSound[0] = swordDrawSound;
  357.  
  358. stateName[1] = "Ready";
  359. stateTransitionOnTriggerDown[1] = "PreFire";
  360. stateAllowImageChange[1] = true;
  361.  
  362. stateName[2] = "PreFire";
  363. stateScript[2] = "onPreFire";
  364. stateAllowImageChange[2] = false;
  365. stateTimeoutValue[2] = 0.1;
  366. stateTransitionOnTimeout[2] = "Fire";
  367.  
  368. stateName[3] = "Fire";
  369. stateTransitionOnTimeout[3] = "CheckFire";
  370. stateTimeoutValue[3] = 0.2;
  371. stateFire[3] = true;
  372. stateAllowImageChange[3] = false;
  373. stateSequence[3] = "Fire";
  374. stateScript[3] = "onFire";
  375. stateWaitForTimeout[3] = true;
  376. stateSound[3] = ThrowingKnifeSwingSound;
  377.  
  378. stateName[4] = "CheckFire";
  379. stateTransitionOnTriggerUp[4] = "StopFire";
  380. stateTransitionOnTriggerDown[4] = "Fire";
  381.  
  382.  
  383. stateName[5] = "StopFire";
  384. stateTransitionOnTimeout[5] = "Ready";
  385. stateTimeoutValue[5] = 0.2;
  386. stateAllowImageChange[5] = false;
  387. stateWaitForTimeout[5] = true;
  388. stateSequence[5] = "StopFire";
  389. stateScript[5] = "onStopFire";
  390.  
  391.  
  392. };
  393.  
  394. function ThrowingKnifeImage::onPreFire(%this, %obj, %slot)
  395. {
  396. %obj.playthread(2, armattack);
  397. }
  398.  
  399. function ThrowingKnifeImage::onStopFire(%this, %obj, %slot)
  400. {
  401. %obj.playthread(2, root);
  402. }
  403.  
  404. package ThrowingKnifePackage
  405. {
  406. function ThrowingKnifeStabProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
  407. {
  408. %currSlot = %obj.currTool;
  409. %client = %obj.sourceObject.client;
  410.  
  411. if(isObject(%col.client.minigame))
  412. {
  413. if(%obj.client.minigame $= %col.client.minigame)
  414. {
  415. if(%col.getClassName() $= "Player")
  416. {
  417. if($ThrowingKnifeStabLimit==1)
  418. {
  419. %obj.sourceObject.tool[%currSlot] = 0;
  420. %obj.sourceObject.weaponCount--;
  421. messageClient(%obj.client,'MsgItemPickup',"",%currSlot,0);
  422. serverCmdUnUseTool(%obj.client);
  423. }
  424.  
  425. serverPlay3D(ThrowingKnifePlayerSound, %pos);
  426. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  427. }
  428. }
  429. }
  430.  
  431. if((%col.getType() && $TypeMasks::FxBrickObjectType))
  432. {
  433. serverPlay3D(ThrowingKnifeBrickSound, %pos);
  434. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  435. }
  436.  
  437. else
  438. {
  439. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  440. }
  441. }
  442.  
  443. function ThrowingKnifeThrowProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
  444. {
  445. if((%col.getType() & $TypeMasks::PlayerObjectType) && isObject(%col.client))
  446. {
  447. serverPlay3D(ThrowingKnifePlayerSound, %pos);
  448. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  449. }
  450.  
  451. if((%col.getType() && $TypeMasks::FxBrickObjectType))
  452. {
  453. serverPlay3D(ThrowingKnifeBrickSound, %pos);
  454. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  455. }
  456.  
  457. else
  458. {
  459. return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
  460. }
  461. }
  462.  
  463.  
  464. function Armor::onTrigger(%this, %player, %slot, %val)
  465. {
  466. if(%player.getMountedImage(0) $= ThrowingKnifeImage.getID() && %slot $= 4 && %val)
  467. {
  468. %currSlot = %player.currTool;
  469. %player.tool[%currSlot] = 0;
  470. %player.weaponCount--;
  471. messageClient(%player.client,'MsgItemPickup','',%currSlot,0);
  472. serverCmdUnUseTool(%player.client);
  473.  
  474. %projectile = ThrowingKnifeThrowProjectile;
  475. %vector = %player.getMuzzleVector(0);
  476. %objectVelocity = %player.getVelocity();
  477. %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
  478. %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
  479. %velocity = VectorAdd(%vector1,%vector2);
  480. %p = new Projectile()
  481. {
  482. dataBlock = %projectile;
  483. initialVelocity = %velocity;
  484. initialPosition = %player.getMuzzlePoint(0);
  485. sourceObject = %player;
  486. sourceSlot = 0;
  487. client = %player.client;
  488. };
  489. serverPlay3D(ThrowingKnifeSwingSound,%player.getPosition());
  490. %player.playthread("3","Activate");
  491. MissionCleanup.add(%p);
  492. return %p;
  493. }
  494. Parent::onTrigger(%this, %player, %slot, %val);
  495. }
  496. };
  497. activatePackage(ThrowingKnifePackage);
Add Comment
Please, Sign In to add comment