Author Topic: Calling ProjectileData::Damage() regardless of minigame damage checks  (Read 1421 times)

According to Badspot, ProjectileData::Damage() and ProjectileData::RadiusDamage() are called after Projectile::OnCollision() does some minigame damage checks.
Quote from: Badspot
(from the pinned Projectile::Damage topic)
When a projectile collides with something, it determines if it should damage it (via minigame checks) then calls this function.

How would I go about calling it anyway, regardless of whether or not the projectile can damage the affected object?
Or, rather, what would be the best method to use without potentially breaking other mods? Packaging MinigameCanDamage, calling it manually, or something else?

I need to package this as part of a mod. Basically, I need to check if a projectile has a certain property on it, and in turn call another function regardless of if the players can damage each other or not.

Why would you want to call the damage function if it isn't supposed to do damage?

Just put your code in projectile::onCollision.

Why would you want to call the damage function if it isn't supposed to do damage?

Just put your code in projectile::onCollision.
It's not supposed to do damage.
I just need any explosions the projectile might have to still affect players that can't damage eachother, for example, two teammates.

It's not supposed to do damage.
I just need any explosions the projectile might have to still affect players that can't damage eachother, for example, two teammates.
So you want indirect friendly fire, like from explosions?

So you want indirect friendly fire, like from explosions?
It's not supposed to do damage.
I just need any explosions the projectile might have to still affect players that can't damage eachother, for example, two teammates.
I suppose you could call it cooperative fire, but once again, I just need a way for teammates that are within the explosion radius to be affected.
« Last Edit: August 25, 2012, 10:54:56 PM by Wheatley »

You can always package miniGameCanDamage. For that matter, you should be able to package any function without breaking any mods as long as you package it correctly. Just package it and have it return true when you need it to.
« Last Edit: August 25, 2012, 11:57:11 PM by TripNick »

Well, I ended up just packaging projectiledata::onCollision(), then using initContainerRadiusSearch() to mimic an explosion.

initContainerRadiusSearch isn't working for some reason.

Code: [Select]
initContainerRadiusSearch(%obj.getPosition(),%this.explosion.damageRadius, $TypeMasks::PlayerObjectType);
while(isObject(%searchObj = containerSearchNext()))
{
  echo(%searchObj);
}
Even though I'm testing this with a rocket launcher and firing it right at my feet, It can never find any objects with the mask PlayerObjectType unless I have the projectile hit me directly.

The only success I've had is using
Code: [Select]
initContainerRadiusSearch(%obj.getPosition(),%this.explosion.damageRadius, $TypeMasks::All);
while(isObject(%searchObj = containerSearchNext()))
{
  if(%searchObj.getClassName() $= "Player")
  {
    echo(%searchObj);
  }
}
(take notice of $Typemasks::all being used instead)
When I use THAT, it actually echoes something.

What am I doing wrong?

Edit: actually, it seems to not be detecting any players that spawned it via an item exclusively; however, it detects the brick that spawned it.
« Last Edit: August 26, 2012, 06:09:13 AM by Wheatley »

It would be easier to package minigameCanDamage I think.

It would be easier to package minigameCanDamage I think.
I can't really think of how I could do that without breaking team-based mods and such.

What arguments does minigameCanDamage have?

minigamecanDamage(%damageSourceObj, %damageTargetObj); I believe

What, and you can't use those? Tell us more in depth what you're using this for

Basically, it's a support script that lets you apply certain fields to projectile datablocks which determine certain ways that the projectile effects players. One of the fields would make the projectile (and its explosion, if any) cancel a damage-over-time schedule, which basically means it would need to be used cooperatively. Because of this, I need to make it work regardless of whether the players can damage one another or not.

Unless there's a way I can backtrace the functions minigameCanDamage is being called from, I'm not sure that method would work.

Edit: Wait, in
minigamecanDamage(%damageSourceObj, %damageTargetObj);
is %damageSourceObj the projectile, or the projectile's source (i.e., the player who shot the projectile)?
« Last Edit: August 26, 2012, 05:05:15 PM by Wheatley »

Edit: Wait, inis %damageSourceObj the projectile, or the projectile's source (i.e., the player who shot the projectile)?
It is the source.