Blockland Forums > Modification Help

Checking if an object is a vehicle

Pages: << < (2/5) > >>

Unicide:

Actually, neither of the .getClassName() solutions seem to be working. It doesn't seem to recognize that it's hit a car.

otto-san:


--- Quote from: Unicide on December 06, 2011, 05:01:36 PM ---Actually, neither of the .getClassName() solutions seem to be working. It doesn't seem to recognize that it's hit a car.

--- End quote ---
post the code

Unicide:


--- Code: --- function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getClassName() == "WheeledVehicle")//it's a vehicle
//TODO Make this apply to units with armor too
{
%vehicleArmor = %col.getDatablock().armorValue;
%weaponPiercing = %obj.sourceObject.getDatablock().armorPiercing;
messageClient(%obj.sourceObject.client,' ',"Hit a vehicle.");
if(%vehicleArmor > 0)//if it is armored
{
messageClient(%obj.sourceObject.client,' ',"Hit an armored vehicle.");
if(%weaponPiercing >= %vehicleArmor)//can penetrate, continue normally.
{
%damApply = %this.directDamage;
}
else
{
%damApply = (%this.directDamage) * 0.5;
}
}
else
{
%damApply = %this.directDamage;//no armor, apply normally
}
}
s%points = %damApply;
//Check if that would be more than the target's health, and if so, set points to max health.
if((%col.getDamageLevel() + %damApply) > %col.getDatablock().maxDamage)
{
%points = %col.getDatablock().maxDamage - %col.getDamageLevel();
}
messageClient(%obj.sourceObject.client,' ',"Points Earned:" @ %points);
Parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}
--- End code ---
When I shoot a jeep with the gun, I get no "hit a vehicle" message.

otto-san:

using ==

should be $=

Unicide:

Typed from memory, actual code has that. Still doesn't work, though.

Pages: << < (2/5) > >>

Go to full version