Blockland Forums > Modification Help
Checking if an object is a vehicle
<< < (3/5) > >>
otto-san:
post the actual code then
Unicide:
I just checked. Replace the == with $= and you have the actual code.
Port:

--- Quote from: Unicide on December 06, 2011, 10:03:02 PM ---
--- Code: ---s%points = %damApply;

--- End code ---

--- End quote ---

Is that s in the actual code?
Anyhow, I suggest you use if(%col.getType() & $TypeMasks::VehicleObjectType) instead of if(%col.getClassName() $= "WheeledVehicle").
Destiny/Zack0Wack0:
Try Projectile::damage instead.
Unicide:

--- Quote from: Port on December 07, 2011, 08:14:30 AM ---Is that s in the actual code?
Anyhow, I suggest you use if(%col.getType() & $TypeMasks::VehicleObjectType) instead of if(%col.getClassName() $= "WheeledVehicle").

--- End quote ---
Yes, turns out it is. Here's the code as it stands, right now, after changes:

--- Code: ---//exec("./Weapon_AntiArmor.cs");//test weapon, testing entry 1
//exec("./armorjeep.cs");//test vehicle, set with armor 1
//REMINDER: Added lines to jeep and rocket launcher scripts, must remove

//Main
package testPackage2
{

function ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt)
{

if(%distanceFactor <= 0)
return;
else if(%distanceFactor > 1)
%distanceFactor = 1;

if(%col.getType() & $Typemasks::VehicleObjectType)//it's a vehicle
{
%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 = %damageAmt * %distanceFactor;
}
else
{
%damApply = (%damageAmt * %distanceFactor) * 0.5;//TODO: Make this loop for armor values above 1.
//Would be ((%damageAmt * &distanceFactor) * 0.5)^(armorValue - armorPiercing) but how2power in C#?
}
}
}
else
{
%damApply = %damageAmt * %distanceFactor;//no armor, apply normally
}
%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);//display points earned
Parent::radiusDamage(%this,%obj,%col,%distanceFactor,%pos,%damApply);
//Parent::radiusDamage(%this,%obj,%col,%distanceFactor,%pos,%damageAmt);

}

function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getType() & $TypeMasks::VehicleObjectType)//it's a vehicle
{
%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;//TODO: Make this loop for armor values above 1.
//Would be ((%damageAmt * &distanceFactor) * 0.5)^(armorValue - armorPiercing) but how2power in C#?
}
}
else
{
%damApply = %this.directDamage;//no armor, apply normally
}
}
%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);
}
};
activatePackage(testPackage2);

--- End code ---

As you can see, I used Projectile::damage and the Typemask suggestions, but neither works. Does Projectile::damage have the same arguments as ProjectileData::damage?
Navigation
Message Index
Next page
Previous page

Go to full version