Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

swimming question

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
stumpymcnub
Member
Member
Posts: 5
Joined: December 9th, 2010, 8:57 pm
Name: Nathan

swimming question

Post by stumpymcnub »

HI guys, I have an area in a map that consists of a lot of swimming. I was hopping that there was a way in 2.6 to put a time limit on how long you can be underwater until your character dies. If so can you let me know? thanks all.
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: swimming question

Post by arcones »

Well, there are a couple of ways that is possible.

1) Code a timer for the water that eventually kills you if you don't get out quickly enough (kinda like the lava only it takes longer to die)
2) Make a level_trigger that automatically starts hurting you once you enter the water (although how and why this would work I'm not quite sure)
3) Make a level_trigger that starts taking away your "oxygen" as you enter the water and once you reach 0 oxygen you die (this one would be easiest)

There are probably more ideas, but those were the ones I came up with. I'll explain 3 in more detail.
3)

Code: Select all

Have an GUI that shows how much Health and Oxygen you have. Set health at 100 and set oxygen at 100.
Have a level_trigger that takes away oxygen once you enter the water (just a little bit) Then have level_triggers in the water which are spaced out from each other. These will also deduct oxygen. Once your oxygen is all gone, the level_triggers will start taking away chunks of your health until you die.
It sounds difficult, but it'd be rather simple. I can provide an example if you like.
Image
Want a user bar like this one? PM Leo!
chocolatepie33
Support Team
Support Team
Posts: 2458
Joined: April 27th, 2010, 5:31 pm
IRC Username: CP

Re: swimming question

Post by chocolatepie33 »

if you're really good at coding, you could make a level trigger (like arc said) that creates a loop starting with 5 million and counts down, and when you get to 0, you "nap" (which is Cubescript for die or whatever).
Julius wrote:Contribute to http://www.opengameart.org NOW!
Save the wiki!
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: swimming question

Post by arcones »

Actually CP, mine would insure that you survive if you get out of the water in time as well as replenish your oxygen (that's something that could be added).

Otherwise once the 5 million counts down, you die whether you're in the water or not.
Image
Want a user bar like this one? PM Leo!
chocolatepie33
Support Team
Support Team
Posts: 2458
Joined: April 27th, 2010, 5:31 pm
IRC Username: CP

Re: swimming question

Post by chocolatepie33 »

oops, yeah that's true...
Julius wrote:Contribute to http://www.opengameart.org NOW!
Save the wiki!
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: swimming question

Post by arcones »

Always look for alternate ways to do something ;)
Image
Want a user bar like this one? PM Leo!
stumpymcnub
Member
Member
Posts: 5
Joined: December 9th, 2010, 8:57 pm
Name: Nathan

Re: swimming question

Post by stumpymcnub »

Thank you guys, that really helps. And no, i am no good at coding, I have never done it before, so using sandbox is kind of a test/learning process for me. An example then would be more then welcome.
arcones
Support Team
Support Team
Posts: 2734
Joined: January 13th, 2010, 12:42 pm
Name: Timothy
IRC Username: I use Steam
Location: Looking over your shoulder...
Contact:

Re: swimming question

Post by arcones »

Okay:

Code: Select all

on_start = [
health = 100
oxygen = 200
]

"level_trigger_1" = [
health = (- $health 10 );
   echo ( format "You now have %1 Health." $health );
   if ( < $health 1 ) [
      nap;
      health = 100;
  ]
]

"level_trigger_2" = [
oxygen = (- $oxygen 10 );
   echo ( format "You now have %1 Oxygen." $oxygen );
   if ( < $oxygen 1 ) [ echo "You have run out of oxygen! You'll start losing health if you don't get out!" ];
   if ( < $oxygen 1 ) [
   health = (- $health 10 );
   if ( < $health 1 ) [
      nap;
      health = 100;
  ]
 ]
]

newgui Inventory [
guibutton "Back" "cleargui 1"
guibar
guitext ( format "You have %1 health." $health )
guitext ( format "You have %1 oxygen." $oxygen )
]

newgui main [
   guilist [
      guilist [
         guibutton "Inventory" "showgui Inventory"
      ]
   ]
   guibar
   @main
]
I'm 98.9% sure this'll work (I just haven't had time to test it out ;D) Place this in your map config to have it work.

Arcones
Image
Want a user bar like this one? PM Leo!
stumpymcnub
Member
Member
Posts: 5
Joined: December 9th, 2010, 8:57 pm
Name: Nathan

Re: swimming question

Post by stumpymcnub »

Fantastic! I'll give this a try and let you know how it works.
t5yvxc
Member
Member
Posts: 15
Joined: November 19th, 2009, 4:03 pm
Name: Tonio
IRC Username: itachi2658

Re: swimming question

Post by t5yvxc »

Im a noob at all of this, can someone tell me where do I find the script to add this? Is it in a folder?
Thanks in advance
Locked