Trying to emulate the Inquisitor's grenade attack
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Re: Trying to emulate the Inquisitor's grenade attack
How would this new feature help? (ie what should the code look like?)
- LilWhiteMouse
- Posts: 2270
- Joined: Tue Jul 15, 2003 7:00 pm
- Location: Maine, US
- Contact:
Re: Trying to emulate the Inquisitor's grenade attack
What does ZDoom use as it's gravitational constant?
Re: Trying to emulate the Inquisitor's grenade attack
Physics is pretty simple. Vertical velocity increases by one point every tic. First tic is doubled. So after one tic of freefall, your speed is 2, after two tics it's 3, after three tics it's 4, after 987 tics it's 988, etc. See [wiki]falling damage[/wiki].
So, if you apply an initial upward vertical velocity, it'll be decreased by 1 every tic until it's 0, then it jumps to 2 downwards, and 3, 4, 5, etc.
So, if you apply an initial upward vertical velocity, it'll be decreased by 1 every tic until it's 0, then it jumps to 2 downwards, and 3, 4, 5, etc.
-
Edward-san
- Posts: 1774
- Joined: Sat Oct 17, 2009 9:40 am
Re: Trying to emulate the Inquisitor's grenade attack
What? So easy?
PREPARE FOR THE MATHS ARENA!!!!!
Example:
let's suppose a grenade monster wants to attack a marines base. For now let's say he knows the right calculation. He fires his projectile, with horizontal speed 'm' and vertical speed 'n', with n and m integers (>0). I assume speed is map_unit/tic. Question: how much high can get the projectile (in map units)?
Let's apply what gez said:
Hence, the value will be: the summation of the first 'n' values!
Let's use Gauss' equality: such value is 'n*(n+1) / 2'!!
Let's use bit shift: "n*(n+1) >> 1" map units!!!!!!!
So this is the hard truth no one wanted to know!
[edit]And, how much did the projectile traverse horizontally in the meantime? Let's say the horizontal speed will be constant (right?). Hence, each tic the projectile has moved 'm' map units.
Oh, this'll be easy: "n*m" map units!!!!
Hell, if the marine base is placed in the same height as the monster's projectile, the monster can attack it from a distance of?
Ready? "n*m (rising time) + m (there's a tic with speed 0) + n*m (falling time)=2*(n+1)*m" map units!!!!
[edit]No, wrong: when the projectile starts to fall, at the first tic the projectile's speed will be '-2', not '-1', hence:
2*(n+1)*m-m=(2*n+1)*m!!!
PREPARE FOR THE MATHS ARENA!!!!!
Example:
let's suppose a grenade monster wants to attack a marines base. For now let's say he knows the right calculation. He fires his projectile, with horizontal speed 'm' and vertical speed 'n', with n and m integers (>0). I assume speed is map_unit/tic. Question: how much high can get the projectile (in map units)?
Let's apply what gez said:
In this case, at the first tic the number of the map units vertically traversed by the projectile will be 'n', in the second tic it'll be 'n-1', ... in the 'n-1'-th tic it'll be '1' and in the 'n'-th tic it'll be '0.So, if you apply an initial upward vertical velocity, it'll be decreased by 1 every tic until it's 0, then it jumps to 2 downwards, and 3, 4, 5, etc.
Hence, the value will be: the summation of the first 'n' values!
Let's use Gauss' equality: such value is 'n*(n+1) / 2'!!
Let's use bit shift: "n*(n+1) >> 1" map units!!!!!!!
So this is the hard truth no one wanted to know!
[edit]And, how much did the projectile traverse horizontally in the meantime? Let's say the horizontal speed will be constant (right?). Hence, each tic the projectile has moved 'm' map units.
Oh, this'll be easy: "n*m" map units!!!!
Hell, if the marine base is placed in the same height as the monster's projectile, the monster can attack it from a distance of?
Ready? "n*m (rising time) + m (there's a tic with speed 0) + n*m (falling time)=2*(n+1)*m" map units!!!!
[edit]No, wrong: when the projectile starts to fall, at the first tic the projectile's speed will be '-2', not '-1', hence:
2*(n+1)*m-m=(2*n+1)*m!!!
-
Edward-san
- Posts: 1774
- Joined: Sat Oct 17, 2009 9:40 am
Re: Trying to emulate the Inquisitor's grenade attack
Btw: isn't it a bug that should be fixed in zdoom code?Enjay wrote:However, this function has a slight problem: the robot has got two shoulder-mounted weapons where the grenades are supposed to come from but the grenades (one in particular) fire much lower than that - pretty much at foot level, certainly low enough to get caught even on relatively small obstacles.
Re: Trying to emulate the Inquisitor's grenade attack
I was about to a post a "but that's how it is in the original exe" post but I thought I'd better check and... it isn't. I wouldn't say that the projectiles are launching as high as the shoulder canons but they are definitely launching quite a bit higher than they do in ZDoom. It's difficult to tell in all the 320x200 glory of the original and there is no "freeze" command to help me out but I'd estimate that they originate near waist level or possibly even as high as the "mouth".Edward-san wrote:Btw: isn't it a bug that should be fixed in zdoom code?
Bug report filed.
http://forum.zdoom.org/viewtopic.php?f=2&t=32499
Re: Trying to emulate the Inquisitor's grenade attack
Related to this: A_Warp - I don't understand the first parameter:
The 72 is just a test value and may change.
I've checked the actor pointers page but I still don't get it. What does "Teleports the calling actor to the pointer they have" mean? All I am trying to do is to raise the height of the Inquisitor shot by having them A_Warp upwards in their first tic. I'm just using 0 as the first argument and it seems to work but even so, I really don't get what that first parameter is supposed to be doing.ptr_destination: Teleports the calling actor to the pointer they have. See Actor pointers for more information.
Code: Select all
actor TestMe : InquisitorShot replaces InquisitorShot
{
States
{
Spawn:
UBAM A 0
UBAM A 0 A_Warp(0, 0, 0, 72, 0, 0, 0)
UBAM A 3
UBAM B 3
goto spawn+2
}
}- XutaWoo
- Posts: 4005
- Joined: Sat Dec 30, 2006 4:25 pm
- Location: beautiful hills of those who are friends
- Contact:
Re: Trying to emulate the Inquisitor's grenade attack
Basically, it sets what actor it warps to. It's limited to the actor's target, tracer, and master and whatever else there is, so that random stuff doesn't happen when you pick a random actor.
Re: Trying to emulate the Inquisitor's grenade attack
The pointer selector is used to determine what actor you start from. The coordinates and angles given are relative to that actor.
0 = AAPTR_DEFAULT.
Unless otherwise noted, the default actor is SELF.
So warping with reference to AAPTR_DEFAULT is actually a way of teleporting something a given distance from its current position.
AAPTR_TARGET, AAPTR_MASTER and AAPTR_TRACER would reference the corresponding actor.
In addition, you can reference other actors that are identifiable to the game. For example, when a player calls a function that uses actor pointers, AAPTR_PLAYER_GETTARGET will reference whatever actor the player is looking at. AAPTR_PLAYER1 will always reference player one, if that player is in the game, and AAPTR_PLAYER2..8 work in exactly the same way. (Thus you can have an actor warp to a position relative to player 1 at any time, using AAPTR_PLAYER1, regardless of any tids and targets; as long as player1 exists, it will be correctly identified.)
0 = AAPTR_DEFAULT.
Unless otherwise noted, the default actor is SELF.
So warping with reference to AAPTR_DEFAULT is actually a way of teleporting something a given distance from its current position.
AAPTR_TARGET, AAPTR_MASTER and AAPTR_TRACER would reference the corresponding actor.
In addition, you can reference other actors that are identifiable to the game. For example, when a player calls a function that uses actor pointers, AAPTR_PLAYER_GETTARGET will reference whatever actor the player is looking at. AAPTR_PLAYER1 will always reference player one, if that player is in the game, and AAPTR_PLAYER2..8 work in exactly the same way. (Thus you can have an actor warp to a position relative to player 1 at any time, using AAPTR_PLAYER1, regardless of any tids and targets; as long as player1 exists, it will be correctly identified.)
Re: Trying to emulate the Inquisitor's grenade attack
Thanks for the explanation. It makes more sense now.

