playMaker

Author Topic: Multiple enemies dying at same time create buggy results  (Read 1404 times)

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Multiple enemies dying at same time create buggy results
« on: May 08, 2020, 09:18:33 PM »
Lets say I have 15 boars. They are all a prefab of the same boar.

Each boar has a variable on it called xpYield which holds a value of 10, which is how much experience they give to the character when they die.

They also count as part of a quest—a quest to kill 10 boars—so when one of them dies, it adds an integer to the boars-killed quest counter.


Everything is great if the character is off killing boars 1 at a time. Even if boars die within 0.2 seconds of each other it is no problem.

But when two boars are killed at the same time or in extremely close succession, it gives the character way more experience than it should, and counts more than it should as well for the quest. 3 boars dying at the same time, instead of giving 30 xp, maybe it will give 150 xp. Or let's say a wolf dies at the same time as the boar, and the wolf is supposed to give 50 xp: the boars might be worth 50 xp each if they die at the same time.

Here is the logic..I have simplified it as much as possible.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Multiple enemies dying at same time create buggy results
« Reply #1 on: May 08, 2020, 10:09:39 PM »
Are you using any global variables here ?

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Multiple enemies dying at same time create buggy results
« Reply #2 on: May 08, 2020, 10:55:23 PM »
Nope

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Multiple enemies dying at same time create buggy results
« Reply #3 on: May 09, 2020, 01:51:43 AM »
Did you tried sending event with random delay ? like between 0-0.1 Seconds.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Multiple enemies dying at same time create buggy results
« Reply #4 on: May 09, 2020, 05:11:12 AM »
Hi.
Adding to an array is so far one of the best solution
But you probably need array maker (array list) instead of the build-in array.

Have a empty array and check count every frame.
If greater than 0 get the data on index 0

Add to counter (or do damage or what ever you need to do)
remove index 0 on array and loop back

Snowbird

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Multiple enemies dying at same time create buggy results
« Reply #5 on: May 10, 2020, 04:39:03 PM »
So lets say I have an empty array: xpArrayF

When an enemy dies, it adds a float value to that array, lets say 10 in this case.
Lets say 3 enemies die within a frame, and it becomes something like xpArrayF = 10, 40, 10

Every frame the game looks at this xpArrayF, and if it finds anything in it, I can program it to do its magic, like maybe add them together or feed it to the right FSM at a more manageble speed.

That sounds great. However, I am slightly lost at how to do the step where the game looks at the array every frame. You said "Have a empty array and check count every frame." There are like 100 different array actions on the Ecosystem, and I have arraymaker too. Which one will help me do that? I am overwhelmed at the many options.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Multiple enemies dying at same time create buggy results
« Reply #6 on: May 11, 2020, 01:31:56 PM »
Hi.
The array list actions do not have a every frame on their own action, so you need to use a next frame event and loop back to the state.

So state 1 have a 'array list count' and an 'int compare'.
if count greater than 0 do the magic if not do next frame event and loop back.

i prefer using array list as its easier to reference.