PDA

View Full Version : [C++ Snippets] Sniper Scope and Covering up



No1uKnow
19th April 2006, 01:34
Well first things first, credits to temp2 for the HUD hide that he posted for lscript, and to whoever showed us how to use staticloadobject to load stuff from the engine.

and fragger for letting me learn from his source

this is the way I did it for norecoil v2 pub that I released for 2.5 minus the HUD hide.

1. Globals and ect



APlayerController* PC;

bool bSniperScope = 1;
bool bHideZoomHud = 1;

static class UTexture* Sniper = NULL;

#define LoadTexture(Texture,Name) \ // using staticloadobject to grab the texture from the engine.
if ( Texture == 0 ) \
{ \
Texture = (UTexture*)UTexture::StaticLoadObject( UTexture::StaticClass(), 0, TEXT(Name), 0, LOAD_NoWarn, 0 ); \
if ( Texture != 0 ) Texture->SetFlags(RF_Keep); \
} \




2. Using LoadTexture

go to your dllmain, and right under where you attach your hack you can call it

e.x


IATHOOK(BLAHBLAH);
LoadTexture (Sniper, "T2-FX.Overlay.m82a1_overlay_sight");


3. The Main code




void AssignScope()
{
MyWeapon = Cast<AAGP_Weapon>(PC->Pawn->Weapon);
if (MyWeapon->_Scope != NULL)
{
ABaseScope* MyWeaponsScope = MyWeapon->_Scope;
MyWeaponsScope->tZoomOverlay = Sniper;
MyWeaponsScope->aZoomFOV(0) = 5.01;
}
}


void TweakEm()
{
if ( bSniperScope )
{
AssignScope();
}
if ( bHideZoomHud )
{
if ( PC->DesiredFOV == PC->DefaultFOV )
{
PC->bHUDHideAmmoCount = false;
PC->bHUDHideWeaponStatus = false;
PC->bHUDHideWeapon = false;
PC->bHUDHideGrenades = false;
PC->bHUDHideMedical = false;
PC->bHUDHideHealth = false;
PC->bHUDHideCombatEffect = false;
PC->bHUDHideOptics = false;
PC->bHUDHideCompass = false;
PC->bHUDHideTimer = false;
PC->bHUDHideObjectives = false;
PC->bHUDHideRadar = false;
}
else
{
PC->bHUDHideAmmoCount = true;
PC->bHUDHideWeaponStatus = true;
PC->bHUDHideWeapon = true;
PC->bHUDHideGrenades = true;
PC->bHUDHideMedical = true;
PC->bHUDHideHealth = true;
PC->bHUDHideCombatEffect = true;
PC->bHUDHideOptics = true;
PC->bHUDHideCompass = true;
PC->bHUDHideTimer = true;
PC->bHUDHideObjectives = true;
PC->bHUDHideRadar = true;
}
}
}


Now call TweakEm(); in your render if your Pawn and Weapon is valid

got any problems? post em, BTW, wtf I cant get the braquets straight in the [.code] blocks >.<

SaTaNa
19th April 2006, 09:12
good job No1 :P

itwasfunny
19th April 2006, 12:32
ya, nice job no1, this is always useful :)

KizZamP-
19th April 2006, 14:58
i like the hud thing,nice job!

gil
19th April 2006, 17:44
Added to the list, thanks :)

PacketStorm
20th April 2006, 02:38
Good job dude, handy for using scopes with with pbss clearing ;)