Author Topic: Weapon Pickups and Script Wizard  (Read 2575 times)

Zindel

  • Visitor
  • *
  • Posts: 4
    • View Profile
Weapon Pickups and Script Wizard
« 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!  ;)

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Weapon Pickups and Script Wizard
« Reply #1 on: 2005-09-05, 06:23:23 PM »
Actually, yes.
Edward Dassmesser