Author Topic: multiple hits  (Read 288342 times)

billybob884-nologin

  • Guest
multiple hits
« Reply #15 on: 2005-11-15, 06:54:00 AM »
Quote from: "bluemonkmn"
If you don't care what kind of weapon you use, you might do something like this:


the only problem is that, my shoot left and shoot right have 2 seperate templates, because of hte way the attack spins in each direction...

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
multiple hits
« Reply #16 on: 2005-11-15, 09:02:37 AM »
The script I supplied uses special functions anyway, but they are automatically created upon Plyaer_OnPlayInit, so you don't have to worry about that.  If class A is the weapon and class B is the enemy, then have a collision between the two activate the COL_<BDef>* Special Function.  That's all you need to do for the script to (supposedly) work.  I suppose I could rework the code so it worked for OnSpritesCollide, but if this works, then there's no need.
Edward Dassmesser

billybob884-no-login

  • Guest
multiple hits
« Reply #17 on: 2005-11-15, 09:17:34 AM »
ok, ill give the script u posted a shot once i get home today.

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
multiple hits
« Reply #18 on: 2005-11-15, 01:10:20 PM »
ok, using durnurds script, it brings up the error:
Code: [Select]
Script stopped at line 15 on character 8:
Expected 'Function'


i believe line 15 is the End sub right before public function getSprite(), unless hte first line counts as 0, then its the forementioned public function... line.

on a wild guess, i tried changing the 3 'end sub' lines to 'end function' lines, and it went past that, giving me hte next error of

Code: [Select]
line 44 character 40: expected 'then'

except, there is already a then in that 'if then' line. maybe changing the end sub was a mistake..


also, small side note, i figured out how to do hte explosions with a second colision thing, but is there a way to make the script alter an inventory item when one is destroyed? i.e. in this case, 'Score'? just +30 for MS and... i guess +20 for MJW.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
multiple hits
« Reply #19 on: 2005-11-15, 02:02:18 PM »
I've updated the script to fix the errors reported so far.  You could just create a collision that activates COL_<ATemplate><BTemplate>* and create special functions called COL_EnemyAttackInventory to add points to your score (you get the idea.  Not like this exactly, but something similar)

Or it could be done in script if you wanted to.

Also, I was thinking the explosion would occur only upon death of the enemy.
Edward Dassmesser

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
multiple hits
« Reply #20 on: 2005-11-15, 03:11:50 PM »
nah, i wanted explosions to occur when the attack touches anything (excet solid tiles). i just got lucky that this didn't turn out to be a problem (its not a bug, its a feature! ;) )

ok, as for the script,
stopped @ line 71 char. 27: expected ')'

thats the line
Code: [Select]
  Hits(i) = ("5-0TheMoon","MJW" & i + 1,2)

i guess it wants a ) where the comma in the center is


also, if i did the colision for the score, wouldnt it really get added twice (3x for MS) since its adding to the score each time it gets hit? i could just devidethe score by 2 (three) then, yea, that'll work just fine
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
multiple hits
« Reply #21 on: 2005-11-15, 04:04:26 PM »
Okay, fixed it.  I'm learning how to do classes in VB and VBScript at the same time here, so there's bound to be a few bugs here and there (still).

Try again
Edward Dassmesser

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
multiple hits
« Reply #22 on: 2005-11-15, 04:08:10 PM »
line 71 character 12: expected end of statement

i believe its the line
Code: [Select]
  Hits(i) "5-0TheMoon","MJW" & i + 1,2
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
multiple hits
« Reply #23 on: 2005-11-15, 07:42:57 PM »
Well, now I'm stumped.  BlueMonk, any ideas?  How do classes work in VBScript?  Any idea?
Edward Dassmesser

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
multiple hits
« Reply #24 on: 2005-11-15, 07:56:58 PM »
eh, don't worry about it, ill just set up inventory for them. it's really not that big a deal, there's not that many of them. thanks for trying though, you got a heck of a lot further then i would have ;)
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
multiple hits
« Reply #25 on: 2005-11-16, 06:13:27 AM »
Looks like you can't combine Default Sub and Arrays very well.  I didn't even know you could have a Default Sub (I thought that was only for properties).  Anyway, you have to do one of the following:
Code: [Select]
Dim NewHit, MyHit(1)
Set NewHit = New Hit
NewHit "5-0TheMoon","MJW1-4",2
Set MyHit(0) = NewHit
Set NewHit = New Hit
NewHit "5-0TheMoon","MS1-13",3
Set MyHit(1) = NewHit
Code: [Select]
Set MyHit(0) = New Hit
MyHit(0).Hit "5-0TheMoon","MJW1-4",2
Set MyHit(1) = New Hit
MyHit(1).Hit "5-0TheMoon","MS1-13",3

billybob884-nologin

  • Guest
multiple hits
« Reply #26 on: 2005-11-16, 09:50:14 AM »
"MJW1-4" and "MS1-13", will the script realise thats a range of sprites, or will it count that as 2? i think this was a concern before.

billybob884-no login-

  • Guest
multiple hits
« Reply #27 on: 2005-11-16, 09:52:17 AM »
also, i just put the first section in to replace
Code: [Select]
Dim Hits(16)
Dim i
for i = 0 to 3
   set Hits(i) = new Hit
   Hits(i) "5-0TheMoon","MJW" & i + 1,2
next
for i = 4 to 16
   set Hits(i) = new Hit
   Hits(i) "5-0TheMoon","MS" & i - 3,3
next


so now i have this

Code: [Select]
Option Explicit

Class Hit
   Private hMap
   Private hSpriteName
   Private hHPs
   Public Default Sub Hit(Map, SpriteName, HPs)
      hMap = Map
      hSpriteName = SpriteName
      hHPs = HPs
   End Sub

   public function getMap()
      getMap = hMap
   End function
   public function getSprite()
      getSprite = hSpriteName
   End function
   public function getHPs()
      getHPs = hHPs
   end function
End Class

Sub Player_OnPlayInit()
   Dim i
   Dim oNewSpecial
   Set oNewSpecial = NewSpecialFunction
   for i = 0 to ubound(Hits)
      oMap = ProjectObj.Maps(Hits(i).getMap())
      oNewSpecial.FuncType = 7 ' SPECIAL_EVENT
      oNewSpecial.Name = "COL_" & Hits(i).getSprite()
      oMap.AddSpecial(hostObj.AsObject(oNewSpecial))
   Next
End Sub

Sub Player_OnSpecialFunction(SpecialObj)
   dim i, layer, idx
   for i = 0 to UBound(Hits)
   spr = Hits(i).getSprite()
   if left(Special.Name,4 + len(spr)) = "COL_" & spr then
      spr = FindSpriteByDef(spr,layer,idx)
      if spr.UserData > Hits(i).getHPs() or spr.UserData < 0 then spr.UserData = 0
      spr.UserData = spr.UserData + 1
      if spr.UserData = Hits(i).getHPs() then
         layer.RemoveSprite(idx)
      end if
   end if
next
End Sub

Function FindSpriteByDef(SpriteName, byref oLayer, byref oSprIndex)
   dim i, j
   oMap = ProjectObj.GamePlayer.rMap
   for i = 0 to rMap.LayerCount
      for j = 0 to rMap.MapLayer(i).SpriteCount()
         if rMap.MapLayer(i).Sprite(j).SpriteDef.Name = SpriteName then
            set oLayer = rMap.MapLayer(i)
            oSprIndex = j
            set FindSpriteByDef = oLayer.Sprite(j)
         end if
      next
   next
End Function

'-----Initialize Sprites-----

Dim NewHit, MyHit(1)
Set NewHit = New Hit
NewHit "5-0TheMoon","MJW1-4",2
Set MyHit(0) = NewHit
Set NewHit = New Hit
NewHit "5-0TheMoon","MS1-13",3
Set MyHit(1) = NewHit

'-----End initialization-----

HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
multiple hits
« Reply #28 on: 2005-11-16, 11:12:19 AM »
Here's the correct thing to have

Code: [Select]

'-----Initialize Sprites-----
Dim Hits(16), newHit, i
for i = 0 to 3
   set newHit = new Hit "5-0TheMoon","MJW" & i + 1,2
   set Hits(i) = newHit
next
for i = 4 to 16
   set newHit = new Hit "5-0TheMoon","MS" & i - 3,3
   set Hits(i) = newHit
next
'-----End Initialization-----


Let me know if this works.  If it does, I may make a scripting wizard add-on for it, but then of course, BlueMonk would have to go about releasing it, which would take time away from working on SGDK 2.0...
Edward Dassmesser

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
multiple hits
« Reply #29 on: 2005-11-16, 01:02:32 PM »
close, but no cigar. line 68, char 25: expected end of statement

i think its
Code: [Select]
  set newHit = new Hit "5-0TheMoon","MJW" & i + 1,2
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy