Jump to content

Make grenades explode at end of turn


Bertilsson

Recommended Posts

I've been trying to figure out how to make grenades explode at the end of turn (or beginning of enemy turn) instead of immediately.

 

Getting the grenades to not explode immediately is simple. All that is needed is to change any of below values -1 to mismatching values.

XComProjectile_FragGrenade.InitProjectile:
m_iTurnToExplode = -1;
XComProjectile_FragGrenade.Tick:
if(m_iTurnToExplode == -1) { Explode(Location, vect(0.0, 0.0, 1.0)); }

By stealing some code from battlescanner I started implementing this:

XComProjectile_FragGrenade.InitProjectile:
m_iTurnToExplode = XComTacticalGRI(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kBattle.m_iPlayerTurn + 1;

However that code is 70 storage bytes long so I really doubt that I will be able to fit a matching check in the Tick function...

 

Does anyone else have any ideas how to accomplish delayed explosion?

 

I guess what I really want is a function that is triggered in beginning or the end of each player/AI turn in which I could call to a repurposed function which check all grenades in the game for a positive m_iturnToExplode value and blow them up.

 

Why do I want to delay it in the first place?

The simple reason is that I read a thread in the 2K forums where basically everyone was diveded into two camps.

One camp that generally think that grenades should blow up _after_ the enemy turn so that the enemy have a chance to run away and another camp that think that would completely unrealistic but were completely fine with the current implementation.

 

I think they are both wrong.

 

You shouldn't be able to run away from a grenade, with the possible exception of lightening reflexes perk.

But neither should you be able to prime a grenade, throw the grenade, wait for it to explode, evaluate the damage and then repeat the sequence with a new soldier until satisified with the result and then in addition be able to start shooting at the now unprotected enemy who is just standing there looking stupid for what would be a very long time in real time.

 

Shooting does not have the same issue since it would extend the turn only by a few seconds real time to imagine a bunch of soldiers shooting at one target and a few of them holding back to see if it goes down or not before taking their shot.

Not accepting that amount of time discrepancy would require each turn to be planned in advance and to play out in parallel and basically require a different game engine which I would probably not like at all...

Link to comment
Share on other sites

In XGSquad is a function EndTurn, which invokes the XGUnit.EndTurn function for each unit in the squad. The trick in my mind is how to hook into a persistent projectile. Battlescanners actually terminate the projectile and spawn the special battlescanner unit. In general I don't think projectiles are designed to persist for very long, but you might be able to get it working :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...