Scrolling Game Development Kit Forum

SGDK Version 1 => Script => Topic started by: Zindel on 2005-09-05, 10:01:28 AM

Title: Weapon Pickups and Script Wizard
Post by: Zindel on 2005-09-05, 10:01:28 AM
Hello again. Was wondering if any of you VB savvy folks might have a solution for my problem. I have three weapons in my game setup through scripting wizard. Each weapon uses a common inventory called power which regerates over a period of time (using global func). The first weapon is a default pistol, the other two are not supposed to be found until later in the game. Currently I have access to each weapon from the start of the game.

I'm pretty sure all I need to do is add an additional inventory requirement for the 2nd and 3rd weapons, but not entirely sure how to add it. Here's a sample


Quote
Sub DoFireButton0()
   Dim NewSpr, DX, DY
   If nShot0Count >= 3 Then Exit Sub
   If ProjectObj.GamePlayer.InvQuantityOwned(2) < 1 Then Exit sub
   ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 1
   Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("pulsar_laser").MakeInstance
   Set arBtn0Shots(nShot0Count) = NewSpr
   nShot0Count = nShot0Count + 1
   With ProjectObj.GamePlayer.PlayerSprite
      .rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
      nExpectCount = nExpectCount + 1
      NewSpr.X = .X + (.Width - NewSpr.Width) / 2
      NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
      GetStateDeltas DX, DY
      NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
      NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
      If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
      ProjectObj.MediaMgr.Clip("pulsar").Play
   End With
End Sub

Sub DoFireButton1()
   Dim NewSpr, DX, DY
   If nShot1Count >= 2 Then Exit Sub
   If ProjectObj.GamePlayer.InvQuantityOwned(2) < 2 Then Exit sub
   ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 2
   Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("freeze_ray").MakeInstance
   Set arBtn1Shots(nShot1Count) = NewSpr
   nShot1Count = nShot1Count + 1
   With ProjectObj.GamePlayer.PlayerSprite
      .rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
      nExpectCount = nExpectCount + 1
      NewSpr.X = .X + (.Width - NewSpr.Width) / 2
      NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
      GetStateDeltas DX, DY
      NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
      NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
      If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
   End With
End Sub

Sub DoFireButton2()
   Dim NewSpr, DX, DY
   If nShot2Count >= 2 Then Exit Sub
   If ProjectObj.GamePlayer.InvQuantityOwned(2) < 3 Then Exit sub
   ProjectObj.GamePlayer.InvQuantityOwned(2) = ProjectObj.GamePlayer.InvQuantityOwned(2) - 3
   Set NewSpr = ProjectObj.GamePlayer.rMap.SpriteDefs("plasma_rifle").MakeInstance
   Set arBtn2Shots(nShot2Count) = NewSpr
   nShot2Count = nShot2Count + 1
   With ProjectObj.GamePlayer.PlayerSprite
      .rDef.rLayer.AddSprite HostObj.AsObject(NewSpr)
      nExpectCount = nExpectCount + 1
      NewSpr.X = .X + (.Width - NewSpr.Width) / 2
      NewSpr.Y = .Y + (.Height - NewSpr.Height) / 2
      GetStateDeltas DX, DY
      NewSpr.DX = DX * NewSpr.rDef.Template.MoveSpeed
      NewSpr.DY = DY * NewSpr.rDef.Template.MoveSpeed
      If NewSpr.rDef.Template.StateCount = 36 Then NewSpr.CurState = RectToPolarState(DX, DY)
   End With
End Sub


Do I just need to add another line like this?
"If ProjectObj.GamePlayer.InvQuantityOwned(X) < 1 Then Exit sub "
Where X is the pickup inventory.



Thanks for any help!  ;)
Title: Weapon Pickups and Script Wizard
Post by: durnurd on 2005-09-05, 06:23:23 PM
Actually, yes.