Jump to content

Animation and script troubles.


Jojash

Recommended Posts

So recently, I've been trying to write a script that will make an NPC change their weapon when a key is pressed. So far, this is what I've got:

 

		If IsControlPressed 18
			If InventoryCounter != 1
				Set InventoryCounter to 1
			Endif
		Elseif InventoryCounter
			If DrawCounter == 1
				TapControl 7
				Return
			Endif
			Set ItemCounter to ListGetCount EmbeddedWeapons + 1
			Set RobotItem to 0
			Set EquipCounter to ListGetFormIndex EmbeddedWeapons RobotWeapon
			Label 20
			Set ItemCounter to ItemCounter - 1
			Set RobotItem to ListGetNthForm EmbeddedWeapons ItemCounter
			If ItemCounter > EquipCounter
				GoTo 20
			Else
				If RobotPosition.GetItemCount RobotItem <= 0
					If ItemCounter == 1
						Set EquipCounter to ListGetCount EmbeddedWeapons
						Set ItemCounter to ListGetCount EmbeddedWeapons + 1
					Endif
					GoTo 20
				Else
					RobotPosition.UnequipItem RobotWeapon
					Set EquipCounter to ItemCounter
					Set RobotWeapon to RobotItem
					RobotPosition.EquipItem RobotWeapon
				Endif
			Set InventoryCounter to 0
			TapControl 7
			Return
		Endif

 

However, when I test this, the NPC it's called on just seems to freeze. I'm must admit, I'm rather stumped as to what I've done wrongly here...

 

My second issue, is to do with animations. I've been trying to get an NPC to fire their weapon when a key is pressed, which they will do, but instead of firing in front of them, as you might expect, the projectiles will instead fire into the ground directly below the NPC. From what little information I've been able to gather, I think this has something to do with the "Equip" anim group. Here's the script dealing with that, it's rather long, so I've put it in a spoiler tag:

 

 

 

		If IsControlPressed 7
			If WeaponCounter != 1
				If DrawCounter != 1
					RobotPosition.SetAlert 1
					RobotPosition.PlayGroup Equip 1
					RobotPosition.PlayGroup Aim 0
					Set DrawCounter to 1
				Else
					RobotPosition.SetAlert 0
					RobotPosition.PlayGroup Unequip 1
					Set DrawCounter to 0
				Endif
				Set WeaponCounter to 1
			Endif
		Elseif WeaponCounter
			RobotPosition.PlayGroup Idle 0
			Set WeaponCounter to 0
		Endif



...

		If IsControlPressed 4 && DrawCounter != 1
			TapControl 7
		Elseif IsControlPressed 4 && RobotPosition.IsAnimPlaying ReloadA != 1 && RobotPosition.IsAnimPlaying JamA != 1 && RobotPosition.IsAnimPlaying JamB != 1 && RobotPosition.IsAnimPlaying ReloadB != 1 && RobotPosition.IsAnimPlaying Equip != 1
			If Fire == 0
				Set RobotWeapon to RobotPosition.GetEquippedObject 5
				Set AnimationType to GetWeaponAttackAnimation RobotWeapon
				If AnimationType == 1
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack3Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack3Down 0
					Else
						RobotPosition.PlayGroup Attack3 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 2
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack4Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack4Down 0
					Else
						RobotPosition.PlayGroup Attack4 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 3
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack5Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack5Down 0
					Else
						RobotPosition.PlayGroup Attack5 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 4
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack6Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack6Down 0
					Else
						RobotPosition.PlayGroup Attack6 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 5
						If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack7Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack7Down 0
					Else
						RobotPosition.PlayGroup Attack7 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 6
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup Attack8Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup Attack8Down 0
					Else
						RobotPosition.PlayGroup Attack8 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 7
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup AttackLeftUp 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup AttackLeftDown 0
					Else
						RobotPosition.PlayGroup AttackLeft 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 8
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup AttackLoopUp 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup AttackLoopDown 0
					Else
						RobotPosition.PlayGroup AttackLoop 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 9
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup AttackRightUp 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup AttackRightDown 0
					Else
						RobotPosition.PlayGroup AttackRight 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 10
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup AttackSpinUp 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup AttackSpinDown 0
					Else
						RobotPosition.PlayGroup AttackSpin 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Elseif AnimationType == 11
					If Player.GetAngle X >= 50
						RobotPosition.PlayGroup AttackSpin2Up 0
					Elseif Player.GetAngle X <= -50
						RobotPosition.PlayGroup AttackSpin2Down 0
					Else
						RobotPosition.PlayGroup AttackSpin2 0
					Endif
					RobotPosition.FireWeapon RobotWeapon
					If GetWeaponIsAutomatic RobotWeapon != 1
						Set Fire to 1
					Endif
				Endif
			Endif
		Elseif Fire
			Set Fire to 0
			RobotPosition.PlayGroup Idle 0
			RobotPosition.PlayGroup Aim 0
		Endif

 

 

 

 

Any help would be greatly appreciated! :)

Link to comment
Share on other sites

Hi Jojash,

I expected there would be major problems with the attack procedure. I hope I will have some time during the weekend to run some tests myself and see if I can help you work this out. In the meantime, if you haven't already, you might want to look into using FireWeapon while playing the attack animation.

Link to comment
Share on other sites

I'm actually already using that, as I've said, I can get the weapon to fire... just not in the right direction. I'm pretty certain that it's got something to do with the "Projectile Node". Anyway, I shall look forward to the weekend, then! :)

Link to comment
Share on other sites

  • 5 weeks later...

That weekend is long passed, and I haven't been around for quite a while.

I think I have a pretty good and workable solution for your problem. That is, if you're still looking.

Link to comment
Share on other sites

I am indeed still looking! I've not been working on it recently, but it only has a couple of things left to do anyway, including the firing. Thank you for getting back to me! :smile:

Edited by Jojash
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...