Author Topic: Gravity projectiles  (Read 906 times)

Hello guys i really need help with a new addone i though i should make.
I was trying to make the fludd addone by
Into a splatoon paint gun.
I though it was a good idea to add gravity to the gun because i wanted to make it just like in the game.
But then i realized by editing the gravity code i seen there i only edited the emitter gravity.
But not the projectile.
Anybody can help?
Code: [Select]
$FLUDD::MaxWater = 1000; //*
//Suggested to at least be 250

$FLUDD::StartWithWater = false;
//Start with a full tank of water?

$FLUDD::DropWaterBottleOnDeath = false;
//When you die, drop a water bottle that can be picked up to
//fill up your FLUDD's tank some/all the way.

$FLUDD::RotateWaterBottle = true;
//Do we want water bottles to spin in around in circles?

$FLUDD::DisplayWaterBottleValue = false;
//Display how much water is in water bottles dropped by
//players?

$FLUDD::WaterBottleDieTime = 12000;
//How long do water bottles take to disappear after they've
//been dropped by a player? Must be above 500.

$FLUDD::AvailableNozzles = 1; //*
//0 = You always have squirt mode and one
//other mode, the other mode is, by default hover mode, but can be
//changed out for a different mode if you find a nozzle box or a
//nozzle spawn.
//1 = Any nozzle may be used at any time.

//*Requires restart if changed.

exec("./waterAmmo.cs");

datablock AudioProfile(FLUDDSwitchSound)
{
filename = "./FLUDD_switch.wav";
description = AudioClosest3d;
preload = true;
};

datablock AudioProfile(FLUDDSquirtSound)
{
filename = "./SplaterShotfire.ogg";
description = AudioClosestLooping3d;
preload = true;
};

datablock ParticleData(FLUDDParticle) //The water that you spray out of the
{       //nozzle.
dragCoefficient = 0.0;
windCoefficient = 1.0;
gravityCoefficient = 1.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1000.0;
lifetimeVarianceMS = 500.0;
spinSpeed = 50.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;

textureName = "base/data/particles/cloud";
animateTexture = false;

colors[0] = "0.000000 0.000000 0.466667 1.000000";
colors[1] = "0.000000 0.400000 0.800000 1.800000";
colors[2] = "0.000000 0.000000 0.000000 1.000000";
colors[3] = "0.000000 0.000000 0.000000 1.000000";

sizes[0] = 0.0946103;
sizes[1] = 0.897272;
  sizes[2] = 1;
  sizes[3] = 1;

    times[0] = 0;
    times[1] = 1;
    times[2] = 2;
  times[3] = 2;

useInvAlpha = true;
};

datablock ParticleEmitterData(FLUDDEmitter) //The water that you spray out
{     //of the nozzle.
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 20;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 5;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
orientOnVelocity = true;
particles = "FLUDDParticle";

uiName = "FLUDD Squirt";
};

datablock ParticleData(FLUDDExplosionParticle) //The splash that appears
{        //when you hit something.
dragCoefficient = 0.0;
gravityCoefficient = 5.0;
windCoefficient = 0.0;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1000.0;
lifetimeVarianceMS = 500.0;
spinSpeed = 50.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;

textureName = "base/data/particles/cloud";
animateTexture = false;

colors[0] = "0.000000 0.000000 0.466667 1.000000";
colors[1] = "0.000000 0.400000 0.800000 1.800000";
colors[2] = "0.000000 0.000000 0.000000";
colors[3] = "0.000000 0.000000 0.000000 1.000000";

sizes[0] = 0.19990225;
sizes[1] = 0.29909;
sizes[2] = 0.25;
sizes[3] = 0.25;

times[0] = 0;
times[1] = 1;
times[2] = 2;
times[3] = 2;

useInvAlpha = true;
};
datablock ParticleEmitterData(FLUDDExplosionEmitter) //The splash that
{      //appears when you hit
ejectionPeriodMS = 40;      //something.
periodVarianceMS = 0;
ejectionVelocity = 3.5;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 35;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
orientOnVelocity = true;
particles = "FLUDDExplosionParticle";

uiName = "FLUDD Splash";
};

datablock ExplosionData(FLUDDExplosion)
{
lifeTimeMS = 128;

particleEmitter = FLUDDExplosionEmitter;
particleDensity = 3;
particleRadius = 0.3;
explosionScale = "5 5 5";

damageRadius = 1;
radiusDamage = 5;

uiName = "FLUDD Splash";
};

addDamageType("FLUDD", '<bitmap:base/client/ui/ci/skull> %1', '%2 <bitmap:base/client/ui/ci/skull> %1', 1, 1);

datablock ProjectileData(FLUDD_SquirtProjectile)
{
directDamage = 35;
directDamageType = $DamageType::FLUDD;
explosion = FLUDDExplosion;

//verticalImpulse = 250;
//impactImpulse = 250;
newVerticleImpulse = 5;
newImpactImpulse = 8;

muzzleVelocity = 25;
velInheritFactor = 1;

armingDelay = 0;
lifetime = 300;
fadeDelay = 0;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0;

uiName = "FLUDD Squirt";
};

datablock ItemData(FLUDDItem)
{
category = "Weapon";
className = "Weapon";

shapeFile = "./SplaterShot.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

uiName = "SplaterShot";
iconName = "./icon_SplaterShot";
doColorShift = false;
colorShiftColor = "1 1 0 1";

image = FLUDD_SquirtModeImage;
canDrop = true;
};

datablock ShapeBaseImageData(FLUDD_SquirtModeImage)
{
shapeFile = "./SplaterShot.dts";
emap = true;
rotation = "1 0 0 0";
correctMuzzleVector = true;
className = "WeaponImage";

item = FLUDDItem;
ammo = " ";
projectile = FLUDD_SquirtProjectile;
projectileType = Projectile;

melee = false;
armReady = true;

doRetraction = false;

doColorShift = false;
colorShiftColor = FLUDDItem.colorShiftColor;

stateName[0]    = "Activate";
stateTimeoutValue[0]    = 0.01;
stateTransitionOnTimeout[0]    = "Ready";
stateSequence[0]    = "Ready";
stateSound[0]    = FLUDDSwitchSound;

stateName[1]    = "Ready";
stateTransitionOnTriggerDown[1]    = "PreFire";
stateAllowImageChange[1]    = true;

stateName[2]    = "PreFire";
stateTransitionOnAmmo[2]    = "Fire";
stateTransitionOnNoAmmo[2]    = "Done";
stateAllowImageChange[2]    = true;

stateName[3]    = "Fire";
stateTransitionOnTriggerUp[3]    = "StopFire";
stateTransitionOnTimeout[3]    = "Fire";
stateTimeoutValue[3]    = 0.04;
stateWaitForTimeout[3]    = true;
stateFire[3]    = true;
stateAllowImageChange[3]    = true;
stateSound[3]    = FLUDDSquirtSound;
stateScript[3]    = "onFire";
stateEmitter[3]    = FLUDDEmitter;
stateEmitterTime[3]    = 0.07;
stateSequence[3]    = "fire";
stateTransitionOnNoAmmo[3]    = "Done";

stateName[4]    = "StopFire";
stateTransitionOnTimeout[4]    = "Ready";
stateWaitForTimeout[4]    = true;
stateAllowImageChange[4]    = true;
stateSequence[4]    = "stopFire";
stateScript[4]    = "ammoCheck";

stateName[5]    = "Done";
stateTimeoutValue[5]    = 0.3;
stateTransitionOnTimeout[5]    = "Ready";
stateAllowImageChange[5]    = false;
stateScript[5]    = "ammoCheck";
};

function FLUDD_SquirtModeImage::onMount(%data, %player, %slot)
{
%player.playThread(0, "armReadyBoth");

if(!%player.ammo["Water"])
{
%player.ammo["Water"] = 0;

if(!%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ff0000>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);

return;
}
}

else if(%player.ammo["Water"] > $FLUDD::MaxWater)
{
%player.ammo["Water"] = $FLUDD::MaxWater;
}

if(!%player.client.hasFLUDDCLient)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ffff00>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}

else
{
commandToClient(%player.client, 'isUsingFLUDD', 1);
commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

function FLUDD_SquirtModeImage::onUnMount(%data, %player, %slot)
{
%player.playThread(0, "root");

if(!%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'clearCenterPrint');
}

else
{
commandToClient(%player.client, 'isUsingFLUDD', 0);
}
}

function FLUDD_SquirtModeImage::ammoCheck(%data, %player, %slot)
{
FLUDD_ammoCheck(%data, %player, %slot);
}

function FLUDD_ammoCheck(%data, %player, %slot)
{
if(%player.isInWater)
{
%player.ammo["Water"] += mFloor($FLUDD::MaxWater / 5 + 0.5);
}

if(!%player.ammo["Water"])
{
%player.ammo["Water"] = 0;
}

else if(%player.ammo["Water"] > $FLUDD::MaxWater)
{
%player.ammo["Water"] = $FLUDD::MaxWater;
}

if((%player.ammo["Water"] <= 0) || (%player.isInWater && %player.ammo["Water"] < $FLUDD::MaxWater))
{
%player.setImageAmmo(%slot, 0);

if(!%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ff0000>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}
}

else
{
%player.setImageAmmo(%slot, 1);

if(!%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ffff00>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}
}

if(%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

function serverCmdFLUDDHandshake(%client)
{
%client.hasFLUDDClient = true;
}

function FLUDDItem::onPickup(%data, %item, %player, %a)
{
parent::onPickup(%data, %item, %player, %a);

if(isObject(%item.spawnBrick) && $FLUDD::StartWithWater)
{
%player.ammo["Water"] = $FLUDD::MaxWater;

commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

registerInputEvent("fxDTSBrick", "onFLUDDHit", "Self fxDTSBrick" TAB "Player player" TAB "Client gameConnection" TAB "MiniGame");

registerOutputEvent(Player, "addFLUDDWater", "int 1" SPC $FLUDD::MaxWater SPC "1");
registerOutputEvent(Player, "deductFLUDDWater", "int 1" SPC $FLUDD::MaxWater SPC "1");
registerOutputEvent(Player, "setFLUDDWater", "int 0" SPC $FLUDD::MaxWater SPC "0");

function FLUDD_SquirtProjectile::onCollision(%data, %player, %col, %fade, %pos, %normal)
{
if(%col.getClassName() $= "fxDTSBrick")
{
$InputTarget_["Self"] = %col;
$InputTarget_["Player"] = %player;
$InputTarget_["Client"] = %player.client;

if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%player.client);
}

else
{
if(getMiniGameFromObject(%col) == getMiniGameFromObject(%player.client))
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%col);
}

else
{
$InputTarget_["MiniGame"] = 0;
}
}

%col.processInputEvent("onFLUDDHit", %player.client);
}

else
{
if(isFunction(%col, "getDataBlock"))
{
if(isFunction(%col.getDataBlock().getName(), "onFLUDDHit"))
{
%col.getDataBlock().onFLUDDHit(%player, %col, %pos);
}
}

if(isFunction(%col.getClassName(), "onFLUDDHit"))
{
%col.onFLUDDHit(%player, %pos);
}
}

if(isObject(SprayDecal1) || isObject(SprayDecal2))
{
initContainerRadiusSearch(%pos, 0.4, $TypeMasks::StaticShapeObjectType);

while(isObject(%obj = containerSearchNext()))
{
if(%obj.isBlood && !isEventPending(%obj.fadeAnimationLoop))
{
fadeAnimationLoop(%obj, 16, %obj.getScale());

if(isObject(bloodSpillSound))
{
serverPlay3D(bloodSpillSound, %obj.getPosition());
}
}
}
}

parent::onCollision(%data, %player, %col, %fade, %pos, %normal);
}

function player::onFLUDDHit(%col, %player, %pos)
{
for(%i = 2; %i < 7; %i++)
{
if(isObject(%col.getMountedImage(%i)))
{
if(%col.getMountedImage(%i).getName() $= "FireBurnPlayerImage" || %col.getMountedImage(%i).getName() $= "gc_burningImage")
{
%col.unMountImage(%i);
}

else if(%col.getMountedImage(%i).getName() $= "PlayerNapalmBurnImage")
{
cancel(%col.damageBurnSched);

%col.damageBurnLoops = 0;
%col.damageBurnDamage = 0;
%col.unMountImage(%i);
}
}
}
}

function player::addFLUDDWater(%player, %num)
{
if(%num < 1)
{
return;
}

if(%num > $FLUDD::MaxWater)
{
%num = $FLUDD::MaxWater;
}

%player.ammo["Water"] += %num;

if(%player.ammo["Water"] > $FLUDD::MaxWater)
{
%player.ammo["Water"] = $FLUDD::MaxWater;
}

if(!%player.client.hasFLUDDClient)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ffff00>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}

else
{
commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

function player::deductFLUDDWater(%player, %num)
{
if(%num < 1)
{
return;
}

if(%num > $FLUDD::MaxWater)
{
%num = $FLUDD::MaxWater;
}

%player.ammo["Water"] -= %num;

if(%player.ammo["Water"] < 0)
{
%player.ammo["Water"] = 0;
}

if(!%player.client.hasFLUDDClient)
{
if(%player.ammo["Water"] <= 0)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ff0000>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}

else
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ffff00>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}
}

else
{
commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

function player::setFLUDDWater(%player, %num)
{
if(%num < 0)
{
return;
}

if(%num > $FLUDD::MaxWater)
{
%num = $FLUDD::MaxWater;
}

%player.ammo["Water"] = %num;

if(!%player.client.hasFLUDDClient)
{
if(%player.ammo["Water"] <= 0)
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ff0000>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}

else
{
commandToClient(%player.client, 'bottomPrint', "<font:impact:30><color:0000ff>Water<color:ffffff>:<color:ffff00>" SPC %player.ammo["Water"] @ "<color:ffffff>/" @ $FLUDD::MaxWater, 0, 1);
}
}

else
{
commandToClient(%player.client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%player.client, 'setFLUDDWater', %player.ammo["Water"]);
}
}

package FLUDD
{
function FLUDD_SquirtModeImage::onFire(%data, %player, %slot)
{
if(%player.isInWater)
{
%player.ammo["Water"] += mFloor($FLUDD::MaxWater / 30 + 0.5);
}

if(%player.ammo["Water"] > $FLUDD::MaxWater)
{
%player.ammo["Water"] = $FLUDD::MaxWater;
}

if(%player.ammo["Water"] >= 1 && !%player.isInWater)
{
%player.ammo["Water"]--;
}

%data.ammoCheck(%player, %slot);

parent::onFire(%data, %player, %slot);
}

function armor::onTrigger(%this, %player, %slot, %val)
{
if(isObject(%player.getMountedImage(0)) && %slot == 4 && %val)
{
if(%player.getMountedImage(0).getName() $= "FLUDD_SquirtModeImage")
{
//Nothing because we don't have models with
} //other nozzles.
}
   
parent::onTrigger(%this, %player, %slot, %val);
}

function armor::damage(%data, %player, %sourceObject, %pos, %damage, %type)
{
if(isObject(%attacker = %sourceObject.sourceObject))
{
if(isFunction(%attacker, "getMountedImage"))
{
if(isObject(%attacker.getMountedImage(0)))
{
if(%attacker.getMountedImage(0).getName() $= "FLUDD_SquirtModeImage")
{
if(%attacker != %player && (%player.getClassName() $= "Player" || %player.getClassName() $= "AIPlayer"))
{
%player.setVelocity(vectorAdd(%player.getVelocity(), vectorAdd(vectorScale(%attacker.getForwardVector(), FLUDD_SquirtProjectile.newImpactImpulse), "0 0" SPC FLUDD_SquirtProjectile.newVerticalImpulse)));
}
}
}
}
}

parent::damage(%data, %player, %sourceObject, %pos, %damage, %type);
}

function armor::onEnterLiquid(%data, %player, %coverage, %type)
{
if(%type < 4)
{
%player.isInWater = true;
}

parent::onEnterLiquid(%data, %player, %coverage, %type);
}

function armor::onLeaveLiquid(%data, %player, %coverage, %type)
{
if(%type < 4)
{
%player.isInWater = false;
}

parent::onEnterLiquid(%data, %player, %coverage, %type);
}

function armor::onRemove(%data, %player)
{
commandToClient(%player.client, 'isUsingFLUDD', 0);

parent::onRemove(%data, %player);
}

function armor::onDisabled(%data, %player, %this)
{
commandToClient(%player.client, 'isUsingFLUDD', 0);

parent::onDisabled(%data, %player, %this);
}

function gameConnection::autoAdminCheck(%client)
{
%parent = parent::autoAdminCheck(%client);

commandToClient(%client, 'FLUDDHandshake');

return %parent;
}

function gameConnection::onClientLeaveGame(%client)
{
commandToClient(%client, 'isUsingFLUDD', 0);
commandToClient(%client, 'setFLUDDWater', 0);

parent::onClientLeaveGame(%client);
}

function gameConnection::spawnPlayer(%client)
{
parent::spawnPlayer(%client);

if($FLUDD::StartWithWater)
{
%client.player.ammo["Water"] = $FLUDD::MaxWater;

commandToClient(%client, 'setMaxFLUDDWater', $FLUDD::MaxWater);
commandToClient(%client, 'setFLUDDWater', %client.player.ammo["Water"]);
}
}

function serverCmdGameModeGuiServer_ChangeGameMode(%client, %num)
{
commandToClient(%client, 'isUsingFLUDD', 0);

return parent::serverCmdGameModeGuiServer_ChangeGameMode(%client, %num);
}
};
activatePackage(FLUDD);


I just realized i posted this in a wrong place.
Silly me.

Look for
Code: [Select]
datablock ProjectileData(FLUDD_SquirtProjectile)add
Code: [Select]
gravityMod = 1.0;

Look for
Code: [Select]
datablock ProjectileData(FLUDD_SquirtProjectile)add
Code: [Select]
gravityMod = 1.0;
ill try that

Look for
Code: [Select]
datablock ProjectileData(FLUDD_SquirtProjectile)add
Code: [Select]
gravityMod = 1.0;
But also one last thing.
What do i need to add so there i can edit the limit the projectile can reach?

But also one last thing.
What do i need to add so there i can edit the limit the projectile can reach?
Assuming you want to change the projectile's range...
You can change the amount of time, speed, and/or gravity of the projectile to change it's range.

Change the lifetimeMS, lifetimeVarianceMS(how much the lifetime can vary), gravityMod, and muzzleVelocity values in the datablock to get the desired range.