Basic Tutorials about Grenades

By LadylexUK

How to create grenades for your player and npcs.

There are two types of grenades you might need; realistic objects that look like ball or stick grenades and have a physical presence in the world, and special effects grenades which are futuristic weapons suitable for sci-fi worlds.

Search for grenade in the gallery and you get Astro Marine Grenade, which is a roughly spherical grenade, and Stick Grenade, which is … well, a stick. There is also the TNT Bundle that can be thrown as an explosive device. Despite them doing very similar things, the 3 grenade objects have different brains. All allow the player to pick up the object and hold it as equipment.None of these brains however will allow your player to throw the object and therefore make the explosives work.

In your player brain add the following

WHEN [right bumper][pressed] DO [throw][equipment]

Now try it out with the 3 explosive objects. Note they act slightly differently when thrown. The round grenade, and the TNT bundle are thrown in an arc, and roll along the floor, after they hit the ground ,before exploding. The stick grenade rotates in the air.

Here is a brain for a grenade that explodes as soon as it hits the ground

  1. WHEN [not][equipped][and][not][is projectile]
  2. …WHEN [interacted] DO [it][equip][me]
  3. WHEN [is projectile]
  4. …WHEN [started to][bump terrain] DO [boolvar:explode][equals][true]
  5. WHEN [boolvar:explode]
  6. …WHEN DO [play sound][Explosions TNT Boom]
  7. …WHEN DO [play fx][Fire explosion][at position][center][volume][0]
  8. …WHEN [for each of][detect]
  9. …/…WHEN DO [damage][it][20]
  10. …/…WHEN DO [push][it][away from][me]
  11. …WHEN DO [destroy]

Grenade throwing skill
To make this a constantly available grenade for the player. Make it a template.
In player brain change your throw command to
WHEN [right bumper][pressed] DO [throw][IWP:grenade]
Your player can now thrown as many grenades as he likes.

To make the skill only available when a meter is full add this kode.

WHEN  DO [display meter][max][10][numvar:throw meter][screen top center]
WHEN [once] DO [numvar:throw meter][equals][10]
WHEN DO [numvar:throw meter][equals][clamp][min][0][max][10][numvar:throw meter]
WHEN [countdown timer][loop] DO [numvar:throw meter][increment by][1]
WHEN [right bumper pressed]
…WHEN [numvar:throw meter][greater than or equal to][10]
…WHEN DO [throw][IWP:grenade}
…WHEN DO [numvar:throw meter][equals][0]
…WHEN [else] DO [play sound][UI negative]

You can change the amount of time it takes to get to 10 or make the number higher for a longer cooldown period.

Special effects grenades.

You can add this brain to a templated special effect too. It acts just like the objects you were throwing.



To get NPCs to throw grenades

try something like:

WHEN [distance to][objvar:my enemy][less than][10][and][distance to][objvar:my enemy][greater or equal to][2]
…WHEN [started to] DO [throw][IWP:grenade][in direction][objvar:my enemy]


Comments are closed.

Website Powered by

Up ↑

%d bloggers like this: