Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ThrowingKnifeKnife.cs
- datablock AudioProfile(ThrowingKnifeBrickSound)
- {
- filename = "./KnifeBrick.wav";
- description = AudioClosest3d;
- preload = true;
- };
- datablock AudioProfile(ThrowingKnifePlayerSound)
- {
- filename = "./KnifePlayer.wav";
- description = AudioClosest3d;
- preload = true;
- };
- datablock AudioProfile(ThrowingKnifeSwingSound)
- {
- filename = "./KnifeSwing.wav";
- description = AudioClosest3d;
- preload = true;
- };
- datablock AudioProfile(swordDrawSound)
- {
- filename = "./swordDraw.wav";
- description = AudioClosest3d;
- preload = true;
- };
- datablock ParticleData(ThrowingKnifeExplosionParticle)
- {
- dragCoefficient = 5;
- gravityCoefficient = 0.1;
- inheritedVelFactor = 0.2;
- constantAcceleration = 0.0;
- lifetimeMS = 500;
- lifetimeVarianceMS = 300;
- textureName = "base/data/particles/chunk";
- spinSpeed = 10.0;
- spinRandomMin = -50.0;
- spinRandomMax = 50.0;
- colors[0] = "0.9 0.9 0.6 0.9";
- colors[1] = "0.9 0.5 0.6 0.0";
- sizes[0] = 0.25;
- sizes[1] = 0.0;
- };
- datablock ParticleEmitterData(ThrowingKnifeExplosionEmitter)
- {
- ejectionPeriodMS = 1;
- periodVarianceMS = 0;
- ejectionVelocity = 5;
- velocityVariance = 0.0;
- ejectionOffset = 0.0;
- thetaMin = 80;
- thetaMax = 80;
- phiReferenceVel = 0;
- phiVariance = 360;
- overrideAdvance = false;
- particles = "ThrowingKnifeExplosionParticle";
- uiName = "ThrowingKnife Hit";
- };
- datablock ExplosionData(ThrowingKnifeExplosion)
- {
- //explosionShape = "";
- lifeTimeMS = 500;
- soundProfile = ThrowingKnifeBrickSound;
- particleEmitter = ThrowingKnifeExplosionEmitter;
- particleDensity = 10;
- particleRadius = 0.2;
- faceViewer = true;
- explosionScale = "0.5 1 1";
- shakeCamera = true;
- camShakeFreq = "20.0 22.0 20.0";
- camShakeAmp = "1.0 1.0 1.0";
- camShakeDuration = 0.5;
- camShakeRadius = 10.0;
- // Dynamic light
- lightStartRadius = 2;
- lightEndRadius = 0;
- lightStartColor = "1 0 0";
- lightEndColor = "0 0 0";
- };
- //Stab Projectile
- AddDamageType("ThrowingKnife", '<bitmap:add-ons/Weapon_Throwing_Knife/CI_ThrowingKnife> %1', '%2 <bitmap:add-ons/Weapon_Throwing_Knife/CI_ThrowingKnife> %1',0.75,1);
- datablock ProjectileData(ThrowingKnifeStabProjectile)
- {
- shapeFile = "base/data/shapes/empty.dts";
- directDamage = 20;
- directDamageType = $DamageType::ThrowingKnife;
- radiusDamageType = $DamageType::ThrowingKnife;
- brickExplosionRadius = 0;
- brickExplosionImpact = true;
- brickExplosionForce = 0;
- brickExplosionMaxVolume = 1;
- brickExplosionMaxVolumeFloating = 2;
- explosion = ThrowingKnifeExplosion;
- muzzleVelocity = 50;
- velInheritFactor = 1;
- armingDelay = 0;
- lifetime = 75;
- fadeDelay = 70;
- bounceElasticity = 0;
- bounceFriction = 0;
- isBallistic = true;
- gravityMod = 0.50;
- hasLight = false;
- lightRadius = 3.0;
- lightColor = "1 0 0";
- uiName = "Throwing Knife Stab";
- };
- datablock ParticleData(spearTrailParticle)
- {
- dragCoefficient = 3.0;
- windCoefficient = 0.0;
- gravityCoefficient = 0.0;
- inheritedVelFactor = 0.0;
- constantAcceleration = 0.0;
- lifetimeMS = 600;
- lifetimeVarianceMS = 0;
- spinSpeed = 10.0;
- spinRandomMin = -50.0;
- spinRandomMax = 50.0;
- useInvAlpha = true;
- animateTexture = false;
- //framesPerSec = 1;
- textureName = "base/data/particles/ring";
- //animTexName = " ";
- // Interpolation variables
- colors[0] = "0.75 0.75 0.75 0.3";
- colors[1] = "0.75 0.75 0.75 0.2";
- colors[2] = "1 1 1 0.0";
- sizes[0] = 0.15;
- sizes[1] = 0.35;
- sizes[2] = 0.05;
- times[0] = 0.0;
- times[1] = 0.1;
- times[2] = 1.0;
- };
- datablock ParticleEmitterData(spearTrailEmitter)
- {
- ejectionPeriodMS = 5;
- periodVarianceMS = 0;
- ejectionVelocity = 0; //0.25;
- velocityVariance = 0; //0.10;
- ejectionOffset = 0;
- thetaMin = 0.0;
- thetaMax = 90.0;
- particles = spearTrailParticle;
- useEmitterColors = true;
- uiName = "Spear Trail";
- };
- datablock ParticleData(arrowExplosionParticle)
- {
- dragCoefficient = 8;
- gravityCoefficient = -0.3;
- inheritedVelFactor = 0.2;
- constantAcceleration = 0.0;
- lifetimeMS = 500;
- lifetimeVarianceMS = 300;
- textureName = "base/data/particles/cloud";
- spinSpeed = 10.0;
- spinRandomMin = -50.0;
- spinRandomMax = 50.0;
- colors[0] = "0.5 0.5 0.5 0.9";
- colors[1] = "0.5 0.5 0.5 0.0";
- sizes[0] = 0.45;
- sizes[1] = 0.0;
- useInvAlpha = true;
- };
- datablock ParticleEmitterData(arrowExplosionEmitter)
- {
- ejectionPeriodMS = 1;
- periodVarianceMS = 0;
- ejectionVelocity = 3;
- velocityVariance = 0.0;
- ejectionOffset = 0.0;
- thetaMin = 0;
- thetaMax = 180;
- phiReferenceVel = 0;
- phiVariance = 360;
- overrideAdvance = false;
- particles = "arrowExplosionParticle";
- useEmitterColors = true;
- uiName = "Arrow Vanish";
- };
- datablock ExplosionData(arrowExplosion)
- {
- //explosionShape = "";
- soundProfile = "";
- lifeTimeMS = 50;
- emitter[0] = arrowExplosionEmitter;
- faceViewer = true;
- explosionScale = "1 1 1";
- shakeCamera = false;
- camShakeFreq = "10.0 11.0 10.0";
- camShakeAmp = "1.0 1.0 1.0";
- camShakeDuration = 0.5;
- camShakeRadius = 10.0;
- // Dynamic light
- lightStartRadius = 0;
- lightEndRadius = 1;
- lightStartColor = "0.3 0.6 0.7";
- lightEndColor = "0 0 0";
- };
- //Thrown projectile
- datablock ProjectileData(ThrowingKnifeThrowProjectile)
- {
- projectileShapeName = "./ThrowingKnifeProjectile.dts";
- directDamage = 100;
- directDamageType = $DamageType::ThrowingKnife;
- radiusDamageType = $DamageType::ThrowingKnife;
- particleEmitter = spearTrailEmitter;
- stickExplosion = ThrowingKnifeExplosion;
- bloodExplosion = ThrowingKnifeExplosion;
- explosion = arrowExplosion;
- explodeOnPlayerImpact = true;
- explodeOnDeath = true;
- armingDelay = 8000;
- lifetime = 8000;
- fadeDelay = 8000;
- isBallistic = true;
- bounceAngle = 180; //stick almost all the time
- minStickVelocity = 10;
- bounceElasticity = 0;
- bounceFriction = 1;
- gravityMod = 0.35;
- doColorShift = false;
- colorShiftColor = "0.471 0.471 0.471 1.000";
- hasLight = false;
- lightRadius = 3.0;
- lightColor = "0 0 1";
- muzzleVelocity = 75;
- velInheritFactor = 1;
- lightColor = "0 0 0.5";
- uiName = "Throwing Knife Throw";
- };
- //////////
- // item //
- //////////
- datablock ItemData(ThrowingKnifeItem)
- {
- category = "Weapon"; // Mission editor category
- className = "Weapon"; // For inventory system
- // Basic Item Properties
- shapeFile = "./ThrowingKnife.dts";
- mass = 1;
- density = 0.2;
- elasticity = 0.2;
- friction = 0.6;
- emap = true;
- //gui stuff
- uiName = "Throwing Knife";
- iconName = "./icon_ThrowingKnife";
- doColorShift = false;
- colorShiftColor = "0.471 0.471 0.471 1.000";
- // Dynamic properties defined by the scripts
- image = ThrowingKnifeImage;
- canDrop = true;
- };
- ////////////////
- //weapon image//
- ////////////////
- datablock ShapeBaseImageData(ThrowingKnifeImage)
- {
- // Basic Item properties
- shapeFile = "./ThrowingKnife.dts";
- emap = true;
- // Specify mount point & offset for 3rd person, and eye offset
- // for first person rendering.
- mountPoint = 0;
- offset = "0 0 0";
- // When firing from a point offset from the eye, muzzle correction
- // will adjust the muzzle vector to point to the eye LOS point.
- // Since this weapon doesn't actually fire from the muzzle point,
- // we need to turn this off.
- correctMuzzleVector = false;
- eyeOffset = "0 0 0";
- // Add the WeaponImage namespace as a parent, WeaponImage namespace
- // provides some hooks into the inventory system.
- className = "WeaponImage";
- // Projectile && Ammo.
- item = ThrowingKnifeItem;
- ammo = " ";
- projectile = ThrowingKnifeStabProjectile;
- projectileType = Projectile;
- //melee particles shoot from eye node for consistancy
- melee = true;
- doRetraction = false;
- //raise your arm up or not
- armReady = true;
- //casing = " ";
- doColorShift = false;
- colorShiftColor = "0.471 0.471 0.471 1.000";
- // Images have a state system which controls how the animations
- // are run, which sounds are played, script callbacks, etc. This
- // state system is downloaded to the client so that clients can
- // predict state changes and animate accordingly. The following
- // system supports basic ready->fire->reload transitions as
- // well as a no-ammo->dryfire idle state.
- // Initial start up state
- stateName[0] = "Activate";
- stateTimeoutValue[0] = 0.5;
- stateTransitionOnTimeout[0] = "Ready";
- stateSound[0] = swordDrawSound;
- stateName[1] = "Ready";
- stateTransitionOnTriggerDown[1] = "PreFire";
- stateAllowImageChange[1] = true;
- stateName[2] = "PreFire";
- stateScript[2] = "onPreFire";
- stateAllowImageChange[2] = false;
- stateTimeoutValue[2] = 0.1;
- stateTransitionOnTimeout[2] = "Fire";
- stateName[3] = "Fire";
- stateTransitionOnTimeout[3] = "CheckFire";
- stateTimeoutValue[3] = 0.2;
- stateFire[3] = true;
- stateAllowImageChange[3] = false;
- stateSequence[3] = "Fire";
- stateScript[3] = "onFire";
- stateWaitForTimeout[3] = true;
- stateSound[3] = ThrowingKnifeSwingSound;
- stateName[4] = "CheckFire";
- stateTransitionOnTriggerUp[4] = "StopFire";
- stateTransitionOnTriggerDown[4] = "Fire";
- stateName[5] = "StopFire";
- stateTransitionOnTimeout[5] = "Ready";
- stateTimeoutValue[5] = 0.2;
- stateAllowImageChange[5] = false;
- stateWaitForTimeout[5] = true;
- stateSequence[5] = "StopFire";
- stateScript[5] = "onStopFire";
- };
- function ThrowingKnifeImage::onPreFire(%this, %obj, %slot)
- {
- %obj.playthread(2, armattack);
- }
- function ThrowingKnifeImage::onStopFire(%this, %obj, %slot)
- {
- %obj.playthread(2, root);
- }
- package ThrowingKnifePackage
- {
- function ThrowingKnifeStabProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
- {
- %currSlot = %obj.currTool;
- %client = %obj.sourceObject.client;
- if(isObject(%col.client.minigame))
- {
- if(%obj.client.minigame $= %col.client.minigame)
- {
- if(%col.getClassName() $= "Player")
- {
- if($ThrowingKnifeStabLimit==1)
- {
- %obj.sourceObject.tool[%currSlot] = 0;
- %obj.sourceObject.weaponCount--;
- messageClient(%obj.client,'MsgItemPickup',"",%currSlot,0);
- serverCmdUnUseTool(%obj.client);
- }
- serverPlay3D(ThrowingKnifePlayerSound, %pos);
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- }
- }
- if((%col.getType() && $TypeMasks::FxBrickObjectType))
- {
- serverPlay3D(ThrowingKnifeBrickSound, %pos);
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- else
- {
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- }
- function ThrowingKnifeThrowProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client)
- {
- if((%col.getType() & $TypeMasks::PlayerObjectType) && isObject(%col.client))
- {
- serverPlay3D(ThrowingKnifePlayerSound, %pos);
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- if((%col.getType() && $TypeMasks::FxBrickObjectType))
- {
- serverPlay3D(ThrowingKnifeBrickSound, %pos);
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- else
- {
- return Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal, %client);
- }
- }
- function Armor::onTrigger(%this, %player, %slot, %val)
- {
- if(%player.getMountedImage(0) $= ThrowingKnifeImage.getID() && %slot $= 4 && %val)
- {
- %currSlot = %player.currTool;
- %player.tool[%currSlot] = 0;
- %player.weaponCount--;
- messageClient(%player.client,'MsgItemPickup','',%currSlot,0);
- serverCmdUnUseTool(%player.client);
- %projectile = ThrowingKnifeThrowProjectile;
- %vector = %player.getMuzzleVector(0);
- %objectVelocity = %player.getVelocity();
- %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
- %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
- %velocity = VectorAdd(%vector1,%vector2);
- %p = new Projectile()
- {
- dataBlock = %projectile;
- initialVelocity = %velocity;
- initialPosition = %player.getMuzzlePoint(0);
- sourceObject = %player;
- sourceSlot = 0;
- client = %player.client;
- };
- serverPlay3D(ThrowingKnifeSwingSound,%player.getPosition());
- %player.playthread("3","Activate");
- MissionCleanup.add(%p);
- return %p;
- }
- Parent::onTrigger(%this, %player, %slot, %val);
- }
- };
- activatePackage(ThrowingKnifePackage);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement