Page 1 of 2

melee and getting it right.

Posted: 09 Jan 2014, 03:11
by smoth
So right now I am trying to brainstorm for melee.

currently this is my thought.

Melee weapon with short range.
Unit aims(just turning torso)
unit fires->triggers punch/slash animation->emits actual melee weapon

all units are capable of blocking some how if they are not gunarms(aka my mech with the giant miniguns for arms.)
-here is my issue-
how do I get the side a unit was hit on AND the current torso rotation to see where the shield(if any) is?

Re: melee and getting it right.

Posted: 09 Jan 2014, 12:05
by Anarchid
how do I get the side a unit was hit
MCL uses per-piece collision volumes. You can get the piece which was hit then.
If you strictly want the side, check relative position of attacker unit maybe?
AND the current torso rotation to see where the shield(if any) is?
Spring.GetUnitPiecePosDir gives you those values (in world space).

Re: melee and getting it right.

Posted: 09 Jan 2014, 17:45
by FLOZi
Or Spring.UnitScript.GetPieceRotation if you want the unit space (or is that piece space?)

Reasonably sure PPCV won't work with the Melee weapon type, in terms of finding which piece was hit, as Melee deals damage directly. Not clear if you are indicating you would use that some other type (probably old reliable - LaserCannon)

You could use PPCV with a LaserCannon fake weapon to control aiming etc and then use Melee to deal damage, perhaps.

Re: melee and getting it right.

Posted: 09 Jan 2014, 21:29
by knorke
emits actual melee weapon
if that is supposed to be the way of actually dealing the damage after animations have been played, I would rather use Spring.AddUnitDamage because seems more reliable and exact.
check relative position of attacker unit maybe
That is way of least hassle imo. Or maybe Explosion() callin to get where the blow was landed on hit unit.

Also maybe
HitByWeapon ( x, z, weaponDefID, damage ) -> nil | number newDamage
This is called if a unit has been hit by a weapon. (x, z) is the direction from which the projectile came in unit space.

http://springrts.com/phpbb/viewtopic.ph ... 20#p498107

Re: melee and getting it right.

Posted: 09 Jan 2014, 23:30
by smoth
knorke wrote:
emits actual melee weapon
if that is supposed to be the way of actually dealing the damage after animations have been played, I would rather use Spring.AddUnitDamage because seems more reliable and exact.
Because I want to know if the unit was facing right way as it was trying to block. By setting damage I do not get the direction the attack came from.

Re: melee and getting it right.

Posted: 10 Jan 2014, 00:46
by knorke
Why do you need still direction *after* it was already decided that the attack was succesful?

Re: melee and getting it right.

Posted: 10 Jan 2014, 01:29
by smoth
Hit test if unit blocked/can block damage is either negated or not

Re: melee and getting it right.

Posted: 10 Jan 2014, 02:05
by knorke
?

Re: melee and getting it right.

Posted: 10 Jan 2014, 02:12
by Anarchid
Quick question - will the defending unit play an animation in case of block? I.e, raise the shield to intercept the incoming strike?

If so, i think you'll need to tell the defender to do the defense animation when attacker starts his animation -- which could be a lot of time before the damage would occur -- and not when the actual melee weapon is emitted and damage is either dealt or not in a single sub-frame event.

(and yeah getting piece direction in worldview would be very useful for determining which way the shield goes in this case)

Re: melee and getting it right.

Posted: 10 Jan 2014, 02:21
by smoth
Right now I am just trying to get a basic version going. I am entirely uninterested in DOW style melee

Re: melee and getting it right.

Posted: 10 Jan 2014, 17:42
by FLOZi
knorke wrote:?
Image

Melee hits don't always lead to damage.

Re: melee and getting it right.

Posted: 10 Jan 2014, 18:35
by SinbadEV
Thinking about it in a timeline:

Step 1:
Attacker chooses target
Step 2:
Attacker starts attack animation
Target has a chance to notice attack
Step 3:
Target may move/animate in response to attack if it was noticed
Attacker continues attack animation
Step 4:
Point of Contact between Attacker's weapon and defender is determined and damage is assigned
Step 5:
Attack (follow through) and Defense (response) animations complete based on point of contact (if the point of contact was a shield then the attack could glance off or the target might be pushed back etc.)... or the defender may start it's "hit" or "death" animation.
Step 6:
Damage is applied to the defender and we return to step 1

But all that said... smoth it asking for programming help to determine the relative orientation of the two units in order to calculate the attack vector and point of contact so I should shut up.

Re: melee and getting it right.

Posted: 10 Jan 2014, 18:58
by smoth
You should shut it yes

Re: melee and getting it right.

Posted: 10 Jan 2014, 19:47
by Evangelion
smoth wrote:how do I get the side a unit was hit on
http://springrts.com/wiki/Lua_SyncedRea ... formations
Not sure if it's possible to hook projectiles/impacts with lua yet. You can calculate where your attacker weapon piece is in relation to the target pieces. Doesn't even have to be precise, just take the nearest piece.
smoth wrote:current torso rotation to see where the shield(if any) is?
http://springrts.com/wiki/Lua_SyncedRead#Unit_Pieces

Re: melee and getting it right.

Posted: 10 Jan 2014, 22:27
by yuritch
You can determine both incoming attack vector and current shield position in the same space (unit space in this case) if you control them from the defender's script. Basically units with shields should implement HitByWeapon, then GetPieceRotation/GetPiecePosDir of the shield and modify damage accordingly, units without shields can just ignore the callin and allow full damage through.

Doing it via gadget should be possible as well with Spring.GetUnitPiecePosDir which returns values in world space.

Re: melee and getting it right.

Posted: 11 Jan 2014, 00:41
by knorke
FLOZi wrote:
knorke wrote:?
http://www.swordacademy.com/academy-vid ... 08.big.jpg

Melee hits don't always lead to damage.
I understood that.
Why do you need still direction *after* it was already decided that the attack was succesful?
The attacker has done his animation, some system has decided if the attack was successful/missed/was blocked etc, the defender has done his animation. Only thing missing is actually damaging the defender, for that I suggested AddUnitDamage instead of EmitSfx-ing a weapon.

Re: melee and getting it right.

Posted: 11 Jan 2014, 01:02
by FLOZi
Who said you need it after?

1. Use an invisible non-melee weapon to detect hits and from that direction
2. Determine if 'body' or 'shield' was hit
3. Apply relevant damage

The more I think about it the more I'm tempted to suggest PPCV after all with shield having its own volume and melee weapons being a very short range LaserCannon emitted from the tip of the weapon model.

Re: melee and getting it right.

Posted: 11 Jan 2014, 01:05
by knorke
FLOZi wrote:Who said you need it after?
here:
http://springrts.com/phpbb/viewtopic.ph ... 04#p552463

Re: melee and getting it right.

Posted: 11 Jan 2014, 02:14
by smoth
smoth wrote: Melee weapon with short range.
1) Unit aims(just turning torso)
2) unit fires->triggers punch/slash animation->emits actual melee weapon
3) all units are capable of blocking some how if they are not gunarms(aka my mech with the giant miniguns for arms.)
So a mech is in melee, it has it's shield raised, a mech punches the target, I then fire a shot of as part of the "punch" animation script. If the shot his the shield it is blocked, random chance the shield is knocked back down/off/etc..

Maybe it didn't have the shield raised? well raise the fucking shield dumbass, unit has shield raised, melee unit attacks again, If the shot his the shield it is blocked, random chance the shield is knocked back down/off/etc.

Re: melee and getting it right.

Posted: 11 Jan 2014, 02:24
by knorke
Was that at me?
Because it does not explain why you need still need direction after the system has already decided that the attack did hit and was not blocked.