Author Topic: Spawned projectiles not doing damage to players  (Read 1400 times)

I'm making a gamemode and I want it at times to spawn missiles in the sky that rains down on everyone below. The problem is: the projectiles aren't doing any damage. Here's the code:

Code: [Select]
for(%i = 0;%i < ClientGroup.getCount();%i++)
{
%subClient = ClientGroup.getObject(%i);

%location = %subClient.player.getTransform();

%x = getWord(%location, 0);
%y = getWord(%location, 1);
%z = getWord(%location, 2);


%x += getRandom(-10, 10);
%y += getRandom(-10, 10);
%z += 50;

%position = %x SPC %y SPC %z;

//messageAll('', %position);

%proj = new Projectile()
{
dataBlock = tankShellProjectile;
//dataBlock = gravityRocketProjectile;
initialPosition = %position;
initialVelocity = 0;
//sourceObject = 0;
minigame = %subClient.minigame;
//client = %subClient;
};

%proj.dump();

MissionCleanup.add(%proj);

}

When I set client = %subclient, it does damage, but obviously that wont work because if someone gets killed by a rocket meant for someone else, that other person will get credit for blowing someone up. That's not preferable. I don't want anyone to get the credit for these kills so I don't want to set a client. But if I don't set a client, it doesn't do damage.

you can rewrite the code for projectiles exploding

or iirc if you have a variable spawnBrick on the projectile set to a brick belonging to the public brickgroup (brickgroup_888888)
it will probably override it or something

also you can overwrite the minigameCanDamage checks since its a gamemode

or iirc if you have a variable spawnBrick on the projectile set to a brick belonging to the public brickgroup (brickgroup_888888)
it will probably override it or something

Well, using events I can spawn a projectile from a public brick, and that will kill me. But I didn't get any results doing spawnBrick = public brick ID unfortunately.

also you can overwrite the minigameCanDamage checks since its a gamemode

I changed the miniGameCanDamage function to this:
function miniGameCanDamage(%obj1, %obj2)
{
   return 1;
}

But it didn't seem to work either...

So I guess the next step would be to overwrite function ProjectileData::damage and function ProjectileData::radiusDamage? Or are you referring to a different function

Well I came up with a work around and I'm not sure if it's a terrible idea or not. I created a script object which is basically a fake client

Code: [Select]
if(!isObject(FakeClientSO))
{
new scriptObject(FakeClientSO)
{
brickgroup = 888888;
bl_id = 888888;
name = "North Korea";
};
}
Code: [Select]

%proj = new Projectile()
{
dataBlock = tankShellProjectile;
initialPosition = %position;
initialVelocity = 0;
client = FakeClientSO;
};

It works... but will I forget up public brick functionality or other bad things by doing this?

EDIT: One thing I've noticed, is that every time I'm killed by a missile I get this error.
base/server/scripts/game.cs (1003): Unknown command getPlayerName.
  Object FakeClientSO(21994) FakeClientSO -> FakeClientSO -> ScriptObject -> SimObject

You're not allowed to make any functions for objects called getPlayerName so there's no real way to get rid of this issue lmao
« Last Edit: January 19, 2017, 06:09:11 AM by Rally »

it would be best if you packaged onExplode. consult a decompiled copy of bl for how damage is normally done.

as for the minigameCanDamage package not working, it could be slayer thats messing with it working. disable it and try hurting yourself again with a clientless projectile after enabling the package

working with minigameCanDamage in my experience is an absolute loving pain in the ass because you have to restart your server for every change you make in your package if you want it to take effect

working with minigameCanDamage in my experience is an absolute loving pain in the ass because you have to restart your server for every change you make in your package if you want it to take effect
I'm not so sure why some functions are like this, even packaging messageClient, messageAllExcept and messageAll have a chance of not working until you restart the server (they sometimes even crash from my experience)

If a package isn't working for unknown reasons, try resetAllOpCallFunc(); in console - it'll re-link all the packages.
« Last Edit: January 25, 2017, 05:14:25 PM by Zeblote »

After all this time I have never seen that function. That's useful.