Skip to content

Commit

Permalink
crouch CJ when mario crouches
Browse files Browse the repository at this point in the history
synchronizes Mario's crouch state with CJ.
allows you to get past the guard in the bar, in the mission Madd Dogg's Rhymes
  • Loading branch information
headshot2017 committed Feb 2, 2024
1 parent 57e16db commit d310d40
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
43 changes: 43 additions & 0 deletions CTaskSimpleDuck2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Plugin-SDK (Grand Theft Auto San Andreas) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"
#include "CTaskSimple.h"
#include "CAnimBlendAssociation.h"
#include "CVector2D.h"

class PLUGIN_API CTaskSimpleDuck2 : public CTaskSimple {
protected:
CTaskSimpleDuck2(plugin::dummy_func_t a) : CTaskSimple(a) {}
public:
unsigned int m_nStartTime;
unsigned short m_nLengthOfDuck;
short m_nShotWhizzingCounter;
CAnimBlendAssociation *m_pDuckAnim;
CAnimBlendAssociation *m_pMoveAnim;

bool m_bIsFinished;
bool m_bIsAborting;
bool m_bNeedToSetDuckFlag; // incase bIsDucking flag gets cleared elsewhere, so we know to stop duck task
bool m_bIsInControl; // if duck task is being controlled by another task then it requires continuous control

CVector2D m_vecMoveCommand;
unsigned char m_nDuckControlType;

unsigned char m_nCountDownFrames;

CTaskSimpleDuck2(eDuckControlTypes DuckControlType, unsigned short nLengthOfDuck, short nUseShotsWhizzingEvents = -1);

public:
static bool CanPedDuck(CPed* ped)
{
return plugin::CallAndReturn<bool, 0x692610, CPed*>(ped);
}
};

VALIDATE_SIZE(CTaskSimpleDuck2, 0x28);
11 changes: 11 additions & 0 deletions mario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "CTaskSimpleIKLookAt.h"
#include "CTaskSimpleIKManager.h"
#include "CTaskSimpleUseGun.h"
#include "CTaskSimpleDuck2.h"
#include "CTaskComplexLeaveCar.h"
#include "CEntryExitManager.h"
#include "CCutsceneMgr.h"
Expand Down Expand Up @@ -813,6 +814,16 @@ void marioTick(float dt)
marioInput.camLookZ = TheCamera.m_fCamFrontYNorm * (pad->GetLookBehindForPed() ? -1 : 1);

if (marioState.action == ACT_DRIVING_VEHICLE) sm64_set_mario_action(marioId, ACT_FREEFALL);

// control CJ crouch
if (marioState.action == ACT_CROUCHING || marioState.action == ACT_START_CROUCHING ||
marioState.action == ACT_CRAWLING || marioState.action == ACT_START_CRAWLING || marioState.action == ACT_STOP_CRAWLING)
{
if (CTaskSimpleDuck2::CanPedDuck(ped) && !ped->m_pIntelligence->m_TaskMgr.GetTaskSecondary(TASK_SECONDARY_DUCK))
ped->m_pIntelligence->SetTaskDuckSecondary(0);
}
else if (ped->m_pIntelligence->m_TaskMgr.GetTaskSecondary(TASK_SECONDARY_DUCK))
ped->m_pIntelligence->ClearTaskDuckSecondary();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion mario_ped_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void marioPedTasksMaxFPS(CPlayerPed* ped, const int& marioId)
if (task->m_pWeaponInfo->m_nFlags.bAimWithArm)
{
// used with normal pistol, sawed-off shotgun and uzi/tec9
bool reloading = !task->m_ArmIKInUse && !task->m_bSkipAim && !task->m_LookIKInUse;
bool reloading = (activeWeapon.m_nState == WEAPONSTATE_RELOADING);
if (!reloading && gunAnimOverrideTable.count(marioState.animInfo.animOverride.current))
{
sm64_set_mario_anim_override(marioId, gunAnimOverrideTable[marioState.animInfo.animOverride.current]);
Expand Down
1 change: 1 addition & 0 deletions sm64-san-andreas.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<Unit filename="CTaskComplexGoPickUpEntity.h" />
<Unit filename="CTaskComplexSequence2.h" />
<Unit filename="CTaskComplexUseSequence.h" />
<Unit filename="CTaskSimpleDuck2.h" />
<Unit filename="CTaskSimpleHoldEntity2.h" />
<Unit filename="TinySHA1.hpp" />
<Unit filename="audio.cpp" />
Expand Down

0 comments on commit d310d40

Please sign in to comment.