Author Topic: Sound system (i ned halp)  (Read 6717 times)

It doesn't need to be.

Er, I did notice a mistake I made though. I forgot to define a size of the radius for the search. So you'll need to change the line that says

initContainerRadiusSearch(%obj.getPosition(), $TypeMasks::PlayerObjectType, %obj); // %obj is the player, not %this

To something like this:

initContainerRadiusSearch(%obj.getPosition(), 150, $TypeMasks::PlayerObjectType, %obj); // %obj is the player, not %this

Line 340 is still being forgeted. Im not sure why. Its at the very end of the OnFire function, i troubleshot it with the console. it gave me hash tags here:
Code: [Select]
MissionCleanup.add(%p);
}
return %p;
}
Something wrong with mission cleanup?

Post the entire function. Chances are its a missing brace or something dumb.

Code: [Select]
function ARX160Image::onFire(%this, %obj, %slot){

initContainerRadiusSearch(%obj.getPosition(), 150, $TypeMasks::PlayerObjectType, %obj); // %obj is the player, not %this
    while(%player = containerSearchNext()) {
        if(!isObject(%player.client))
            continue; // ignore bots
        %dist = vectorDist(%obj.getPosition(), %player.getPosition());
        if(%dist < 50)
            %player.client.play3D(ARX160Fire, %obj.getPosition());
        else if(%dist < 100)
            %player.client.play3D(ARX160Med, %obj.getPosition());
        else
            %player.client.play3D(ARX160Long, %obj.getPosition());
    }
}
%obj.spawnExplosion(testRecoilProjectile,"1 1 1");

if(%obj.getDamagePercent() >= 1.0)
return;

if(vectorLen(%obj.getVelocity()) < 0.1 && (getSimTime() - %obj.lastShotTime) > 50)
{
%projectile = ARX160Projectile;
%spread = 0.0025;
}
else
{
%projectile = ARX160Projectile;
%spread = 0.0030;
}

%obj.lastShotTime = getSimTime();
%shellcount = 1;

%obj.playThread(2, root);
%shellcount = 1;
%obj.toolAmmo[%obj.currTool]--;
commandToClient(%obj.client,'bottomPrint',"<color:0aa000><just:right><font:Arial:20>\c6" @ %obj.toolAmmo[%obj.currTool] @ " / " @ "32 " @ "", 4, 2, 3, 4);

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

here you go.

You're closing the function right after the while loop.

If you use an editor such as Notepad++, it will help you with keeping track of where braces are closing. Thorfin is right here, you have an extra closing brace at the end of your while loop.

oh stuff your right. Good find

If you use an editor such as Notepad++, it will help you with keeping track of where braces are closing. Thorfin is right here, you have an extra closing brace at the end of your while loop.
so i took out the bracket
Code: [Select]
function ARX160Image::onFire(%this, %obj, %slot){

initContainerRadiusSearch(%obj.getPosition(), 150, $TypeMasks::PlayerObjectType, %obj); // %obj is the player, not %this
    while(%player = containerSearchNext()) {
        if(!isObject(%player.client))
            continue; // ignore bots
        %dist = vectorDist(%obj.getPosition(), %player.getPosition());
        if(%dist < 50)
            %player.client.play3D(ARX160Fire, %obj.getPosition());
        else if(%dist < 100)
            %player.client.play3D(ARX160Med, %obj.getPosition());
        else
            %player.client.play3D(ARX160Long, %obj.getPosition());
}

and i ran into another problem. The console says: initContainerRadiusSearch - wrong number of arguments

Every time I've used initContainerRadiusSearch in my code, I've never used a fourth argument. Try just omitting it.

Leave out what? The fourth argument? Well i guess i could just use serverplay2d to play the ARX160Long sound.

Leave out what? The fourth argument? Well i guess i could just use serverplay2d to play the ARX160Long sound.
The fourth argument is %obj

The fourth argument is %obj
so how would this still work if i leave out %Obj?

Radius searches just perform a search from a location. All you need is a position, radius, and thing to look for. The fourth argument is none of these.

Yeah it's only supposed to have three arguments, not four. That's why you get the error.

Radius searches just perform a search from a location. All you need is a position, radius, and thing to look for. The fourth argument is none of these.
so take out %Obj and replace with what?

so take out %Obj and replace with what?
Replace it with nothing. It's not supposed to be there.