Americas Army 2:Code Snippets
From UnKnoWnCheaTs Game Hacking Wiki
By: smaller
Contents
Info
There are a lot of nice pieces of code over at MPC forums which are very nice for people new to AA coding, but since links are not allowed, i thought it would be helpful if i post some here. this is the stuff i havent seen in the C++tutorials here
Source:
WALLHACK: (credits to tamimego)
define the bool (can be toggled with a menu)
bool bWallHack = true;
check if the target is valid
bool ValidTarget (APawn* Target) { return (Target != NULL) && (Target != pController->Pawn) && (!Target->bHidden) && (!Target->bDeleteMe) && (Target->Health > 0) && (Target->Level == pController->Pawn->Level); }
define
void WallHack (UCanvas* Canvas, APawn* Target) { if (bWallHack) { Canvas->DrawActor(Target, 0, 1, pController->FovAngle); Target->bHidden = 0; } }
call it in your postrender/render
void PostRender (class UCanvas * Canvas) { //....stuffs if ((Canvas != NULL) && (Canvas->Viewport != NULL) && (Canvas->Viewport->Actor != NULL) && (Canvas->Viewport->Actor->PlayerReplicationInfo != NULL) && (Canvas->Viewport->Actor->XLevel != NULL)) { pController = Canvas->Viewport->Actor; if (pController->Pawn != NULL) { for (TObjectIterator<APawn> Target; Target; ++Target) { APawn* pTarget= *Target; if (ValidTarget(pTarget)) { WallHack(Canvas,pTarget); } } } } //moar stuffs... }
WIREHACK:
in the above code, replace
Canvas->DrawActor(Target, 0, 1, pController->FovAngle);
with
Canvas->DrawActor(Target, 1, 1, pController->FovAngle);
SNIPER ZOOM: (credits to fragger)
bool inline IsGoodWeapon(void) { if(pController->Pawn == NULL || pController->Pawn->Weapon == NULL || pController->Pawn->Weapon->AmmoType == NULL || pController->Pawn->Weapon->AmmoType->MaxAmmo < 1) return 0; else return 1; }
in your postrender/render:
if(IsGoodWeapon()) { if (MyWeapon->_Scope != NULL) { ABaseScope* MyWeaponsScope = MyWeapon->_Scope; MyWeaponsScope->aZoomFOV(0) = 7.083; }; }
CROSSHAIR: (credits to google22)
void DrawCrossHair (UCanvas* Canvas) { UTexture* CrossHair = (UTexture*)UTexture::StaticLoadObject(UTexture::StaticClass(),NULL,TEXT("Engine.WhiteSquareTexture"),NULL,LOAD_NoFail,NULL); Canvas->DrawIcon((UMaterial*)CrossHair,Canvas->ClipX/2,Canvas->ClipY/2,2,2,1,FColor(154,205,0,255).Plane(),FPlane(1,1,1,1)); }
in your postrender/render
DrawCrossHair(Canvas);
AUTORELOAD & FIXJAM: (credits to temp2)
in your postrender:
//AutoFixJam if (MyPlayerController->Pawn->Weapon != NULL && MyPlayerController->Pawn->Weapon->bIsJammed == true ) { //Weapon.FixJam(); UFunction* pFunc = MyPlayerController->FindFunction(FName(TEXT("FixJam")),FNAME_Find); if ( pFunc != NULL ) { MyPlayerController->ProcessEvent(pFunc, NULL, NULL); } } //AutoReload if (MyPlayerController->Pawn->Weapon != NULL ) { INT bReload = false; AAGP_Weapon* MyWeapon = Cast<AAGP_Weapon>(MyPlayerController->Pawn->Weapon); if (MyWeapon->eROF == MyWeapon->AuxROF) { // In Aux mode if (MyWeapon->AuxAmmoType != NULL && MyWeapon->AuxAmmoType->AmmoAmount == 0) { for(INT i=0; i < 16; i++ ) { if (MyWeapon->_AuxAmmoClips[i] > 0) { bReload = true; } } } } else { // In Normal mode if (MyWeapon->AmmoType != NULL && MyWeapon->AmmoType->AmmoAmount == 0) { for(INT i=0; i < 16; i++ ) { if (MyWeapon->_AmmoClips[i] > 0) { bReload = true; } } } } if (bReload == true) { // Weapon.Reload(); UFunction* pFunc = MyPlayerController->FindFunction(FName(TEXT("Reload")),FNAME_Find); if ( pFunc != NULL ) { MyPlayerController->ProcessEvent(pFunc, NULL, NULL); } } }
NO FOG: (credits to humm3r)
void inline RemoveFog () { for (TObjectIterator<AZoneInfo> Target; Target; ++Target) { AZoneInfo* ZI = *Target; ZI->bClearToFogColor = false; ZI->bDistanceFog = false; } }
in postrender:
RemoveFog();
Source: Here