Alright so all model changes are done. Now I'm trying to change the left mouse button attack function to something more similar to the pill script where you can eat the pizza and gain health. While keeping the right mouse button attack throw.
//server.cs
datablock AudioProfile(ThrowingKnifeBrickSound)
{
filename = "./KnifeBrick.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(ThrowingKnifePlayerSound)
{
filename = "./KnifePlayer.wav";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(knifeDrawSound)
{
filename = "./knifeDraw.wav";
description = AudioClosest3d;
preload = true;
};
datablock ParticleData(PizzaExplosionParticle)
{
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(PizzathrownExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 5;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 80;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "PizzathrownExplosionParticle";
uiName = "PizzaThrown Hit";
};
datablock ExplosionData(PizzathrownExplosion)
{
//explosionShape = "";
lifeTimeMS = 500;
soundProfile = ThrowingKnifeBrickSound;
particleEmitter = PizzathrownExplosionEmitter;
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";
};
datablock DecalData(Pizzastab)
{
textureName = "add-ons/Weapon_Pizza/CI_Pizza.png";
};
//Stab Projectile
AddDamageType("Pizzastab", '<bitmap:add-ons/Weapon_Pizza/CI_Pizza> %1', '%2 <bitmap:add-ons/Weapon_Pizza/CI_Pizza> %1',0.75,1);
datablock ProjectileData(PizzaStabProjectile)
{
shapeFile = "base/data/shapes/empty.dts";
directDamage = 20;
directDamageType = $DamageType::Pizzastab;
radiusDamageType = $DamageType::Pizzastab;
brickExplosionRadius = 0;
brickExplosionImpact = true;
brickExplosionForce = 0;
brickExplosionMaxVolume = 1;
brickExplosionMaxVolumeFloating = 2;
explosion = PizzathrownExplosion;
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 = "Pizza Stab";
};
datablock ParticleData(PizzaTrailParticle)
{
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(PizzaTrailEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 0; //0.25;
velocityVariance = 0; //0.10;
ejectionOffset = 0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = PizzaTrailParticle;
useEmitterColors = true;
uiName = "Pizza Trail";
};
datablock ParticleData(PizzaExplosionParticle)
{
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(PizzaExplosionEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "PizzaExplosionParticle";
useEmitterColors = true;
uiName = "Pizza Vanish";
};
datablock ExplosionData(PizzaExplosion)
{
//explosionShape = "";
soundProfile = "";
lifeTimeMS = 50;
emitter[0] = PizzaExplosionEmitter;
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";
};
datablock DecalData(Pizzathrow)
{
textureName = "add-ons/Weapon_Pizza/CI_Pizza.png";
};
//Thrown projectile
AddDamageType("Pizzathrow", '<bitmap:add-ons/Weapon_Pizza/CI_Pizza> %1', '%2 <bitmap:add-ons/Weapon_Pizza/CI_Pizza> %1',0.75,1);
datablock ProjectileData(PizzaThrowProjectile)
{
projectileShapeName = "./Pizza-projectile.dts";
directDamage = 35;
directDamageType = $DamageType::Pizzathrow;
radiusDamageType = $DamageType::Pizzathrow;
particleEmitter = PizzaTrailEmitter;
stickExplosion = PizzathrownExplosion;
bloodExplosion = PizzathrownExplosion;
explosion = PizzaExplosion;
explodeOnPlayerImpact = true;
explodeOnDeath = true;
armingDelay = 20;
lifetime = 6000;
fadeDelay = 20;
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 = "Pizza Throw";
};
package PizzaPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "PizzaItem" && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}
if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(PizzaPackage);
//////////
// item //
//////////
datablock ItemData(PizzaItem)
{
category = "Weapon"; // Mission editor category
className = "Weapon"; // For inventory system
// Basic Item Properties
shapeFile = "./Pizza.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;
//gui stuff
uiName = "Pizza";
iconName = "./icon_Pizza";
doColorShift = false;
colorShiftColor = "0.471 0.471 0.471 1.000";
// Dynamic properties defined by the scripts
image = PizzaImage;
canDrop = true;
};
////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(PizzaImage)
{
// Basic Item properties
shapeFile = "./Pizza.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 = PizzaItem;
ammo = " ";
projectile = PizzaStabProjectile;
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] = knifeDrawSound;
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;
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 PizzaImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack);
}
function PizzaImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
package PizzaPackage
{
function PizzaStabProjectile::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($PizzaStabLimit==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 PizzaThrowProjectile::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) $= PizzaImage.getID() && %slot $= 4 && %val)
{
%currSlot = %player.currTool;
%player.tool[%currSlot] = 0;
%player.weaponCount--;
messageClient(%player.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%player.client);
%projectile = PizzaThrowProjectile;
%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(PizzaPackage);