Ryder.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. //--------------------------------------------------------------------------
  23. // Sounds
  24. //--------------------------------------------------------------------------
  25. datablock SFXProfile(RyderFireSound)
  26. {
  27. filename = "art/sound/weapons/wpn_ryder_fire";
  28. description = AudioClose3D;
  29. preload = true;
  30. };
  31. datablock SFXProfile(RyderReloadSound)
  32. {
  33. filename = "art/sound/weapons/wpn_ryder_reload";
  34. description = AudioClose3D;
  35. preload = true;
  36. };
  37. datablock SFXProfile(RyderSwitchinSound)
  38. {
  39. filename = "art/sound/weapons/wpn_ryder_switchin";
  40. description = AudioClose3D;
  41. preload = true;
  42. };
  43. // ----------------------------------------------------------------------------
  44. // Particles
  45. // ----------------------------------------------------------------------------
  46. //-----------------------------------------------------------------------------
  47. // Explosion
  48. //-----------------------------------------------------------------------------
  49. //--------------------------------------------------------------------------
  50. // Shell ejected during reload.
  51. //-----------------------------------------------------------------------------
  52. //-----------------------------------------------------------------------------
  53. // Projectile Object
  54. //-----------------------------------------------------------------------------
  55. //-----------------------------------------------------------------------------
  56. // Ammo Item
  57. //-----------------------------------------------------------------------------
  58. datablock ItemData(RyderClip)
  59. {
  60. // Mission editor category
  61. category = "AmmoClip";
  62. // Add the Ammo namespace as a parent. The ammo namespace provides
  63. // common ammo related functions and hooks into the inventory system.
  64. className = "AmmoClip";
  65. // Basic Item properties
  66. shapeFile = "art/shapes/weapons/Ryder/TP_Ryder.DAE";
  67. mass = 1;
  68. elasticity = 0.2;
  69. friction = 0.6;
  70. // Dynamic properties defined by the scripts
  71. pickUpName = "Ryder clip";
  72. count = 1;
  73. maxInventory = 10;
  74. };
  75. datablock ItemData(RyderAmmo)
  76. {
  77. // Mission editor category
  78. category = "Ammo";
  79. // Add the Ammo namespace as a parent. The ammo namespace provides
  80. // common ammo related functions and hooks into the inventory system.
  81. className = "Ammo";
  82. // Basic Item properties
  83. shapeFile = "art/shapes/weapons/Ryder/TP_Ryder.DAE";
  84. mass = 1;
  85. elasticity = 0.2;
  86. friction = 0.6;
  87. // Dynamic properties defined by the scripts
  88. pickUpName = "Ryder bullet";
  89. maxInventory = 8;
  90. clip = RyderClip;
  91. };
  92. //--------------------------------------------------------------------------
  93. // Weapon Item. This is the item that exists in the world, i.e. when it's
  94. // been dropped, thrown or is acting as re-spawnable item. When the weapon
  95. // is mounted onto a shape, the SoldierWeaponImage is used.
  96. //-----------------------------------------------------------------------------
  97. datablock ItemData(Ryder)
  98. {
  99. // Mission editor category
  100. category = "Weapon";
  101. // Hook into Item Weapon class hierarchy. The weapon namespace
  102. // provides common weapon handling functions in addition to hooks
  103. // into the inventory system.
  104. className = "Weapon";
  105. // Basic Item properties
  106. shapeFile = "art/shapes/weapons/Ryder/TP_Ryder.DAE";
  107. mass = 1;
  108. elasticity = 0.2;
  109. friction = 0.6;
  110. emap = true;
  111. PreviewImage = 'ryder.png';
  112. // Dynamic properties defined by the scripts
  113. pickUpName = "Ryder pistol";
  114. description = "Ryder";
  115. image = RyderWeaponImage;
  116. reticle = "crossHair";
  117. };
  118. datablock ShapeBaseImageData(RyderWeaponImage)
  119. {
  120. // Basic Item properties
  121. shapeFile = "art/shapes/weapons/Ryder/TP_Ryder.DAE";
  122. shapeFileFP = "art/shapes/weapons/Ryder/FP_Ryder.DAE";
  123. emap = true;
  124. imageAnimPrefix = "Pistol";
  125. imageAnimPrefixFP = "Pistol";
  126. // Specify mount point & offset for 3rd person, and eye offset
  127. // for first person rendering.
  128. mountPoint = 0;
  129. firstPerson = true;
  130. useEyeNode = true;
  131. animateOnServer = true;
  132. // When firing from a point offset from the eye, muzzle correction
  133. // will adjust the muzzle vector to point to the eye LOS point.
  134. // Since this weapon doesn't actually fire from the muzzle point,
  135. // we need to turn this off.
  136. correctMuzzleVector = true;
  137. // Add the WeaponImage namespace as a parent, WeaponImage namespace
  138. // provides some hooks into the inventory system.
  139. class = "WeaponImage";
  140. className = "WeaponImage";
  141. // Projectiles and Ammo.
  142. item = Ryder;
  143. ammo = RyderAmmo;
  144. clip = RyderClip;
  145. projectile = BulletProjectile;
  146. projectileType = Projectile;
  147. projectileSpread = "0.0";
  148. altProjectile = GrenadeLauncherProjectile;
  149. altProjectileSpread = "0.02";
  150. casing = BulletShell;
  151. shellExitDir = "1.0 0.3 1.0";
  152. shellExitOffset = "0.15 -0.56 -0.1";
  153. shellExitVariance = 15.0;
  154. shellVelocity = 3.0;
  155. // Weapon lights up while firing
  156. lightType = "WeaponFireLight";
  157. lightColor = "0.992126 0.968504 0.700787 1";
  158. lightRadius = "4";
  159. lightDuration = "100";
  160. lightBrightness = 2;
  161. // Shake camera while firing.
  162. shakeCamera = "1";
  163. camShakeFreq = "10 10 10";
  164. camShakeAmp = "5 5 5";
  165. // Images have a state system which controls how the animations
  166. // are run, which sounds are played, script callbacks, etc. This
  167. // state system is downloaded to the client so that clients can
  168. // predict state changes and animate accordingly. The following
  169. // system supports basic ready->fire->reload transitions as
  170. // well as a no-ammo->dryfire idle state.
  171. useRemainderDT = true;
  172. // Initial start up state
  173. stateName[0] = "Preactivate";
  174. stateTransitionOnLoaded[0] = "Activate";
  175. stateTransitionOnNoAmmo[0] = "NoAmmo";
  176. // Activating the gun. Called when the weapon is first
  177. // mounted and there is ammo.
  178. stateName[1] = "Activate";
  179. stateTransitionGeneric0In[1] = "SprintEnter";
  180. stateTransitionOnTimeout[1] = "Ready";
  181. stateTimeoutValue[1] = 1.5;
  182. stateSequence[1] = "switch_in";
  183. stateSound[1] = RyderSwitchinSound;
  184. // Ready to fire, just waiting for the trigger
  185. stateName[2] = "Ready";
  186. stateTransitionGeneric0In[2] = "SprintEnter";
  187. stateTransitionOnMotion[2] = "ReadyMotion";
  188. stateScaleAnimation[2] = false;
  189. stateScaleAnimationFP[2] = false;
  190. stateTransitionOnNoAmmo[2] = "NoAmmo";
  191. stateTransitionOnTriggerDown[2] = "Fire";
  192. stateSequence[2] = "idle";
  193. // Ready to fire with player moving
  194. stateName[3] = "ReadyMotion";
  195. stateTransitionGeneric0In[3] = "SprintEnter";
  196. stateTransitionOnNoMotion[3] = "Ready";
  197. stateWaitForTimeout[3] = false;
  198. stateScaleAnimation[3] = false;
  199. stateScaleAnimationFP[3] = false;
  200. stateSequenceTransitionIn[3] = true;
  201. stateSequenceTransitionOut[3] = true;
  202. stateTransitionOnNoAmmo[3] = "NoAmmo";
  203. stateTransitionOnTriggerDown[3] = "Fire";
  204. stateSequence[3] = "run";
  205. // Fire the weapon. Calls the fire script which does
  206. // the actual work.
  207. stateName[4] = "Fire";
  208. stateTransitionGeneric0In[4] = "SprintEnter";
  209. stateTransitionOnTimeout[4] = "WaitForRelease";
  210. stateTimeoutValue[4] = 0.23;
  211. stateWaitForTimeout[4] = true;
  212. stateFire[4] = true;
  213. stateRecoil[4] = "";
  214. stateAllowImageChange[4] = false;
  215. stateSequence[4] = "fire";
  216. stateScaleAnimation[4] = true;
  217. stateSequenceNeverTransition[4] = true;
  218. stateSequenceRandomFlash[4] = true; // use muzzle flash sequence
  219. stateScript[4] = "onFire";
  220. stateEmitter[4] = GunFireSmokeEmitter;
  221. stateEmitterTime[4] = 0.025;
  222. stateEjectShell[4] = true;
  223. stateSound[4] = RyderFireSound;
  224. // Wait for the player to release the trigger
  225. stateName[5] = "WaitForRelease";
  226. stateTransitionGeneric0In[5] = "SprintEnter";
  227. stateTransitionOnTriggerUp[5] = "NewRound";
  228. stateTimeoutValue[5] = 0.05;
  229. stateWaitForTimeout[5] = true;
  230. stateAllowImageChange[5] = false;
  231. // Put another round in the chamber
  232. stateName[6] = "NewRound";
  233. stateTransitionGeneric0In[6] = "SprintEnter";
  234. stateTransitionOnNoAmmo[6] = "NoAmmo";
  235. stateTransitionOnTimeout[6] = "Ready";
  236. stateWaitForTimeout[6] = "0";
  237. stateTimeoutValue[6] = 0.05;
  238. stateAllowImageChange[6] = false;
  239. // No ammo in the weapon, just idle until something
  240. // shows up. Play the dry fire sound if the trigger is
  241. // pulled.
  242. stateName[7] = "NoAmmo";
  243. stateTransitionGeneric0In[7] = "SprintEnter";
  244. stateTransitionOnMotion[7] = "NoAmmoMotion";
  245. stateTransitionOnAmmo[7] = "ReloadClip";
  246. stateTimeoutValue[7] = 0.1; // Slight pause to allow script to run when trigger is still held down from Fire state
  247. stateScript[7] = "onClipEmpty";
  248. stateTransitionOnTriggerDown[7] = "DryFire";
  249. stateSequence[7] = "idle";
  250. stateScaleAnimation[7] = false;
  251. stateScaleAnimationFP[7] = false;
  252. stateName[8] = "NoAmmoMotion";
  253. stateTransitionGeneric0In[8] = "SprintEnter";
  254. stateTransitionOnNoMotion[8] = "NoAmmo";
  255. stateWaitForTimeout[8] = false;
  256. stateScaleAnimation[8] = false;
  257. stateScaleAnimationFP[8] = false;
  258. stateSequenceTransitionIn[8] = true;
  259. stateSequenceTransitionOut[8] = true;
  260. stateTransitionOnAmmo[8] = "ReloadClip";
  261. stateTransitionOnTriggerDown[8] = "DryFire";
  262. stateSequence[8] = "run";
  263. // No ammo dry fire
  264. stateName[9] = "DryFire";
  265. stateTransitionGeneric0In[9] = "SprintEnter";
  266. stateTransitionOnAmmo[9] = "ReloadClip";
  267. stateWaitForTimeout[9] = "0";
  268. stateTimeoutValue[9] = 0.7;
  269. stateTransitionOnTimeout[9] = "NoAmmo";
  270. stateScript[9] = "onDryFire";
  271. // Play the reload clip animation
  272. stateName[10] = "ReloadClip";
  273. stateTransitionGeneric0In[10] = "SprintEnter";
  274. stateTransitionOnTimeout[10] = "Ready";
  275. stateWaitForTimeout[10] = true;
  276. stateTimeoutValue[10] = 2.0;
  277. stateReload[10] = true;
  278. stateSequence[10] = "reload";
  279. stateShapeSequence[10] = "Reload";
  280. stateScaleShapeSequence[10] = true;
  281. stateSound[10] = RyderReloadSound;
  282. // Start Sprinting
  283. stateName[11] = "SprintEnter";
  284. stateTransitionGeneric0Out[11] = "SprintExit";
  285. stateTransitionOnTimeout[11] = "Sprinting";
  286. stateWaitForTimeout[11] = false;
  287. stateTimeoutValue[11] = 0.5;
  288. stateWaitForTimeout[11] = false;
  289. stateScaleAnimation[11] = false;
  290. stateScaleAnimationFP[11] = false;
  291. stateSequenceTransitionIn[11] = true;
  292. stateSequenceTransitionOut[11] = true;
  293. stateAllowImageChange[11] = false;
  294. stateSequence[11] = "sprint";
  295. // Sprinting
  296. stateName[12] = "Sprinting";
  297. stateTransitionGeneric0Out[12] = "SprintExit";
  298. stateWaitForTimeout[12] = false;
  299. stateScaleAnimation[12] = false;
  300. stateScaleAnimationFP[12] = false;
  301. stateSequenceTransitionIn[12] = true;
  302. stateSequenceTransitionOut[12] = true;
  303. stateAllowImageChange[12] = false;
  304. stateSequence[12] = "sprint";
  305. // Stop Sprinting
  306. stateName[13] = "SprintExit";
  307. stateTransitionGeneric0In[13] = "SprintEnter";
  308. stateTransitionOnTimeout[13] = "Ready";
  309. stateWaitForTimeout[13] = false;
  310. stateTimeoutValue[13] = 0.5;
  311. stateSequenceTransitionIn[13] = true;
  312. stateSequenceTransitionOut[13] = true;
  313. stateAllowImageChange[13] = false;
  314. stateSequence[13] = "sprint";
  315. camShakeDuration = "0.2";
  316. };