AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   change killer in trigger_multiple + func_mortar_field chain (https://forums.alliedmods.net/showthread.php?t=144519)

fysiks 12-05-2010 02:36

change killer in trigger_multiple + func_mortar_field chain
 
I have a map that has a trigger_multiple that gets touched by Allied (Day of Defeat) and that trigger_multiple's target is a func_mortar_field. However, the mortar field is in the Allied area so when an Allied soldier is killed by this mortar field the killer is another Allied which causes a team kill.

I need to prevent DOD TK Revenge from thinking it is a TK.

I still want it to ultimately be triggered by Allied soldiers but I need the killer to be anyone but an Allied soldier (to prevent a team kill).

I'm currently working with register_message() and DeathMsg and am able to change the killer. I think this may work to prevent DOD TK Revenge from seeing a TK, however, I still need to filter out the mortar as the weapon used to kill the player.

So, I was hoping that I would be able to somehow intervene with this chain of events much much sooner. I was thinking maybe I could hook the player/trigger_multiple touch, supercede it and then manually do it with another entity as the "killer" (so to speak). Or, maybe between the trigger_multiple and then func_mortar_field.

I'm not entirely sure which if either of these is possible. Let me know if you have any ideas.

And example of the entities involved:

Code:

{
"model" "*74"
"m_iDamage" "200"
"m_fControl" "0"
"m_iCount" "1"
"m_flSpread" "64"
"targetname" "field_4"
"classname" "func_mortar_field"
}
{
"model" "*75"
"teamonly" "0"
"wait" "5"
"delay" "0"
"sounds" "0"
"style" "32"
"target" "field_4"
"spawnflags" "512"
"classname" "trigger_multiple"
}


ConnorMcLeod 12-05-2010 07:18

Re: change killer in trigger_multiple + func_mortar_field chain
 
You may have to do something like set pev_inflictor to 0 or to entity index when player takes the damage.

fysiks 12-05-2010 15:29

Re: change killer in trigger_multiple + func_mortar_field chain
 
I will try something like that if I can't get this to work out:

Ok, so I finally figured out how the DeathMsg args work (in Day of Defeat). However, I was under the impression that if I register the message and change the arguments then the arguments when I register the same as an event will also be changed. However, it does not seem to work correctly.

PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin("dod_wolfie fix""0.1""Fysiks")
    
register_message(get_user_msgid("DeathMsg"), "msgDeathMsg")
    
register_event("DeathMsg""EventDeathMsg""a")
}

public 
msgDeathMsg(msg_idmsg_destmsg_entity)
{
    new 
killervictimweapon
    killer 
get_msg_arg_int(1)
    
victim get_msg_arg_int(2)
    
weapon get_msg_arg_int(3)
    if( 
weapon == 32 )
    {
        
set_msg_arg_int(1ARG_BYTE0)
    }
    
client_print(0print_chat"MsgDeathMsg >>>> Killer: %d <<>> Victim: %d <<>> Weapon: %d"killervictimweapon)
}

public 
EventDeathMsg()
{
    new 
killer2victim2weapon2
    killer2 
read_data(1)
    
victim2 read_data(2)
    
weapon2 read_data(3)
    
client_print(0print_chat"EvtDeathMsg >>>> Killer: %d <<>> Victim: %d <<>> Weapon: %d"killer2victim2weapon2)


killer2 is not 0 when weapon is 32 (killer = killer2). BUT, it will show on screen that there was no killer (which is what I want) but I need killer2 to be 0 so that when another plugin hooks DeathMsg event that they will see it as no killer (0).

ConnorMcLeod 12-06-2010 00:52

Re: change killer in trigger_multiple + func_mortar_field chain
 
I was thinking that the TK plugin was working as ATAC does, by inflictor, but you seems to say it works with event DeathMsg, and yes, register a message doesn't affect arguments passed in registered event, you have to come earlier, maybe in TraceAttack or TakeDamage, supercede and send your own should do the job.
OR you can edit the TK plugin for your needs, could be better.

fysiks 12-06-2010 18:24

Re: change killer in trigger_multiple + func_mortar_field chain
 
Quote:

Originally Posted by ConnorMcLeod (Post 1364291)
I was thinking that the TK plugin was working as ATAC does, by inflictor, but you seems to say it works with event DeathMsg [...] OR you can edit the TK plugin for your needs, could be better.

Yeah, the plugin uses DeathMsg. Would like to avoid modifying it as it would be much easier to convince the server owner to use just my plugin on the one map.

Quote:

Originally Posted by ConnorMcLeod (Post 1364291)
and yes, register a message doesn't affect arguments passed in registered event, you have to come earlier, maybe in TraceAttack or TakeDamage, supercede and send your own should do the job.

Ok, I got to thinking about it after I posted and came up with that conclusion. I will work with TakeDamage and/or TraceAttack and see what I can get working.

fysiks 12-12-2010 00:17

Re: change killer in trigger_multiple + func_mortar_field chain
 
Ok, so I think I've got the best thing yet for this (and it has been working throughout my testing):

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("dod_wolfie fix""0.1""Fysiks")
    
RegisterHam(Ham_Use"func_mortar_field""hamUsed_func_mortar_field"0)
    
register_cvar("who_use""0")
}

public 
hamUsed_func_mortar_field(thisidcalleridactivatoruse_typeFloat:value)
{
    
client_print(0print_chat"Ham_Use on func_mortar_field: %d %d %d %d %f"thisidcalleridactivatoruse_typevalue)
    
console_print(0"Ham_Use on func_mortar_field: %d %d %d %d %f"thisidcalleridactivatoruse_typevalue)
    
SetHamParamEntity(2get_cvar_num("who_use"))
    return 
HAM_HANDLED


The cvar is for testing purposes only. When I change it to worldspawn (0) it will show the people that got hit by the mortar as having died by worldspawn. When I change it to an Axis player it works as expected and the people hit by the mortar are killed with a mortar (weapon image) by that Axis player. All is as expected there.

I would really like to keep the mortar as the weapon image which seems to mean I need to find an Axis player every time to put in the place of the cvar. I would like to keep this plugin as computationally small as possible so I would like to avoid this. I would gratefully accept a solution that would mean there would be NO killer (blank) but still killed with the mortar.

Anyways . . ., I can't think of any pitfalls of this method yet but if you guys think of something let me know.

ConnorMcLeod 12-12-2010 00:31

Re: change killer in trigger_multiple + func_mortar_field chain
 
How does it work by default ?
What is caller, activator, why does it detect Team Attack, etc...
What is mortar ??? xD

fysiks 12-12-2010 02:55

Re: change killer in trigger_multiple + func_mortar_field chain
 
Quote:

Originally Posted by ConnorMcLeod (Post 1369062)
What is mortar ??? xD

http://en.wikipedia.org/wiki/Mortar_%28weapon%29


Quote:

Originally Posted by ConnorMcLeod (Post 1369062)
How does it work by default ?
What is caller, activator, why does it detect Team Attack, etc...

The sequence is as follows (basically):

Player touches trigger_multiple > trigger_multiple uses func_mortar_field > func_motar_field does it's work and sends out a motar bomb (in the area of the brush that defines the entity's physical space) > Bomb kills players near explosion :)

The caller is the player that originally started the sequence (the one that touched the trigger_multiple). The activator seems to be the actual trigger_multiple that used the func_mortar_field.


I will just use what I have and consider just replacing my cvar with a random enemy team member.

ConnorMcLeod 12-12-2010 07:20

Re: change killer in trigger_multiple + func_mortar_field chain
 
Have you tried to replace activator with caller ?

fysiks 12-12-2010 13:26

Re: change killer in trigger_multiple + func_mortar_field chain
 
Quote:

Originally Posted by ConnorMcLeod (Post 1369225)
Have you tried to replace activator with caller ?

The way I read what you said is this: SetHamParamEntity(3, idcaller), but that's definitely not what I want.

If you meant replace caller with activator (SetHamParamEntity(2, idactivator))then it works the same as using worldspawn (0).

I think I will either leave it as caller is worldspawn or get a random axis player to put as the caller.


All times are GMT -4. The time now is 07:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.