Author Topic: Projectile does not Damage vehicles (Need help)  (Read 2261 times)

That's the shock that initially throws off a lot of aspiring coders such as yourself. You learn quite quickly that the only one that can teach you is yourself. Give it your best shot, like the most you have and then come here and ask us.

Also, to assure you that all of us go through this, when I used to come and get help, people would use abbreviations like %client and %player and I had absolutely no idea what i was supposed to do. For a solid day I sat there wondering why nothing was happening when I tried to use just %client and %player in my code and not actually declare them.

I dont want too, show me how to do it from scratch please.
Show me how to do it from scratch, it shouldnt be that hard for you to do so.
Idk, its just that last time i posted my attempts of making a peice of code work, it was pretty embarassing to say the least. i Dont wish to debug, i wish to learn and execute myself.
... you want help, so help us help you
if you post the code you have, it'll be a lot easier for us to make it work
if you don't post the code, we have no idea how you're trying to go about making it work
you already researched  the method of making it work, but refuse to figure out the syntax errors with/without help

your unwillingness to make it work, by yourself or through others, and instead just wanting the code, is what would make this belong in suggestions and requests and not coding help, because you don't want help, you just want it done
if you continue like this, you won't learn because you're not trying to or wanting to, there's no need to kid yourself
either try to do it yourself (by going through the code and trying to understand, or by posting it here for us to help), or just ask for it to be done for you as a suggestion/request

Code: [Select]
package gc_RaycastDamageSystem
{
  function gc_RaycastDamageSystem(%this,%obj,%col,%pos)
  {
    if((%col.getType() & $TypeMasks::PlayerObjectType) || (%col.getType() & $TypeMasks::VehicleObjectType)) {
    if(getMiniGameFromObject(%col) == -1) return 0;
    if(miniGameCanDamage(%obj,%col) == 0) return 0;
    if($GCStuff::DmgSystem == 0){%col.damage(%obj,%pos,%this.directDamage / getWord(%col.getScale(),2),%this.directDamageType);return 1;}
    if(%col.getType() & $TypeMasks::VehicleObjectType){%col.damage(%obj,%pos,%this.vehicleDamage / getWord(%col.getScale(),2),%this.directDamageType);return 1;}
    if(%col.getType() & $TypeMasks::PlayerObjectType) {
    if(%col.isCrouched() == 1){if(!getRandom(2)){gc_bleed(%col,getRandom(20,100));}%col.damage(%obj,%pos,(%this.directDamage * 2) / getWord(%col.getScale(),2),%this.directDamageType);return 1;}
    %colscale = getWord(%col.getScale(),2);
    if(getWord(%pos,2) > getWord(%col.getWorldBoxCenter(),2) - 3.3*%colscale)
    {
      %col.damage(%obj,%pos,%this.headshotDamage / getWord(%col.getScale(),2),%this.directDamageType);
      return 3;
    }
    %col.damage(%obj,%pos,%this.directDamage / getWord(%col.getScale(),2),%this.directDamageType);
    if(!getRandom(2)) gc_bleed(%col,getRandom(20,100),%obj);
    return 2; } }
  }
};
activatePackage(gc_RaycastDamageSystem);


This is the code from the Damagesystem. After this is put in your effects.cs, you need to go to the weapon's CS file and under the weapon's image you need to put "vehicleDamage = 1;. But when i did that in my weapon set, it had no effect.

What are you using to interact with it?

The effects.cs is interacting with the rest of the weapons.

I mean what is calling the function.

The weapon is calling the function

I mean show us the code.

Code: [Select]
datablock ShapeBaseImageData(M60E4Image)
{
   shapeFile = "./M60E4.dts";
   emap = true;
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = "0 0 0";    //eyeOffset = "0.4896 0.6088 0.0685"; -Left +Right, -Back +Front, -Down +Up
   rotation = eulerToMatrix( "0 0 0" );
   correctMuzzleVector = true;
   className = "WeaponImage";
   item = M60E4Item;
   ammo = " ";
   projectile = M60E4Projectile;
   projectileType = Projectile;
   casing = ARShellDebris;
   shellExitDir        = "1.0 0.1 1.0";
   shellExitOffset     = "0 0 0";
   shellExitVariance   = 10.0;
   shellVelocity       = 5.0;
   melee = false;
   armReady = true;
   doColorShift = false; 
   vehicleDamage = 5;

Idk, its just that last time i posted my attempts of making a peice of code work, it was pretty embarassing to say the least. i Dont wish to debug, i wish to learn and execute myself.
That's how you get better though. You post your code, people who know what they're doing figure out what mistakes you made and help you fix them, not steal your code and call you an idiot for something idiotic like misplacing a bracket or w/e.

This could also help me too because I'm trying to figure out how to make projectiles affect vehicles differently, but when I tried looking at Gcat's code its set up to work with raycasts, and I have no fugging clue how to convert that code to work with actual projectiles

pulled code from one of my old projects and modified it a little
Code: [Select]
function ronpaul2012Projectile::damage(%this,%obj,%col,%fade,%pos,%normal) //specify the projectile whose damage you want to modify
{
%damageType = $DamageType::Direct; //just calls the damage type already assigned to the projectiledata of the above specified projectile
if(%this.DirectDamageType)
{
%damageType = %this.DirectDamageType;
}
%scale = getWord(%obj.getScale(), 2);
%directDamage = 15; //the damage dealt to anything that's not a player, bot, or bot vehicle(horse, boat, etc); essentially "vehicle damage"
%damage = %directDamage;
%sobj = %obj.sourceObject;
if(%col.getType() & $TypeMasks::PlayerObjectType)
{
%directDamage = 24; //base player damage overwrite
%colscale = getWord(%col.getScale(),2);
if(getword(%pos, 2) > getword(%col.getWorldBoxCenter(), 2) - 3.3*%colscale)
{
%directDamage = 60; //headshot damage, just set this to the same as the %directDamage above if you don't want any headshot bonus
}
%col.damage(%obj, %pos, %directDamage, %damageType);
}
else
{
%col.damage(%obj,%pos,%directDamage,%damageType);
}
}
ldrop in change a few values n ur done lol

thank you for this!


It works!
« Last Edit: June 11, 2015, 02:19:26 AM by Ctrooper »