Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Find out which actor killed another actor
Find out which actor killed another actor
2007-08-23, 12:01 PM #1
In my level, there are police, there are peaceful, law abiding citizens, and then there is everyone else. If you shoot a civilian, the police will go into aggressive mode on you until you pay some sort of bribe/fine. But I also want to make it so that if an NPC shoots a civilian (stray fire, for instance), the police will go after that NPC and the NPC will either try to flee or fight back. How should I approach this problem?

I was thinking of checking the damaged message in the civilian's classcog and sending a trigger with one of the params being the thing number of the SourceRef of the damage, but I guess that's the projectile. I forget, is there some way to get the parent of the projectile in damaged? I suppose there must be, in order to know who killed who in MP.

And then for the police vs. criminal aspect, I know how to make all the police choose the criminal as their fireTarget, but how do I make the cops potentially aggressive to only the criminal, or only you, or both yuo and a criminal NPC? And how would I make the NPC be aggressive to you and the cops?

This is for JK.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2007-08-23, 12:20 PM #2
GetThingParent?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2007-08-23, 2:17 PM #3
For the cop-criminal bit, set or clear the appropriate AI Mode flags when setting the actor's fire target. The 0x2000 ai mode flag is probably your best bet. You'll most likely need to add some cog checks to make sure the actor's ai isn't active when he could attack the player (e.g. target goes out of range or is killed)

When acquiring a target, you might use:

Code:
AISetFireTarget(actor, target);
AIClearMode(actor, 0x2000); //enable AI


and when the target is eliminated or lost (perhaps a LOS and health check in a pulse...):

Code:
AISetMode(actor, 0x2000); //disable AI


Hopefully that's enough to get you started at least :)
May the mass times acceleration be with you.
2007-08-29, 8:56 AM #4
Make a cog that goes something like

message damaged

code

damaged:

attacker = getthingparent(getsourceref()); // either source or sender, don't remember which one

if (attacker != player)
{
SendTriggerEx(-1, attacker, player, beingattacked);
}

return;

end

Should look something like that, then you would have a trigger in the cop cogs that would set them hostile to the attacker. You would want to make sure that the cops check to make sure they aren't attacking other cops (in case of misfire or cog fail). you would do that by if (GetThingModel(attacker) == copmodel) return;
:) ;) :) ;) :) ;) :) ;) :) ;) :) ;) Im Happy

↑ Up to the top!