whats wrong

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

whats wrong

Post by darksmaster923 »

whats wrong with this script? (this is a practice script)

Code: Select all

{
lbutton		[false]
reloading	[false]
bullets		[5]
clipsize	[30]

	Spawn[ ()
	{
	Console(true);
	HideFromRadar(true);
	LowLevel("setup");
	} ]
	setup[ ()
	{
		self.think = "idle";
		PawnRender(false);
	} ]
	idle[ ()
	{
		self.ThinkTime = 0;


		if(self.lbutton_pressed and (lbutton = false))
		{
			if(bullets > 0)
			{
				fire();
				AnimateHold(SHOOT);
				self.think = "shoot";
				return 0;
			}
			else
			{
				PlaySound(emptysound);
				firetime = self.time + firerate;
				if(fullauto = 0)
				{
					lbutton = true;
				}
			}

		}

		if(self.animate_at_end)
		{
			AnimateHold(IDLE);
		}

		if(((bullets = 0) or ((bullets < clipsize) and IsKeyDown(17))) and (GetAttribute(ammoattribute,"Player") > 0))
		{
			reloading = true;
		}

		if(reloading)
		{
			zoom = 1;
			reloading = false;
			AnimateHold(RELOAD);
			self.think = "reload";
			return 0;
		}
	} ]
	fire[ ()
	{
		FireProjectile(rifle_shell, BIP01, 25, 25, 25, enemy_health;
	} ]

}
[/code]
Herp derp.
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

I believe it's a stripped version of my weapon scripts? :)

There's a lot wrong with it.

Code: Select all

         if(bullets > 0)
         {
            fire();
            AnimateHold(SHOOT);
            self.think = "shoot";
            return 0;
         } 
There is no order called 'shoot'.

Code: Select all

         else
         {
            PlaySound(emptysound);
            firetime = self.time + firerate;
            if(fullauto = 0)
            {
               lbutton = true;
            }
         } 
There are no variables called 'emptysound', 'firetime', 'firerate' or 'fullauto'.

Code: Select all

      if(self.animate_at_end)
      {
         AnimateHold(IDLE);
      } 
There is no variable called 'IDLE'.

Code: Select all

      if(((bullets = 0) or ((bullets < clipsize) and IsKeyDown(17))) and (GetAttribute(ammoattribute,"Player") > 0))
      {
         reloading = true;
      } 
Again, you haven't defined 'ammoattribute' variable.

Code: Select all

      if(reloading)
      {
         zoom = 1;
         reloading = false;
         AnimateHold(RELOAD);
         self.think = "reload";
         return 0;
      } 
No such variable as 'RELOAD' or order called 'reload'.

Code: Select all

   fire[ ()
   {
      FireProjectile(rifle_shell, BIP01, 25, 25, 25, enemy_health;
   } ] 
You're missing a ')' in the end of the command.
Also, strings must have " " symbols. So they would be: "rifle_shell", "BIP01" and "enemy_health".
And you're telling the pawn to fire a projectile without a point where to fire. I guess it will fire, but who knows where!


These are only the spelling errors and 'things that don't exist'. Even fixing those problems will not make this a working weapon script, but it's a good start. :)
BTW, I think you should have posted this in your earlier thread about scripted weapons. I'll try to explain how to make them work in that thread some day... when I find some time.
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 »

i was practicing making weapon scripts so i looked at urs lol
Herp derp.
Post Reply