Author Topic: Checking if an object is a vehicle  (Read 2310 times)

You used $ instead of &. :o

Changed that, didn't work. I've updated the previous post with the current code.

What it DOES do is spit back the points value earned, but it doesn't say anything about hitting a vehicle.

My mistake, ProjectileData is the correct one you should be using. You've got to mistakes:
1) %col.getClassName() & $TypeMasks::VehicleObjectType - it should be %col.getType(), not %col.getClassName()
2) There are no multi-line comments in TorqueScript, so it's causing a syntax error.

I have fixed both of those issues and updated the code with them. However, I still have run into the same issue - it prints the points value but neither adjusts damage for armor or prints "Vehicle hit" when I shoot a vehicle.

Oh WOW. I had written the points part of the script before V20. All this time I'd been sending my changes to C:/Blockland rather than My Documents/Blockland. As you may guess, everything works now.


If you wanted to check if it was any vehicle - not just a wheeled one - you would use if(%col.getType() & $Typemasks::VehicleObjectType)
I'd like to know whether this can work for all vehicles, including the horse. Right now it only works for physics vehicles. I know that I can do if(%col.getType() & ($Typemasks::VehicleObjectType | $Typemasks::PlayerObjectType)) but that also works for players, which I don't want.

Your best bet is to get the datablock and if the datablock has the "canMount" (I think that's what it's called) value set to 1, assume it's a vehicle.