View Full Version : Damaged Message Troubles...
Sabre_Wulf
08-25-2004, 11:13 PM
I've read up a bit on the damaged message, but I'm still confused. How does it work? I read that SourceRef is the attacker, and SenderRef is the victim. I wanna make a protected mode so that you can damage a player, but you get killed, damaged back, or something like that.
damaged:
player = GetLocalPlayerThing();
AttackerDude = GetSourceRef();
if(AttackerDude == player) Return;
// insert commands here for consequences
[This message has been edited by Sabre_Wulf (edited August 25, 2004).]
Quib Mask
08-25-2004, 11:46 PM
For my example I'll use item_shields.cog because player damage is routed through there, but isn't controlled by a force power (if you want it to be, you add a damaged message to the force power then add the correct flag to the bin in items.dat so it gets the damaged messages).
flex damage=-1 local
thing player=-1 local
thing damager=-1 local
int damagerType=0 local
template projectile_exp=+sequencer_exp local // This will be used to send damage back to the thing that hurt you
message damaged
damaged:
damage = GetParam(0); // How much damage you took
player = GetSenderRef(); // This is you getting hurt
damager = GetSourceRef(); // This is what damaged you
damagerType = GetThingType(damager); // This is important, you only want to send damage back to a thing
if((damagerType == 3) || (damagerType == 6)) damager = GetThingParent(damager);
damagerType = GetThingType(damager); // Repeated in case we move to a weapon's parent
if((damagerType == 3) || (damagerType == 6)) damager = GetThingParent(damager);
damagerType = GetThingType(damager); // Repeated again for good measure
if((damagerType == 2) || (damagerType == 10)) TeleportThing(FireProjectile(player, projectile_exp, -1, -1, '0 0 0', '0 0 0', damage / 100, 0x2, 0.0, 0.0), damager);
// You teleport an explosion onto them, so you get credit for the damage done
// The 0x2 flag scales the damage of the explosion, damage / 100 because the base damage of the explosion is 100
ReturnEx(damage); // or ReturnEx(0); if you don't want to take any damage
Return;
Totally untested, but should work...
QM
[This message has been edited by Quib Mask (edited August 26, 2004).]
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.