Talk:Grenade

From UFOpaedia
Jump to: navigation, search

When using a grenade to remove terrain you can set the timer to 1 instead of 0. The aliens will move before the grenade explodes, giving you first use of the cleared terrain. -Egor


I always had a great deal of trouble "breaching" UFO's side-walls with High Explosives (playing with XComUtil or UFO Extender) to make tactical entries because after the "new door" was opened, I inevitably took a full turn of plasma in the face from the suddenly-exposed occupants (in ADDITION to reaction fire!) Only recently did I realize that by setting the timer to turn 1, the UFO would be breached AFTER the alien's turn, giving my troops a full turn to riddle the enemy through the breach. This one discovery has made breaching UFOs with HE much more useful; and keeps HE useful even after blaster bombs are available (since blaster bomb detonations cannot be delayed.)

--Demetrious 03:26, 28 November 2010 (UTC)


There's a trick you can perform with a 1 turn grenade with UFO doors if you know an alien will be walking through. By placing the 1-turn grenade in front of the UFO door, the alien will walk through, open the door, and end its turn. By then the grenade will explode and hit the alien. And because it's exploding before the doors are closed again, it can send a small wave into the UFO and strike any aliens that are behind the door.

It won't always work, but it's something that you can do.

- NKF


Timers

I thought I had found a bug but it's just my misunderstanding I think. I was setting timers to 3, carrying the grenade around, then it would go off when I dropped it. From this article it looks like the timer counts down while you are carrying it, but "holds" at zero. Is that true? If so we can put a clarification in for dummies like me. (I thought the timer countdown would start when I throw/drop the grenade).

PS this is a silly way for grenades to work and it's hard to think of a realistic equivalent. The timer, once set, ought to start when you release the grenade. Oh well :)

Spike 05:51, 25 March 2008 (PDT)

That is indeed a misunderstanding. Once a grenade is set, the game starts counting down the turns; as soon as it reaches 0, the grenade will explode IF IT IS ON THE GROUND. If it is not on the ground, it does indeed 'hold' at 0, and will detonate at the end of the next turn that it is sitting on the ground, regardless of how it got there. (This is the behavior used by people who want their soldiers to have dead-man switches; AKA, soldier dies, drops live grenade, blows up nearby aliens at tend of turn.) Arrow Quivershaft 09:47, 25 March 2008 (PDT)
If you want to add some difficulty in your games, you can do so that the primed grenades will detonate on due time even if handed. I did only a few tests so it may cause trouble, particularly if the soldier survives the explosion - the code should remove the grenade from its hand, but I make no promise ;). Simply patch at offset 0x1E095:
0F 85 E4 00 00 00
into
90 90 90 90 90 90
and your done. Now you should really make sure you have enough TUs to throw those nades :) Seb76 16:08, 18 May 2008 (PDT)
Seb, can you give any details about how you figure this stuff out? I'm a fairly accomplished programmer, but I only have a little experience with assembler, and this is all a mystery to me. I'd love to learn more. :) Phasma Felis 14:47, 2 June 2008 (PDT)
Actually this is possible thanks to the best disassembler in town... I started by cross-checking error messages (e.g. "couldnt allocate craftlist") with malloc/fread calls to identify the main datastructure pointers (every xxx.dat file has an equivalent in memory). Then with crossing with information from this site (offsets and stuff), I could identify some higher level functions. From there you can start analysing strange behaviors. Luck is also a factor, the disassembly is quite huge, and sometimes I just wander around and find some interesting stuff ^^ I'll post more explicit screenshots later. Seb76 15:55, 2 June 2008 (PDT)
Here you go, I "circled" the lines that check if the grenade on the floor or in a soldier inventory:

Detonate.png

This is quite huge so I'll stop for now. I have the UFO Power Source explosion sequence and unitref offset 0x3c explanation ready if you want more examples ;-) Seb76 16:14, 2 June 2008 (PDT)

Thanks very much, Seb76! I actually wouldn't mind some more examples, with more detailed comments :) But can I interest you in dropping me an e-mail? I have some non-grenade-related ideas I've been working on, and I could use some advice from someone with even a little understanding of the source code. Phasma Felis 21:53, 2 June 2008 (PDT)
OK, I finally set up a user page, so you can reach me on the talk page :) Seb76 13:27, 4 June 2008 (PDT)
I've been planning to create a new article to cover and explain all the little itty bitty things about how grenades (in general) function. The timer and the dead-man-switch definitely need to be explained.
Any suggestions on what the section should be called? I can't think of an appropriate article name for it except perhaps Grenade Mechanics or How Grenades Work. -NKF 21:52, 25 March 2008 (PDT)

Sounds like a great idea. For a title how about just "Using Grenades" or "More On Grenades and Explosives"? Spike 13:23, 26 March 2008 (PDT)

Thought I'd go with Understanding Grenades. We can always rename it later to something more appropriate. It's taken me a bit of time because I've had a lot of difficulty in trying to write it in a manner that even I could understand (and failing every time). I've decided to just throw up what I've managed to put together so far to get the ideas out there.
I realize the potential for a fence-post problem with my explanation on the grenade's time trigger (equal-or-greater than vs. greater-than), but hopefully the idea will still get across. - NKF 00:17, 4 April 2008 (PDT)

Changing the TUs to prime

Is there an easy way to change the number of TUs it takes to prime a grenade? As it is, it's a lot harder to use frag grenades tactically, which IMO makes things less interesting. Phasma Felis

If there is, it looks like it's probably coded somewhere inside the executable. It isn't in OBDATA.DAT which would be where I'd have expected it. Arrow Quivershaft 20:41, 11 June 2008 (PDT)
The values in Obdata only control the firing modes for the basic snap, auto and aimed modes. All other special attack modes and other misc uses might be coded in the tactical.exe portion of the game. I suppose if you searched for values of 50%, you'd find it soon enough. Finding the location of a number of other fixed percentage and fixed cost values would be handy too. - NKF 22:32, 11 June 2008 (PDT)
NKF: I knew that, but I figured that maybe they tried a trick, which they obviously didn't. In any case, what other numbers? Gimme a list and I'll see what I can do. (I'm thinking the list would include throwing, Mind Probe, Psi Amp, and inventory. Anything else?) Arrow Quivershaft 23:12, 11 June 2008 (PDT)
Off the top of my head, motion scanner, medikit, and possibly things like opening doors. Phasma Felis 23:35, 11 June 2008 (PDT)

Let's see...

  • Priming: 50%
  • Throwing: 25%
  • Probe: 50%
  • Stun: 30%
  • Melee Attack: 50%
  • Medikit usage: 10TUs
  • Psi-Amp mind control and panic: 25TUs
  • Motion Scanner: 25%
  • Blaster Launcher Launch command: 66%

There might be a few actions I've missed, but that's the bulk of it.

Then there are all the other non-hand-action TU costs such as the inventory movement to/from cross reference table, walking, alien actions, etc, but I guess these are best left for another rainy day.

- NKF 03:12, 12 June 2008 (PDT)

So you want to be able to prime and throw a grenade with 1% TUs and launch a Blaster Bomb with 1%, eh, NKF?  ;) I'll see what I can do. Arrow Quivershaft 07:24, 12 June 2008 (PDT)
For priming, you can try to patch at offset 0x1D622:
8A 56 19 D0 EA 66 0F B6 D2
into
66 BA 01 00 90 90 90 90 90
Cheers ;) Seb76 13:12, 12 June 2008 (PDT)
I don't have any savegame with medkits but you can try to patch the byte at offset 0x1D712 with your desired value (default is 0x0A=10). I make no promise... Seb76 13:28, 12 June 2008 (PDT)
Also TUs for mind control has been discussed here. Seb76 13:34, 12 June 2008 (PDT)
Tests reveal that the Medi-Kit edit changes the TU usage display. So it lists that it will use 2 TUs. However, it continues to use 10 TUs for all functions, so that must be elsewhere(likely nearby.) PS. Seb, do you use IM? It'd allow us to work together better. Arrow Quivershaft 14:02, 12 June 2008 (PDT)
The previous patch indeed only changes what is shown in the menu, to change the usage, there are 2 more bytes to patch:
TU check:
.text:0040AF50 B0 0A                      mov     al, 0Ah
TU consumption:
.text:0040AFA5 80 40 0C F6                add     byte ptr [eax+0Ch], 0F6h
0xF6 = hexa for -10. Seb76 14:21, 12 June 2008 (PDT)
For blaster launcher (not tested), patch at 0x1D66E:
8A 56 19 D1 E2 F7 EA 8B C2 C1 E8 1F 03 D0 66 41
into
66 BA 01 00 90 90 90 90 90 90 90 90 90 90 90 90
I'll check for the medkit cost problem. Also I don't use IM. Seb76 14:09, 12 June 2008 (PDT)