/*---------------------------------------------------------------------------*/ /* Cond.cpp : Definition of general Condition.*/ /* auteur : Olivier Didelot.*/ /* date : 07/10/1996*/ /* 970131 : O.C. conditions and keywords tables + beginning of Lint verifications*/ /* modify : Olivier Couvreur*/ /* date : 03/02/1997 Lint 2 warnings excepted those specified at the end of AIMacros.h*/ /* Testing float's for equality (lines 112 and 115) we're waiting for MTH update*/ /* modify : Olivier Couvreur*/ /* date : 18/02/1997 CPA_EXPORT + new functions for editor*/ /* modify : Olivier Couvreur*/ /* date : 21/02/1997 Add <= , >= conditions and some keywords for editor + rewrite of sz????NameFromId functions*/ /* modify : 11/03/1997 CollideWithWall and CollideWithGround Conditions*/ /* modify : 03/04/1997 new button conditions*/ /* modify : Olivier Couvreur*/ /* date : 27/06/1997 Conditions use function pointers*/ /*---------------------------------------------------------------------------*/ #include "AIUseCPA.h" #include "specif/AIOption.h" #include "AIMacros.h" #include "AI_Erm.h" #include "AI_Struc.h" #include "StrIntel.h" #include "Intell.h" #include "DsgMem.h" /* for fn_bFindPersoInList*/ #include "specif/AITools.h" #include "EnumCond.h" #include "Operator.h" #include "EnumOper.h" #include "Convert.h" #include "safe.h" #define _WP_D_WAYPOINT_FRIEND_ #include "WPWayPt.h" #include "TMR.h" #include "GAM\specif\DS_TouchPanel.h" //chbani TouchPanel for DS MTH3D_tdstVector gv_LatestStyletTP, gv_CurrentStyletTP; /* *================================================================================================= *================================================================================================= */ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ ACP_tdxBool fn_bIsInComport(HIE_tdxHandleToSuperObject p_stAimedPerso, long lNumComport) { tdstIntelligence *p_stAimedPersoIntel = AI_M_p_stGetIntelligence(AI_M_stGetMindOfSuperObj(p_stAimedPerso)); return (M_GetCurrentComport(p_stAimedPersoIntel) == M_GetComportN(p_stAimedPersoIntel, lNumComport)); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* *================================================================================================= *================================================================================================= */ ACP_tdxBool fn_bTestTypeOfGameMaterial(GMT_tdxHandleToGameMaterial hGameMat, GMT_tdxMask xTestMask) { GMT_tdxHandleToCollideMaterial hCollMat; GMT_tdxMask xCollMask; if (!GMT_fn_b_ulIsValid(hGameMat)) return FALSE; hCollMat = GMT_fn_hGetCollideMaterial(hGameMat); if (hCollMat == (GMT_tdxHandleToCollideMaterial)GMT_C_InvalidCollideMaterial) return FALSE; xCollMask = GMT_fn_hGetCollideMaterialIdentifier(hCollMat); return ((xCollMask & xTestMask) == xTestMask); } /* *================================================================================================= *================================================================================================= */ ACP_tdxBool fn_bIsTypeOfGMT(HIE_tdxHandleToSuperObject p_SuperObjPerso, GMT_tdxMask xTestMask) { DNM_tdstReport *p_stDynamReport; if ((p_stDynamReport = fn_pstGetDNMReport(p_SuperObjPerso)) == NULL) return FALSE; return fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetCollidedMaterial(DNM_M_p_stReportGetGround(p_stDynamReport)), xTestMask); } /* *================================================================================================= *================================================================================================= */ #if !defined(OPTIMIZED_COMMAND) #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) tdstNodeInterpret *fn_p_stDefaultCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { p_SuperObjPerso=p_SuperObjPerso; *p_lValue=(long) FALSE; #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return(p_stTree); } #endif /* _DEBUG_AI__*/ #endif /* OPTIMIZED_COMMAND*/ /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stComparisonCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam1, stParam2; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); long lIsFloat; MTH_tdxReal xParam1,xParam2; M_EvalNextTwoParameter(); /* look if both parameters are of the same type*/ lIsFloat = (long)M_GetSetParam_Type(&stParam1); if (lIsFloat == (long)M_GetSetParam_Type(&stParam2)) { if (lIsFloat == E_vt_Float) { /* both are float*/ xParam1 = M_GetSetParam_xValue(&stParam1); xParam2 = M_GetSetParam_xValue(&stParam2); } else if (lIsFloat == E_vt_Vector) { switch (eCondId) { case eCond_Equal : *p_lValue = MTH3D_M_bEqualVector(&M_GetSetParam_stVectorValue(&stParam1) , &M_GetSetParam_stVectorValue(&stParam2)); break; case eCond_Different : *p_lValue = !MTH3D_M_bEqualVector(&M_GetSetParam_stVectorValue(&stParam1) , &M_GetSetParam_stVectorValue(&stParam2)); break; default: #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; break; } return(p_stTree); } else { /* both are long...*/ switch (eCondId) { case eCond_Equal : *p_lValue = (M_GetSetParam_lValue(&stParam1) == M_GetSetParam_lValue(&stParam2)); break; case eCond_Different : *p_lValue = (M_GetSetParam_lValue(&stParam1) != M_GetSetParam_lValue(&stParam2)); break; case eCond_Lesser : *p_lValue = (M_GetSetParam_lValue(&stParam1) < M_GetSetParam_lValue(&stParam2)); break; case eCond_Greater : *p_lValue = (M_GetSetParam_lValue(&stParam1) > M_GetSetParam_lValue(&stParam2)); break; case eCond_LesserOrEqual : *p_lValue = (M_GetSetParam_lValue(&stParam1) <= M_GetSetParam_lValue(&stParam2)); break; case eCond_GreaterOrEqual: *p_lValue = (M_GetSetParam_lValue(&stParam1) >= M_GetSetParam_lValue(&stParam2)); break; default: #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; break; } return(p_stTree); } } else { /* types are different --> translate into float*/ if (lIsFloat == E_vt_Float) { xParam1 = M_ReturnParam_xValue(&stParam1); xParam2 = MTH_M_xLongToReal(M_GetSetParam_lValue(&stParam2)); } else { xParam1 = MTH_M_xLongToReal(M_GetSetParam_lValue(&stParam1)); xParam2 = M_ReturnParam_xValue(&stParam2); } } switch (eCondId) { case eCond_Equal : *p_lValue = MTH_M_bEqual(xParam1, xParam2); break; case eCond_Different : *p_lValue = MTH_M_bDifferent(xParam1, xParam2); break; case eCond_Lesser : *p_lValue = MTH_M_bLess(xParam1, xParam2); break; case eCond_Greater : *p_lValue = MTH_M_bGreater(xParam1, xParam2); break; case eCond_LesserOrEqual : *p_lValue = MTH_M_bLessEqual(xParam1, xParam2); break; case eCond_GreaterOrEqual: *p_lValue = MTH_M_bGreaterEqual(xParam1, xParam2); break; default: #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; break; } return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stBooleanCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stValue; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /* first parameter*/ M_EvalNextParameter(&stValue); *p_lValue=M_GetSetParam_lValue(&stValue); switch (eCondId) { case eCond_Et : if (*p_lValue==FALSE) { #if defined(OPTIMIZE_SWAP_PARAMETER) if(M_NodeToSkip(p_stTree)) { p_stTree+=M_NodeToSkip(p_stTree); } else { tdstNodeInterpret *p_stTreeInit=p_stTree; p_stTree = fn_p_stSwapNextParameter(p_stTree); M_NodeToSkip(p_stTreeInit)=(unsigned short) (p_stTree-p_stTreeInit); } #else p_stTree = fn_p_stSwapNextParameter(p_stTree); #endif } else { /* second parameters*/ M_EvalNextParameter(&stValue); *p_lValue= M_GetSetParam_lValue(&stValue); } return(p_stTree); break; case eCond_Ou : if (*p_lValue!=FALSE) { /*CBOPT*/ #if defined(OPTIMIZE_SWAP_PARAMETER) if(M_NodeToSkip(p_stTree)) { p_stTree+=M_NodeToSkip(p_stTree); } else { tdstNodeInterpret *p_stTreeInit=p_stTree; p_stTree = fn_p_stSwapNextParameter(p_stTree); M_NodeToSkip(p_stTreeInit)=(unsigned short) (p_stTree-p_stTreeInit); } #else p_stTree = fn_p_stSwapNextParameter(p_stTree); #endif } else { /* second parameters*/ M_EvalNextParameter(&stValue); *p_lValue= M_GetSetParam_lValue(&stValue); } return(p_stTree); break; case eCond_Not : *p_lValue = (long) ((*p_lValue==FALSE) ? TRUE : FALSE); return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_XOr: { long l1 = *p_lValue; M_EvalNextParameter(&stValue); *p_lValue = (l1 ^ *p_lValue) ? TRUE : FALSE; return(p_stTree); } break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stButtonCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stValue; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); IPT_tdxHandleToEntryElement IPT_xHandle; /* get button handle*/ M_EvalNextParameter(&stValue); IPT_xHandle=(IPT_tdxHandleToEntryElement) M_GetSetParam_lValue(&stValue); switch (eCondId) { /* pressed*/ case eCond_PressedBut: *p_lValue = (long) (IPT_fn_bIsValidated(IPT_xHandle)); return(p_stTree); break; /* just pressed*/ case eCond_JustPressedBut: *p_lValue = (long) (IPT_fn_bIsJustValidated(IPT_xHandle)); return(p_stTree); break; /* released*/ case eCond_ReleasedBut: *p_lValue = (long) (IPT_fn_bIsInvalidated(IPT_xHandle)); return(p_stTree); break; /* just released*/ case eCond_JustReleasedBut: *p_lValue = (long) (IPT_fn_bIsJustInvalidated(IPT_xHandle)); return(p_stTree); break; default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stZDDCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; HIE_tdxHandleToSuperObject hCharacter1=NULL; HIE_tdxHandleToSuperObject hCharacter2=NULL; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /* get common parameters*/ M_EvalNextParameter(&stParam); hCharacter1=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); switch (eCondId) { case eCond_CollidePersoZDDNoWithPerso: /* test if there is collision between a ZDD character of a perso and another perso*/ #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_CollideModuleZDDNoWithPerso: /* test if there is collision between a ZDD module of a perso and another perso*/ #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ { unsigned char ucModuleOrCharacter=(eCondId==eCond_CollidePersoZDDNoWithPerso)?AI_ZDX_CHARACTER:AI_ZDX_MODULE; unsigned char ucChannelNumber=(unsigned char) M_GetSetParam_lModuleValue(&stParam); M_EvalNextParameter(&stParam); hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); /*if (eCondId==eCond_CollidePersoZDDNoWithPerso) { ucModuleOrCharacter=AI_ZDX_CHARACTER; }*/ /* else if (eCondId==eCond_CollideModuleZDDNoWithPerso) { ucModuleOrCharacter=AI_ZDX_MODULE; } */ if (hCharacter1) *p_lValue=(long) fn_bIsCharacterTWODetectedByThisZddOfCharacterOne(hCharacter1,ucModuleOrCharacter,ucChannelNumber,hCharacter2); else *p_lValue=(long) FALSE; }; return(p_stTree); break; case eCond_CollidePersoAllZDDWithPerso: /* test if there is collision between at least one ZDD of a perso and another perso*/ { hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); if( hCharacter1 && hCharacter2) *p_lValue=(long) fn_bIsCharacterTWODetectedByCharacterOne(hCharacter1,hCharacter2); else *p_lValue=(long) FALSE; } return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ /* test if there is collision between a ZDD character of a perso and any other perso*/ case eCond_CollidePersoZDDWithAnyPerso: /* test if there is collision betwwen a ZDD module of a perso and any other perso*/ case eCond_CollideModuleZDDWithAnyPerso: { unsigned char ucChannelNumber=0; unsigned char ucModuleOrCharacter=(eCondId==eCond_CollidePersoZDDWithAnyPerso)?AI_ZDX_CHARACTER:AI_ZDX_MODULE; ucChannelNumber=(unsigned char) M_GetSetParam_lModuleValue(&stParam); if (hCharacter1) *p_lValue=(long) fn_ucAtLeastOnePersoInZdd(hCharacter1, ucModuleOrCharacter, ucChannelNumber); else *p_lValue=(long) FALSE; } return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stZDECondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; HIE_tdxHandleToSuperObject hCharacter1=NULL; HIE_tdxHandleToSuperObject hCharacter2=NULL; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); switch (eCondId) { case eCond_CollidePersoZDENoWithPersoZDENo: /* test if there is collision between a ZDE character of a perso and a ZDE character of another perso*/ #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_CollideModuleZDENoWithPersoZDENo: /* test if there is collision between a ZDD module of a perso and a ZDE character of another perso*/ case eCond_CollidePersoZDENoWithModuleZDENo: /* test if there is collision between a ZDD character of a perso and a ZDE module of another perso*/ case eCond_CollideModuleZDENoWithModuleZDENo: /* test if there is collision between a ZDD module of a perso and a ZDE module of another perso*/ #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ { unsigned char ucChannelNumber1=0,ucChannelNumber2=0; unsigned char ucModuleOrCharacter1=0,ucModuleOrCharacter2=0; M_EvalNextParameter(&stParam); hCharacter1= M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); ucChannelNumber1=(unsigned char) M_GetSetParam_lModuleValue(&stParam); M_EvalNextParameter(&stParam); hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); ucChannelNumber2=(unsigned char) M_GetSetParam_lModuleValue(&stParam); if (eCondId==eCond_CollidePersoZDENoWithPersoZDENo) { ucModuleOrCharacter1=AI_ZDX_CHARACTER; ucModuleOrCharacter2=AI_ZDX_CHARACTER; } #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ else if (eCondId==eCond_CollideModuleZDENoWithPersoZDENo) { ucModuleOrCharacter1=AI_ZDX_MODULE; ucModuleOrCharacter2=AI_ZDX_CHARACTER; } else if (eCondId==eCond_CollidePersoZDENoWithModuleZDENo) { ucModuleOrCharacter1=AI_ZDX_CHARACTER; ucModuleOrCharacter2=AI_ZDX_MODULE; } else if (eCondId==eCond_CollideModuleZDENoWithModuleZDENo) { ucModuleOrCharacter1=AI_ZDX_MODULE; ucModuleOrCharacter2=AI_ZDX_MODULE; } #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ if (hCharacter1 && hCharacter2) *p_lValue=(long) fn_bThisZdeFromOneVsThisZdeFromTwo(hCharacter1,ucModuleOrCharacter1,ucChannelNumber1,hCharacter2,ucModuleOrCharacter2,ucChannelNumber2); else *p_lValue=(long) FALSE; } return(p_stTree); break; case eCond_CollidePersoZDENoWithPersoTypeZDE: /* test if there is collision between a peculiar ZDE character of a perso and a ZDE (of certain type) of another perso*/ #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_CollideModuleZDENoWithPersoTypeZDE: /* test if there is collision between a peculiar ZDE module of a perso and a ZDE (of certain type) of another perso*/ #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ { unsigned char ucChannelNumber; unsigned char ucModuleOrCharacter=0; GMT_tdxMask xMask; M_EvalNextParameter(&stParam); hCharacter1= M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); ucChannelNumber=(unsigned char) M_GetSetParam_lModuleValue(&stParam); M_EvalNextParameter(&stParam); hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); xMask=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); if (eCondId==eCond_CollidePersoZDENoWithPersoTypeZDE) { ucModuleOrCharacter=AI_ZDX_CHARACTER; } #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ else if (eCondId==eCond_CollideModuleZDENoWithPersoTypeZDE) { ucModuleOrCharacter=AI_ZDX_MODULE; } #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ if (hCharacter1 && hCharacter2) *p_lValue=(long) fn_bThisZdeFromOneVsAllZdeFromTwo(hCharacter1,ucModuleOrCharacter,ucChannelNumber,hCharacter2,xMask); else *p_lValue=(long) FALSE; } return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_CollidePersoTypeZDEWithPersoTypeZDE: /* test if there is collision between a ZDE (of a certain type) of a perso and a ZDE (of a certain type) of another perso*/ case eCond_CollidePersoTypeZDEWithPersoAllZDE: /* test if there is collision between a ZDE (of a certain type) of a perso and at least one ZDE of another perso*/ #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ case eCond_CollidePersoAllZDEWithPersoAllZDE: /* test if there is collision between at least one ZDE of a perso and a ZDE of another perso*/ case eCond_CollidePersoAllZDEWithPersoTypeZDE: /* test if there is collision between at least one ZDE of a perso and a ZDE (of a certain type) of another perso*/ { GMT_tdxMask xMask1; GMT_tdxMask xMask2; GMT_fn_vResetEntireMask(&xMask1); GMT_fn_vResetEntireMask(&xMask2); M_EvalNextParameter(&stParam); hCharacter1=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); if (eCondId==eCond_CollidePersoAllZDEWithPersoAllZDE) { hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); } else if (eCondId==eCond_CollidePersoAllZDEWithPersoTypeZDE) { hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); xMask2=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); } #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ else if (eCondId==eCond_CollidePersoTypeZDEWithPersoAllZDE) { xMask1=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); M_EvalNextParameter(&stParam); hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); } else if (eCondId==eCond_CollidePersoTypeZDEWithPersoTypeZDE) { xMask1=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); M_EvalNextParameter(&stParam); hCharacter2=M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); xMask2=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); } #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ if (hCharacter1 && hCharacter2) *p_lValue=(long) fn_bThisTypeFromOneVsThisTypeFromTwo(hCharacter1,xMask1,hCharacter2,xMask2); else *p_lValue=(long) FALSE; } return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ /* test if there is collision between a ZDE character of a perso and a type of ZDE (of any other perso)*/ case eCond_CollidePersoZDENoWithTypeZDE: /* test if there is collision betwwen a ZDE module of a perso and a type of ZDE (of any other perso)*/ case eCond_CollideModuleZDENoWithTypeZDE: { unsigned char ucModuleOrCharacter=(eCondId==eCond_CollidePersoZDENoWithTypeZDE)?AI_ZDX_CHARACTER:AI_ZDX_MODULE; unsigned char ucChannelNumber=0; GMT_tdxMask xMask; M_EvalNextParameter(&stParam); hCharacter1= M_GetSetParam_p_stSupObjValue(&stParam); M_EvalNextParameter(&stParam); ucChannelNumber=(unsigned char) M_GetSetParam_lModuleValue(&stParam); M_EvalNextParameter(&stParam); xMask=(GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); if (hCharacter1) *p_lValue=(long) fn_ucAtLeastOnePersoInZde(hCharacter1, ucModuleOrCharacter, ucChannelNumber, xMask); else *p_lValue=(long) FALSE; } return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stReportOnSurfaceCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { DNM_tdstReport *p_stDynamReport; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ if ((p_stDynamReport=fn_pstGetDNMReport(hNewSuperObjPerso))==NULL) { *p_lValue = (long)FALSE; return p_stTree; } else { unsigned long ulSurfState = DNM_M_ulReportGetSurfaceState(p_stDynamReport); switch (eCondId) { case eCond_CollideWithGround: *p_lValue = (long)((ulSurfState & C_WOT_ulGround) == C_WOT_ulGround); return p_stTree; break; case eCond_CollideWithWall: *p_lValue = (long)((ulSurfState & C_WOT_ulWall) == C_WOT_ulWall); return p_stTree; break; case eCond_CollideWithNothing: *p_lValue = (long)(ulSurfState == C_WOT_ulNoObstacle); return p_stTree; break; /*case eCond_CollideWithSlope: *p_lValue = (long)((ulSurfState & C_WOT_ulSlope) == C_WOT_ulSlope); return p_stTree; break;*/ /*case eCond_CollideWithAttic: *p_lValue = (long)((ulSurfState & C_WOT_ulAttic) == C_WOT_ulAttic); return p_stTree; break;*/ case eCond_CollideWithCeiling: *p_lValue = (long)((ulSurfState & C_WOT_ulCeiling) == C_WOT_ulCeiling); return p_stTree; break; case eCond_CollideWithPerso: *p_lValue = (long)((ulSurfState & C_WOT_ulMobile) == C_WOT_ulMobile); return p_stTree; break; /*case eCond_CollideWithTrap: *p_lValue = (long)(ulSurfState == C_WOT_ulTrap); return p_stTree; break;*/ case eCond_CollideWithWater: *p_lValue = (long)((ulSurfState & C_WOT_ulWater) == C_WOT_ulWater); return p_stTree; break; default: break; } } *p_lValue = (long)FALSE; #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return p_stTree; } tdstNodeInterpret *fn_p_stReportThisPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { DNM_tdstReport *p_stDynamReport; tdstGetSetParam stParam; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); DNM_tdstObstacle* p_stCharacterObstacle; HIE_tdxHandleToSuperObject hPersoSupObj; HIE_tdxHandleToSuperObject hSupObj; /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ M_EvalNextParameter(&stParam); hPersoSupObj=M_GetSetParam_p_stSupObjValue(&stParam); if ((p_stDynamReport=fn_pstGetDNMReport(hNewSuperObjPerso))==NULL) { *p_lValue = (long)FALSE; return p_stTree; } if ( (DNM_M_ulReportGetSurfaceState(p_stDynamReport)&C_WOT_ulMobile) == C_WOT_ulMobile ) { p_stCharacterObstacle = DNM_M_p_stReportGetCharacter(p_stDynamReport); hSupObj = DNM_M_p_stObstacleGetObject (p_stCharacterObstacle); if (HIE_fn_bIsSuperObjectValid(hSupObj)) { *p_lValue = ( MEC_fn_hGetFatherActor (hSupObj) == hPersoSupObj ); return p_stTree; } } *p_lValue = (long)FALSE; return p_stTree; } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stReportOnZDMSurfaceCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; DNM_tdstReport *p_stDynamReport; unsigned long ulSurfState; GMT_tdxMask xTestMask; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ /**** BEWARE ULTRA ****/ if ((p_stDynamReport=fn_pstGetDNMReport(hNewSuperObjPerso))==NULL) { *p_lValue = (long)FALSE; return p_stTree; } ulSurfState = DNM_M_ulReportGetSurfaceState(p_stDynamReport); /* Eval type of ZDM.*/ M_EvalNextParameter(&stParam); xTestMask = (GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); switch (eCondId) { case eCond_ZDMCollideWithGround: if ((ulSurfState & C_WOT_ulGround) == C_WOT_ulGround) *p_lValue = (long)fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetGround(p_stDynamReport)), xTestMask); else *p_lValue = (long)FALSE; return p_stTree; break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_ZDMCollideWithWall: if ((ulSurfState & C_WOT_ulWall) == C_WOT_ulWall) *p_lValue = (long)fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetWall(p_stDynamReport)), xTestMask); else *p_lValue = (long)FALSE; return p_stTree; break; case eCond_ZDMCollideWithNothing: if (ulSurfState != C_WOT_ulNoObstacle) /* Careful C_WOT_ulNoObstacle == 0*/ { if ( ((ulSurfState & C_WOT_ulGround) == C_WOT_ulGround) /*|| ((ulSurfState & C_WOT_ulSlope) == C_WOT_ulSlope)*/ ) *p_lValue = (long)!fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetGround(p_stDynamReport)), xTestMask); else if ( ((ulSurfState & C_WOT_ulWall) == C_WOT_ulWall) /*|| ((ulSurfState & C_WOT_ulAttic) == C_WOT_ulAttic)*/ ) *p_lValue = (long)!fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetWall(p_stDynamReport)), xTestMask); else if ((ulSurfState & C_WOT_ulCeiling) == C_WOT_ulCeiling) *p_lValue = (long)!fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetCeil(p_stDynamReport)), xTestMask); else *p_lValue = (long)TRUE; } else *p_lValue = (long)TRUE; return p_stTree; break; /*case eCond_ZDMCollideWithSlope: if ((ulSurfState & C_WOT_ulSlope) == C_WOT_ulSlope) *p_lValue = (long)fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetGround(p_stDynamReport)), xTestMask); else *p_lValue = (long)FALSE; return p_stTree; break;*/ /*case eCond_ZDMCollideWithAttic: if ((ulSurfState & C_WOT_ulAttic) == C_WOT_ulAttic) *p_lValue = (long)fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetWall(p_stDynamReport)), xTestMask); else *p_lValue = (long)FALSE; return p_stTree; break;*/ case eCond_ZDMCollideWithCeiling: if ((ulSurfState & C_WOT_ulCeiling) == C_WOT_ulCeiling) *p_lValue = (long)fn_bTestTypeOfGameMaterial(DNM_M_hObstacleGetMyMaterial(DNM_M_p_stReportGetCeil(p_stDynamReport)), xTestMask); else *p_lValue = (long)FALSE; return p_stTree; break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } *p_lValue = (long) FALSE; #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return p_stTree; } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stListCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam1, stParam2; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); switch(eCondId) { /* List*/ case eCond_IsPersoInList : M_EvalNextTwoParameter(); *p_lValue = (long)fn_bFindPersoInList((tdstList *)M_GetSetParam_Dsg_List(&stParam1),M_GetSetParam_p_stSupObjValue(&stParam2)); return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 07/06/99 { */ case eCond_IsModelInList : M_EvalNextTwoParameter(); *p_lValue = (long)fn_bFindModelInList((tdstList *)M_GetSetParam_Dsg_List(&stParam1),M_GetSetParam_p_stModel(&stParam2)); return(p_stTree); break; case eCond_IsFamilyInList : M_EvalNextTwoParameter(); *p_lValue = (long)fn_bFindFamilyInList((tdstList *)M_GetSetParam_Dsg_List(&stParam1),M_GetSetParam_hFamily(&stParam2)); return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ } */ case eCond_ListEmptyTest : M_EvalNextParameter(&stParam1); *p_lValue = (long)M_bListEmptyTest((tdstList *) M_GetSetParam_Dsg_List(&stParam1)) ; return(p_stTree); break; default: break; } *p_lValue = (long) FALSE; #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stTimeCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; unsigned long ulCurrentTime=g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; unsigned long ulSavedTime,ulDeltaTime,ulLimitDeltaTime; M_EvalNextParameter(&stParam); ulSavedTime=M_GetSetParam_ulTimeValue(&stParam); M_EvalNextParameter(&stParam); ulLimitDeltaTime=M_GetSetParam_ulTimeValue(&stParam); if (ulCurrentTime>=ulSavedTime) { ulDeltaTime=ulCurrentTime-ulSavedTime; } else { ulDeltaTime = (unsigned long)(-(long)(ulCurrentTime-ulSavedTime)); } *p_lValue=(ulDeltaTime>=ulLimitDeltaTime); return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stValidityCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); #if defined(__DEBUG_AI__) fn_vSetDontCheckNULLFlag(1); #endif /*__DEBUG_AI__*/ M_EvalNextParameter(&stParam); #if defined(__DEBUG_AI__) fn_vSetDontCheckNULLFlag(-1); #endif /*__DEBUG_AI__ */ switch(eCondId) { case eCond_IsValidText: *p_lValue = (long) ( M_GetSetParam_hText(&stParam) != FON_C_xInvalidTextHandle ); return(p_stTree); break; case eCond_IsValidObject: { MS_tdxHandleToStandardGame hStdGame; tdstEngineObject *hObject = M_GetSetParam_p_stEngineObjValue(&stParam); *p_lValue = (long) ( ( hObject != NULL ) /* the objet is valid*/ && ( (hStdGame = hObject->h_StandardGame) != NULL ) /* it is not a destroyed always*/ && !fn_bf1StandardGameGetIsDesactivateAtAll(hStdGame) /* the object isn't definitively dead*/ ); } return(p_stTree); break; case eCond_IsValidWayPoint: *p_lValue=(long) ((M_GetSetParam_WayPointValue(&stParam))!=WP_C_hWayPointInvalid); return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_IsValidGMT: *p_lValue=(long) ((M_GetSetParam_hGameMaterial(&stParam))!=NULL); return(p_stTree); break; case eCond_IsValidAction: *p_lValue=(long) ((M_GetSetParam_ActionValue(&stParam))!=NULL); return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stMiscCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); switch ( eCondId ) { case eCond_EngineReinitRequested : /* true if a previously processed character requested an engine reinit */ *p_lValue = (long) ( g_stEngineStructure . eEngineMode != EM_ModePlaying ) ; return p_stTree; break; case eCond_CmtIdentifierContainsMask: { GMT_tdxMask xTestedMask, xBits; /*read the tested CMT*/ M_EvalNextParameter(&stParam); xTestedMask = (GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); /*read the bits to test it against*/ M_EvalNextParameter(&stParam); xBits = (GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); /*if the cmt contains some or all the test bits, the condition is true*/ *p_lValue = (long) (( xTestedMask & xBits ) ? TRUE : FALSE); } return p_stTree; break; case eCond_HitByCollider: { MS_tdxHandleToCollSet hCollSet = M_GetMSHandle(p_SuperObjPerso,CollSet); if ( (*p_lValue = ((hCollSet && fn_ucCollSetGetColliderPriority(hCollSet)) ? TRUE : FALSE)) ) /*clear, so that another collision information may be recorded next time*/ fn_vCollSetSetColliderPriority(hCollSet, 0); } return p_stTree; break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_IsTypeOfGMTCollide: { GMT_tdxMask xTestMask; unsigned long ulSurfState; DNM_tdstReport *p_stDynamReport; M_EvalNextParameter(&stParam); if ((p_stDynamReport=fn_pstGetDNMReport(p_SuperObjPerso))==NULL) { *p_lValue = (long)FALSE; return p_stTree; break; } ulSurfState = DNM_M_ulReportGetSurfaceState(p_stDynamReport); if (ulSurfState != C_WOT_ulNoObstacle) { xTestMask = (GMT_tdxMask) M_GetSetParam_xMaskValue(&stParam); *p_lValue = fn_bIsTypeOfGMT(p_SuperObjPerso, xTestMask); } else *p_lValue = FALSE; } return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ /* Comport or Reflex*/ case eCond_IsInReflexComport: case eCond_IsInComport: { HIE_tdxHandleToSuperObject hTempPerso; tdstIntelligence *p_stIntelligence; M_EvalNextParameter(&stParam); hTempPerso=M_GetSetParam_p_stSupObjValue(&stParam); SAF_M_AssertWithMsg(hTempPerso, "l'acteur spécifié est nul"); M_EvalNextParameter(&stParam); p_stIntelligence = (eCondId == eCond_IsInComport) ? AI_M_p_stGetIntelligence(AI_M_stGetMindOfSuperObj(hTempPerso)) : AI_M_p_stGetReflex(AI_M_stGetMindOfSuperObj(hTempPerso)); if (p_stIntelligence!=NULL) *p_lValue = (long) (M_GetCurrentComport(p_stIntelligence) == M_GetSetParam_pComport(&stParam) ); else *p_lValue =(long) FALSE; } return(p_stTree); break; /* Special*/ case eCond_IsInAction: M_EvalNextParameter(&stParam); *p_lValue = (unsigned long)PLA_fn_bTestCurrentAction(p_SuperObjPerso, M_GetSetParam_ActionValue(&stParam)); return(p_stTree); break; case eCond_ChangeActionEnable: M_EvalNextParameter(&stParam); *p_lValue = (unsigned long)PLA_fn_bTestNewState(p_SuperObjPerso, M_GetSetParam_ActionValue(&stParam)); return(p_stTree); break; #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ case eCond_IsThereMechEvent: { unsigned char ucVarId; unsigned short uwNbFrame; #if defined(__DEBUG_AI__) M_AI_DEBUG_ASSERT((M_GetTypeInterpret(p_stTree) == E_ti_DsgVarRef), E_uwAIBadLeftInAffectation); #endif ucVarId = (unsigned char) M_ucVarIdInterpret(p_stTree); p_stTree++; uwNbFrame = fn_uwGetNbEngineFrameSinceLastMechEvent(p_SuperObjPerso); if (uwNbFrame != LME_INVALID) { /* Affect DsgVar with the number of frame.*/ M_Full_GetSetParam_Integer(&stParam, uwNbFrame); if (fn_ucSetDsgVar(ucVarId, 0,AI_M_stGetMindOfSuperObj(p_SuperObjPerso), &stParam) == C_INVALID_SET) { /* error or not error ????*/ *p_lValue = (long) FALSE; } else *p_lValue = (long) TRUE; } else *p_lValue = (long) FALSE; } return(p_stTree); break; #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ default: break; } #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif *p_lValue=(long) FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ #ifdef D_USE_LIPSYNC tdstNodeInterpret *fn_p_stLipsSynchroCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ *p_lValue = (long)fn_bIsDiscussionOver(hNewSuperObjPerso); return p_stTree; } #endif /* D_USE_LIPSYNC*/ /* *================================================================================================= *================================================================================================= */ unsigned char fn_bPerso1Point1IntersectPerso2Point2(HIE_tdxHandleToSuperObject hPerso1, MTH3D_tdstVector *p_stVertex1,HIE_tdxHandleToSuperObject hPerso2, MTH3D_tdstVector *p_stVertex2) { MTH3D_tdstVector stTempVector; HIE_tdxHandleToSuperObject hSector1,hSector2,hSector; int i; SECT_tdxHandleOfElementLstGraphicInteraction hList; hSector1=GAM_fn_hGetCurrentSector(hPerso1); if (hSector1==NULL) return FALSE; hSector2=GAM_fn_hGetCurrentSector(hPerso2); if (hSector2==NULL) return FALSE; MTH3D_M_vSubVector(&stTempVector, p_stVertex2, p_stVertex1); if(HIE_bDetectIntersectSegmentWithSuperObject(p_stVertex1/*, p_stVertex2*/, &stTempVector, hSector1)) return TRUE; if(hSector1 != hSector2) { if( HIE_bDetectIntersectSegmentWithSuperObject(p_stVertex1/*,p_stVertex2*/, &stTempVector, hSector2)) return TRUE; } SECT_M_ForEachGraphicNodeInGraphicInteractionList(hSector1, hList, i) { hSector = SECT_GetSectorInGraphicList(hList); if( (hSector != hSector2) && HIE_bDetectIntersectSegmentWithSuperObject(p_stVertex1/*,p_stVertex2*/, &stTempVector,hSector)) { return TRUE; } } return FALSE; } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stSectorCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ switch (eCondId) { case eCond_SeePerso: { HIE_tdxHandleToSuperObject pPerso1=hNewSuperObjPerso; HIE_tdxHandleToSuperObject pPerso2; MTH3D_tdstVector stVertex1,stVertex2; M_EvalNextParameter(&stParam); pPerso2=M_GetSetParam_p_stSupObjValue(&stParam); SAF_M_AssertWithMsg(pPerso2, "l'acteur spécifié est nul"); fn_vGetCenterOfBoundingVolume(pPerso1,&stVertex1); fn_vGetCenterOfBoundingVolume(pPerso2,&stVertex2); /* both centers are in world coordinates*/ *p_lValue = (long) (!fn_bPerso1Point1IntersectPerso2Point2(pPerso1,&stVertex1,pPerso2,&stVertex2)); return(p_stTree); break; } default: break; } *p_lValue = (long) FALSE; #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return p_stTree; } /* *================================================================================================= *================================================================================================= */ #if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/ tdstNodeInterpret *fn_p_stLightCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /* should be eCond_IsLightOn*/ MS_tdxHandleToMSLight h_MSLight; long lValue=FALSE; /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ /* BEWARE_ULTRA */ h_MSLight=M_GetEngineObject(hNewSuperObjPerso)->h_MSLight; if (h_MSLight!=NULL) { switch(eCondId) { case eCond_IsPersoLightOn: lValue=(long) fn_ucMSLightGetOnOff(h_MSLight); break; case eCond_IsPersoLightPulseOn: lValue=(long) fn_bMSLightGetPulse(h_MSLight); break; case eCond_IsPersoLightGyroPhareOn: lValue=(long) fn_bMSLightGetGiroPhare(h_MSLight); break; default: break; } } *p_lValue=lValue; return(p_stTree); } #endif /* _AI_EXCLUDE_NEVER_USED_ }*/ /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_st_ActivationCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /* should be eCond_IsActivable*/ /********************************************************************************/ /* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */ /********************************************************************************/ HIE_tdxHandleToSuperObject hNewSuperObjPerso; fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCondId),p_SuperObjPerso,&hNewSuperObjPerso); /********************************************************************************/ *p_lValue=(long) M_ObjectIsActivable(M_GetEngineObject(hNewSuperObjPerso)); return (p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_st_HandledCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; /*enum tdeCondId_ eCondId = M_eCondIdInterpret(p_stTree-1); // should be eCond_IsAlreadyHandled*/ M_EvalNextParameter( &stParam ); SAF_M_AssertWithMsg(M_GetSetParam_p_stEngineObjValue(&stParam), "l'acteur spécifié est nul"); SAF_M_AssertWithMsg(M_GetSetParam_p_stEngineObjValue(&stParam) != HIE_fn_hGetSuperObjectObject(p_SuperObjPerso), "cette condition ne doit pas être appelée sur soi-même"); SAF_M_AssertWithMsg(M_GetSetParam_p_stEngineObjValue(&stParam)->h_StandardGame, "l'acteur spécifié n'existe plus (always détruit ?)"); *p_lValue = (long) M_ObjectIsAlreadyTreated(M_GetSetParam_p_stEngineObjValue(&stParam)); return (p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_st_UserEvent_IsSet(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *_p_lValue) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tdstGetSetParam stParam; unsigned char ucEventIndex, ucVarId = 0; enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ switch ( eCondId ) { default: #if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO)) M_AIFatalError(E_uwAIFatalNotValidCondition); #endif return (p_stTree); break; case eCond_UserEvent_IsSet: case eCond_UserEvent_IsSet2: M_EvalNextParameter( &stParam ); ucEventIndex = (unsigned char) M_GetSetParam_lValue( &stParam ); if ( eCondId == eCond_UserEvent_IsSet2 ) { ucVarId = (unsigned char) M_ucVarIdInterpret(p_stTree); p_stTree ++; } } if ( ucEventIndex <= (C_ucEvent_User7 - C_ucEvent_User0) ) { MTH3D_tdstVector stPosition; *_p_lValue = fn_b3dDataGetUserEventFlag( M_GetMSHandle( p_SuperObjPerso, 3dData), ucEventIndex, &stPosition ); /* if there is an event and we want to retrieve its position in the AI*/ if ( (*_p_lValue) && (eCondId == eCond_UserEvent_IsSet2) ) { /* modify the designer variable with the result, condition fails if we could not do it*/ M_Full_GetSetParam_p_stVertex(&stParam, &stPosition); if ( fn_ucSetDsgVar(ucVarId, 0, AI_M_stGetMindOfSuperObj(p_SuperObjPerso), &stParam) == C_INVALID_SET ) *_p_lValue = FALSE; } } else *_p_lValue = FALSE; return(p_stTree); } /* *================================================================================================= *================================================================================================= */ tdstNodeInterpret *fn_p_stAlw_IsMine(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ tdstGetSetParam stParam; HIE_tdxHandleToSuperObject hNewSuperObjPerso; tdstEngineObject *hAlwaysObject; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /* Get ultra operator */ fn_vGetUltraOperatorPerso(fn_ucGetConditionUltraOperator(eCond_Alw_IsMine),p_SuperObjPerso,&hNewSuperObjPerso); /* get always, without checking its validity, so that the call can replace ObjetValide() */ #if defined(__DEBUG_AI__) fn_vSetDontCheckNULLFlag(1); #endif /* __DEBUG_AI__ */ M_EvalNextParameter(&stParam); #if defined(__DEBUG_AI__) fn_vSetDontCheckNULLFlag(-1); #endif /* __DEBUG_AI__ */ hAlwaysObject = M_GetSetParam_p_stEngineObjValue(&stParam); *p_lValue = (hAlwaysObject && hAlwaysObject->h_StandardGame) /* if always is still active, check it is ours*/ ? (long) fn_ucIsAlwaysGeneratedByMe( M_GetSetParam_p_stSupObjValue(&stParam), hNewSuperObjPerso) : 0; /* else it is not*/ return(p_stTree); } #include "Cond1.cxx" /* FQ IAenC*/ tdstNodeInterpret *fn_p_stDummyCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { #ifdef U64 enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree-1); M_PrintfStopErrorN64(("DummyCondition %d, spo=0x%x!!", eCondId, p_SuperObjPerso)); #endif /* U64 */ *p_lValue=TRUE; return p_stTree; } /*KWN : begin***********************************************************************************************************************************************/ tdstNodeInterpret *fn_p_stStyletCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { enum tdeCondId_ eCondId = M_eCondIdInterpret(p_stTree-1); *p_lValue=(long) FALSE; switch (eCondId) { /* pressed*/ case eCond_StyletPressed: *p_lValue=(long) ( DS_bTPPressed()); break; /* just pressed*/ case eCond_StyletJustPressed: *p_lValue=(long) ( DS_bTPJustPressed()); break; /* just released*/ case eCond_StyletJustReleased: *p_lValue=(long) ( DS_bTPJustReleased()); break; default: break; } return(p_stTree); } tdstNodeInterpret *fn_p_stStyletSlice(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; MTH3D_tdstVector stVector01,stVector02,stTemp; unsigned long ulCurrentBits; int iScreenX; int iScreenY; *p_lValue=(long) FALSE; M_EvalNextParameter( &stParam ); stVector01 = M_GetSetParam_stVectorValue(&stParam); //Down M_EvalNextParameter( &stParam ); stVector02 = M_GetSetParam_stVectorValue(&stParam); //Up ulCurrentBits = fn_ulStandardGameGetCustomBits(M_GetMSHandle(p_SuperObjPerso,StandardGame)); if( ulCurrentBits & GAM_C_CustBitOutOfVisibility) return(p_stTree); if( DS_bTPPressed() == false ) return(p_stTree); if( stVector01.xY < stVector02.xY) { stTemp = stVector01; stVector01 = stVector02; stVector02 = stTemp; } if( stVector01.xX < 0.0f || stVector01.xX > 1000.0f || stVector02.xX < 0.0f || stVector02.xX > 1000.0f ) return(p_stTree); if( stVector01.xY > 1000.0f ) stVector01.xY = 1000.0f; if( stVector02.xY < 0.0f ) stVector01.xY = 0.0f; DS_bTPGetPosition(&iScreenX,&iScreenY); if ( DS_bTPJustPressed() ) { gv_CurrentStyletTP.xX = MTH_M_xMul(MTH_M_xLongToReal(iScreenX), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwWidth)); gv_CurrentStyletTP.xY = MTH_M_xMul(MTH_M_xLongToReal(iScreenY), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwHeight)); gv_LatestStyletTP = gv_CurrentStyletTP; } else { float f_a,fSpeed,C_SpeedLimite; MTH3D_tdstVector vSpeed; stTemp = gv_CurrentStyletTP; gv_CurrentStyletTP.xX = MTH_M_xMul(MTH_M_xLongToReal(iScreenX), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwWidth)); gv_CurrentStyletTP.xY = MTH_M_xMul(MTH_M_xLongToReal(iScreenY), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwHeight)); if( stTemp.xX != gv_CurrentStyletTP.xX || stTemp.xY != gv_CurrentStyletTP.xY ) gv_LatestStyletTP = stTemp; C_SpeedLimite = MTH_M_xFloatToReal(255.0f); f_a = MTH_M_xMul(MTH_M_xAdd(stVector01.xX,stVector02.xX), MTH_M_xFloatToReal(0.5)); if( (MTH_M_xSign(gv_LatestStyletTP.xX - f_a)*MTH_M_xSign(gv_CurrentStyletTP.xX - f_a)) <= 0 ) { MTH3D_M_vSubVector(&vSpeed, &gv_LatestStyletTP , &gv_CurrentStyletTP) ; fSpeed = MTH_M_xAdd(MTH_M_xMul(vSpeed.xX,vSpeed.xX) , MTH_M_xMul(vSpeed.xY,vSpeed.xY)); if ( MTH_M_bGreaterEqual(gv_CurrentStyletTP.xY,stVector02.xY) && MTH_M_bLessEqual(gv_CurrentStyletTP.xY,stVector01.xY) ) { if MTH_M_bGreater(fSpeed,C_SpeedLimite) *p_lValue=(long) TRUE; } } } return(p_stTree); } tdstNodeInterpret *fn_p_stCheckStyletRotation(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; MTH3D_tdstVector stCentre, stStyletPos; int iScreenX, iScreenY; unsigned long ulCurrentTime_R, ulCurrentTime_L, C_DelaiMAX, C_Limite; unsigned long ulCurrentBits; BOOL b_Right; C_DelaiMAX = 500; *p_lValue=(long) FALSE; M_EvalNextParameter( &stParam ); stCentre = M_GetSetParam_stVectorValue(&stParam); M_EvalNextParameter( &stParam ); C_Limite = M_GetSetParam_ulValue(&stParam); M_EvalNextParameter( &stParam ); b_Right = M_GetSetParam_lValue(&stParam); ulCurrentBits = fn_ulStandardGameGetCustomBits(M_GetMSHandle(p_SuperObjPerso,StandardGame)); if( DS_bTPPressed() == false || (ulCurrentBits & GAM_C_CustBitOutOfVisibility) ) return(p_stTree); DS_bTPGetPosition(&iScreenX,&iScreenY); iScreenX = MTH_M_xMul(MTH_M_xLongToReal(iScreenX), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwWidth)); iScreenY = MTH_M_xMul(MTH_M_xLongToReal(iScreenY), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwHeight)); if( iScreenX < (stCentre.xX - C_Limite)|| iScreenX > (stCentre.xX + C_Limite) || iScreenY < (stCentre.xY - C_Limite)|| iScreenY > (stCentre.xY + C_Limite) ) return(p_stTree); stStyletPos.xX = MTH_M_xLongToReal(iScreenX); stStyletPos.xY = MTH_M_xLongToReal(iScreenY); stStyletPos.xZ = 0.0f; if( DS_bTPJustPressed() ) { fn_InitStyletRotationDATA(stCentre,stStyletPos,true); fn_InitStyletRotationDATA(stCentre,stStyletPos,false); } else { if ( b_Right ) { ulCurrentTime_R = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; if ( (ulCurrentTime_R - ulSavedTime_R) < C_DelaiMAX ) { if ( fni_GetStyletCurrentSector(stCentre,stStyletPos) == TAB_IDxNextSector_R[i_IDX_R] ) i_IDX_R ++; if ( i_IDX_R == 4) { *p_lValue=(long) TRUE; fn_InitStyletRotationDATA(stCentre,stStyletPos,true); } } else { fn_InitStyletRotationDATA(stCentre,stStyletPos,true); } } else { ulCurrentTime_L = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; if ( (ulCurrentTime_L - ulSavedTime_L) < C_DelaiMAX ) { if ( fni_GetStyletCurrentSector(stCentre,stStyletPos) == TAB_IDxNextSector_L[i_IDX_L] ) i_IDX_L ++; if ( i_IDX_L == 4) { *p_lValue=(long) TRUE; fn_InitStyletRotationDATA(stCentre,stStyletPos,false); } } else { fn_InitStyletRotationDATA(stCentre,stStyletPos,false); } } } return(p_stTree); } tdstNodeInterpret *fn_p_stCheckStyletGratter(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, long *p_lValue) { tdstGetSetParam stParam; MTH3D_tdstVector stLimiteL, stLimiteR, stOldStyletPos, stvTemp; int iScreenX, iScreenY; unsigned long ulCurrentTimeAction, ulDelaiActionMAX, C_InactifDELAYMAX; unsigned long ulCurrentBits; float C_StyletSpeedMIN; C_InactifDELAYMAX = 300; C_StyletSpeedMIN = 10.0f; *p_lValue=(long) FALSE; M_EvalNextParameter( &stParam ); stLimiteL = M_GetSetParam_stVectorValue(&stParam); M_EvalNextParameter( &stParam ); stLimiteR = M_GetSetParam_stVectorValue(&stParam); M_EvalNextParameter( &stParam ); ulDelaiActionMAX = M_GetSetParam_ulValue(&stParam); ulCurrentBits = fn_ulStandardGameGetCustomBits(M_GetMSHandle(p_SuperObjPerso,StandardGame)); if( DS_bTPPressed() == false || (ulCurrentBits & GAM_C_CustBitOutOfVisibility) ) { g_ulTimeAction = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; return(p_stTree); } DS_bTPGetPosition(&iScreenX,&iScreenY); iScreenX = MTH_M_xMul(MTH_M_xLongToReal(iScreenX), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwWidth)); iScreenY = MTH_M_xMul(MTH_M_xLongToReal(iScreenY), MTH_M_xFloatToReal(1000.0f / (float)g_stEngineStructure.stViewportAttr.dwHeight)); if( iScreenX < stLimiteL.xX || iScreenX > stLimiteR.xX || iScreenY < stLimiteL.xY || iScreenY > stLimiteR.xY ) { g_ulTimeAction = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; return(p_stTree); } stOldStyletPos = g_stStyletPos; g_stStyletPos.xX = MTH_M_xLongToReal(iScreenX); g_stStyletPos.xY = MTH_M_xLongToReal(iScreenY); g_stStyletPos.xZ = 0.0f; MTH3D_M_vSubVector(&stvTemp,&stOldStyletPos,&g_stStyletPos); if ( MTH3D_M_xNormVector(&stvTemp) < C_StyletSpeedMIN ) g_ulTimeInactif += g_stEngineStructure.stEngineTimer.ulUsefulDeltaTime; else g_ulTimeInactif = 0; if ( g_ulTimeInactif > C_InactifDELAYMAX) { g_ulTimeAction = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; return(p_stTree); } ulCurrentTimeAction = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; if ( (ulCurrentTimeAction - g_ulTimeAction) > ulDelaiActionMAX) { *p_lValue=(long) TRUE; g_ulTimeInactif = 0; g_ulTimeAction = g_stEngineStructure.stEngineTimer.ulCurrentTimerCount; } return(p_stTree); } /*KWN : End***********************************************************************************************************************************************/ /************************************************************************************************************************************************/ /* *================================================================================================= *================================================================================================= */ #if !defined(OPTIMIZED_COMMAND) #include "ProtCond.h" void fn_vInitConditionEntries(void) { /* Init*/ #if defined(__DEBUG_AI__) fn_vInitConditionTable(fn_p_stDefaultCondition); #endif /* __DEBUG_AI__*/ /* Condition definition*/ #define M_DEFINE_CONDITION(a,b,english,c,d,e,f) \ fn_vDefineConditionEntry(M_CONDITION_ENTRY(a,b,english,c,d,e)); \ fn_vSetConditionUltraOperator(a,f); #include "DefCond.h" #undef M_DEFINE_CONDITION /* Check*/ #if defined(__DEBUG_AI__) fn_vCheckConditionTable(fn_p_stDefaultCondition); #endif /* __DEBUG_AI__*/ } #endif /* OPTIMIZED_COMMAND*/