Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with NPC (bot)
#3
As GOTO10 said, without knowing what your game is, specific help is impossible.

With pygame, this is how I time random things in my games (mostly, enemies to shoot at random intervals).

random_chance_role = pg.random.randrange(1000)
if random_chance_role < 5:
          do_random_thing = True  # OR whatever your game requires
This will give you a .5% chance / frame. You can change the numbers to suit your needs.
Reply


Messages In This Thread
Need help with NPC (bot) - by Paul_Choi06 - Jun-25-2020, 04:44 PM
RE: Need help with NPC (bot) - by GOTO10 - Jun-25-2020, 07:54 PM
RE: Need help with NPC (bot) - by michael1789 - Jun-25-2020, 08:13 PM
RE: Need help with NPC (bot) - by armila - Sep-04-2020, 07:51 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020