Advertisement
Guest User

Untitled

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