Author Topic: Is there a way to make randomized kill messages?  (Read 1899 times)

/title
Not much else to say about it.

Yes.
Not much else to say about it.


Gonna hazard a guess here:

I'm assuming that you can change a projectile's DamageType after it's created right? So you could package Projectile::onAdd to set a random DamageType to every projectile

Jk lol package Armor::Damage instead

Like such:
Code: [Select]
package RandomKillMessage
{
function Armor::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType)
{
%damageType = getRandom(3, 20);

Parent::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType);
}
};
ActivatePackage(RandomKillMessage);

Replace getRandom(3, 20); with whatever logic you're using to get random DamageTypes

Replace getRandom(3, 20); with whatever logic you're using to get random DamageTypes
help i dont know what this means or how to

Create a damage type with this command:

addDamageType(%name, %Self DeleteMsg, %killMsg, %vehicleDmgScale, %isDirectDamage);

Like so:
Code: [Select]
AddDamageType("RocketDirect",   '<bitmap:add-ons/Weapon_Rocket_Launcher/CI_rocket> %1',    '%2 <bitmap:add-ons/Weapon_Rocket_Launcher/CI_rocket> %1',1,1);
AddDamageType("RocketRadius",   '<bitmap:add-ons/Weapon_Rocket_Launcher/CI_rocketRadius> %1',    '%2 <bitmap:add-ons/Weapon_Rocket_Launcher/CI_rocketRadius> %1',1,0);

A typical Self Delete message might be:
'%1 commit Self Delete'

And a typical kill message might be:
'%2 killed %1'

So you could do something like this:

Code: [Select]
AddDamageType("RandKill1",   '%1 commit Self Delete',    '%2 murdered %1',1,1);
AddDamageType("RandKill2",   '%1 ended themselves',    '%2 pwnd %1',1,1);
AddDamageType("RandKill3",   '%1 opted out',    '%2 obliterated %1',1,1);

package RandomKillMessage
{
function Armor::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType)
{
%random = getRandom(1, 3);

switch(%random)
{
case 1:
%damageType = $DamageType::RandKill1;
case 2:
%damageType = $DamageType::RandKill2;
case 3:
%damageType = $DamageType::RandKill3;
}

Parent::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType);
}
};
ActivatePackage(RandomKillMessage);

I haven't actually tested this code so it might explode but that's the idea

Code: [Select]
AddDamageType("RandKill1",   '%1 commit Self Delete',    '%2 murdered %1',1,1);
AddDamageType("RandKill2",   '%1 ended themselves',    '%2 pwnd %1',1,1);
AddDamageType("RandKill3",   '%1 opted out',    '%2 obliterated %1',1,1);

package RandomKillMessage
{
function Armor::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType)
{
%random = getRandom(1, 3);

switch(%random)
{
case 1:
%damageType = $DamageType::RandKill1;
case 2:
%damageType = $DamageType::RandKill2;
case 3:
%damageType = $DamageType::RandKill3;
}

Parent::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType);
}
};
ActivatePackage(RandomKillMessage);

I haven't actually tested this code so it might explode but that's the idea
better way to do this would be like so:

Code: [Select]
AddDamageType("RandKill1",   '%1 commit Self Delete',    '%2 murdered %1',1,1);
AddDamageType("RandKill2",   '%1 ended themselves',    '%2 pwnd %1',1,1);
AddDamageType("RandKill3",   '%1 opted out',    '%2 obliterated %1',1,1);

package RandomKillMessage
{
function Armor::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType)
{
%random = getRandom(1, 3);
%damageType = $DamageType::RandKill[%random];

Parent::Damage(%data, %obj, %sourceObject, %position, %damage, %damageType);
}
};
ActivatePackage(RandomKillMessage);
to add more damage types you would just copy/paste the AddDamageType statements above and just increment the numbers at the end of their names. after that, you would then change the 3 in %random = getRandom(1, 3); to whatever the max damage type number is and that stuff should work

if you don't know how to put this into an add-on, you create a new folder in your add-ons directory with a server.cs and description.txt file inside (the description.txt file is required for the add-on to be shown in the add-on selection menu, but you can leave it empty if you want) and place the code you've made into the server.cs

I do not recommend using Armor::Damage if you plan to.

I do not recommend using Armor::Damage if you plan to.

Why not?
Would GameConnection::onDeath be a better alternative?

Would GameConnection::onDeath be a better alternative?
Yes. Currently you're doing that every time someone is being damaged, seems unnecessary to me.

Why not?
Would GameConnection::onDeath be a better alternative?
yeah
mocha posted the function code a few days ago in his/her topic you might want to check it out

I don't think Table has any actual idea what's going on

I don't think Table has any actual idea what's going on

...Do you?

This is a scripting help thread. You seem to have no actual idea what's going on.

I don't think Table has any actual idea what's going on
i dont think thats particularly relevant in any way. he's asking a question, and we answered it. i dont know if he expects to learn anything from the subsequent discussion but its not that particularly difficult to pick up