diff options
Diffstat (limited to 'src/modules')
| -rwxr-xr-x | src/modules/modAI.c | 25 | ||||
| -rwxr-xr-x | src/modules/modTeleport.c | 18 |
2 files changed, 27 insertions, 16 deletions
diff --git a/src/modules/modAI.c b/src/modules/modAI.c index 105b410..ccd444a 100755 --- a/src/modules/modAI.c +++ b/src/modules/modAI.c @@ -137,15 +137,15 @@ int draw(int x, int y, int w, int h) } #endif -tux_t *findOtherTux(list_t *list) +tux_t *findOtherTux(space_t *space) { int i; - for( i = 0 ; i < list->count ; i++ ) + for( i = 0 ; i < getSpaceCount(space) ; i++ ) { tux_t *thisTux; - thisTux = list->list[i]; + thisTux = getItemFromSpace(space, i); if( thisTux->control != TUX_CONTROL_AI ) { @@ -191,7 +191,7 @@ static void shotTux(arena_t *arena, tux_t *tux_ai, tux_t *tux_rival) } } -static void eventTux(tux_t *tux) +static void eventTuxAI(tux_t *tux) { arena_t *arena; tux_t *rivalTux; @@ -218,7 +218,7 @@ static void eventTux(tux_t *tux) arena = export_fce->fce_getCurrentArena(); - rivalTux = findOtherTux(arena->spaceTux->list); + rivalTux = findOtherTux(arena->spaceTux); if( rivalTux == NULL || rivalTux->status != TUX_STATUS_ALIVE ) { @@ -340,13 +340,22 @@ static void eventTux(tux_t *tux) */ } +static void action_tuxAI(space_t *space, tux_t *tux, void *p) +{ + if( tux->control == TUX_CONTROL_AI && + tux->status == TUX_STATUS_ALIVE ) + { + eventTuxAI(tux); + } +} + int event() { static my_time_t lastEvent = 0; my_time_t curentTime; arena_t *arena; int countTuxAI; - int i; + //int i; if( lastEvent == 0 ) { @@ -372,6 +381,8 @@ int event() countTuxAI = 0; + actionSpace(arena->spaceTux, action_tuxAI, NULL); +/* for( i = 0 ; i < arena->spaceTux->list->count ; i++ ) { tux_t *thisTux; @@ -385,7 +396,7 @@ int event() countTuxAI = 0; } } - +*/ return 0; } diff --git a/src/modules/modTeleport.c b/src/modules/modTeleport.c index 3dafd77..0ce27bf 100755 --- a/src/modules/modTeleport.c +++ b/src/modules/modTeleport.c @@ -159,15 +159,15 @@ static void cmd_teleport(char *line) addObjectToSpace(spaceTeleport, new); } -static teleport_t* getRandomTeleportBut(list_t *list, teleport_t *teleport) +static teleport_t* getRandomTeleportBut(space_t *space, teleport_t *teleport) { - int x; + int index; do{ - x = random() % list->count; - }while( list->list[x] == teleport ); + index = random() % getSpaceCount(space); + }while( getItemFromSpace(space, index) == teleport ); - return (teleport_t *) list->list[x]; + return (teleport_t *) getItemFromSpace(space, index); } static int getRandomPosition() @@ -202,16 +202,16 @@ static void teleportTux(tux_t *tux, teleport_t *teleport) return; } - distTeleport = getRandomTeleportBut(spaceTeleport->list, teleport); + distTeleport = getRandomTeleportBut(spaceTeleport, teleport); fce_move_tux(tux, distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h); } -static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, list_t *list) +static void moveShotFromTeleport(shot_t *shot, teleport_t *teleport, space_t *space) { teleport_t *distTeleport; - distTeleport = getRandomTeleportBut(list, teleport); + distTeleport = getRandomTeleportBut(space, teleport); fce_move_shot(shot, getRandomPosition(), teleport->x, teleport->y, distTeleport->x, distTeleport->y, distTeleport->w, distTeleport->h); @@ -277,7 +277,7 @@ static void action_eventteleportshot(space_t *space, teleport_t *teleport, shot_ return; } - moveShotFromTeleport(shot, teleport, spaceTeleport->list); + moveShotFromTeleport(shot, teleport, spaceTeleport); } static void action_eventshot(space_t *space, shot_t *shot, space_t *spaceTeleport) |