Author Topic: Inventory question  (Read 2753 times)

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
Inventory question
« on: 2006-01-04, 02:44:52 PM »
Ok ladies and gentlemen, it's time for America's favorite game show: Help Mike Script! Where the prizes are insignificant and the questions will make you think, "wtf is wrong with this kid?".

ok, now that that's outta my system, back to business. As my title states, i was hoping that there was a way to have a function in the game call upon the script, and have the script check how much of one of the inventory items the player has, then act accordingly. say for instance, I'm just making this up, I have no idea if this is actual script or not,
If "InventoryA" > 15000 then Switch to "Map1"
If "InventoryA" < 15000 then Switch to "Map2"

i would be using this for a little bonus at the end where if the player has a minimum amount of the score inventory, they would go to like some sort of mini-game or something, and if they didn't it would just go back ot the menu. Now that I think about it, since my scoring goes by multiples of 5 points per enemy kill, I could have the number like 15002 and the score would never be = to that, it would always be < or >.
Let me know how plausable this sounds.
"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
Re: Inventory question
« Reply #1 on: 2006-01-04, 05:24:47 PM »
This is doable without script, unless the special function has to be activated by some non-standard means (other than the player touching it).
Edward Dassmesser

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Inventory question
« Reply #2 on: 2006-01-04, 05:42:49 PM »
I wrote and tested a quick script and it does work.  (durdurd must of did his response while I was working on it)

here it is, just cut and paste it into your current script.:
Code: [Select]
sub Player_OnSpecialFunction(SpecialObj)
  with specialobj
    if .name = "ScriptConditionalWarp" then
  if ProjectObj.GamePlayer.InvQuantityOwned(0)>"1" then
    call ProjectObj.GamePlayer.ActivateFunction(ProjectObj.GamePlayer.rmap.Specials("WarpToMapA"))
  else
    call ProjectObj.GamePlayer.ActivateFunction(ProjectObj.GamePlayer.rmap.Specials("WarpToMapB"))
  end if
end if

'if .name= other function then
  'perform action
'end if
  end with

What is required for this script to work is 3 special functions.  One I called "ScriptConditionalWarp" which is activated whenever the designer needs, and effect is "raise an event" which lets the script handle the effect.

The other 2 functions are 2 functions that have no activation parameters (only able to be activated by other functions).  The effects of these 2 functions are simple "Switch to Map"  Whichever to maps you used.  I called the 2 functions "WarpToMapA" and "WarpToMapB"

You can name the functions whatever you want provided you change the names in the code too.  Also I used inventory "0" in code, which is #1 in SGDK IDE i believe, and I only required 1 insead of 15000, but these two numbers can be changed to suit your needs as well.