axis and norm of HitByWeapon & HitByWeaponId

axis and norm of HitByWeapon & HitByWeaponId

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

axis and norm of HitByWeapon & HitByWeaponId

Post by zwzsg »

In Cavedog's units scripts, HitByWeapon are used only to make unit rock under impact. Currently this work incorrectly because the value passed are measured along map absolute axis instead of unit-relative axis.

However, many people, including me, FLOZi, WhiteHawk, Quanto, and everybody else wanting some kind of directionnal damage, are about to expand the use of that function. And we are limited by how the arguments are null for any non-pushing weapon.



In the current "nightly build" Spring code, the first two arguments of both HitByWeapon and HitByWeaponId:
- are measured along the axis of the map, and not the axis of the unit
- are related to the "impulse" power of the shot, so they are null for weapon that have no "impulse".

That they use the axis of the map and not of the unit is I assume a simple omission and so should just be fixed. Look at a standard, Cavedoggy, rockunit.h from totala1.hpi or Scriptor, and you'll see it expects HitByWeapon arguments to be along the unit axis, not the map axis.


That only weapons with pushing power make those arguments non null is I assume deliberate: since most of the time HitByWeapon is only used to make unit rock when shot at, it would make sense that the rocking is proportionnal to the "pushing power" of the shot. However, it makes it impossible to determine the direction of a non pushing weapon. Since we now have two functions, HitByWeapon and HitByWeaponId, maybe we could leave HitByWeapon arguments be proportionnal to pushing power, and HitByWeaponId arguments non null even for impulseless shot. In TA the arguments were so their norms was always 400. Ie:
get ATAN(z,x) would give the direction of impact
get HYPOT(z,x) would be 400, no matter what
But I think it would be nice if instead of being fixed to 400, the norm would give use the distance to the point of impact. That way, we would know not only which angle the impact was, but also how far from center.


I'd like the following changes to the argument of those script function:

HitByWeapon(z,x):
- Change the axis to unit's axis
- Keep the norm of x,z as it is now


HitByWeaponId(z,x,weapon_id,shot_power):
- Change the axis to unit's axis
- Change the norm of x,z, so it's independant of impulse,
but instead is the distance between unit and point of impact.


While this is certainly not as important as fixing crash & exploits, it would be great if that could be fixed before modders start using HitByWeapon on a large scale. Oh, and please make sure the z,x argument have not only the same axis but also the same sign as they had in TotalA.

And should you need to check the value of HitByWeapon arguments in either Spring or TA, read them with that unit.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

BUMP
I'm putting this in the bonusshield/dodamage overhaul, and have a couple questions.
I didn't get any comments in the bonus shield thread, but apparently I screwed up the link. meh. This is a better place anyway.

Using unit coordinates is easy and already done, and I've put in a pretty good implementation of always having a proper hitdir, even without impulse, but I have questions about the rest:

Would it be better to do the norm thing, or just pass the distance seperately? Either one is very simple.
Passing the distance would prevent losing resolution at low distances.
If so, should hypot(z,x) be left at 500 as spring currently does or be changed to 400 to be compatible?

Passing extra arguments doesn't seem to cause any problems, but would units get upset in TA if they didn't get extra 5th, 6th, 7th arguments beyond what TA gives?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Naah, you can have any number of arguments in the script, too few and you just ignore the last ones and too many and you only get zeroes for those.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

KDR_11k wrote:Naah, you can have any number of arguments in the script, too few and you just ignore the last ones and too many and you only get zeroes for those.
in TA too? good.

Is there any speed benefit to doin the multiply rather than passing an additional variable? One that's large enough to make up for a possible hypot call? I wouldn't think so...

And if not, that just leaves the question of whether to leave the multiplication factor at 500, or change it to 400.

Do any scripts depend on the factor being 500 anyway? If they just get the direction, then it doesn't matter. Any reason not to make it compatable?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

TA doesn't have a HitByWeaponId function, only HitByWeapon so any script using it would act up in TA anyway.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post by lurker »

KDR_11k wrote:TA doesn't have a HitByWeaponId function, only HitByWeapon so any script using it would act up in TA anyway.
Okay, but any reason not to change it to 400 in both HitByWeapon and HitByWeaponId?

Or why not make the angle more accurate and just use *65536?
Post Reply

Return to “Feature Requests”