Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Multiplayer health via script

  1. #1

    Default Multiplayer health via script

    G'day folks,
    Is there a way to give health to a player standing at or in a trigger?
    I don't want to simply use health pick-ups.

    I have tried the suggestions of the health script thread in this forum but it won't work for me. Maybe that's a single player thing?

    I have two scenarios that I'd like to implement health in.
    One is a trigger_multiple where I'd like the healing to be admitted in increments, the longer the player stays within the trigger.
    The second scenario would be something like 10% health at the end of a trigger_use thread to ensure that the player stuck around for the entire thread.

    I somehow got it working for the trigger_multiple but it jumped straight to 100% health and I had included bind / unbind then swapped that for glue / unglue because the player footsteps sound continued although standing still.
    That denied the sound effect I wanted to use.
    So I kept editing the script and now I've lost every that was working for the related thread(s).

    Thanks in advance for any help given.

  2. #2

    Default

    Okay I've removed the trigger_multiple and made that location a trigger_use.
    This allowed me the sound effects I made for it. And not continuous footsteps when bound.
    I added the bind /unbind line as before, to ensure the player stays for the thread duration, however it doesn't bind this time.
    In fact, if I walk backwards (while supposedly bound) I am able to walk through solid walls. But only during the bind period.
    Feeling the urge to walk away from the PC before I smash something. $#@ing stupid **)??! of a game. lol

    *Deep breaths, Rob*

    Righto, I've replaced "bind" & "unbind" with "glue" & "unglue" and now that part is working.
    Now I just need to add the health.

  3. #3
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,269

    Default

    Hey,

    Few Questions.

    So you want the player to be standing inside a trigger ( I will call it square 1 ) and once inside, they will start healing? But you want it done in increments, so the longer the person is inside square1 they will be healed even more?
    So for example:
    Player standing inside of square 1.
    < 5 seconds, heal at rate of 1 hp per second.
    > 5 < 20, heal at rate of 10 hp per second.
    etc.

    Is that about right? for scenario 1.

    Scenario 2 seems more simple, that you want the player to be in the trigger for a specific amount of time before being healed, and if they leave within a timeframe ( 10 seconds for example ), but they only recieve the health upon leaving the square?

    I am a bit lost on the binding/glueing?

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  4. #4

    Default

    Whoohoo! I've got it, finally.

    Yes Purple, mate, that was what i was after and I finally got it.
    Thanks for replying though.

    I might remove the binding / gluing but I need that to also stop the sound effect.

    I only came back to delete this thread. lol

  5. #5

    Default

    Here's what I came up with, pretty much a copy of the other thread (without crouching) that didn't work for me the first time around.
    Only the names have been changed to protect the guilty. lol


    Code:
    square1 local.player :
    	$square1_trig nottriggerable
    	local.player = parm.other
    	local.player glue $square1_step
    	$square1_step playsound square1sound
    	while(local.player) {
    	local.player heal 0.05
    	wait 0.3
    	}
    	wait 12 // length of sound effect.
    	local.player unglue $square1_step
    	$square1_trig triggerable
    end
    As I said, I might drop the glue binding, but then the sound will continue. :/
    Last edited by AccadaccA; February 10th, 2020 at 12:08 AM.

  6. #6

    Default

    Yeah, that script won't be good for what you want. It will continue trying to heal the player until they leave the game. You also don't want to have an arbitrary wait of '12' that only starts counting down AFTER the player has healed because this will make the trigger unresponsive for other players during that period.

    What you want is something like this:

    square1:
    local.player = parm.other
    local.trigger = self

    // if player is already healing or he's already at full health, don't do anything and end here
    if (local.player.healing || local.player.health == local.player.max_health) end

    // player is healing
    local.player.healing = 1
    local.player loopsound square1sound

    // start on these values
    local.healvalue = 0.01 // amount of health given each time
    local.healtime = 0 // time taken healing (starts at 0)
    local.healwait = 0.25 // amount of time to wait between heals
    local.healinc = 2.5 // seconds to wait before increasing healing rate (this is for exponential healing)
    local.healmult = 2 // amount to multiply the previous healing rate (this is for exponential healing)

    // begin the heal
    while(1)
    {
    local.player heal local.healvalue
    wait local.healwait

    // stop healing if player is dead, or left game, or not touching trigger, or at full health
    if !(isAlive local.player) break
    if !(local.player isTouching local.trigger) break
    if !(local.player.health < local.player.max_health) break

    // increment the time spent healing
    local.healtime += local.healwait
    if (local.healtime >= local.healinc)
    {
    // player was healing long enough to increase healing amount
    local.healvalue = local.healvalue * local.healmult
    local.healtime = 0
    }
    }

    // healing has completed, if the player still exists then stop the sound and reset healing value
    if (local.player)
    {
    local.player stoploopsound
    local.player.healing = 0
    }
    end


    I went with example 1 (exponential healing). Needs a trigger_multiple. Bear in mind that you don't need this function copied for each square. Just point all your healing triggers to 'square1' (though 'healingsquare' would be a better name) and it will work fine. You can play around with the 5 values till you get something you're happy with.
    Last edited by 1337Smithy; February 10th, 2020 at 06:04 AM.

  7. #7

    Default

    Cheers Smithy ol' mate.
    The binding was pissing me off. While "bind" didn't bind, "glue" didn't unglue. lol
    I'll give your suggested script a go (with "healing_square" or perhaps just "healer") and I'm sure I'll be smiling again.
    "square1" was just a space filler created by Purple for example purposes.

    Dang, I have a lot of script that I've somehow stumbled through (trial and error) and I almost made it to the finish line without physical help.
    This part of the script was a last minute inclusion / idea.


    edit: It's perfect.
    Thanks again Smithy.
    Last edited by AccadaccA; February 10th, 2020 at 07:13 AM.

  8. #8

    Default

    Yeah, I wouldn't mess around with binding the triggers to the players, as that could displace them. You shouldn't need to do anything like that .

  9. #9

    Default

    lol I actually wrote in my edit "It's perfect as is. I'll leave it well enough alone." and "There's no need for the healingsquare (or healer) script_object."

    Or words to that effect. I dunno why I backspaced it.

  10. #10

    Default

    Okay I still can't work out how to give a one of lump sum of health for a trigger_use.
    I want to add different amounts of health at the end of existing threads.

    I've been messing with a copy of Smithy's script (in another thread), trying to make it suit my needs, without success.
    Similar to the health pickups, I'd like to inject a certain amount of health in one go (in other areas of the map).
    For example: +5hp, +10hp or +15hp, depending on the thread, and not the 25, 50 or 100hp default health pickups.

    Cheers

    ********

    I've been trying to make sense out of the Game Module Classes
    But I don't know whether to include the brackets or use a period or a space between key and value. Or whatever they're called.

    Having a hint on that page of how to use this info would help, "teach a man to fish" and all that instead of just throwing the bait at him and saying "Here, go for it". :/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •