I can't believe but it appears I have everything working correctly. I didn't think I would get this far really. I seemed to have squashed the other "value out range" problems but have a new one and I'm going mad. I haven't slept well in days. Okay.
This is the new one
Engine/source/core/stream/bitStream.cpp(339,0): {Fatal} - BitStream::writeInt: value out of range: -1/64 (6 bits)
I'm pretty sure it stems from this in player.cpp
stream->writeSignedFloat(fTranquilized, 6);
It seems to be a variable that effects speed while the players are zoomed and it crashes almost every time when I'm getting melee'd by an AIPlayer.
I'm just going to post the snippets from everywhere I can find it. Maybe if someone can think of a work around to keep it a positive number or something. It seems to be consistently fatal with a -1 value.
Any help would be appreciated. Thank you.
player.h
488 F32 fTranquilized;
733 void Player::setTranquilized(const F32 & tranquilized);
734 const F32 & Player::getTranquilized();
player.cpp
1673 fTranquilized=0.0f;
2801 if(doStandardMove)
2802 {
2803 F32 p = move->pitch * (mPose == SprintPose ? mDataBlock->sprintPitchScale : 1.0f);
2804 if (fTranquilized>0.0f) p+=fTranquilized * mSin((F32)Sim::getCurrentTime()/200.0f); //TAIKWeapons++
2805 if (p > M_PI_F)
2806 p -= M_2PI_F;
2807 mHead.x = mClampF(mHead.x + p,mDataBlock->minLookAngle,
2808 mDataBlock->maxLookAngle);
2836 F32 y = move->yaw * (mPose == SprintPose ? mDataBlock->sprintYawScale : 1.0f);
2837 if (fTranquilized>0.0f) y+=fTranquilized * mCos((F32)Sim::getCurrentTime()/300.0f); //TAIKWeapons++
2838 if (y > M_PI_F)
2839 y -= M_2PI_F;
6833 stream->writeSignedFloat(fTranquilized, 6);
6929 fTranquilized = stream->readSignedFloat(6);
(lines 7131 to 7149)
ConsoleMethod( Player, IsTranquilized, F32, 2, 2, "Return if tranquilizer is enabled.")
{
Player* obj = static_cast<Player*>(object);
return obj->getTranquilized();
}
ConsoleMethod( Player, SetTranquilized, void, 3, 3, "(F32) Sets tranquilizer.")
{
Player* obj = static_cast<Player*>(object);
obj->setTranquilized(dAtof(argv[2]));
}
const F32 & Player::getTranquilized() {
return fTranquilized;
}
void Player::setTranquilized(const F32 & tranquilized) {
fTranquilized = tranquilized;
}
TorqueScript(TAIKZoom.cs)
function serverCmdCallZoomFunction( %client, %out )
{
%zoomer = %client.getControlObject();
//%curWeapon = %zoomer.getMountedImage($WeaponSlot).item.getName();
//%curWeapon = %zoomer.getMountedImage($WeaponSlot);
%zoomer.handleZoom(%out);
}
function Player::handleZoom(%this,%out)
{
%iS = %this.getImageState(0);
if (%this.isLeaning && !%out)
return;
if (%is $= "GLReady" || %is $= "GLActivate" || %is $= "GLPutAway" || %is $= "GLReload")
return;
if (%iS $= "ReloadClip")
%out = true;
if (%iS !$= "Ready" && %is !$= "NoAmmo" && %is !$= "DryFire" && %is !$= "Activate")
%out = true;
if (!%this.zoomOn && !%out)
{
%this.zoomOn = true;
%this.setSpeedMult(0.5);
%this.setTranquilized(0.0002);
// Figure out what type of sights we should be using
if (%this.getMountedImage(2))
{
if (%this.getMountedImage(2).getName() $= "M68Image" || %this.getMountedImage(2).getName() $= "SquareDotImage"
|| %this.getMountedImage(2).getName() $= "CMoreImage" || %this.getMountedImage(2).getName() $= "GlockDotImage"
|| %this.getMountedImage(2).getName() $= "EOTechImage" || %this.getMountedImage(2).getName() $= "AKDotImage"
|| %this.getMountedImage(2).getName() $= "F2000DotImage")
{
// Red dot
%sightType = 2;
}
else if (%this.getMountedImage(2).getName() $= "AUGScopeImage")
{
//2x AUG Scope
%sightType = 5;
}
else if (%this.getMountedImage(2).getName() $= "M4HandleImage" || %this.getMountedImage(2).getName() $= "M16HandleImage" || %this.getMountedImage(2).getName() $= "F2000IronImage")
{
// Iron sight
%sightType = 1;
}
else
{
// ACOG
if (%this.getMountedImage(2).getName() $= "ACOG1Image" || %this.getMountedImage(2).getName() $= "AKACOGImage")
%sightType = 3;
else
%sightType = 4; // Default sniper scope
}
}
else
{
if (%this.getMountedImage(0).permanentScope)
{
// Scope that cannot be dismounted
%sightType = 3;
}
else
{
// Iron sights
%sightType = 1;
}
}
}
else
{
%this.zoomOn = false;
%sightType = 0;
%this.setSpeedMult(1.0);
%this.setTranquilized(0);
}
%cScope = %this.getMountedImage(0).scope;
%wName = %this.getMountedImage(0).getName();
if (%wName $= "M24Image" || %wName $= "M110Image" || %wName $= "M14Image")
if (%sightType != 3)
%cScope = "M24Scope";
commandToClient(%this.client,'ZoomClientSide',%sightType,%this.getMountedImage(0).getName(),%cScope);
}