Advertisement
Guest User

Untitled

a guest
May 4th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.55 KB | None | 0 0
  1.  
  2.  
  3. AddDamageType("assaultrifle",   '<bitmap:add-ons/Weapon_assault_rifle/CI_assaultriflenew> %1',    '%2 <bitmap:add-ons/Weapon_assault_rifle/CI_assaultriflenew> %1',0.2,1);
  4. datablock ProjectileData(assaultrifleProjectile)
  5. {
  6.    projectileShapeName = "add-ons/Weapon_Gun/bullet.dts";
  7.    directDamage        = 20;
  8.    directDamageType    = $DamageType::assaultrifle;
  9.    radiusDamageType    = $DamageType::assaultrifle;
  10.  
  11.    brickExplosionRadius = 0;
  12.    brickExplosionImpact = false;          //destroy a brick if we hit it directly?
  13.    brickExplosionForce  = 10;
  14.    brickExplosionMaxVolume = 1;          //max volume of bricks that we can destroy
  15.    brickExplosionMaxVolumeFloating = 2;  //max volume of bricks that we can destroy if they aren't connected to the ground
  16.  
  17.    impactImpulse         = 0;
  18.    verticalImpulse    = 0;
  19.    explosion           = gunExplosion;
  20.    particleEmitter     = bulletTrailEmitter;
  21.  
  22.    muzzleVelocity      = 90;
  23.    velInheritFactor    = 1;
  24.  
  25.    armingDelay         = 00;
  26.    lifetime            = 4000;
  27.    fadeDelay           = 3500;
  28.    bounceElasticity    = 0.5;
  29.    bounceFriction      = 0.20;
  30.    isBallistic         = false;
  31.    gravityMod = 0.0;
  32.  
  33.    hasLight    = false;
  34.    lightRadius = 3.0;
  35.    lightColor  = "0 0 0.5";
  36.  
  37.    uiName = "Assault Rifle Bullet";
  38. };
  39.  
  40. //////////
  41. // item //
  42. //////////
  43. datablock ItemData(AssaultRifleItem)
  44. {
  45.     category = "Weapon";  // Mission editor category
  46.     className = "Weapon"; // For inventory system
  47.  
  48.      // Basic Item Properties
  49.     shapeFile = "./assaultriflenew.dts";
  50.     rotate = false;
  51.     mass = 1;
  52.     density = 0.2;
  53.     elasticity = 0.2;
  54.     friction = 0.6;
  55.     emap = true;
  56.  
  57.     //gui stuff
  58.     uiName = "Assault Rifle";
  59.     iconName = "./icon_assaultriflenew";
  60.     doColorShift = true;
  61.     colorShiftColor = "1 1 1 1.000";
  62.  
  63.      // Dynamic properties defined by the scripts
  64.     image = assaultrifleImage;
  65.     canDrop = true;
  66. };
  67.  
  68. ////////////////
  69. //weapon image//
  70. ////////////////
  71. datablock ShapeBaseImageData(assaultrifleImage)
  72. {
  73.    // Basic Item properties
  74.    shapeFile = "./assaultriflenew.dts";
  75.    emap = true;
  76.  
  77.    // Specify mount point & offset for 3rd person, and eye offset
  78.    // for first person rendering.
  79.    mountPoint = 0;
  80.    offset = "0 0 0";
  81.    eyeOffset = 0; //"0.7 1.2 -0.5";
  82.    rotation = eulerToMatrix( "0 0 0" );
  83.  
  84.    // When firing from a point offset from the eye, muzzle correction
  85.    // will adjust the muzzle vector to point to the eye LOS point.
  86.    // Since this weapon doesn't actually fire from the muzzle point,
  87.    // we need to turn this off.  
  88.    correctMuzzleVector = true;
  89.  
  90.    // Add the WeaponImage namespace as a parent, WeaponImage namespace
  91.    // provides some hooks into the inventory system.
  92.    className = "WeaponImage";
  93.  
  94.    // Projectile && Ammo.
  95.    item = assaultrifleItem;
  96.    ammo = " ";
  97.    projectile = assaultrifleProjectile;
  98.    projectileType = Projectile;
  99.  
  100.     casing = gunShellDebris;
  101.     shellExitDir        = "2.0 -1.3 1.0";
  102.     shellExitOffset     = "0 0 0";
  103.     shellExitVariance   = 15.0;
  104.     shellVelocity       = 7.0;
  105.  
  106.    //melee particles shoot from eye node for consistancy
  107.    melee = false;
  108.    //raise your arm up or not
  109.    armReady = true;
  110.  
  111.    doColorShift = true;
  112.    colorShiftColor = assaultrifleItem.colorShiftColor;//"0.400 0.196 0 1.000";
  113.  
  114.    //casing = " ";
  115.  
  116.    // Images have a state system which controls how the animations
  117.    // are run, which sounds are played, script callbacks, etc. This
  118.    // state system is downloaded to the client so that clients can
  119.    // predict state changes and animate accordingly.  The following
  120.    // system supports basic ready->fire->reload transitions as
  121.    // well as a no-ammo->dryfire idle state.
  122. // Initial start up state
  123.     stateName[0]                     = "Activate";
  124.     stateTimeoutValue[0]             = 0.1;
  125.     stateTransitionOnTimeout[0]       = "Ready";
  126.  
  127.     stateSound[0]                   = activateSound;
  128.  
  129.     stateName[1]                     = "Ready";
  130.     stateTransitionOnTriggerDown[1]  = "Fire";
  131.     stateAllowImageChange[1]         = true;
  132.  
  133.     stateSequence[1]    = "Ready";
  134.  
  135.     stateName[2]                    = "Fire";
  136.     stateTransitionOnTimeout[2]     = "smoke";
  137.     stateTimeoutValue[2]            = 0.075;
  138.     stateFire[2]                    = true;
  139.     stateAllowImageChange[2]        = false;
  140.     stateSequence[2]                = "Fire";
  141.     stateScript[2]                  = "onFire";
  142.     stateWaitForTimeout[2]          = true;
  143.     stateEmitter[2]                 = gunFlashEmitter;
  144.     stateEmitterTime[2]             = 0.05;
  145.     stateEjectShell[2]            = true;
  146.     stateEmitterNode[2]             = "muzzleNode";
  147.     stateSound[2]                   = gunshot1Sound;
  148.    stateSequence[2]                = "Fire";
  149.     stateEjectShell[2]       = true;
  150.  
  151.  
  152.  
  153.  
  154.  
  155.     stateName[3] = "Smoke";
  156.     stateEmitter[3]                 = gunSmokeEmitter;
  157.     stateEmitterTime[3]             = 0;
  158.     stateEmitterNode[3]             = "muzzleNode";
  159.     stateTimeoutValue[3]            = 0.0;
  160.         stateTransitionOnTimeout[3]     = "Reload";
  161.  
  162.  
  163.  
  164.     stateName[4]            = "Reload";
  165.     stateAllowImageChange[4]        = false;
  166.     stateTimeoutValue[4]            = 0.05;
  167.     stateWaitForTimeout[4]      = true;
  168.     stateTransitionOnTimeout[4]     = "Check";
  169.     //stateTransitionOnTriggerUp[4]     = "Ready";
  170.  
  171.    
  172.     stateName[5]            = "Check";
  173.     stateTransitionOnTriggerUp[5]   = "StopFire";
  174.     stateTransitionOnTriggerDown[5] = "Ready";
  175.    
  176.     stateName[6]                    = "StopFire";
  177.     stateTransitionOnTimeout[6]     = "Ready";
  178.     stateTimeoutValue[6]            = 0.01;
  179.     stateAllowImageChange[6]        = false;
  180.     stateWaitForTimeout[6]          = true;
  181.  
  182.     stateScript[6]                  = "onStopFire";
  183. };
  184.  
  185. function assaultrifleImage::onFire(%this,%obj,%slot)
  186. {
  187.     if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
  188.         return;
  189.     %obj.lastFireTime = getSimTime();
  190.  
  191.     %projectile = %this.projectile;
  192.     %spread = 0.001;
  193.     %shellcount = 1;
  194.  
  195.     for(%shell=0; %shell<%shellcount; %shell++)
  196.     {
  197.         %vector = %obj.getMuzzleVector(%slot);
  198.         %objectVelocity = %obj.getVelocity();
  199.         %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
  200.         %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
  201.         %velocity = VectorAdd(%vector1,%vector2);
  202.         %x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
  203.         %y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
  204.         %z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
  205.         %mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
  206.         %velocity = MatrixMulVector(%mat, %velocity);
  207.  
  208.         %p = new (%this.projectileType)()
  209.         {
  210.             dataBlock = %projectile;
  211.             initialVelocity = %velocity;
  212.             initialPosition = %obj.getMuzzlePoint(%slot);
  213.             sourceObject = %obj;
  214.             sourceSlot = %slot;
  215.             client = %obj.client;
  216.         };
  217.         MissionCleanup.add(%p);
  218.     }
  219.     return %p;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement