reman3/Rayman_X/cpa/tempgrp/AI/AIGame/ProcRay2.cxx

2378 lines
85 KiB
C++
Raw Blame History

/************************************************************************************************
* Name: ProcRay2.c *
* Use : Procedures for AI of Rayman II *
* Author: Christophe Giraud *
* (c) UBI Simulations Annecy *
************************************************************************************************/
/*ANNECY CG {*/
#ifdef __cplusplus
extern "C"{
#endif
#define TEXT_MAX_PARAMETERS 10
int TEXT_gai_IntParameters[TEXT_MAX_PARAMETERS];
float TEXT_gaf_FloatParameters[TEXT_MAX_PARAMETERS];
char TEXT_gc_ViewportFixed = 1;
#ifdef __cplusplus
}
#endif
#if !defined(U64)
#include "ray.h"
#endif
#include "DataRay2.h"
/* XB 05/05/99 */
#ifdef U64
#include "ino\Specif\u_demo.h"
void fn_vSwitchToDemoLevel(void);
#endif /* U64 */
/* End XB 05/05/99 */
extern void qsort(void *,size_t,size_t,int (*)(const void *,const void *)); /*for qsort*/
/* Force text to be or not (to be) super imposed */
tdstNodeInterpret *fn_p_stTextSuperImposed(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
M_EvalNextParameter(&stParam);
TEXT_gc_ViewportFixed = (char) M_GetSetParam_lValue(&stParam);
return p_stTree;
}
#ifndef U64
/*******************FabPerez *******************/
#include "GAM\GamOpt.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern int fn_iVersionN64_PC(void);
extern StructRecupPosSlot * g_p_LastStructRecupPosSlot;
extern long g_ucNbSaveGameSlots;
extern char g_a_szSlotNames[4];
#ifdef __cplusplus
}
#endif
/***************************************************/
#endif // ! U64
char g_a_szOldSlotNames[C_ucNbSaveGameSlots][C_ucSaveGameSlotNameLength + 1]={0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0};
/**********************************************************************************************************
* Function: MNU_ValidenomDuSlot *
* *
* Use : MNU_ValidenomDuSlot( Slot number, VAR_STRING *
* *
* Author : Christophe Giraud *
* Date of last modification: 12/08/98 *
* *
**********************************************************************************************************/
tdstNodeInterpret *fn_p_stCode4ValideNomDuSlot(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
long lSlotId = 0;
char *pszSlotName = NULL;
long lNbOfLums = 0;
#ifndef U64
StructRecupPosSlot *p_StructRecupPosSlot;
BOOL bResult = FALSE;
int iNum = 1;
int Version = 0;
#endif
/* Get the slot number*/
M_EvalNextParameter(&stParam);
lSlotId = M_GetSetParam_lValue(&stParam);
/* Get the name of the slot*/
M_EvalNextParameter(&stParam);
pszSlotName = (char *)fn_szGetStringFromTextOrStringParam(&stParam);
/* Get the number of lums */
M_EvalNextParameter(&stParam);
lNbOfLums = M_GetSetParam_lValue(&stParam);
if (lNbOfLums<0) lNbOfLums = 0;
if (lNbOfLums>999) lNbOfLums = 999;
if(!pszSlotName)
g_stGameOptions.a_szSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
else
switch ( eProcedureId )
{
case eProc_ValideNomDuSlot:
{
#ifdef U64
SAF_M_AssertWithMsg((lSlotId >= 1 && lSlotId <= C_ucNbSaveGameSlots),"Slot de sauvegarde inexistant");
#else
SAF_M_AssertWithMsg(( lSlotId >= 1 && lSlotId <= (long) fn_lGetNbAvailableSlotsPc() ),"Slot de sauvegarde inexistant");
#endif
while( *pszSlotName++ == '/')
{
while( *pszSlotName++ != ':' );
}
pszSlotName[2]='\0';
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
memcpy(g_a_szOldSlotNames[lSlotId-1], g_stGameOptions.a_szSlotNames[lSlotId-1], C_ucSaveGameSlotNameLength );
g_a_szOldSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
if (lNbOfLums<100)
sprintf(g_stGameOptions.a_szSlotNames[lSlotId-1],"%s 0%2.1f",pszSlotName-1,(float)(lNbOfLums/10.0f));
else
sprintf(g_stGameOptions.a_szSlotNames[lSlotId-1],"%s %2.1f",pszSlotName-1,(float)(lNbOfLums/10.0f));
g_stGameOptions.a_szSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
}
else if( Version == 2 /* PC */)
{
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
if( lSlotId > g_ucNbSaveGameSlots )
{
g_p_LastStructRecupPosSlot = (StructRecupPosSlot *) TMP_M_p_Malloc( sizeof(StructRecupPosSlot) );
g_p_LastStructRecupPosSlot->pt_NextStructRecupPosSlot = p_StructRecupPosSlot;
g_p_LastStructRecupPosSlot->pos = ++g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
}
else
{
while( iNum < lSlotId)
{
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
iNum++;
}
}
strcpy( p_StructRecupPosSlot->a_szOldSlotNames, p_StructRecupPosSlot->a_szSlotNames);
if (lNbOfLums<100)
sprintf( p_StructRecupPosSlot->a_szSlotNames, "%3s 0%2.1f", g_a_szSlotNames, (float)(lNbOfLums/10.0f));
else
sprintf( p_StructRecupPosSlot->a_szSlotNames, "%3s %2.1f", g_a_szSlotNames, (float)(lNbOfLums/10.0f));
}
#else /* PC sans EDITOR*/
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
if( lSlotId > g_ucNbSaveGameSlots )
{
g_p_LastStructRecupPosSlot = (StructRecupPosSlot *) TMP_M_p_Malloc( sizeof(StructRecupPosSlot) );
g_p_LastStructRecupPosSlot->pt_NextStructRecupPosSlot = p_StructRecupPosSlot;
g_p_LastStructRecupPosSlot->pos = ++g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
}
else
{
while( iNum < lSlotId)
{
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
iNum++;
}
}
strcpy( p_StructRecupPosSlot->a_szOldSlotNames, p_StructRecupPosSlot->a_szSlotNames);
if (lNbOfLums<100)
sprintf( p_StructRecupPosSlot->a_szSlotNames, "%3s 0%2.1f", g_a_szSlotNames, (float)(lNbOfLums/10.0f));
else
sprintf( p_StructRecupPosSlot->a_szSlotNames, "%3s %2.1f", g_a_szSlotNames, (float)(lNbOfLums/10.0f));
#endif // EDITOR
#else /* U64*/
memcpy(g_a_szOldSlotNames[lSlotId-1], g_stGameOptions.a_szSlotNames[lSlotId-1], C_ucSaveGameSlotNameLength );
g_a_szOldSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
//FB this fucking test is necessary on N64 : the use of %02.1f in sprintf doesn't work
if (lNbOfLums<100)
sprintf(g_stGameOptions.a_szSlotNames[lSlotId-1],"%s 0%2.1f",pszSlotName-1,(float)(lNbOfLums/10.0f));
else
sprintf(g_stGameOptions.a_szSlotNames[lSlotId-1],"%s %2.1f",pszSlotName-1,(float)(lNbOfLums/10.0f));
g_stGameOptions.a_szSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
#endif // U64
}
break;
default:
{
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
}
break;
}
return p_stTree;
}
/**********************************************************************************************************
* Function: MNU_RestorenomDuSlot *
* *
* Use : MNU_RestorenomDuSlot( Slot number) *
* *
**********************************************************************************************************/
tdstNodeInterpret *fn_p_stCode4RestoreNomDuSlot(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
long lSlotId = 0;
int Version =0;
/* Get the slot number*/
M_EvalNextParameter(&stParam);
lSlotId = M_GetSetParam_lValue(&stParam);
switch ( eProcedureId )
{
case eProc_RestoreNomDuSlot:
{
#ifdef U64
SAF_M_AssertWithMsg((lSlotId >= 1 && lSlotId <= C_ucNbSaveGameSlots),"Slot de sauvegarde inexistant");
#else
SAF_M_AssertWithMsg(( lSlotId >= 1 && lSlotId <= (long) fn_lGetNbAvailableSlotsPc() ),"Slot de sauvegarde inexistant");
#endif
#ifdef U64
memcpy(g_stGameOptions.a_szSlotNames[lSlotId-1], g_a_szOldSlotNames[lSlotId-1], C_ucSaveGameSlotNameLength );
g_stGameOptions.a_szSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
#else /* PC */
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
memcpy(g_stGameOptions.a_szSlotNames[lSlotId-1], g_a_szOldSlotNames[lSlotId-1], C_ucSaveGameSlotNameLength );
g_stGameOptions.a_szSlotNames[lSlotId-1][C_ucSaveGameSlotNameLength] = '\0';
}
else if ( Version == 2 /* PC */)
{
strcpy( g_p_LastStructRecupPosSlot->a_szSlotNames, g_p_LastStructRecupPosSlot->a_szOldSlotNames);
}
#else /* PC sans EDITOR*/
strcpy( g_p_LastStructRecupPosSlot->a_szSlotNames, g_p_LastStructRecupPosSlot->a_szOldSlotNames);
#endif // Editor
#endif // U64
}
break;
default:
{
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
}
break;
}
return p_stTree;
}
/**********************************************************************************************************
**********************************************************************************************************/
tdstNodeInterpret *fn_p_stTextIntegerParameter(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
long l_NumInt, l_ValInt;
/* Get the number of the int to set */
M_EvalNextParameter(&stParam);
l_NumInt = M_GetSetParam_lValue(&stParam);
/* Get the value of the int */
M_EvalNextParameter(&stParam);
l_ValInt = M_GetSetParam_lValue(&stParam);
if(l_NumInt >= TEXT_MAX_PARAMETERS)
l_NumInt = TEXT_MAX_PARAMETERS - 1;
TEXT_gai_IntParameters[l_NumInt] = l_ValInt;
return p_stTree;
}
/**********************************************************************************************************
**********************************************************************************************************/
tdstNodeInterpret *fn_p_stTextRealParameter(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
long l_NumInt;
MTH_tdxReal x_ValInt;
/* Get the number of the int to set */
M_EvalNextParameter(&stParam);
l_NumInt = M_GetSetParam_lValue(&stParam);
/* Get the value of the int */
M_EvalNextParameter(&stParam);
x_ValInt = M_GetSetParam_xValue(&stParam);
if(l_NumInt >= TEXT_MAX_PARAMETERS)
l_NumInt = TEXT_MAX_PARAMETERS - 1;
TEXT_gaf_FloatParameters[l_NumInt] = x_ValInt;
return p_stTree;
}
/**********************************************************************************************************
* Function: TEXT_FormatTexte *
* *
* Use : TEXT_FormatTexte( "formatage", VAR_STRING_SOURCE, VAR_STRING_DESTINATION ) *
* *
* Author : Christophe Giraud *
* Date of last modification: 11/08/98 *
* *
**********************************************************************************************************/
tdstNodeInterpret * fn_p_stCode4FormateTexte ( HIE_tdxHandleToSuperObject p_SuperObjPerso , tdstNodeInterpret * p_stTree )
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret ( p_stTree - 1 ) ;
char * pszStringFormat = NULL , * pszStringSource = NULL , * pszStringDestination = NULL ;
/* Get String format parameter*/
M_EvalNextParameter ( & stParam ) ;
pszStringFormat = ( char * ) fn_szGetStringFromTextOrStringParam ( & stParam ) ;
/* Get String source*/
M_EvalNextParameter ( & stParam ) ;
pszStringSource = ( char * ) fn_szGetStringFromTextOrStringParam ( & stParam ) ;
/* Get String destination*/
M_EvalNextParameter ( & stParam ) ;
pszStringDestination = ( char * ) fn_szGetStringFromTextOrStringParam ( & stParam ) ;
switch ( eProcedureId )
{
case eProc_FormateTexte:
{
char szTmpString [ 255 ] ;
#if defined ( U64 ) || defined ( ACTIVE_EDITOR )
long lMaxSize ;
#endif /* U64 || ACTIVE_EDITOR */
long lSizeBis;
lSizeBis = strlen ( pszStringDestination ) ;
#ifndef U64
#ifdef ACTIVE_EDITOR
lMaxSize = ( long ) ( short ) * ( ( short * ) ( pszStringDestination + lSizeBis + 1 ) ) ;
#endif /* ACTIVE_EDITOR */
#else
lMaxSize = ( long ) ( unsigned char ) * ( ( unsigned char * ) ( pszStringDestination + lSizeBis + 1 ) ) ;
#endif
/* create the result string */
strcpy ( szTmpString , pszStringFormat ) ;
strcat ( szTmpString , pszStringSource ) ;
#if defined ( U64 ) || defined ( ACTIVE_EDITOR )
/* check for destination string possible overflow */
if ( ( long ) strlen ( szTmpString ) >= lMaxSize )
{
strcpy ( szTmpString , "E!" ) ;
}
#endif /* U64 || ACTIVE_EDITOR */
/* copy the result in the destination string */
strcpy ( pszStringDestination , szTmpString ) ;
lSizeBis = strlen ( pszStringDestination ) ;
/*HP 091198*/
#ifndef U64
#ifdef ACTIVE_EDITOR
* ( ( short * ) ( pszStringDestination + lSizeBis + 1 ) ) = ( short ) lMaxSize ;
#endif /* ACTIVE_EDITOR */
#else
*((unsigned char *)pszStringDestination + lSizeBis+1) = (unsigned char) lMaxSize;
#endif
}
break;
default:
{
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
}
break;
}
return p_stTree;
}
/**********************************************************************************************************
* Function: TEXT_ChangeCaractere *
* *
* Use : TEXT_ChangeCaractere( VAR_STRING, Position in string, Value of the caractere ) *
* *
* Author : Christophe Giraud *
* Date of last modification: 11/08/98 *
* *
**********************************************************************************************************/
tdstNodeInterpret *fn_p_stCode4ChangeCaractere(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
tdstEngineObject *p_stEngineObject = NULL;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree - 1);
unsigned char ucPosLetter = 0 , ucLetter = 0 ;
char *pszString = NULL ;
/* Get Always parameter*/
M_EvalNextParameter(&stParam);
p_stEngineObject = M_GetSetParam_p_stEngineObjValue(&stParam);
/* Get String Parameter*/
M_EvalNextParameter(&stParam);
pszString = (char *)fn_szGetStringFromTextOrStringParam(&stParam);
/* Get position of the letter*/
M_EvalNextParameter(&stParam);
ucPosLetter = M_GetSetParam_ucValue(&stParam);
/* Get number of the letter*/
M_EvalNextParameter(&stParam);
ucLetter = M_GetSetParam_ucValue(&stParam);
switch ( eProcedureId )
{
case eProc_ChangeCaractere:
{
if ( pszString )
{
register int iCpt = 0;
int iStrLen = strlen(pszString), iTrueLetterPos;
/* Search the beginning of the string*/
while( pszString[iCpt++] == '/')
{
while( pszString[iCpt++] != ':' );
}
iTrueLetterPos = ucPosLetter + iCpt - 1;
/* Change letter in string*/
if ( iTrueLetterPos > iStrLen )
{
pszString[iStrLen - 1] = ucLetter;
}
else
{
pszString[iTrueLetterPos] = ucLetter;
}
/* Change letter in super object*/
TFMT_vChangeLetter( M_GetSuperObject(p_stEngineObject), ucPosLetter, ucLetter );
}
}
break;
default:
{
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif
}
break;
}
return p_stTree;
}
/*********************************************************************
* Procedure: AirPointsProcedure *
* *
* Use : FixePointsDair( Entier Nb_Points_D_Air ) *
* Fixe les points d'Air pour Rayman (0-255) *
* *
* Use : FixePointsDairMax( Entier Nb_Points_D_Air_Max ) *
* Fixe les points d'Air Max pour Rayman *
* *
* Use : AjoutePointsDair( Entier Nb_Points_D_Air ) *
* Ajoute des pts d'Air aux pts d'Air de Rayman *
* *
* Use : AjoutePointsDairMax( Entier Nb_Points_D_Air_Max ) *
* Ajoute des pts d'Air aux pts d'Air Max de Rayman *
* *
* Use : EnlevePointsDair( Entier Nb_Points_D_Air ) *
* Enleve des pts d'Air aux pts d'Air de Rayman *
* *
* Use : EnlevePointsDairMax( Entier Nb_Points_D_Air_Max ) *
* Enleve des pts d'Air aux pts d'Air Max de Rayman *
* *
* Author : Christophe Giraud *
* Date of last modification: 24/02/98 *
**********************************************************************/
tdstNodeInterpret *fn_p_stCode4AirPointsProcedures(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
MTH_tdxReal xAirPoints; /* Temporary variable to stock Air points value*/
MTH_tdxReal xSign = 1.0f;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* Get the value of the parameter*/
M_EvalNextParameter(&stParam);
xAirPoints = M_GetSetParam_xValue(&stParam);
/* Check the AI function*/
switch(eProcedureId)
{
case eProc_InitPointsDair:
case eProc_FixePointsDair:
stExtendDatas4Ray.xAirPoints4Ray = xAirPoints;
return(p_stTree);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_InitPointsDairMax:
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_FixePointsDairMax:
stExtendDatas4Ray.xAirPointsMax4Ray = xAirPoints;
return(p_stTree);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_EnlevePointsDair:
xSign = -1.0f;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
case eProc_AjoutePointsDair:
stExtendDatas4Ray.xAirPoints4Ray += xSign * xAirPoints;
/* Test if Air points > Air points max*/
if ( stExtendDatas4Ray.xAirPoints4Ray > stExtendDatas4Ray.xAirPointsMax4Ray )
stExtendDatas4Ray.xAirPoints4Ray = stExtendDatas4Ray.xAirPointsMax4Ray;
else if ( stExtendDatas4Ray.xAirPoints4Ray < 0 )
stExtendDatas4Ray.xAirPoints4Ray = 0;
return(p_stTree);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_EnlevePointsDairMax:
xSign = -1.0f;
case eProc_AjoutePointsDairMax:
stExtendDatas4Ray.xAirPointsMax4Ray += xSign * xAirPoints;
if ( stExtendDatas4Ray.xAirPointsMax4Ray < 0 )
stExtendDatas4Ray.xAirPointsMax4Ray = 0;
if ( stExtendDatas4Ray.xAirPoints4Ray > stExtendDatas4Ray.xAirPointsMax4Ray )
stExtendDatas4Ray.xAirPoints4Ray = stExtendDatas4Ray.xAirPointsMax4Ray;
return(p_stTree);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
break;
}
/* Function not treated. Display a warning*/
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
/*********************************************************************
* Procedure: MagicPointsProcedure *
* *
* Use : FixePointsDeMagie( Entier Nb_Points_De_Magie ) *
* Fixe les points de magie pour Rayman (0-255) *
* *
* Use : FixePointsDeMagieMax( Entier Nb_Points_De_Magie_Max ) *
* Fixe les points de magie Max pour Rayman *
* *
* Use : AjoutePointsDeMagie( Entier Nb_Points_De_Magie ) *
* Ajoute des pts de magie aux pts de magie de Rayman *
* *
* Use : AjoutePointsDeMagieMax( Entier Nb_Points_De_Magie_Max ) *
* Ajoute des pts de magie aux pts de magie Max de Rayman *
* *
* Use : EnlevePointsDeMagie( Entier Nb_Points_De_Magie ) *
* Enleve des pts de magie aux pts de magie de Rayman *
* *
* Use : EnlevePointsDeMagieMax( Entier Nb_Points_De_Magie_Max ) *
* Enleve des pts de magie aux pts de magie Max de Rayman *
* *
* Author : Christophe Giraud *
* Date of last modification: 22/10/97 *
**********************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret *fn_p_stCode4MagicPointsProcedures(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
unsigned char iMagicPoints; /* Temporary variable to stock magic points value*/
/* Evaluation of the parameter (number of magic points)*/
M_EvalNextParameter(&stParam);
/* Get the value of the parameter*/
iMagicPoints = M_GetSetParam_ucValue(&stParam);
/* Check the AI function*/
switch(eProcedureId)
{
case eProc_InitPointsDeMagie:
case eProc_FixePointsDeMagie:
{
stExtendDatas4Ray.iMagicPoints4Ray = iMagicPoints;
return(p_stTree);
break;
}
case eProc_InitPointsDeMagieMax:
case eProc_FixePointsDeMagieMax:
{
stExtendDatas4Ray.iMagicPointsMax4Ray = iMagicPoints;
return(p_stTree);
break;
}
case eProc_AjoutePointsDeMagie:
{
stExtendDatas4Ray.iMagicPoints4Ray += iMagicPoints;
/* Test if magic points > Magic points max*/
if ( stExtendDatas4Ray.iMagicPoints4Ray > stExtendDatas4Ray.iMagicPointsMax4Ray )
{
stExtendDatas4Ray.iMagicPoints4Ray = stExtendDatas4Ray.iMagicPointsMax4Ray;
}
return(p_stTree);
break;
}
case eProc_EnlevePointsDeMagie:
{
stExtendDatas4Ray.iMagicPoints4Ray -= iMagicPoints;
/* Test if magic points < 0*/
if ( stExtendDatas4Ray.iMagicPoints4Ray < 0 )
{
stExtendDatas4Ray.iMagicPoints4Ray = 0;
}
return(p_stTree);
break;
}
case eProc_AjoutePointsDeMagieMax:
{
stExtendDatas4Ray.iMagicPointsMax4Ray += iMagicPoints;
/* Test if Number of magic points > MAXMAGICPOINTS*/
/*if ( stExtendDatas4Ray.iMagicPointsMax4Ray > C_MAXMAGICPOINTS )*/
/*{*/
/* stExtendDatas4Ray.iMagicPointsMax4Ray = C_MAXMAGICPOINTS;*/
/*}*/
return(p_stTree);
break;
}
case eProc_EnlevePointsDeMagieMax:
{
stExtendDatas4Ray.iMagicPointsMax4Ray -= iMagicPoints;
/* Test if Number of magic points Max < 0*/
if ( stExtendDatas4Ray.iMagicPointsMax4Ray < 0 )
{
stExtendDatas4Ray.iMagicPointsMax4Ray = 0;
}
return(p_stTree);
break;
}
default:
break;
}
/* Function not treated. Display a warning*/
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
/*END ANNECY }*/
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
/*ANNECY CT 14/01/98 {*/
/*********************************************************************
* Procedure: FixeLumierePersoLocal *
* *
* Use : FixeLumierePersoLocal(Perso,Local,OnlyLocal) *
* Permet de fixer les 2 flags pour une lumiere locale *
* *
* Author : Carlos Torres *
* Date of last modification: 14/01/98 *
**********************************************************************/
tdstNodeInterpret *fn_p_stSetLocalLight(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
MS_tdxHandleToMSLight hMSLight;
/* Check the AI function*/
if(eProcedureId == eProc_FixeLumierePersoLocal) {
HIE_tdxHandleToSuperObject p_SuperObjPersoTreated; /* Character Treated*/
unsigned char bLocalLight; /* Local Light -> light only the character*/
unsigned char bOnlyLocalLight; /* Only Local Light -> exclude other light to compute perso light*/
/* Evaluation of the parameter Character*/
M_EvalNextParameter(&stParam);
p_SuperObjPersoTreated=M_GetSetParam_p_stSupObjValue(&stParam);
SAF_M_AssertWithMsg(p_SuperObjPersoTreated, "l'acteur sp<73>cifi<66> est nul");
/* Evaluation of the parameter LocalLight*/
M_EvalNextParameter(&stParam);
bLocalLight = M_GetSetParam_ucValue(&stParam);
/* Evaluation of the parameter OnlyLocalLight*/
M_EvalNextParameter(&stParam);
bOnlyLocalLight = M_GetSetParam_ucValue(&stParam);
hMSLight = M_GetMSHandle(p_SuperObjPersoTreated,MSLight);
/* check if mini structure exist*/
if (!hMSLight)
return(p_stTree);
/* Light only the character*/
if (bLocalLight) {
/* remove from dyn light list*/
SECT_fn_vIsolateDNMLightsListNode(fn_hMSLightGetLightNodeInSector(hMSLight));
/* update super object struct*/
HIE_fn_vSetSuperObjectExcluLight(p_SuperObjPersoTreated,bOnlyLocalLight);
/* update Mini structure*/
fn_vMSLightSetLocalLight(hMSLight,TRUE);
fn_vMSLightSetOnlyLocalLight(hMSLight,bOnlyLocalLight);
}
else {
HIE_tdxHandleToSuperObject hSector = GAM_fn_hGetCurrentSector(p_SuperObjPersoTreated);
/* update super object struct*/
HIE_fn_vSetSuperObjectExcluLight(p_SuperObjPersoTreated, bOnlyLocalLight);
/* add in dyn light list*/
if (hSector) {
SECT_fn_vIsolateDNMLightsListNode(fn_hMSLightGetLightNodeInSector(hMSLight));
SECT_fn_vAddTailDNMLightsListNode(hSector,fn_hMSLightGetLightNodeInSector(hMSLight));
}
/* update Mini structure*/
fn_vMSLightSetLocalLight(hMSLight,FALSE);
fn_vMSLightSetOnlyLocalLight(hMSLight, bOnlyLocalLight);
}
return(p_stTree);
}
/* Function not treated. Display a warning*/
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
/*ENDANNECY CT }*/
/*ANNECY CT 22/01/98 {*/
/*********************************************************************
* Procedure: FixeLumiereStaticOnOff *
* FixeLumiereStaticNearFar *
* FixeLumiereStaticColor *
* CalculeLumiereEffet *
* *
* Use : FixeLumiereStaticOnOff(Lumiere,Booleen) *
* Permet d'allumer ou d'eteindre une lumiere *
* FixeLumiereStaticNearFar(Lumiere,Real,Real) *
* Permet de fixer les param Near et Far d'une lumiere *
* FixeLumiereStaticColor(Lumiere,Real,Real,Real,Real) *
* Permet de fixer la couleur RGBA d'une lumiere *
* CalculeLumiereEffet() *
* Recalcule l'effet de toutes les lumieres sur le monde*
* *
* Author : Carlos Torres *
* Date of last modification: 22/01/98 *
**********************************************************************/
tdstNodeInterpret *fn_p_stSetLight(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
GLI_tdxHandleToLight hLight = NULL; /* First param handle of the light*/
/* Evaluation of the parameter Light*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* XB 28/07/99 {*/
if (eProcedureId != eProc_CalculeLumiereEffet) {
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
M_EvalNextParameter(&stParam);
hLight = M_GetSetParam_LightValue(&stParam);
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* XB 28/07/99 {*/
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
switch(eProcedureId) {
case eProc_FixeLumiereStaticOnOff:
{
unsigned char bOnOff; /* Second Param True to light, false to unlight*/
/* Evaluation of the parameter OnOff*/
M_EvalNextParameter(&stParam);
bOnOff = M_GetSetParam_ucValue(&stParam);
GLI_xSetLightState(hLight,bOnOff);
return(p_stTree);
break;
}
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_FixeLumiereStaticNearFar:
{
MTH_tdxReal xNear,xFar; /* Second&Third Param Near&Far values*/
/* Evaluation of the parameter Near*/
M_EvalNextParameter(&stParam);
xNear = M_GetSetParam_xValue(&stParam);
/* Evaluation of the parameter Far*/
M_EvalNextParameter(&stParam);
xFar = M_GetSetParam_xValue(&stParam);
GLI_vSetLightNearFar(hLight,xNear,xFar);
return(p_stTree);
break;
}
case eProc_FixeLumiereStaticColor:
{
GEO_tdstColor stColor; /* Second Param color value*/
/* Evaluation of the parameter Red*/
M_EvalNextParameter(&stParam);
stColor.xR=M_GetSetParam_xValue(&stParam);
/* Evaluation of the parameter Green*/
M_EvalNextParameter(&stParam);
stColor.xG=M_GetSetParam_xValue(&stParam);
/* Evaluation of the parameter Blue*/
M_EvalNextParameter(&stParam);
stColor.xB=M_GetSetParam_xValue(&stParam);
/* Evaluation of the parameter Alpha*/
M_EvalNextParameter(&stParam);
stColor.xA=M_GetSetParam_xValue(&stParam);
GLI_xSetLightColor(hLight,&stColor);
return(p_stTree);
break;
}
case eProc_CalculeLumiereEffet:
{
/*XB*/
#if !defined(U64)
RAY_vComputeAllSector(SECT_hFatherSector);
#endif /* U64 */
/*End XB*/
return(p_stTree);
break;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
break;
}
/* Function not treated. Display a warning*/
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
/*ENDANNECY CT }*/
/* Capability procedures*/
/*
----------------------------------------------------------------------------------------
Description : *fn_p_stCapabilityProcedure
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 28/01/98
----------------------------------------------------------------------------------------
*/
tdstNodeInterpret *fn_p_stCapabilityProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
unsigned long ubf32Capabilities;
long lValue;
struct tdstEngineObject_ * hEngineObj; /* there's no "tdhEngineObject" ? ? ? ? ? ? ! ! !*/
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
hEngineObj = M_GetEngineObject(hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Caps);
#endif /* __DEBUG_AI__*/
ubf32Capabilities = (unsigned long) M_GetSetParam_CapsValue(&stParam);
switch(eProcedureId)
{
case eProc_SetCapabilities :
fn_vSetCapabilities(hEngineObj, ubf32Capabilities);
return(p_stTree);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_AddCapabilities :
fn_vAddCapabilities(hEngineObj, ubf32Capabilities);
return(p_stTree);
break;
case eProc_SubCapabilities :
fn_vSubCapabilities(hEngineObj, ubf32Capabilities);
return(p_stTree);
break;
case eProc_ChangeCapabilities :
M_EvalNextParameter(&stParam);
lValue = M_GetSetParam_lValue(&stParam) ;
fn_vChangeCapabilities(hEngineObj, ubf32Capabilities, lValue);
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_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
tdstNodeInterpret *fn_p_stReinitGraphProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
WP_tdHandleOfGraph hGraph;
tdstGetSetParam stParam;
/* Evaluation of parameters*/
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Graph);
#endif /* __DEBUG_AI__*/
hGraph = M_GetSetParam_GraphValue(&stParam) ;
WPG_fn_vReinitGraph (hGraph);
return(p_stTree);
}
/*ANNECY CT 02/02/98{*/
/*********************************************************************
* Procedure: MAT_FixeVitesseTexture *
* MAT_ScrollingOnOff *
* *
* Use : MAT_FixeVitesseTexture(GMT,Reel,Reel) *
* Fixe les composantes U,V de scrolling de textures *
* MAT_ScrollingOnOff(GMT,Booleen) *
* Permet de mettre en marche ou d'arreter le scrolling *
* Rem : La vitesse n'est pas re-initialisee *
* *
* Author : Carlos Torres *
* Modif : Fred "Bart" Compagnon *
* Date of last modification: 13/10/98 *
**********************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret *fn_p_stSetScrollSpeed(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
tdstGetSetParam stParam ; /* Structure d'<27>change*/
GMT_tdxHandleToGameMaterial hMaterial; /* first param : material to set*/
/* get material*/
M_EvalNextParameter(&stParam);
hMaterial=M_GetSetParam_hGameMaterial(&stParam);
if (eProcedureId==eProc_FixeVitesseTexture)
{
MTH_tdxReal xU,xV; /* 2nd&3th param : speed values*/
/* get speed (U,V)*/
M_EvalNextParameter(&stParam);
xU=M_GetSetParam_xValue(&stParam);
xU=MTH_M_xDiv(xU,MTH_M_xLongToReal(100));
M_EvalNextParameter(&stParam);
xV=M_GetSetParam_xValue(&stParam);
xV=MTH_M_xDiv(xV,MTH_M_xLongToReal(100));
GLI_xSetMaterialTextureScrollingCoef(GMT_fn_hGetVisualMaterial(hMaterial),0,1,xU,xV);
return (p_stTree);
}
else if (eProcedureId==eProc_ScrollingOnOff) {
unsigned char bOn;
/* get switch On/Off*/
M_EvalNextParameter(&stParam);
bOn=M_GetSetParam_ucValue(&stParam);
GLI_xSetMaterialTextureScrollingOnOff(GMT_fn_hGetVisualMaterial(hMaterial),bOn);
return (p_stTree);
}
else if (eProcedureId==eProc_FixeDecalageTexture)
{
MTH_tdxReal xU,xV; /* 2nd&3th param : speed values*/
/* get speed (U,V)*/
M_EvalNextParameter(&stParam);
xU=M_GetSetParam_xValue(&stParam);
xU=MTH_M_xDiv(xU,MTH_M_xLongToReal(100));
M_EvalNextParameter(&stParam);
xV=M_GetSetParam_xValue(&stParam);
xV=MTH_M_xDiv(xV,MTH_M_xLongToReal(100));
GLI_xSetMaterialTextureDecalage(GMT_fn_hGetVisualMaterial(hMaterial),0,2,xU,xV);
/*GLI_xSetMaterialTextureScrollingCoef(GMT_fn_hGetVisualMaterial(hMaterial),0,1,xU,xV);*/
/*GLI_xSetMaterialTextureScrollingOnOff(GMT_fn_hGetVisualMaterial(hMaterial), 2); // BART : 2 (set value)*/
return (p_stTree);
}
else if (eProcedureId==eProc_ScrollingPause) {
unsigned char bOn;
/* get switch On/Off*/
M_EvalNextParameter(&stParam);
bOn=M_GetSetParam_ucValue(&stParam);
GLI_xSetMaterialTextureScrollingOnOff(GMT_fn_hGetVisualMaterial(hMaterial), bOn?3:1); /* BART : 1 (continue scrolling) or 3 (pause at current value)*/
return (p_stTree);
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
/*ENDANNECY CT }*/
/*ANNECY JMD {*/
/**********************************************************************
* Procedure: RLI_Fixe ; RLI_Blend
* Use : RLI_Fixe ( index )
* Use : RLI_Blend (index1, index2, pourcentage)
*
* Author : Jean-Marc Drouaud
* Date of last modification: 11-02-98
**********************************************************************/
tdstNodeInterpret *fn_p_stRLIProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree){
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
MS_tdxHandleToMSLight hMSLight ;
tdstGetSetParam stParam;
long lIndex1 = -1;
long lIndex2 = -1;
long lNbRLI = -1;
long lPercent = -1;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
hMSLight = M_GetMSHandle(hNewSuperObjPerso,MSLight);
switch(eProcedureId) {
case eProc_NoRLI :
lNbRLI = 0 ;
lIndex1 = 0 ;
lIndex2 = 0 ;
lPercent = 0 ;
break ;
case eProc_FixeRLI :
lNbRLI = 1 ;
M_EvalNextParameter(&stParam);
lIndex1 = M_GetSetParam_lValue(&stParam);
lIndex2 = 0 ;
lPercent = 0 ;
break ;
case eProc_BlendRLI :
lNbRLI = 2 ;
M_EvalNextParameter(&stParam);
lIndex1 = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lIndex2 = M_GetSetParam_lValue(&stParam) ;
M_EvalNextParameter(&stParam);
lPercent = M_GetSetParam_lValue(&stParam) ;
break ;
default:
break;
}
fn_vMSLightSetRLIParameter ( hMSLight, lNbRLI, lIndex1, lIndex2, lPercent) ;
return p_stTree;
}
/*END ANNECY JMD }*/
/*ANNECY CT 17/02/98{*/
/*********************************************************************
* Procedure: ANI_ChangeFrameCourante *
* ANI_ChangeFrameAleatoire *
* *
* Use : Perso.ANI_ChangeFrameCourante(entier) *
* Fixe la frame de l'anim courante *
* Perso.ANI_ChangeFrameAleatoire() *
* Fixe une frame au hazard dans l'anim courante *
* *
* Author : Carlos Torres *
* Date of last modification: 17/02/98 *
**********************************************************************/
tdstNodeInterpret * fn_p_stManageFrame(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
tdstGetSetParam stParam ; /* Structure d'<27>change*/
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
switch(eProcedureId) {
/*ANI_ChangeFrameCourante*/
case eProc_ChangeCurrFrame :
{
short wFrame;
/* get frame*/
M_EvalNextParameter(&stParam);
wFrame = M_GetSetParam_wValue(&stParam);
;
/* the frame is bound between 0 and the number of frames. if we inadvertantly provide a frame that designates*/
/* a random frame (that value is negative), provide -1 instead so that we dont end up with a random frame*/
/* instead of frame 0, which we will get anyway for any other negative specified frame value*/
PLA_fn_vSetCurrFrame(hNewSuperObjPerso, (short) ((wFrame == PLA_C_wRandomFrame) ? -1 : wFrame));
}
return(p_stTree);
break;
/*ANI_ChangeFrameAleatoire*/
case eProc_ChangeRandomFrame :
PLA_fn_vSetCurrFrame(hNewSuperObjPerso,PLA_C_wRandomFrame);
return(p_stTree);
break;
default:
break;
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
/*ENDANNECY CT}*/
/*ANNECY JMD {*/
/**********************************************************************
* Procedure: setsurimposed
* Use : SPO_SetSuperImpose ( Xratio, Yratio, Zdepth )
*
* Author : Jean-Marc Drouaud
* Date of last modification: 24-02-98
**********************************************************************/
tdstNodeInterpret *fn_p_stSPOSuperimpoed(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
enum tdeProcedureId_ eProcedureId = M_eProcedureIdInterpret(p_stTree-1);
tdstGetSetParam stParam;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
switch ( eProcedureId )
{
case eProc_ReleaseSuperimposed:
HIE_fn_SO_vClearSuperimposedFlag(hNewSuperObjPerso);
/* when the object is removed from the second viewport, it reappears in the main character's current sector*/
fn_vSectInfoSetCurrentSector(
M_GetMSHandle(hNewSuperObjPerso,SectInfo),
fn_h_SectInfoGetCurrentSector(M_GetMSHandle(MC_fn_hGetCharacterInMainCharacterNode( MC_fn_hGetFirstMainCharNode()),SectInfo))
);
fn_vInsertObjectInSectorList(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(hNewSuperObjPerso,SectInfo)),hNewSuperObjPerso);
return p_stTree;
break;
case eProc_SetSuperimposed:
{
POS_tdstCompletePosition *hPersoGlobalMatrix ;
long lX, lY, lZ ;
MTH_tdxReal xX, xY, xZ ;
MTH3D_tdstVector stVertex;
MS_tdxHandleToDynam h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
HIE_fn_SO_vSetSuperimposedFlag(hNewSuperObjPerso);
/* objects in the second viewport do not belong to a sector*/
fn_vRemoveObjectInSectorList(hNewSuperObjPerso);
/*get the global matrix of the actor's superobject*/
hPersoGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
lX = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lY = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lZ = M_GetSetParam_lValue(&stParam);
xX = MTH_M_xDiv( MTH_M_xLongToReal(lX), MTH_M_xLongToReal(1000) ) ;
xY = MTH_M_xDiv( MTH_M_xLongToReal(lY), MTH_M_xLongToReal(1000) ) ;
xZ = MTH_M_xDiv( MTH_M_xLongToReal(lZ), MTH_M_xLongToReal(1000) ) ;
GLI_vGet3DVertexFromScreenPos(&g_stEngineStructure.stFixViewportAttr, &stVertex, xX, xY, xZ);
POS_fn_vSetTranslationVector(hPersoGlobalMatrix,&stVertex);
#ifndef U64
hPersoGlobalMatrix->ulType = 4;
hPersoGlobalMatrix->stTransformMatrix.stCol_2.xZ = hPersoGlobalMatrix->stTransformMatrix.stCol_0.xX = g_stEngineStructure.stFixViewportAttr.dwWidth / 640.0f;
#endif /* U64 */
if ( h_Dynam )
{
DNM_tdstDynamics *p_stDynamics = fn_p_stDynamGetDynamics(h_Dynam);
MEC_vInitTranslation( p_stDynamics, hNewSuperObjPerso, &stVertex ) ;
}
HIE_fn_vComputeNewRelativeMatrix(hNewSuperObjPerso);
}
return p_stTree;
break;
case eProc_SetSuperimposed2 :
{
POS_tdstCompletePosition *hPersoGlobalMatrix ;
MTH3D_tdstVector stVertex;
MS_tdxHandleToDynam h_Dynam = M_GetMSHandle(hNewSuperObjPerso,Dynam);
HIE_fn_SO_vSetSuperimposedFlag(hNewSuperObjPerso);
/* objects in the second viewport do not belong to a sector*/
fn_vRemoveObjectInSectorList(hNewSuperObjPerso);
/*get the global matrix of the actor's superobject*/
hPersoGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
stVertex.xX = M_GetSetParam_xValue(&stParam);
M_EvalNextParameter(&stParam);
stVertex.xY = M_GetSetParam_xValue(&stParam);
M_EvalNextParameter(&stParam);
stVertex.xZ = M_GetSetParam_xValue(&stParam);
POS_fn_vSetTranslationVector(hPersoGlobalMatrix,&stVertex);
hPersoGlobalMatrix->ulType = 4;
hPersoGlobalMatrix->stTransformMatrix.stCol_2.xZ = hPersoGlobalMatrix->stTransformMatrix.stCol_0.xX = g_stEngineStructure.stFixViewportAttr.dwWidth / 640.0f;
if ( h_Dynam )
{
DNM_tdstDynamics *p_stDynamics = fn_p_stDynamGetDynamics(h_Dynam);
MEC_vInitTranslation( p_stDynamics, hNewSuperObjPerso, &stVertex ) ;
}
HIE_fn_vComputeNewRelativeMatrix(hNewSuperObjPerso);
}
return p_stTree ;
break;
case eProc_SwitchSuperimposedTab :
{
long lParam ;
M_EvalNextParameter(&stParam);
lParam = M_GetSetParam_lValue(&stParam);
HIE_fn_SO_SwitchSuperImposedTab(lParam) ;
}
return (p_stTree) ;
break;
default:
break;
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
/*END ANNECY JMD }*/
/*ANNECY CT 26/02/98{*/
/**********************************************************************
* Procedure : SPO_FixeCoordonnees *
* Use : SPO_FixeCoordonnees(SPO,NewPosition) *
* *
* Author : Carlos Torres *
* Date of last modification: 26/02/98 *
**********************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret * fn_p_stSetSPOCoordinates(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcId=M_eProcedureIdInterpret(p_stTree-1);
tdstGetSetParam stParam ; /* Structure d'<27>change*/
HIE_tdxHandleToSuperObject hSpo;
MTH3D_tdstVector * p_stCoordinates;
/* get the super object*/
M_EvalNextParameter(&stParam);
hSpo=M_GetSetParam_SuperObjectValue(&stParam);
/* get the super object*/
M_EvalNextParameter(&stParam);
p_stCoordinates=&M_GetSetParam_stVectorValue(&stParam);
if (eProcId == eProc_SetSPOCoordinates) {
if (HIE_fn_bIsSuperObjectValid(hSpo))
POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectMatrix(hSpo),p_stCoordinates);
return (p_stTree);
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*ENDANNECY CT}*/
/*
----------------------------------------------------------------------------------------
Description : *fn_p_stMiscProcOnTypeOfWP
----------------------------------------------------------------------------------------
Author : Fred 'Bart#02' Compagnon
Date : 03/07/98
----------------------------------------------------------------------------------------
*/
tdstNodeInterpret *fn_p_stMiscProcOnTypeOfWP(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
long lTypeOfWP, lIndex;
WP_tdHandleOfGraph hGraph;
WP_tdhWayPoint hWayPoint;
WP_tdhGraphNode hCurrentNode, hTheNode;
long lValue;
/* Evaluation of parameters*/
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Graph);
#endif /* __DEBUG_AI__*/
hGraph = M_GetSetParam_GraphValue(&stParam) ;
/*get the waypoint to search*/
M_EvalNextParameter( &stParam );
hWayPoint = M_GetSetParam_WayPointValue(&stParam) ;
lTypeOfWP = 0L;
/*get the TypeOfWP to affect to the WP*/
M_EvalNextParameter( &stParam );
lTypeOfWP = (long)M_GetSetParam_CapsValue(&stParam);
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Integer);
#endif /* __DEBUG_AI__*/
lValue = (unsigned char) M_GetSetParam_lValue(&stParam);
/* now scan the list of connections from the current waypoint*/
lIndex = -1; /* juste pour faire plaisir <20> YLG !*/
hTheNode = (WP_tdhGraphNode)NULL;
/* looking for the starting WP :*/
LST2_M_DynamicForEachElementOf(&hGraph->m_hListOfNode, hCurrentNode, lIndex)
{
if ( hCurrentNode->m_hWayPoint == hWayPoint )
{
hTheNode = hCurrentNode;
break ;
}
}
if (lValue == 2)/* we modifie the type of all the nodes in the graph*/
{
LST2_M_DynamicForEachElementOf(&hGraph->m_hListOfNode, hCurrentNode, lIndex)
{
hCurrentNode->m_lTypeOfWP &= ~lTypeOfWP;
}
}
if (lValue == 3)/* we erase the type of all the nodes in the graph*/
{
LST2_M_DynamicForEachElementOf(&hGraph->m_hListOfNode, hCurrentNode, lIndex)
{
hCurrentNode->m_lTypeOfWP = 0;
}
}
if ( !hTheNode ) /* we did not found the waypoint in the graph*/
return(p_stTree);
switch (lValue)
{
case 0:
case 2:
hTheNode->m_lTypeOfWP |= lTypeOfWP; /* add the type*/
break;
case 1:
case 3:
hTheNode->m_lTypeOfWP = lTypeOfWP; /* change all the types field*/
break;
case 4:
hTheNode->m_lTypeOfWP &= ~lTypeOfWP;; /* sub the type*/
case 5:
hTheNode->m_lTypeOfWP = 0; /* erase all the types field*/
break;
}
return(p_stTree);
}
/*
----------------------------------------------------------------------------------------
Description : *fn_p_stTractionFactorProcedure
----------------------------------------------------------------------------------------
Author : Fred 'Bart#02' Compagnon
Date : 11/03/98
----------------------------------------------------------------------------------------
*/
tdstNodeInterpret *fn_p_stTractionFactorProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
unsigned char ucTractionFactor;
struct tdstEngineObject_ * hEngineObj; /* there's no "tdhEngineObject" ? ? ? ? ? ? ! ! !*/
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
hEngineObj = M_GetEngineObject(hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
/*M_VerifyTypeOfParamAction(&stParam, E_vt_0To255); //BUG BIZARRE : il me trouve E_vt_Integer au lieu de E_vt_0To255*/
#endif /* __DEBUG_AI__*/
ucTractionFactor = (unsigned char) M_GetSetParam_ucValue(&stParam);
switch(eProcedureId)
{
case eProc_SetTractionFactor :
fn_vStandardGameSetTractionFactor(hEngineObj->h_StandardGame, ucTractionFactor);
return(p_stTree);
break;
default:
break;
}
#if defined(__DEBUG_AI__) || (defined(U64) && defined(D_CHECK_AI_FPCO))
M_AIFatalError(E_uwAIFatalNotValidProcedure);
#endif /* __DEBUG_AI__*/
return(p_stTree);
}
/**********************************************************************
* Procedure : ACT_OrienteVersPositionAngle *
* Use : ACT_OrienteVersPositionAngle(Position,AngleMax) *
* Procedure : ACT_OrienteVersPositionVitesse *
* Use : ACT_OrienteVersPositionVitesse(Position,Vitesse) *
* *
* Author : Carlos Torres *
* Date of last modification: 10/03/98 *
* Modif : 17/06/98 bug recuperation vecteur & persoDirection - Carlos *
**********************************************************************/
tdstNodeInterpret * fn_p_stTurnToPosition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcId=M_eProcedureIdInterpret(p_stTree-1);
tdstGetSetParam stParam ; /* Structure d'<27>change*/
MTH3D_tdstVector stPosition,stLocalPosition,stPersoDirection,stCrossProd;
MTH_tdxReal xMaxAngle,xAngle;
POS_tdstCompletePosition mGlobalToPerso;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
/* get the position*/
M_EvalNextParameter(&stParam);
stPosition=M_GetSetParam_stVectorValue(&stParam);
/* get the real : AngleMax or Speed*/
M_EvalNextParameter(&stParam);
//xMaxAngle=M_GetSetParam_xValue(&stParam);
xMaxAngle=M_ReturnParam_xValue(&stParam);
xMaxAngle=MTH_M_xDegToRad(MTH_M_xAbs(xMaxAngle));
/* set matrix global to local Perso*/
POS_fn_vInvertMatrix(&mGlobalToPerso,HIE_fn_hGetSuperObjectGlobalMatrix(hNewSuperObjPerso));
/* change position to local perso coordinates*/
POS_fn_vMulMatrixVertex(&stLocalPosition,&mGlobalToPerso,&stPosition);
/*check if position is at origin*/
if (MTH3D_M_bIsNullVector(&stLocalPosition))
return (p_stTree);
MTH3D_M_vSetVectorElements(&stPersoDirection,MTH_C_ZERO,MTH_C_MinusONE,MTH_C_ZERO);
MTH3D_M_vSetZofVector(&stLocalPosition,MTH_C_ZERO);
/* compute Angle*/
xAngle=MTH3D_M_xDotProductVector(&stPersoDirection,&stLocalPosition);
xAngle/=MTH3D_M_xNormVector(&stLocalPosition);
xAngle=MTH_M_xACos(xAngle);
/* compute max angle when we have max speed*/
if (eProcId == eProc_TurnToPositionSpeed) {
xMaxAngle=MTH_M_xMul(xMaxAngle,MTH_M_xMul(g_stEngineStructure.stEngineTimer.ulUsefulDeltaTime,MTH_M_xFloatToReal(0.001f)));
}
/* maximize rotation and compute speed*/
xAngle=MTH_M_xMin(xAngle,xMaxAngle);
/* set the sign*/
MTH3D_M_vCrossProductVectorWithoutBuffer(&stCrossProd,&stPersoDirection,&stLocalPosition);
if (MTH_M_bLess(MTH3D_M_xGetZofVector(&stCrossProd),MTH_C_ZERO))
xAngle=MTH_M_xNeg(xAngle);
if (!fn_ucInternalTurn(hNewSuperObjPerso,xAngle)) {
fn_vSetProcedureActionReturn(C_ACTION_ENGINE_STOP);
}
return(p_stTree);
}
/**********************************************************************
* Procedure : ANI_GelerPerso *
* Use : [ULTRA.]ANI_GelerPerso() *
* Procedure : ANI_DegelerPerso *
* Use : [ULTRA.]ANI_DegelerPerso() *
* *
* Author : Carlos Torres *
* Date of last modification: 13/03/98 *
**********************************************************************/
//#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret * fn_p_stFreezeAnim(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
switch(eProcId)
{
/* Freeze the actor*/
case eProc_FreezeAnim :
ANI_fn_vFreeze(hNewSuperObjPerso);
return(p_stTree);
break;
/* UnFreeze the actor*/
case eProc_UnFreezeAnim :
ANI_fn_vUnFreeze(hNewSuperObjPerso);
return(p_stTree);
break;
default:
break;
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
//#endif /* _AI_EXCLUDE_NEVER_USED_ } */
/*******************************************************************
* Procedure: FAD_FixePositionFade *
* Use : FixePositionFade( IPO, X, Y, Z ) *
* Author : Christophe Giraud *
* Date of last modification: 12/03/98 *
*******************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret *fn_p_stFixePositionFade( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
HIE_tdxHandleToSuperObject hSpo;
MTH3D_tdstVector stVertex ;
MTH_tdxReal xX, xY, xZ ;
long lX, lY, lZ ;
POS_tdstCompletePosition *hPersoGlobalMatrix ;
/*XB980429*/
/* enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);*/
/*End XB*/
/* Get first parameter that is a Super object*/
M_EvalNextParameter(&stParam);
hSpo=M_GetSetParam_SuperObjectValue(&stParam);
/*get the global matrix of the actor's superobject*/
HIE_fn_SO_vSetSuperimposedFlag(hSpo) ;
/* objects in the second viewport do not belong to a sector*/
fn_vRemoveObjectInSectorList(hSpo);
hPersoGlobalMatrix = HIE_fn_hGetSuperObjectMatrix(hSpo);
M_EvalNextParameter(&stParam);
lX = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lY = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lZ = M_GetSetParam_lValue(&stParam);
xX = MTH_M_xDiv( MTH_M_xLongToReal(lX), MTH_M_xLongToReal(100) ) ;
xY = MTH_M_xDiv( MTH_M_xLongToReal(lY), MTH_M_xLongToReal(100) ) ;
xZ = MTH_M_xDiv( MTH_M_xLongToReal(lZ), MTH_M_xLongToReal(1000) ) ;
GLI_vGet3DVertexFromScreenPos ( &g_stEngineStructure.stFixViewportAttr, &stVertex, xX, xY, xZ ) ;
POS_fn_vSetTranslationVector(hPersoGlobalMatrix,&stVertex);
hPersoGlobalMatrix->ulType = 4;
hPersoGlobalMatrix->stTransformMatrix.stCol_2.xZ = hPersoGlobalMatrix->stTransformMatrix.stCol_0.xX = g_stEngineStructure.stFixViewportAttr.dwWidth / 640.0f;
return p_stTree;
}
/*ENDANNECY CG }*/
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/*******************************************************************
* Procedure: TAB_TRIE *
* Use : TAB_Trie(Tableau, NbElements, Type) *
* Type : 0: ordre decroissant, 1:ordre croissant *
* Author : Yann Le Guyader *
* Date of last modification: 24/03/98 *
*******************************************************************/
int fni_CompareIntegerLess(const void *_pv_Elem1, const void *_pv_Elem2)
{
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
long *p_lElement1 = (long *) _pv_Elem1;
long *p_lElement2 = (long *) _pv_Elem2;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* Compare */
return (*p_lElement2 < *p_lElement1) ? -1 : (*p_lElement2 == *p_lElement1) ? 0 : 1;
}
int fni_CompareIntegerGreater(const void *_pv_Elem1, const void *_pv_Elem2)
{
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
long *p_lElement1 = (long *) _pv_Elem1;
long *p_lElement2 = (long *) _pv_Elem2;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* Compare */
return (*p_lElement2 > *p_lElement1) ? -1 : (*p_lElement2 == *p_lElement1) ? 0 : 1;
}
int fni_CompareFloatGreater(const void *_pv_Elem1, const void *_pv_Elem2)
{
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
MTH_tdxReal *p_xElement1 = (MTH_tdxReal *) _pv_Elem1;
MTH_tdxReal *p_xElement2 = (MTH_tdxReal *) _pv_Elem2;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* Compare */
return (MTH_M_bGreater(*p_xElement2, *p_xElement1)) ? -1 : (MTH_M_bEqual(*p_xElement2, *p_xElement1)) ? 0 : 1;
}
int fni_CompareFloatLess(const void *_pv_Elem1, const void *_pv_Elem2)
{
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
MTH_tdxReal *p_xElement1 = (MTH_tdxReal *) _pv_Elem1;
MTH_tdxReal *p_xElement2 = (MTH_tdxReal *) _pv_Elem2;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* Compare */
return (MTH_M_bLess(*p_xElement2, *p_xElement1)) ? -1 : (MTH_M_bEqual(*p_xElement2,*p_xElement1)) ? 0 : 1;
}
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
tdstNodeInterpret *fn_p_stSortArray( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
tdstArray *p_stArray;
unsigned char ucVarId;
long lNbElements;
long lType;
int (*p_fnCompare)(const void *, const void *);
/* int iSize;*/
ucVarId = (unsigned char) M_ucVarIdInterpret(p_stTree);
p_stTree ++;
p_stArray = (tdstArray*) M_GetDsgVarAddr(AI_M_stGetMindOfSuperObj(p_SuperObjPerso),ucVarId);
M_EvalNextParameter(&stParam);
lNbElements = M_GetSetParam_lValue(&stParam);
M_EvalNextParameter(&stParam);
lType = M_GetSetParam_lValue(&stParam);
if (lNbElements > (long)p_stArray->ucMaxSize)
lNbElements = (long)p_stArray->ucMaxSize;
switch(p_stArray->eType)
{
case eDsgVarType_Integer:
{
/*iSize = sizeof(int);*/
if (lType)
p_fnCompare = fni_CompareIntegerGreater;
else
p_fnCompare = fni_CompareIntegerLess;
break;
}
case eDsgVarType_Float:
{
/*iSize = sizeof(MTH_tdxReal);*/
if (lType)
p_fnCompare = fni_CompareFloatGreater;
else
p_fnCompare = fni_CompareFloatLess;
break;
}
default :
{
return p_stTree;
break;
}
}
qsort((void *)p_stArray->d_ArrayElement, (int)lNbElements, C_SizeOfArrayElement, p_fnCompare);
return p_stTree;
}
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
/**********************************************************************
* Procedure : Option_ActiveJoystickAnalogique *
* Use : Option_ActiveJoystickAnalogique() *
* Procedure : Option_DesactiveJoystickAnalogique *
* Use : Option_DesactiveJoystickAnalogique() *
* *
* Author : Carlos Torres *
* Date of last modification: 26/03/98 *
**********************************************************************/
tdstNodeInterpret * fn_p_stActiveJoystickAnal(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcId=M_eProcedureIdInterpret(p_stTree-1);
switch(eProcId)
{
/* Activate an analogique joystick*/
case eProc_ActiveJoystickAnal :
IPT_fn_vDesactiveJoystickAndPadControl();
/* CHRISTOPHE MODIFICATION PAD ANALOGIQUE */
IPT_fn_vActiveJoystickControl();
/* END CHRISTOPHE MODIFICATION PAD ANALOGIQUE */
return(p_stTree);
break;
/* DesActivate an analogique joystick*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_UnActiveJoystickAnal :
IPT_fn_vDesactiveJoystickAndPadControl();
return(p_stTree);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
break;
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
/*******************************************************************
* Procedure: ZON_FixeTailleZDMSphere *
* Use : Perso.ZON_FixeTailleZDMSphere(ZDM,Rayon) *
* Procedure: ZON_FixeTailleZDDCone *
* Use : Perso.ZON_FixeTailleZDDCone(ZDD,Angle,Hauteur) *
* Author : Carlos Torres *
* Date of last modification: 16/04/98 *
*******************************************************************/
tdstNodeInterpret *fn_p_stSetZDxSize( HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
tdstGetSetParam stParam;
long lZoneNumber;
ACP_tdxHandleOfObject hGeoObj;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
/* Get first parameter that is a ZDx*/
M_EvalNextParameter( &stParam );
lZoneNumber = (long) M_GetSetParam_lZDMIdValue(&stParam);
/* get the zone*/
switch(eProcedureId) {
/* ZDM*/
case eProc_SetZDMSizeSphere:
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex( C_ucTypeZdm, (unsigned short)(lZoneNumber-1),hNewSuperObjPerso);
break;
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
/* ZDD*/
case eProc_SetZDDSizeCone:
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex( C_ucTypeZdd, (unsigned short)(lZoneNumber-1),hNewSuperObjPerso);
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
/* Procedure does not exist !!*/
M_AIFatalError(E_uwAIFatalNotValidProcedure);
return(p_stTree);
break;
}
/* Move geometric object*/
if( hGeoObj )
{
switch(eProcedureId)
{
/* Sphere treatment*/
case eProc_SetZDMSizeSphere:
if (*hGeoObj->d_xListOfElementsTypes == GEO_C_xElementSpheres)
{
MTH_tdxReal xRadius;
/* Get Radius and set it*/
M_EvalNextParameter( &stParam );
xRadius=M_GetSetParam_xValue(&stParam);
M_AI_DEBUG_ASSERT(MTH_M_bGreater(xRadius,MTH_C_ZERO),E_uwAIFatalInvalidParameter);
GEO_vSetRadiusOfIndexedSphere (hGeoObj,0,0,xRadius);
}
return p_stTree;
break;
/* Cone treatment*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
case eProc_SetZDDSizeCone:
if (*hGeoObj->d_xListOfElementsTypes == GEO_C_xElementCones)
{
MTH_tdxReal xAngle,xHeight,xRadius;
MTH3D_tdstVector stBasePoint,stTopPoint,stVector;
ACP_tdxIndex xBasePoint,xTopPoint;
/* Get Angle*/
M_EvalNextParameter( &stParam );
xAngle=M_GetSetParam_xValue(&stParam);
M_AI_DEBUG_ASSERT(MTH_M_bGreater(xAngle,MTH_C_ZERO)&&MTH_M_bLess(xAngle,MTH_M_xFloatToReal(90.0)),E_uwAIFatalInvalidParameter);
/* Get Height*/
M_EvalNextParameter( &stParam );
xHeight=M_GetSetParam_xValue(&stParam);
M_AI_DEBUG_ASSERT(!MTH_M_bIsNull(xHeight),E_uwAIFatalInvalidParameter);
/* get Base and Top Point*/
GEO_vGetPointsOfIndexedCone(hGeoObj,0,0,&xBasePoint,&xTopPoint);
GEO_vGetPointOfObject(hGeoObj,&stBasePoint,xBasePoint);
GEO_vGetPointOfObject(hGeoObj,&stTopPoint,xTopPoint);
/* compute vector*/
MTH3D_M_vSubVector(&stVector,&stBasePoint,&stTopPoint);
MTH3D_M_vNormalizeVector(&stVector,&stVector);
MTH3D_M_vMulScalarVector(&stVector,xHeight,&stVector);
/* !! Base is supposed on 0,0,0 and cone placed at top point*/
/* !! so move is reversed*/
/* move base to move top*/
if (MTH_M_bGreater(xHeight,MTH_C_ZERO))
{
MTH3D_M_vAddVector(&stBasePoint,&stTopPoint,&stVector);
GEO_vSetPointOfObject(hGeoObj,&stBasePoint,xBasePoint);
}
/* move top to move base*/
else
{
MTH3D_M_vAddVector(&stTopPoint,&stBasePoint,&stVector);
GEO_vSetPointOfObject(hGeoObj,&stTopPoint,xTopPoint );
}
/* compute radius and set it*/
xRadius=MTH_M_xMul(MTH_M_xAbs(xHeight),MTH_M_xTan(MTH_M_xDegToRad(xAngle)));
GEO_vSetRadiusOfIndexedCone(hGeoObj,0,0,xRadius);
}
return p_stTree;
break;
#endif /* _AI_EXCLUDE_NEVER_USED_ }*/
default:
break;
}
}
return(p_stTree);
}
/**********************************************************************
* Procedure : [ULTRA.]SON_FixeAnimVolume *
* Use : [ULTRA.]SON_FixeAnimVolume(Entier) *
* Procedure : SON_FixeMusicVolume *
* Use : SON_FixeMusicVolume(Entier) *
* Procedure : SON_FixeAmbianceVolume *
* Use : SON_FixeAmbianceVolume(Entier) *
* *
* Author : Carlos Torres *
* Date of last modification: 23/07/98 *
* 12/01/99 : add SON_FixeAmbianceVolume *
**********************************************************************/
tdstNodeInterpret * fn_p_stSetSoundVolume(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcId = M_eProcedureIdInterpret(p_stTree-1);
long lVolume;
tdstGetSetParam stParam;
switch ( eProcId )
{
/* Change the volume of sound launch by an object*/
case eProc_SetSoundVolumeAnim :
{
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
/* Get the volume*/
M_EvalNextParameter(&stParam);
lVolume = M_GetSetParam_lValue(&stParam);
/* volume must be in the intervall [0;127]*/
M_AI_DEBUG_ASSERT((lVolume>=0) && (lVolume<128),E_uwAIFatalInvalidParameter);
SND_fn_vChangeVolumeSound((long )hNewSuperObjPerso,g_lSoundObjectTypeAnim,lVolume);
}
return(p_stTree);
break;
/* Change the volume of music launch by an object*/
case eProc_SetSoundVolumeMusic :
/* Get the volume*/
M_EvalNextParameter(&stParam);
lVolume = M_GetSetParam_lValue(&stParam);
/* volume must be in the intervall [0;127]*/
M_AI_DEBUG_ASSERT((lVolume>=0) && (lVolume<128),E_uwAIFatalInvalidParameter);
SND_fn_vChangeVolumeSound((long)SND_C_OBJET_FANTOME,g_lSoundObjectTypeMusic,lVolume);
return(p_stTree);
break;
/* Change the volume of Ambiance sound*/
case eProc_SetSoundVolumeAmbiance :
/* Get the volume*/
M_EvalNextParameter(&stParam);
lVolume = M_GetSetParam_lValue(&stParam);
/* volume must be in the intervall [0;127]*/
M_AI_DEBUG_ASSERT((lVolume>=0) && (lVolume<128),E_uwAIFatalInvalidParameter);
SND_fn_vChangeVolumeSound((long)SND_C_OBJET_FANTOME,g_lSoundObjectTypeAnim,lVolume);
return(p_stTree);
break;
default:
break;
}
M_AIFatalError(E_uwAIFatalNotValidFunction);
return(p_stTree);
}
/**********************************************************************
* Procedure : SON_ChangeEffetDoppler *
* Use : SON_ChangeEffetDoppler(Reel) *
* *
* Author : Carlos Torres - 07/09/98 *
**********************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret * fn_p_stSetDopplerEffect(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
/*long lVolume;*/
tdstGetSetParam stParam;
MTH_tdxReal xDoppler;
/* Get Doppler Value*/
M_EvalNextParameter(&stParam);
xDoppler = M_GetSetParam_xValue(&stParam);
SND_fn_vSetDopplerFactorSound(M_DoubleToRealSnd(xDoppler));
return(p_stTree);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
/**********************************************************************
* Procedure : SON_Pause SON_Reprendre *
* Procedure : SON_ArretSonMenu *
* Use : SON_Pause() *
* Use : SON_Reprendre() *
* Use : SON_ArretSonMenu() *
* *
* Author : Carlos Torres - 03/11/98 *
**********************************************************************/
tdstNodeInterpret * fn_p_stPauseSound(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
enum tdeProcedureId_ eProcId = M_eProcedureIdInterpret(p_stTree-1);
switch(eProcId)
{
case eProc_PauseSound :
SND_fn_vPauseSound();
break;
case eProc_ResumeSound :
SND_fn_vResumeSound();
break;
case eProc_StopMenuSound :
SND_fn_vKillAllObjectTypeSound(g_lSoundObjectTypeMenu);
break;
/* Oliv' - Portage v15 - IL FAUT TOUJOURS METTRE UN DEFAULT POUR EVITER LES WARNINGS. merci*/
default:
break;
/* EndOfOliv'*/
}
return(p_stTree);
}
/********************************************************
* Procedure : DEM_JoueDemo *
* Use : DEM_JoueDemo (name of the map, name of the demo file, VRAI if the demo can be interrupt
* when pressing a button, FALSE otherwise, name of the map to load once the demo is finished)
* *
* Author : Alexis VAISSE - September 15, 1998 *
********************************************************/
#ifndef U64
tdstNodeInterpret * fn_p_stPlayDemo (HIE_tdxHandleToSuperObject p_SuperObjPerso , tdstNodeInterpret * p_stTree)
{
tdstGetSetParam stParam;
char szMapName [40];
char * szDemoFileName;
BOOL bTestInput;
char szNextMapName [40];
char szDemoCompleteFileName [40];
char * p_cDelimiter;
char * p_cNextMapName;
long lSubMapNumber;
char * p_cMapName;
long lCurrentSubMapNumber;
/* Get the name of the map for the demo ("*" means the current map)*/
M_EvalNextParameter (& stParam);
p_cMapName = fn_szGetStringFromTextOrStringParam (& stParam);
lCurrentSubMapNumber = fn_lGetSubMapNumber ();
/* map name */
if (*p_cMapName == '*')
{
/* same level*/
strcpy (szMapName , fn_p_szGetLevelName ());
/* submap number ????? */
p_cDelimiter = strchr (p_cMapName , '$');
if ((p_cDelimiter == 0) || (*(p_cDelimiter+1) == '*')) lSubMapNumber = lCurrentSubMapNumber;
else lSubMapNumber = atol(p_cDelimiter+1);
}
else
{
/* explicit level*/
strcpy (szMapName , p_cMapName);
/* submap number ????? */
p_cDelimiter = strchr (szMapName , '$');
if (p_cDelimiter == 0) lSubMapNumber = 0;
else
{
*p_cDelimiter = 0;
if (*(p_cDelimiter+1) == '*') lSubMapNumber = lCurrentSubMapNumber;
else lSubMapNumber = atol(p_cDelimiter+1);
}
}
/* Get the name of the demo file*/
M_EvalNextParameter (& stParam);
szDemoFileName = fn_szGetStringFromTextOrStringParam (& stParam);
/* Do we have to test the input ?*/
M_EvalNextParameter (& stParam);
bTestInput = M_GetSetParam_ucValue (& stParam);
/* Get the name of the name to load once the demo is finished ("*" mean the current map)*/
M_EvalNextParameter (& stParam);
p_cNextMapName = fn_szGetStringFromTextOrStringParam (& stParam);
if (*p_cNextMapName == '*')
{
/* same level*/
/* submap number ????? */
p_cDelimiter = strchr (p_cNextMapName , '$');
if ((p_cDelimiter == 0) || (*(p_cDelimiter+1) == '*'))
{
if(lCurrentSubMapNumber)
sprintf (szNextMapName , "%s$%02d" , fn_p_szGetLevelName () , lCurrentSubMapNumber);
else
strcpy (szNextMapName , fn_p_szGetLevelName ());
}
else
sprintf (szNextMapName , "%s%s" , fn_p_szGetLevelName () , p_cDelimiter);
}
else
{
/* explicit level*/
strcpy (szNextMapName , p_cNextMapName);
/* submap number ????? */
p_cDelimiter = strchr (szNextMapName , '$');
if ((p_cDelimiter != 0) && (*(p_cDelimiter+1) == '*'))
{
if (lCurrentSubMapNumber) sprintf (p_cDelimiter+1 , "%02d" , lCurrentSubMapNumber);
else *p_cDelimiter = 0;
}
}
/* If the map for the demo is not the current map, we load it*/
if ( (stricmp (szMapName , fn_p_szGetLevelName ())) || (lSubMapNumber != lCurrentSubMapNumber) )
{
char szName [40];
if(lSubMapNumber)
sprintf (szName , "%s$%02d" , szMapName , lSubMapNumber);
else
strcpy (szName , szMapName);
/* when loading a demo, we always save the current level's status */
GAM_fn_vAskToChangeLevel (szName, TRUE);
}
/* Load the demo*/
if (lSubMapNumber == 0)
sprintf (szDemoCompleteFileName , "Demos\\%s\\%s" , szMapName , szDemoFileName);
else
sprintf (szDemoCompleteFileName , "Demos\\%s\\%02d\\%s" , szMapName , lSubMapNumber , szDemoFileName);
DEMO_fn_vLoadFromFile (szDemoCompleteFileName);
/* Set the demo options*/
DEMO_fn_vSetTestInputDuringDemo (bTestInput);
DEMO_fn_vSetMapToLoadWhenDemoFinished (szNextMapName);
/* Launch the demo*/
DEMO_fn_vPrepareForRead (2); /* Wait 2 frames before launching the demo*/
return p_stTree;
}
#else
extern char g_szMapNameToLoadWhenDemoFinished[20];
/*HP 981105*/
tdstNodeInterpret * fn_p_stPlayDemo (HIE_tdxHandleToSuperObject p_SuperObjPerso , tdstNodeInterpret * p_stTree)
{
tdstGetSetParam stParam;
/* XB 05/05/99 */
/* char szMapName [40]; */
/* End XB 05/05/99 */
/* BOOL bTestInput; - Oliv' - Portage v15*/
/* char szNextMapName [40]; - Oliv' - Portage v15*/
/* char szDemoCompleteFileName [40]; - Oliv' - Portage v15*/
char * p_cNextMapName;
char * p_cMapName;
/* Get the name of the map for the demo ("*" means the current map)*/
M_EvalNextParameter (& stParam);
p_cMapName = M_GetSetParam_szString (& stParam);
/* Get the name of the demo file*/
M_EvalNextParameter (& stParam);
/* Do we have to test the input ?*/
M_EvalNextParameter (& stParam);
/* bTestInput = M_GetSetParam_ucValue(& stParam);*/
/* Get the name of the name to load once the demo is finished ("*" mean the current map)*/
M_EvalNextParameter (& stParam);
p_cNextMapName = M_GetSetParam_szString (& stParam);
// if (*p_cNextMapName == '*')
strcpy(g_szMapNameToLoadWhenDemoFinished,fn_p_szGetLevelName ());
// else
// strcpy(g_szMapNameToLoadWhenDemoFinished, p_cNextMapName);
/* map name */
/* if (*p_cMapName == '*')
{
/* /*same level*/
/* fn_vReinitTheMap();
}
else
{
/* explicit level*/
/* strcpy (szMapName , p_cMapName);
GAM_fn_vAskToChangeLevel(szMapName);
}*/
INO_fn_vU64PlayDemo();
fn_vSwitchToDemoLevel();
/* DEMO_fn_vPrepareForRead (2); // Wait 2 frames before launching the demo*/
return p_stTree;
}
#endif
/********************************************************
* Procedure : ACT_FixeLimiteEloignement *
* Use : ACT_FixeLimiteEloignement (Value) *
* *
* Author : Marc TRABUCATO 22/10/98 *
********************************************************/
tdstNodeInterpret *fn_p_stSetTooFarLimit(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
long lValue;
struct tdstEngineObject_ * hEngineObj;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
hEngineObj = M_GetEngineObject(hNewSuperObjPerso);
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Integer);
#endif /* __DEBUG_AI__*/
lValue = M_GetSetParam_lValue(&stParam);
if(hEngineObj && hEngineObj->h_StandardGame)
{
fn_vStandardGameSetTooFarLimit(hEngineObj->h_StandardGame,(unsigned char)lValue);
}
return(p_stTree);
}
/************************************************************
* Procedure : ACT_FixeZoneTransparence *
* Use : ACT_FixeZoneTransparence(ValueMin,ValueMax) *
* *
* Author : Marc TRABUCATO 22/10/98 *
************************************************************/
tdstNodeInterpret *fn_p_stSetTransparencyZone(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
tdstGetSetParam stParam;
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
long lValueMin,lValueMax;
struct tdstEngineObject_ * hEngineObj;
/********************************************************************************/
/* BEWARE THE ULTRA OPERATOR : Must be at the beginning and respect this syntax */
/********************************************************************************/
HIE_tdxHandleToSuperObject hNewSuperObjPerso;
fn_vGetUltraOperatorPerso(fn_ucGetProcedureUltraOperator(eProcedureId),p_SuperObjPerso,&hNewSuperObjPerso);
/********************************************************************************/
hEngineObj = M_GetEngineObject(hNewSuperObjPerso);
/* Get Min Value*/
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Integer);
#endif /* __DEBUG_AI__*/
lValueMin = M_GetSetParam_lValue(&stParam);
/* Get Max Value*/
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Integer);
#endif /* __DEBUG_AI__*/
lValueMax = M_GetSetParam_lValue(&stParam);
#if defined(__DEBUG_AI__)
M_AI_DEBUG_ASSERT((lValueMin>=0) && (lValueMin<=lValueMin) && (lValueMax<=255),E_uwAIFatalInvalidParameter);
#endif /* __DEBUG_AI__*/
if(hEngineObj && hEngineObj->h_StandardGame)
{
fn_vStandardGameSetTransparencyZoneMin(hEngineObj->h_StandardGame,(unsigned char)lValueMin);
fn_vStandardGameSetTransparencyZoneMax(hEngineObj->h_StandardGame,(unsigned char)lValueMax);
}
return(p_stTree);
}
/************************************************************
* Procedure : Effet_SetBaseFrequenceForMenu (reel base)
* Use :
*
* Author : Jean-Marc Drouaud 30/11/98
************************************************************/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT 08/06/99 { */
tdstNodeInterpret *fn_p_stBaseFrequenceForMenu(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
tdstGetSetParam stParam;
M_EvalNextParameter(&stParam);
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(&stParam, E_vt_Float);
#endif /* __DEBUG_AI__*/
GLI_vSetSinEffetBase (M_GetSetParam_xValue(&stParam)) ;
return(p_stTree);
}
#endif /* _AI_EXCLUDE_NEVER_USED_ } */
/************************************************************
* Procedure : Effet_SaveSinusContext ()
* Use :
*
* Author : Jean-Marc Drouaud 01/12/98
************************************************************/
tdstNodeInterpret *fn_p_stSaveSinusEffectContext(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree) {
enum tdeProcedureId_ eProcedureId=M_eProcedureIdInterpret(p_stTree-1);
if ( eProcedureId == eProc_SaveSinusContext) {
GLI_vSaveSinusContext () ;
}
else {
GLI_vRestoreSinusContext () ;
}
return(p_stTree);
}