How to make a random generator? Created 2 years ago2021-09-18 15:55:59 UTC by RealMamitler RealMamitler

Created 2 years ago2021-09-18 15:55:59 UTC by RealMamitler RealMamitler

Posted 2 years ago2021-09-18 15:55:59 UTC Post #345937
Hi, I'm trying to make a random chance generator which activates one or 2 different objects every time,
does anyone know how to do this? I'm using J.A.C.K also, the free version.

Thanks for reading!
RealMamitler RealMamitler(new mapper)
Posted 2 years ago2021-09-18 17:36:55 UTC Post #345938
Unfortunately Half-Life doesn't provide something like a trigger_random entity, but eventually some mapper(s) came up with a technique to trigger random entities. By using a high-damage env_beam that randomly targets one of several info_targets, and by placing func_buttons in front of those targets, you can trigger different entities depending on which info_target the beam decides to strike. It's described in more detail in the following tutorials: A Random Event Generator and Random entity triggering.

If you want to trigger multiple things at the same time, you can give them the same name (so they'll always be triggered together), or you can trigger a multi_manager, an entity that can trigger multiple entities (see Tutorial: Multi_manager for more info).
Posted 2 years ago2021-09-18 21:38:26 UTC Post #345939
Thanks!
RealMamitler RealMamitler(new mapper)
Posted 2 years ago2021-09-18 21:43:36 UTC Post #345940
Also, does your method work with buttons? Like if you press a button it randomly picks a entity? Thanks
RealMamitler RealMamitler(new mapper)
Posted 2 years ago2021-09-21 20:36:50 UTC Post #345947
Yes, that's also possible. The catch is that the button press should enable and then quickly disable the beam, so that it can only trigger one random entity, instead of continuing to trigger random entities. Here's how you can do that:
  1. In the env_beam's properties, disable the 'Start On' flag and enable the 'Toggle' flag, so you can disable the beam by triggering it again.
  2. Set the env_beam's 'Life' property to 0.1 seconds - or longer, if you don't want it to be reusable too soon.
  3. Create a multi_manager, and make it trigger the env_beam twice. First with a delay of 0, then with a delay that matches the env_beam's 'Life' property.
  4. Set the 'Target' property of your func_button to the name of this multi_manager.
You must be logged in to post a response.