Forum Discussion

LadyMo218's avatar
LadyMo218
MHCP Member
10 months ago

Scripting a Grenade - Codeblocks

If i put a script on a grenade and connect to the trigger that when entered by a player (target player) would this script work?

(I have a playerManager script that this would be linked to)

Thanks in advance

16 Replies

  • Looking back over, this wouldnt work. The trigger would become enabled but it would still be sitting under the world somewhere and never triggering the explosion because it wouldn't be receiving a player.  So what about this:

     

    • gausroth's avatar
      gausroth
      MHCP Mentor

      There is a chance that the grenade will still be moving after detonate has been called. But this seems to be more like a mine than a grenade. I would call the grenade event right after the detonate and you don't even need the trigger.

      • LadyMo218's avatar
        LadyMo218
        MHCP Member

        So would I move “connect grenadeTrig” event down under when “detonate is received” rather than when world is started?

  • In Desert Sand PVP I run a While loop on detonation to check the distance from each player's position in the world, if their position is within the range of the blast, I send the applyDamage event to that player. This also gives you flexibility to set different distances to be able to apply different amounts of damage depending on how close to the blast they are adding a bit more realism.

  • Lol of course you both would suggest something that’s above my pay grade 😆😆😆

    • gausroth's avatar
      gausroth
      MHCP Mentor

      I'm thinking it would look something like this. 

       

       

      • Biggie_Pauls's avatar
        Biggie_Pauls
        Meta Employee

        I apologize for not being thorough, I thought it was implied that I was iterating through the list. I was answering your question as to what the check was within the while loop. You are absolutely correct, you must use an iterator. I also scripted this 2 years ago and those while loops are probably pretty bulky. I try not to have too many lines in there which is why I just check for the distance from the player to the blast position and send the event out to calculate appropriate damage in the subsequent event.