finding player's weapon

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

finding player's weapon

Post 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
Herp derp.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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...).
Pain is only psychological.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post 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;
		}
	} ]
}
Herp derp.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

You don't need the '( ... )' symbols around self.player_weapon.
if(self.player_weapon = 2) should be enough.
Pain is only psychological.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post 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
Herp derp.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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")
Pain is only psychological.
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

your awesome juutis thanks
Herp derp.
Post Reply