Author Topic: Corp's Errors and questions thread. I need some coding help here!  (Read 1542 times)

Fixed OP, need help here.

New thing.
I want the FOV of this weapon to change when it's switched to ironsights.
But I've managed to adjust it to a good point, and now thats all I need.
Code: [Select]
offset = "-0.2 0.3 0"; //-Left +Right, -Back +Front, -Down +Up
   eyeOffset="-0.1103 0.49 -0.1565"; //-Left +Right, -Back +Front, -Down +Up



Another thing I'm having a problem with is weapon spread-
I'm trying to get it to work a certain way-
Waist fire-Not accurate at all
Crouch Waist Fire-still not as accurate
Scoped-Accurate
Crouched scoped-Accurate as crap
And whenever the player is moving, they can't shoot for crap.

Code: [Select]
unction MK11Fire(%this,%obj,%slot,%spread,%shellcount,%recoil)
{
if(%obj.isCrouched()==1)
{
%spread=%spread-0.1;
%recoil=%recoil/2;
}
if(vectorLen(%obj.getVelocity()) >= 0.1 && !isObject(%obj.getObjectMount()))
{
%spread=%spread+0.1;
}
%vector=%obj.getMuzzleVector(%slot);
%p=new Projectile()
{
dataBlock=MK11Recoil;
initialVelocity=%obj.getVelocity();
initialPosition=%obj.getEyePoint();
sourceObject=%obj;
sourceSlot=%slot;
yclient=%obj.client;
};
for(%shell=0;%shell<%shellcount;%shell++)
{
%x=(getRandom()-0.5)*10.415926*%spread;
%y=(getRandom()-0.5)*10.415926*%spread;
%z=(getRandom()-0.5)*10.415926*%spread;
%p=new Projectile()

}
« Last Edit: March 08, 2012, 04:38:18 PM by The Corporation »

You forgot the semi colon at the end of the line above that.
Code: [Select]
^verticalImpulse=1;
^explosion=##M##K11bulletExplosion;

You forgot the semi colon at the end of the line above that.
Code: [Select]
^verticalImpulse=1;
^explosion=##M##K11bulletExplosion;
well how did i miss that...

I'll keep this topic up just in case I have any more problems.

A lot of times the error will be above the line with ##


Well what exactly is the problem?

For the spread thing, 'function' is missing an 'f'
Also, the last 'for' statement is missing a closing bracket
« Last Edit: March 04, 2012, 04:40:35 PM by Treynolds416 »

Well what exactly is the problem?

For the spread thing, 'function' is missing an 'f'
Also, the last 'for' statement is missing a closing bracket
that's because I cut it out on accident
The real script has that.
But I'm still at lost as to how to fix this.

I really hate to bump this, but this stuff has been bugging me for quite a while.

I really hate to bump this, but this stuff has been bugging me for quite a while.

You cannot force a player to zoom/change their FOV without a client mod I believe
You can use !iscrouched() silly or armor::ontrigger(%dtb, %pl, %slot, %x) detecting %slot == 3 and %x == 0
If you want to look at a weapon script that changes accuracy based on if the player is scoped or not, you can look at the Old School Rifle or something.

You cannot force a player to zoom/change their FOV without a client mod I believe
You can use !iscrouched() silly or armor::ontrigger(%dtb, %pl, %slot, %x) detecting %slot == 3 and %x == 0
If you want to look at a weapon script that changes accuracy based on if the player is scoped or not, you can look at the Old School Rifle or something.

Wait, wait, explain to me how is that when I put the weapon away, the FOV changes?
Obj.client.SetCameraFOV(90); ?

Wait, wait, explain to me how is that when I put the weapon away, the FOV changes?
Obj.client.SetCameraFOV(90); ?


Oh, I basically did dumpconsolefunctions(); and then filtered to show only clientcmd's, and looked for something that looked like it might set fov, but that might be handled by c++ and not torque, so it wouldn't be apparent.  I don't do much with weapons and stuff so I really don't know.  Now that I think about it I think some playertypes do that.

Anyway, if you know that %player.setcamerafov(); will work, then that is a question answered.

Oh, I basically did dumpconsolefunctions(); and then filtered to show only clientcmd's, and looked for something that looked like it might set fov, but that might be handled by c++ and not torque, so it wouldn't be apparent.  I don't do much with weapons and stuff so I really don't know.  Now that I think about it I think some playertypes do that.

Anyway, if you know that %player.setcamerafov(); will work, then that is a question answered.
trying right now.

Didn't do anything, in fact-

Code: [Select]
function MK11ImageScoped::onMount(%this,%obj,%slot)
{
if(%obj.toolMag[%obj.currTool]$="")
{
%obj.toolMag[%obj.currTool]=%this.item.MK11maxmag;
}
parent::onMount(%this,%obj,%slot);
%obj.hideNode("LHand");
%obj.hideNode("RHand");
%obj.hideNode("LHook");
%obj.hideNode("RHook");

[b] if(isObject(%obj.client))
{
%obj.client.setControlCameraFov(90);
}
else
{
%obj.client.setControlCameraFov(20);
}[/b]
}

The game just simply ignores that.

Bump-
-See OP for a change in wording
-Above posts are kinda useless tries at fixing issues I'm having.
-If you want to see what I'm messing with, it's this