need script:Headshot=2Frags
need script:Headshot=2Frags
Hi, I need your help in UnrealScript:
I tried to create a mutator which, when you do a headshot, gives you 2 frags (not 1), and says a message (in the top left), like " %k just sniped for 2 frags". But I didn't find how to do this...so can you help me?
I tried to create a mutator which, when you do a headshot, gives you 2 frags (not 1), and says a message (in the top left), like " %k just sniped for 2 frags". But I didn't find how to do this...so can you help me?
- Feralidragon
- Godlike
- Posts: 5493
- Joined: Wed Feb 27, 2008 6:24 pm
- Personal rank: Work In Progress
- Location: Liandri
Re: need script:Headshot=2Frags
Well, in the mutator, use the function PreventDeath to detect a "death", and use the arguments of that function to identify the Killer, the Killed and the damageType.
The damageType will say if it's an headshot or not (damageType=='Decapitated'), then you just have to increment the score of the Killer (the KillCount and I think there's another you must increment or function to call, at least in Team games).
I did that a long time ago within my Venom, but I don't remember the exact code, but it should be very easy.
As for the message, you can use the BroadCastMessage function (I think this the one), however the original message will still appear as well (there might be a way to prevent this, but I don't dominate that coding area, so someone who did the code already might help you better).
The damageType will say if it's an headshot or not (damageType=='Decapitated'), then you just have to increment the score of the Killer (the KillCount and I think there's another you must increment or function to call, at least in Team games).
I did that a long time ago within my Venom, but I don't remember the exact code, but it should be very easy.
As for the message, you can use the BroadCastMessage function (I think this the one), however the original message will still appear as well (there might be a way to prevent this, but I don't dominate that coding area, so someone who did the code already might help you better).
Re: need script:Headshot=2Frags
I already tried with the preventdeath, and if damagetype='Decapitated', increase Killer.KillCount, but after i tested and it didn't work...but i will retry
- Feralidragon
- Godlike
- Posts: 5493
- Joined: Wed Feb 27, 2008 6:24 pm
- Personal rank: Work In Progress
- Location: Liandri
Re: need script:Headshot=2Frags
Just checked my code at the Venom, there's another value you must increment:
Killer.PlayerReplicationInfo.Score
So just make
Killer.PlayerReplicationInfo.Score += 1;
But don't remove the KillCount increment, let both of them stay.
Killer.PlayerReplicationInfo.Score
So just make
Killer.PlayerReplicationInfo.Score += 1;
But don't remove the KillCount increment, let both of them stay.
Re: need script:Headshot=2Frags
This is my script (it doesn't work):
Why it doesn't work?
Code: Select all
class HardSniper_MUT expands Mutator;
function bool PreventDeath(Pawn Killed, Pawn Killer, name damageType, vector HitLocation)
{
local bool bMessage;
local string HeadShot;
HeadShot="HeadShot!!";
if ( NextMutator != None )
return NextMutator.PreventDeath(Killed,Killer, damageType,HitLocation);
if ( damageType == 'Decapitated' )
{
Killer.KillCount += 1;
Killer.PlayerReplicationInfo.Score += 1;
bMessage = MutatorBroadcastMessage( None, None, HeadShot, true);
}
return false;
}
function bool MutatorBroadcastMessage( Actor Sender, Pawn Receiver, out coerce string Msg, optional bool bBeep, out optional name Type )
{
if ( NextMessageMutator != None )
return NextMessageMutator.MutatorBroadcastMessage( Sender, Receiver, Msg, bBeep, Type );
else
return true;
}
Why it doesn't work?
- Feralidragon
- Godlike
- Posts: 5493
- Joined: Wed Feb 27, 2008 6:24 pm
- Personal rank: Work In Progress
- Location: Liandri
Re: need script:Headshot=2Frags
This:
is in the wrong place.
Place it right before "return false", like this:
Basically, where it was, just took NextMutator != None to the function "return" and not run the rest of it, thus not running your code afterwards at all.
Code: Select all
if ( NextMutator != None )
return NextMutator.PreventDeath(Killed,Killer, damageType,HitLocation);
Place it right before "return false", like this:
Code: Select all
function bool PreventDeath(Pawn Killed, Pawn Killer, name damageType, vector HitLocation)
{
local bool bMessage;
local string HeadShot;
HeadShot="HeadShot!!";
if ( damageType == 'Decapitated' )
{
Killer.KillCount += 1;
Killer.PlayerReplicationInfo.Score += 1;
bMessage = MutatorBroadcastMessage( None, None, HeadShot, true);
}
if ( NextMutator != None )
return NextMutator.PreventDeath(Killed,Killer, damageType,HitLocation);
return false;
}
Re: need script:Headshot=2Frags
I totally forgot this, sorry
I rebuild all of this and test
EDIT: Now the game count 2 frags per headshot, but it doesn't print the BroadCast message...But for the code
I rebuild all of this and test
EDIT: Now the game count 2 frags per headshot, but it doesn't print the BroadCast message...But for the code
Re: need script:Headshot=2Frags
A little up!!
Anyone knows who must be the receiver and the sender when i call the broadcast message function?
Anyone knows who must be the receiver and the sender when i call the broadcast message function?
- The_Cowboy
- Skilled
- Posts: 165
- Joined: Mon Jan 24, 2011 3:22 am
- Personal rank: Codezilla
Re: need script:Headshot=2Frags
Code: Select all
function bool PreventDeath(Pawn Killed, Pawn Killer, name damageType, vector HitLocation)
{
if ( damageType == 'Decapitated' )
{
Killer.KillCount += 1;
Killer.PlayerReplicationInfo.Score += 1;
BroadcastMessage(Killer.PlayerReplicationInfo.PlayerName&" took off "Killed.PlayerReplicationInfo.PlayerName$"'s head");
}
if ( NextMutator != None )
return NextMutator.PreventDeath(Killed,Killer, damageType,HitLocation);
return false;
}
Patreon: https://www.patreon.com/FreeandOpenFeralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything
- The_Cowboy
- Skilled
- Posts: 165
- Joined: Mon Jan 24, 2011 3:22 am
- Personal rank: Codezilla
Re: need script:Headshot=2Frags
I am not sure but I think receivers are all the pawns( player classes ) and sender could be anyone, from mutator to gametype you are playing(CTFGame etc ).Basically it should be an Actor.DarKobalt wrote:A little up!!
Anyone knows who must be the receiver and the sender when i call the broadcast message function?
Patreon: https://www.patreon.com/FreeandOpenFeralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything
-
- Godlike
- Posts: 3774
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: need script:Headshot=2Frags
Cowboy is right. The easiest way is to use broadcast message. If you want to send a message to a specific person (like the killer) you'd use:
There are a couple of caveats though you need to be aware of. There is not a way to change the First Blood and Head Shot announcement through mutator. You have to access those two in gametype (thank you Epic for that). Being able to change the announcer for First Blood was surprisingly difficult and took me several evenings to get.
and then script your own specific message.Killer.ReceiveLocalizedMessage(class'MH2HeadShotMessage5');
There are a couple of caveats though you need to be aware of. There is not a way to change the First Blood and Head Shot announcement through mutator. You have to access those two in gametype (thank you Epic for that). Being able to change the announcer for First Blood was surprisingly difficult and took me several evenings to get.
So long, and thanks for all the fish
Re: need script:Headshot=2Frags
I did something simular, but I used killer.playerrplicationinfo.score += 1;
why is the killer.killcount += 1; needed?
@DarKobalt
you can alse use: killer.clientmessage(message);
why is the killer.killcount += 1; needed?
@DarKobalt
you can alse use: killer.clientmessage(message);
- The_Cowboy
- Skilled
- Posts: 165
- Joined: Mon Jan 24, 2011 3:22 am
- Personal rank: Codezilla
Re: need script:Headshot=2Frags
Rakiayn wrote: why is the killer.killcount += 1; needed?
Headshotgives one frag.1 frag is manually added to make it count 2 frags for each headshotDarKobalt wrote: need script:Headshot=2Frags
Patreon: https://www.patreon.com/FreeandOpenFeralidragon wrote:Trial and error is sometimes better than any tutorial, because we learn how it works for ourselfs, which kills any doubts about anything
Re: need script:Headshot=2Frags
killer.playerrplicationinfo.score += 1The_Cowboy wrote:Rakiayn wrote: why is the killer.killcount += 1; needed?Headshotgives one frag.1 frag is manually added to make it count 2 frags for each headshotDarKobalt wrote: need script:Headshot=2Frags
already does that