Author Topic: Special Function Reset... Is it possible?  (Read 2431 times)

Skeletor9000

  • Visitor
  • *
  • Posts: 1
    • View Profile
    • Email
Special Function Reset... Is it possible?
« on: 2006-03-08, 10:47:43 AM »
I have several special functions on a map set as "initial touch only" and as "remove after use". I'd like for them to essentially reset so that the player can retrigger them if they die and start the level over. Currently, when the player dies I am triggering a special function that calls a map switch to the same map. The sprites all reset but the speical functions are no longer active. Is there any way to get the special functions to activate after the player has triggered them once and died (i.e. reloaded the map)? 

P.S. I am a scripting newb, so if this can be accomplished through a special function, so much the better.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Special Function Reset... Is it possible?
« Reply #1 on: 2006-03-08, 03:05:18 PM »
Once you remove a special function, it's gone.  The only way to get it back is to create it again through script or to load the game.  One option would be to have a global special function on each map that is set to "remove after use" that automatically save the state of the game.  Then, when they die, instead of switching to the map, have a special function that activates a series of special functions:  First, load the game, second, subtract one life from the inventory... if you keep track of lives.  If you don't, you would just have to load the game and that's all.  You wouldn't have to have a series or anything.

Also, if you have a special function set to "remove after use" you don't need it also set to "initial touch only".
Edward Dassmesser

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Special Function Reset... Is it possible?
« Reply #2 on: 2006-03-08, 07:34:26 PM »
agree with durdurd, check out the load/save special functions

do a save at beginning of each level or at each checkpoint, have any death activate a load function.
This has the added bonus of allowing you to load a game in the opening menu too (ie push ctrl to continue, space to start at beginning)

I'm not entirely sure on how a load works if its in a series and not at the end.  Does it loading the previous state essentially cancel the remaineder of the current special function sequence?

I do know that if you have a script raise an event to script, the script is executed after the function is carried out, this includes load.  So if the sequence doesn't work, you can alter the "life" inventory in script from the load function's raised event.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Special Function Reset... Is it possible?
« Reply #3 on: 2006-03-09, 12:00:52 AM »
As long as there is a special function with the correct name on the same map that you are currently on, then activating a special function after you load a game should still work.  The way a series works is this:

Code: [Select]
Get all the functions to activate
Loop through all of the functions
   If the function exists on this map then
      If the function we're activating isn't this same one again then
         Activate the function with the given name on this map(Load the game happens here, as does removing inventory)
Go to the next function

After it's completely done loading the game, it returns to the calling sub and loops to the next function to activate and activates it.  it uses rMap to refer to the current map.  Since rMap is changed to the current map when loading the game, then it will still activate the correct special function even after you load the game.

At least, that's what I think will happen.  Computers are complex causal systems, and I can't formally prove that it will work (nor would I try even if they were purely abstract machines), but the easiest way to find out would be to just try it.
Edward Dassmesser

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Special Function Reset... Is it possible?
« Reply #4 on: 2006-03-09, 06:35:29 PM »
Thats good news.

I remember having some problems with functions not firing properly when in a sequence with a save/load function.  They could have been unrelated, but I just assumed that load was haulting all functions.  I suppose I could do the testing since I already have a project all setup for it, wouldn't take me long. :)

i am working on a project that uses the load function on death, but i want the player to keep the items he has collected, so I have the load function raise an event that takes all the collected items off the map and adds them to the player's inventory.  Kind of a treasure hunting game, and I don't want to annoy the player by making him recollect every life.

My goal was to make the simplest game possible, but once again "feature creep" has got me writing a bloated script file and scores of special functions.  :(