Page 1 of 1

finding player's weapon

Posted: Mon Mar 05, 2007 2:20 am
by darksmaster923
well, i have an idea for weapon inaccuracy, it works with bugs, but i need to find the player's weapon and self.player_weapon
doesnt seem to work or im doing it wrong

Posted: Mon Mar 05, 2007 9:53 am
by Juutis
You know, you should put some more info on these posts. It's impossible to tell what's wrong all you say is "self.player_weapon doesn't seem to work". For example, you could add how you are trying to use it. Or is the script running OK? Is there anything in the log? Posting the whole script wouldn't hurt anyone, either...

And yes, self.player_weapon should work. It returns the slot of the currently armed weapon (0,1,2,3...).

Posted: Mon Mar 05, 2007 4:42 pm
by darksmaster923

Code: Select all

{
	moved			[false]
	moved1			[false]
	moved2			[false]
	mouseright_pressed	[false]

	Spawn[ ()
	{
	Console(true); //Turns on debug
	Gravity(false); //No grav
	SetNoCollision(); //No collision
	HideFromRadar(true); //uh... speaks for itself
	BoxWidth(20); //width of bounding box
	LowLevel("Setup"); //LowLevel commands to setup
	} ]

	Setup[ ()
	{
		self.ideal_pitch = self.camera_pitch; //face player dir
		self.ideal_yaw = self.player_yaw;
		ChangeYaw();
		ChangePitch();
		self.think = "Idle"; //to IDLE!!

	} ]

	Idle[ ()
	{
		self.ThinkTime = "0.1";
		clearkeys();
		PositionToPlayer(0, 0, 0, true, true);
		if((self.player_weapon) = 2)
		{
			if(self.lbutton_pressed and (moved = false) and (moved1 = false) and (moved2 = false))
			{
				switch(random(1,3)) // play 3 different movements omg
				{
					case 1
					{
					PlayerToPosition(5, 0, -5, true);
					moved = true;
					}
					case 2
					{
					PlayerToPosition(-4, 5, -4, true);
					moved1 = true;
					}
					case 3
					{
					PlayerToPosition(6, 0, -6, true);
					moved2 = true;
					}
				}
			}
		}
	} ]


	clearkeys[ ()
	{
		if(moved = true)
		{
			PlayerToPosition(-5, 0, 5, true);
			moved = false;
		}
		if(moved1 = true)
		{
			PlayerToPosition(4, 0, 4, true);
			moved1 = false;
		}
		if(moved2 = true)
		{
			PlayerToPosition(-6, 0, 6, true);
			moved2 = false;
		}
		if(self.lbutton_pressed = false)
		{
			moved = false;
			moved1 = false;
			moved2 = false;
		}
		if(self.rbutton_pressed = false)
		{
			mouseright_pressed = false;
		}
	} ]
}

Posted: Mon Mar 05, 2007 5:24 pm
by Juutis
You don't need the '( ... )' symbols around self.player_weapon.
if(self.player_weapon = 2) should be enough.

Posted: Tue Mar 06, 2007 12:13 am
by darksmaster923
ah. but if i put 0 it works on my slot 2 weapon? :shock:
okay, but how do i make it find if the player is crouching

Posted: Tue Mar 06, 2007 10:55 am
by Juutis
There is a variable called self.player_animation. You could name all your crouch animations crouch_idle, crouch_shoot etc, and then check

Code: Select all

if(LeftCopy(self.player_animation,6) = "crouch")

Posted: Wed Mar 07, 2007 12:41 am
by darksmaster923
your awesome juutis thanks