void OpticDrawEnvelopes( PLOT *plot, SYSTEM *system, int style, int axis, double unit ) { int n, state, do_surface, complete ; OPTIC *optic ; ENSEMBLE *view ; if( OpticUpdate( system ) ) IOerror( IO_ERR, "OpticDrawEnvelopes", "system is not ready to trace" ) ; OpticPositions( system ) ; /* set coordinates */ do_surface = 1 ; for( view = system->view ; view ; view = view->next ) { optic = &( system->optic[ view->surface ] ) ; /* * Determine if this surface is shown at all * */ if( optic->terms[TERM_MARK].v == OpticDrawStart ) do_surface = 1 ; if( optic->terms[TERM_MARK].v == OpticDrawEnd ) do_surface = 0 ; if( !do_surface ) continue ; state = complete = 0 ; for( n = 0 ; n < view->N ; n++ ) { if( view->ray[n].state ) { if( state ) PathEnd(0) ; state = 0 ; } else { if( !state ) { state = 1 ; PathStart( plot, style, axis, unit ) ; if( n == 0 ) complete = 1 ; } PathDraw3( optic, Q(view->ray+n) ) ; } } if( state ) { if( complete ) PathDraw3( optic, Q(view->ray) ) ; PathEnd(0) ; } } }
bool ReCalculatePath(int NpcIndex) { bool retval = false; /* '*************************************************** */ /* 'Author: Unknown */ /* 'Last Modification: - */ /* 'Returns true if we have to seek a new path */ /* '*************************************************** */ if (Npclist[NpcIndex].PFINFO.PathLenght == 0) { retval = true; } else if (UserNear(NpcIndex) && PathEnd(NpcIndex)) { retval = true; } return retval; }
static void OpticDrawRays0( PLOT *plot, SYSTEM *system, int style, int axis, double unit, ENSEMBLE *start ) { int n, N, state, mark ; OPTIC *opt ; ENSEMBLE *view ; PlotComment( plot, "Entering OpticDrawRays0" ) ; for( view = start ; view ; view = view->next ) { if( view->alt ) OpticDrawRays0( plot, system, style, axis, unit, view->alt ) ; } N = start->N ; for( n = 0 ; n < N ; n++ ) { state = 0 ; mark = 1 ; for( view = start ; view ; view = view->next ) { opt = &( system->optic[ view->surface ] ) ; if( opt->terms[TERM_MARK].v == OpticDrawStart ) mark = 1 ; if( opt->terms[TERM_MARK].v == OpticDrawEnd ) { if( state ) PathEnd(0) ; state = 0 ; mark = 0 ; } if( !mark ) continue ; if( opt->function & FUNCTION_BAFFLE ) { if( view->ray[n].state && state ) { PathDraw3( opt, Q(view->ray+n) ) ; PathEnd(0) ; state = 0 ; } continue ; } if( view->ray[n].state ) { if( state ) { PathDraw3( opt, Q(view->ray+n) ) ; PathEnd(0) ; } state = 0 ; } else { if( !state ) { state = 1 ; PathStart( plot, style, axis, unit ) ; } PathDraw3( opt, Q(view->ray+n) ) ; } } if( state ) PathEnd(0) ; state = 0 ; } }
void NPCAI(int NpcIndex) { /* '************************************************************** */ /* 'Author: Unknown */ /* 'Last Modify by: ZaMa */ /* 'Last Modify Date: 15/11/2009 */ /* '08/16/2008: MarKoxX - Now pets that do mel� attacks have to be near the enemy to attack. */ /* '15/11/2009: ZaMa - Implementacion de npc objetos ai. */ /* '************************************************************** */ /* '<<<<<<<<<<< Ataques >>>>>>>>>>>>>>>> */ if (Npclist[NpcIndex].MaestroUser == 0) { /* 'Busca a alguien para atacar */ /* '�Es un guardia? */ if (Npclist[NpcIndex].NPCtype == eNPCType_GuardiaReal) { GuardiasAI(NpcIndex, false); } else if (Npclist[NpcIndex].NPCtype == eNPCType_Guardiascaos) { GuardiasAI(NpcIndex, true); } else if (Npclist[NpcIndex].Hostile && Npclist[NpcIndex].Stats.Alineacion != 0) { HostilMalvadoAI(NpcIndex); } else if (Npclist[NpcIndex].Hostile && Npclist[NpcIndex].Stats.Alineacion == 0) { HostilBuenoAI(NpcIndex); } } else { /* 'Evitamos que ataque a su amo, a menos */ /* 'que el amo lo ataque. */ /* 'Call HostilBuenoAI(NpcIndex) */ } /* '<<<<<<<<<<<Movimiento>>>>>>>>>>>>>>>> */ switch (Npclist[NpcIndex].Movement) { case TipoAI_MueveAlAzar: if (Npclist[NpcIndex].flags.Inmovilizado == 1) { return; } if (Npclist[NpcIndex].NPCtype == eNPCType_GuardiaReal) { if (RandomNumber(1, 12) == 3) { MoveNPCChar(NpcIndex, vb6::CByte( RandomNumber(eHeading_NORTH, eHeading_WEST))); } PersigueCriminal(NpcIndex); } else if (Npclist[NpcIndex].NPCtype == eNPCType_Guardiascaos) { if (RandomNumber(1, 12) == 3) { MoveNPCChar(NpcIndex, vb6::CByte( RandomNumber(eHeading_NORTH, eHeading_WEST))); } PersigueCiudadano(NpcIndex); } else { if (RandomNumber(1, 12) == 3) { MoveNPCChar(NpcIndex, vb6::CByte( RandomNumber(eHeading_NORTH, eHeading_WEST))); } } /* 'Va hacia el usuario cercano */ break; case TipoAI_NpcMaloAtacaUsersBuenos: IrUsuarioCercano(NpcIndex); /* 'Va hacia el usuario que lo ataco(FOLLOW) */ break; case TipoAI_NPCDEFENSA: SeguirAgresor(NpcIndex); /* 'Persigue criminales */ break; case TipoAI_GuardiasAtacanCriminales: PersigueCriminal(NpcIndex); break; case TipoAI_SigueAmo: if (Npclist[NpcIndex].flags.Inmovilizado == 1) { return; } SeguirAmo(NpcIndex); if (RandomNumber(1, 12) == 3) { MoveNPCChar(NpcIndex, vb6::CByte(RandomNumber(eHeading_NORTH, eHeading_WEST))); } break; case TipoAI_NpcAtacaNpc: AiNpcAtacaNpc(NpcIndex); break; case TipoAI_NpcObjeto: AiNpcObjeto(NpcIndex); break; case TipoAI_NpcPathfinding: if (Npclist[NpcIndex].flags.Inmovilizado == 1) { return; } if (ReCalculatePath(NpcIndex)) { PathFindingAI(NpcIndex); /* 'Existe el camino? */ /* 'Si no existe nos movemos al azar */ if (Npclist[NpcIndex].PFINFO.NoPath) { /* 'Move randomly */ MoveNPCChar(NpcIndex, RandomNumber(eHeading_NORTH, eHeading_WEST)); } } else { if (!PathEnd(NpcIndex)) { FollowPath(NpcIndex); } else { Npclist[NpcIndex].PFINFO.PathLenght = 0; } } break; default: break; } return; }