21.5 C
New York
Monday, April 28, 2025

Structure: Easy methods to deal with advanced unintended effects and sequencing occasions in a sport in shifts like Xcom?


I’m attempting to make a sport in flip like Xcom, and I’ve encountered an structure downside that I’ve not been in a position to resolve for fairly a while.

In my sport, logic is totally separated from animations: when one thing occurs on the earth of the sport, for instance, a unit has a command to maneuver, then all the results of this motion are calculated, and the corresponding animations are queued To breed.

However I don’t perceive find out how to construct a logical structure taking into consideration a number of unintended effects accurately. The same old depth method first, when one impact merely causes one other, and so forth in a waterfall, shouldn’t be solely appropriate.

For instance, there’s the next situation:

  • A unit shot (the motion factors are deducted, the ammunition is subtracted, the trajectory is calculated)

  • The shot hits an explosive barrel. Your well being falls to zero and “dies”

  • The barrel triggers the impact of “demise rattle”, and explodes

  • All items and objects across the barrel obtain harm

  • All tiles across the barrel are wrapped in flames

  • Every affected unit loses morality

  • Some items and objects die from the harm they obtain

  • One of many destroyed objects is one other barrel, and in addition triggers the “demise rattle”, which results in a sequence response

  • Panic items start to develop their panic actions in flip: escape, shoot, which might additionally result in chain reactions

On this situation, treating harm doesn’t instantly lead on to the demise of a unit, and his demise doesn’t lead on to the “demise rattle”, they’ve some kind of delayed impact. And it appears to me that the system ought to work in a mode in layers: first it’s all the harm, then all of the deaths, then all of the rattles of demise, and so forth.

Nevertheless, there’s one other situation by which this logic ought to work in a different way:

  • A unit makes a sequence of photographs (an machine gun burst)

  • Every of the photographs reaches some purpose, this goal is straight away broken, its morality falls and a few of the victims enter the “useless” state.

  • When all of the photographs are completed, the remaining results are performed: demise rattle, unity panic, chain reactions

It can be crucial right here that a few of the results should happen instantly after the bullet “arrives”, and others after all of the “blows”, that is vital for the right animation order:

  • Projectile animation 1

  • Harm animation

  • Demise animation

  • Projectile animation 2

  • Harm animation

  • Demise animation

  • Demise ratch 1

  • Demise Ratch 2

  • panic 1

  • panic 2

  • and so forth

That is essentially totally different from the instance with the explosion beforehand, as a result of the explosion from the standpoint happens at one time, whereas the taking pictures line already extends in time.

The remainder of the results needs to be performed as ordinary, in spite of everything successes. As a result of it might be unusual if throughout the line any unit panic and escape.

I perceive find out how to encode such a system, however it can lead to loads of work, and it appears to me that there’s a extra elegant method right here, which I can’t attain.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles