PDA

View Full Version : [UT2k4] AimDot / Forced Walk or crouch while firing


Major-Lee-High
31st Mar 2004, 10:39 PM
Ok so i just made a new versions of the sniper rifle (classic), basically i removed the smoke and made it "bFireOnRelease=True".

Now what i want to do to it, is make it so that when your holding down fire you are forced to walk or crouch along with no jumping. I made the new sniper with no problem so far (not even one error woot!!) but i dont know where to start with this. I also want to do the same thing to other guns like the minigun so when its being fired you cant jump etc just the same.

Also for the sniper rifle i want a aimdot when its being held down as well, just like the TFC sniper rifle so that it can be seen by other players on walls etc. In the remote strike mod for 2k3 there was something very similar to this although i dont know how it was done or even if other players could see it. This might be a bit harder to do (i dont know) and im still a newb at coding. The no jumping etc seems like it should be pretty simple (i hope lol, im sure i have seen something similar in a mod or other unreal game) but this im not sure of.

Please help meh!! Im a noob like i said too so please explain to help!!

Thanks (hopefully :P)

:rolleyes: :lol:

[SAS]Solid Snake
1st Apr 2004, 04:39 AM
Well try investigating the Player movement states, as they are the places where you can alter how a player moves like. There is PlayerWalking, PlayerSwimming etc etc.

Make a new state (copy & paste is the best way atm since your learning), which checks if the weapon being held is your sniper rifle and that one of the firemodes is being held down. If that is true, then give the conditions that you cannot press the jump key.

This method of course requires you to have your own player controller class.

Major-Lee-High
1st Apr 2004, 02:51 PM
Hmm im confuseed :P

Ive looked for a state that says its firing (bisfiring?) and tried to change the groundspeed when its being held down but i couldnt get it working :(

Thanks ill mess with it some more.

Major-Lee-High
1st Apr 2004, 06:16 PM
I think if i could figure out how to tell if fir or alt fire is being held down, or if the weapon is zoomed i could prolly get this to work. I cant figure out where to get that info though.

bfire and bfirealt?

[SAS]Solid Snake
1st Apr 2004, 07:19 PM
There is a boolean that gets set when the fire button is pressed called bIsFiring or bFire or something. It's defined in the User.INI. To check if it is zoomed, simply see what the current FOV of the player is.

Major-Lee-High
1st Apr 2004, 09:01 PM
Cool thanks, ill go look in the ini.

Major-Lee-High
2nd Apr 2004, 01:18 AM
Uggh this is getting annoying....

I dont see why i need a new player controller just for this.... Our class based mutator makes all teh classes right out of inventory, calling pawn to change move speeds etc.... so i dont see why the hell i cant get it to let me temporarily change a few properties without making a whole lot more work than it should take...

Can this even work from teh fire class atl all? Or should i try to do it in the Sniper Class, although i would need to figure out how to tell what guns being held so it doesnt mess up the other weapons hell have...

Just slowing the player down alot would be fine with me.... or even making it so that if the player is running or jumping the gun wont fire or something....

This seems like it should be soo dammed easy, but every thing i do, even with no errors etc doesnt do ****...

Major-Lee-High
2nd Apr 2004, 11:31 PM
Heres my latest try....

I moved me attempts into the weapon class because it comes from inventory just like our classes..... Still cant get it to work or for my LOG to show at all...

class newsniper extends classicsniperrifle;

function SlowedPlayer(xpawn p)
{
if ( Instigator.Controller.bFire != 0 )
{
P.AirControl *= 0.1;
P.GroundSpeed *= 0.1;
P.WaterSpeed *= 0.1;
P.AirSpeed *= 0.1;
P.JumpZ *= 0.0;
log("Fire was pressed");
}

else
{
P.AirControl *= 1.0;
P.GroundSpeed *= 1.0;
P.WaterSpeed *= 1.0;
P.AirSpeed *= 1.0;
P.JumpZ *= 1.0;
}
}

defaultproperties
{
FireModeClass(0)=NewSniper.NewSniperFire
PickupClass=NewSniper.NewSniperPickup
AttachmentClass=NewSniper.NewSniperAttachment
}

Tried like 100 diffrent if things....

Zer0Zer0
3rd Apr 2004, 05:29 AM
from noob to noob have you tried this:


simulated function ClientStartFire(int mode)
{
if (mode == 1)
{
FireMode[mode].bIsFiring = true;
if( Instigator.Controller.IsA( 'PlayerController' ) )
PlayerController(Instigator.Controller).ToggleZoom();
//Slow Your man down here (zoomed mode)
}
else
{
If (!bFireOnRelease){
Super.ClientStartFire(mode);
}
else
{
While(!bReleased){ //This loop will not work though, you'll have to figure this bit out
//Slow Player
}
Super.ClientStartFire(mode);
}
}
}


May need some tweaking and I'm not sure if it will work but that looks like the area you need to mess with.

Super.ClientStartFire calls the weapon class to spawn the bullets etc. I think so what you need to do is hold up this function from being called until the fire button is released and during this time slow the player down.

Major-Lee-High
3rd Apr 2004, 03:40 PM
Thanks man ill mess with that a bit more, i tried using that once but the gun wouldnt fire at all lol >_<

Mr_Evi1
3rd Apr 2004, 04:07 PM
You may find the pawn function SetWalking(bool bNewIsWalking) useful.

Major-Lee-High
3rd Apr 2004, 05:03 PM
Hmm ill look for that, would that make it so you could croutch too though?

Mr_Evi1
3rd Apr 2004, 05:15 PM
I don't think it will affect your ability to crouch, but I haven't tested that.

Postal
3rd Apr 2004, 05:40 PM
Try looking at the camo combo, I think that forces you to crouch.

Major-Lee-High
3rd Apr 2004, 07:34 PM
Ill look at that, but i dont want to force a crouch, just disallow jumping and slow the groundspeed, or only allow walking and crouching.

Major-Lee-High
3rd Apr 2004, 10:04 PM
Ok, heres my code (thanks to Rigear) for the Rocket Launcher atm. It makes it so when the gun is out, your all slow and gimpy, i also have primary fire wait for release set (so you have to let off the button to fire it again) and the multi rockets max hold time is 5 minutes, so you can charge up rockets and stand around, along with not killing yourself as much cause of the stupid ass auto fire...

This will be ok for the rl and mingun for now, since i also have special Shield guns made they can just whip those out and run around at their class speed then switch to their main gun and be slow, even though i would still like the only when firing command....

So common guys there HAS TO BE A WAY to make this into a state inside the weapon (like the biorifles hold state) or something, so that it only happens when YOU PRESS A FIRE KEY!!

PLEASE HELP :P


class NewRL extends RocketLauncher;

var bool InUse;

simulated function BringUp( optional Weapon PrevWeapon )
{
Instigator.AirControl = InStigator.AirControl *= 0.5;
Instigator.GroundSpeed = InStigator.GroundSpeed *= 0.5;
Instigator.AirSpeed = InStigator.AirSpeed *= 0.5;
Instigator.WaterSpeed = InStigator.WaterSpeed *= 0.5;
Instigator.Jumpz = InStigator.Jumpz *= 0.5;
InUse = true;

Super.BringUp( PrevWeapon );
}

simulated function bool PutDown()
{
Instigator.AirControl = InStigator.Default.AirControl;
Instigator.GroundSpeed = InStigator.Default.GroundSpeed;
Instigator.AirSpeed = InStigator.Default.AirSpeed;
Instigator.WaterSpeed = InStigator.Default.WaterSpeed;
Instigator.Jumpz = InStigator.Default.Jumpz;
InUse = false;

if ( Super.PutDown() )
return true;
return false;
}



defaultproperties
{
InUse=false
SeekCheckFreq=0.500000
SeekRange=8000.000000
LockRequiredTime=1.250000
UnLockRequiredTime=0.500000
LockAim=0.996000
FireModeClass(0)=NewRL.NewRLFire
FireModeClass(1)=NewRL.NewRLMultiFire
PickupClass=NewRL.NewRLPickup
}

Postal
4th Apr 2004, 12:00 AM
make a function slowdown and a function speedup
then in the code where it starts firing call slowdown, and when you release fire, class speedup

Major-Lee-High
4th Apr 2004, 01:29 AM
Hmm maybee thats why my code doesnt ever work lol, ive been just making a new function but never calling it?

Problem ive had so far is that i cant figure out how to tell if someone is firing, and if i do figure that out how to make the functions and call them :O

So could i do like....

Function SlowDown()
{
Instigator.AirControl = InStigator.AirControl *= 0.5;
Instigator.GroundSpeed = InStigator.GroundSpeed *= 0.5;
Instigator.AirSpeed = InStigator.AirSpeed *= 0.5;
Instigator.WaterSpeed = InStigator.WaterSpeed *= 0.5;
Instigator.Jumpz = InStigator.Jumpz *= 0.5;
}


Then make one like

Function DefualtSpeed()
{
Instigator.AirControl = InStigator.Default.AirControl;
Instigator.GroundSpeed = InStigator.Default.GroundSpeed;
Instigator.AirSpeed = InStigator.Default.AirSpeed;
Instigator.WaterSpeed = InStigator.Default.WaterSpeed;
Instigator.Jumpz = InStigator.Default.Jumpz;
}


Then somehow make the if statements using the bFire or bIsFiring os would it be !bIsFiring or something, that would call one of those functions?

>_< Where would i put the if statement, do i need to use a existing function thats called for the gun or can i just make a function with anyname that will run???

*head explodes*

Major-Lee-High
4th Apr 2004, 01:50 AM
HOLY SH!T I HAVE DONE IT!!!!!!

OMG THANK EVERYONE!!!!


class NewSniper extends ClassicSniperRifle;

simulated function ClientStartFire(int mode)
{
if (mode == 0)
{
FireMode[mode].bIsFiring = true;
if( Instigator.Controller.IsA( 'PlayerController' ) )
SlowDown();
}
else
{
Super.ClientStartFire(mode);
}
}

simulated function ClientStopFire(int mode)
{
if (mode == 0)
{
FireMode[mode].bIsFiring = false;
if( PlayerController(Instigator.Controller) != None )
DefualtSpeed();
}
else
{
Super.ClientStopFire(mode);
}
}

Function SlowDown()
{
Instigator.AirControl = InStigator.AirControl *= 0.5;
Instigator.GroundSpeed = InStigator.GroundSpeed *= 0.5;
Instigator.AirSpeed = InStigator.AirSpeed *= 0.5;
Instigator.WaterSpeed = InStigator.WaterSpeed *= 0.5;
Instigator.Jumpz = InStigator.Jumpz *= 0.5;
}

Function DefualtSpeed()
{
Instigator.AirControl = InStigator.Default.AirControl;
Instigator.GroundSpeed = InStigator.Default.GroundSpeed;
Instigator.AirSpeed = InStigator.Default.AirSpeed;
Instigator.WaterSpeed = InStigator.Default.WaterSpeed;
Instigator.Jumpz = InStigator.Default.Jumpz;
}

defaultproperties
{
FireModeClass(0)=NewSniper.NewSniperFire
PickupClass=NewSniper.NewSniperPickup
AttachmentClass=NewSniper.NewSniperAttachment
}

Major-Lee-High
4th Apr 2004, 03:48 AM
Aiiieeee now ive got another problem.

The defualt settings are setting the defualts of the defualt players instead of our classes.

I COULD just make the defualt speed function match the class that uses it, but there has to be a diffrent way to call the speeds etc of our classes instead of instigator right?

I was thinking instigator meant whoever had it so that whatever their settings where would be changed, but i guess thats in pawn or something.

So what would i change in my functions to change teh settings of our new classes?

In the classes we have this:

function AlterPlayer(Pawn Player)
{
local int i;
local inventory tInv;

Player.GroundSpeed*=ClassMaxSpeed;
Player.DodgeSpeedFactor*=ClassDodgeSpeed;
Player.DodgeSpeedZ*=ClassDodgeZ;
Player.JumpZ*=ClassJumpZ;
Player.HealthMax=ClassHealthMax;
Player.Health=ClassHealth;

So i assume there is a way to call the class file and change the ClassMaxSpeed etc instead of ground speed, then default back to the class?

Like i said i thought instigator was the player, but i guess its in pawn >_< ill try some things.

Major-Lee-High
5th Apr 2004, 03:45 AM
Ok, so the instigator lines are messing up our classes speeds AND they dont work online at all..... WTF!!! How would i get that to work online too >_<

Also, i have added a dynamic projector for the aimdot.... And wow they dont work on net games at all ... So i need to figure out how to change my code to work with a xemitter for the dot like the painterbeamspot, or how to enable the projector online. One problem with the code for the aimdot offline atm is that, while it works fine unzoomed, when zoomed strafing jumping crouching pretty much anything but loking around with the mouse leaves the dot behind, so i dont know wtf to even do there lol...

Heres my code atm, id really like help on getting these both to work online.... since this is a online game things should work offline and on easily.... pretty damm dumb if you ask me >_<

class cbSniper extends ClassicSniperRifle;

var const vector beamoffset;
var cbsniperspot beam;
var bool aimdoton;

function setaimdot()
{
if(aimdoton)
{
beam.AttachProjector();
}
else
{
beam.DetachProjector();
}
}

function rotator GetViewRotation()
{
return xPlayer(instigator.controller).Rotation;
}


function Tick(float deltatime)
{
super.Tick(deltatime);
beam.DetachProjector(); //order is important

beam.SetRotation(GetViewRotation());
//if you use set base, you don't need to update the location every tick
//beam.setlocation(location);
beam.AttachProjector();
}


simulated function ClientStartFire(int mode)
{

if (mode == 0)
{
FireMode[mode].bIsFiring = true;
if( Instigator.Controller.IsA( 'PlayerController' ) )
SlowDown();

}
else
{
Super.ClientStartFire(mode);
}
}

simulated function ClientStopFire(int mode)
{
if (mode == 0)
{
FireMode[mode].bIsFiring = false;
if( PlayerController(Instigator.Controller) != None )
DefualtSpeed();

}
else
{
Super.ClientStopFire(mode);
}
}

Function SlowDown()
{
local vector RotX, RotY, RotZ;

// local vector projheight;
// projheight.z = Instigator.EyeHeight;
// Super.PostNetBeginPlay();
GetAxes(Rotation,RotX,RotY,RotZ);


beam = spawn(class'CBSniperSpot', self,,location + beamoffset.x * rotx + beamoffset.y * roty + beamoffset.z * rotz, GetViewRotation() );
beam.SetBase(self);



Instigator.AirControl = Instigator.AirControl *= 0.5;
Instigator.GroundSpeed = Instigator.GroundSpeed *= 0.5;
Instigator.AirSpeed = Instigator.AirSpeed *= 0.5;
Instigator.WaterSpeed = Instigator.WaterSpeed *= 0.5;
Instigator.Jumpz = Instigator.Jumpz *= 0.5;

aimdoton = true;

}

Function DefualtSpeed()
{
Instigator.AirControl = Instigator.Default.AirControl;
Instigator.GroundSpeed = Instigator.Default.GroundSpeed;
Instigator.AirSpeed = Instigator.Default.AirSpeed;
Instigator.WaterSpeed = Instigator.Default.WaterSpeed;
Instigator.Jumpz = Instigator.Default.Jumpz;

aimdoton = false;
beam.Destroy();

}

defaultproperties
{
BeamOffset=(X=-100.000000,Y=-15.000000,Z=21.000000)
FireModeClass(0)=utcb.cbSniperFire
PickupClass=utcb.cbsniperpickup
AttachmentClass=utcb.cbSniperAttachment
}