Asking because I want to make Spinosaurus semiaquatic (I can take the dated long-legged model, it is a 2006 game after all, but the palaeoenthusiast that I am just wants to make it a little bit more scientifically accurate there) but it lacks the swimming animations, so I set it to use the same ones it uses normally.
Below is the custom class I made for it:
Code: Select all
class CSpinosaurus inherit CAnimal
const real SWIM_DEPTH=5.5f;
var string m_sIdleAnim;
var string m_sHump;
var vec3 m_vHeight;
var vec3 m_vPosition;
export constructor()
if(CMirageSrvMgr.Get().NoHumpWalking())then
m_sHump="def";
else
m_sHump="hump";
endif;
endconstructor;
export proc void OnInit(bool p_bLoad)
super.OnInit(p_bLoad);
SetCanSwim(true);
SetIdleAnim();
if(!p_bLoad)then
ReBuildWeapon();
CheckWaterLand();
endif;
endproc;
export proc void OnPostLoad()
super.OnPostLoad();
CheckWaterLand();
endproc;
export proc void OnActionEnd(bool p_bBroken)
super.OnActionEnd(p_bBroken);
CheckWaterLand(); //fallback
endproc;
export proc void SetPos(vec3 p_vPos)
//somebody beams me around -> I must check my pos for land/water
super.SetPos(p_vPos);
CheckWaterLand();
endproc;
export proc void CheckWaterLand()
OnAmphibianWaterLandTransition(!IsInWater(),true);
endproc;
//this function will be called from inside the walk action
proc void OnAmphibianWaterLandTransition(bool p_bWaterToLand, bool p_bInto)
if(p_bWaterToLand)then
m_sIdleAnim="standanim";
m_xWalkSet="def";
m_xHumpWalkSet=m_sHump;
WaterToLand();
else
m_sIdleAnim="standanim";
m_xWalkSet="def";
m_xHumpWalkSet="m_sHump";
LandToWater();
endif;
SetDefaultWalkSet(m_xWalkSet);
endproc;
export proc void LandToWater()
m_vHeight.SetZ(Math.Max(CSrvWrap.GetScapeMgr().GetHeight(m_vHeight.GetX(),m_vHeight.GetY()),m_fWaterLevel)-SWIM_DEPTH);
endproc;
export proc void WaterToLand()
m_vHeight.SetZ(Math.Max(CSrvWrap.GetScapeMgr().GetHeight(m_vHeight.GetX(),m_vHeight.GetY()),m_fWaterLevel));
endproc;
export proc ref CFourCC GetWalkSet()
return m_xWalkSet;
endproc;
export proc string EatAnim()
if(IsInWater())then
return "attack_front";
else
return "feeding";
endif;
endproc;
export proc bool IsBugged()
if(IsInWater())then
return true;
endif;
return m_bBugged;
endproc;
export proc string GetVictoryAnim()
var string sAnim="menace";
var int iR=Random.GetInt()%3;
if(iR==1)then
sAnim="shake";
elseif(iR==2)then
sAnim="scratch";
endif;
return sAnim;
endproc;
endclass;
I'm trying to figure out what I did wrong or if I missed something. Any assistance would be appreciated.