If Pawn scores a kill & custom reticle.

Discussions about Coding and Scripting
Post Reply
User avatar
UTDeath
Skilled
Posts: 248
Joined: Sat Apr 20, 2013 11:35 pm
Personal rank: Tournament Champion.
Location: Mexico.

If Pawn scores a kill & custom reticle.

Post by UTDeath »

Hello everyone.
As some of you may know I'm working a weapon pack right now but I'm also modifying the pickups.
Right now I'm having trouble making a function for the UDamage now called Berserk Damage.
On the Timer function of the Activated state I'm want to make an If that for each kill the owner does while having the Berserk Damage, his Damage Scaling will go up, so I have this:
If (What I need help with)
Pawn(Owner).DamageScaling += 01;
On another topic, I made an extension of the Sniper Rifle but I can't change the reticle, I imported one that works and changed the code so it uses my reticle and not the original but it doesn't work, the original one is displayed over my custom one.
How can I fix this? Do I have to extend the tournament weapons instead of the Sniper Rifle? Also, how can I increase the zooming range further than 8.3?
You cannot kill what is already dead.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: If Pawn scores a kill & custom reticle.

Post by Feralidragon »

@Damage: Use a mutator to detect the kill (PreventDeath or ScoreKill function, perhaps the latter), and check if the instigator has that pickup to increase his damage scale.
You can add the mutator in run-time from the pickup itself. You can check my AddAuxMutator function in my NaliWeapons class in the NW3 mod, which only serves to add mutators dynamically to the game (since I needed to detect kills and other small things too because of some weapons, like the Freezer to be able to freeze the players properly, and the Cybot Launcher so their beacons would appear in your screen).

@Sniper reticle: Show your code, you probably have something wrong there.

@Sniper zoom: The standard sniper uses standard PlayerPawn functions to activate the zoom, then the PlayerPawn itself manages the FOV needed.
To go beyond that value, you would need to control the player FOV value directly (DesiredFOV) and set it to smaller values (but always above 0 otherwise odd things may happen).
Spectra
Masterful
Posts: 542
Joined: Tue Jan 22, 2013 5:23 pm
Personal rank: Nullified!
Location: (X) Unable To Locate....

Re: If Pawn scores a kill & custom reticle.

Post by Spectra »

I can only help you in Sniper Reticle and Sniper Zoom.

For Sniper Reticle:
Here is the simple Sniper Reticle Code:

Code: Select all

simulated function PostRender( canvas Canvas )
{
	local PlayerPawn P;
	local float Scale;

	Super.PostRender(Canvas);
	P = PlayerPawn(Owner);
	if ( (P != None) && (P.DesiredFOV != P.DefaultFOV) ) 
	{
		bOwnsCrossHair = true;
		Scale = Canvas.ClipX/640;
		Canvas.SetPos(0.5 * Canvas.ClipX - 128 * Scale, 0.5 * Canvas.ClipY - 128 * Scale );
		if ( Level.bHighDetailMode )
			Canvas.Style = ERenderStyle.STY_Translucent;
		else
			Canvas.Style = ERenderStyle.STY_Normal;
		Canvas.DrawIcon(Texture'RReticle', Scale);
		Canvas.SetPos(0.5 * Canvas.ClipX + 64 * Scale, 0.5 * Canvas.ClipY + 96 * Scale);
		Canvas.DrawColor.R = 0;
		Canvas.DrawColor.G = 255;
		Canvas.DrawColor.B = 0;
		Scale = P.DefaultFOV/P.DesiredFOV;
		Canvas.DrawText("X"$int(Scale)$"."$int(10 * Scale - 10 * int(Scale)));
	}
	else
		bOwnsCrossHair = false;
}
Now here after Importing your Custom Texture do the following changes shown below:

Canvas.DrawIcon(Texture'YourImportedTexture',Scale);
AND
if ( Level.bHighDetailMode )
Canvas.Style = ERenderStyle.STY_Translucent;
else
Canvas.Style = ERenderStyle.STY_Translucent;

Rest the other Codes will do your Work.
This will replace the Sniper Reticle with yours.

For Sniper Zoom:
As Ferali said, The Sniper Zoom depends upon the FOV(Field Of View) of the player (if you see on the Codes). Increasing your FOV will increase your Sniper Zoom Range like for eg: your FOV will be of 90 then your Sniper Zoom will show range of 8.3 and if your FOV is 100 (as I use it) your Sniper Zoom Range will increase to 9.2 and same way for higher FOV.
User avatar
UTDeath
Skilled
Posts: 248
Joined: Sat Apr 20, 2013 11:35 pm
Personal rank: Tournament Champion.
Location: Mexico.

Re: If Pawn scores a kill & custom reticle.

Post by UTDeath »

I got the reticle to work, turns out I have to copy the Sniper code into a new one and extend the TournamentWeapon, not the SniperRifle.
I have yet to work on the detection of the kills but now I know where to start.
Also, I got the zoom increase so thanks a lot guys :)
You cannot kill what is already dead.
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: If Pawn scores a kill & custom reticle.

Post by Feralidragon »

You don't have to extend from TournamentWeapon, you can change the reticle by extending the sniper. You probably had something wrong in your code, like a Super.PostRender(Canvas) instead of a Super(TournamentWeapon).PostRender(Canvas) for example.
User avatar
Rakiayn
Masterful
Posts: 550
Joined: Fri Aug 28, 2009 3:33 pm

Re: If Pawn scores a kill & custom reticle.

Post by Rakiayn »

so if you use 'Super(TournamentWeapon).PostRender(Canvas)' in a subclaass of the sniperrifle, postrender in tournamentweapon will be called instead of it being called in the sniperrifle. didnt know that thnx
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: If Pawn scores a kill & custom reticle.

Post by Feralidragon »

Yep, you can call any Super function of any parent class. Generally calling Super(something) is needed exactly to override the Super class version of the function while retaining the class "something" one.
User avatar
UTDeath
Skilled
Posts: 248
Joined: Sat Apr 20, 2013 11:35 pm
Personal rank: Tournament Champion.
Location: Mexico.

Re: If Pawn scores a kill & custom reticle.

Post by UTDeath »

Super :D
I have yet to try that.
You cannot kill what is already dead.
User avatar
UTDeath
Skilled
Posts: 248
Joined: Sat Apr 20, 2013 11:35 pm
Personal rank: Tournament Champion.
Location: Mexico.

Re: If Pawn scores a kill & custom reticle.

Post by UTDeath »

Calling SuperPostRender from TournamentWeapon did the thing :)
I only have to think exactly what I want the player to see, so many options.
You cannot kill what is already dead.
Post Reply