This page is no longer up-to-date since qmax left without letting us know about his status.
ahuillet did part of what is suggested here already (linked lists, hit_enemy(), etc.),
and he rewrote a large part of the code.
This page is kept here for historical purposes.
Refactoring enemy code aims:
- gather all code affecting droids state and behaviour in single file (enemy.c)
- separate simulation/animation/physics code from behaviour control code
- optimize droids lookup, probably with per-level linked lists
the enemy-related code scattered all over the sources
below is list of files to change and cross-references enemy.
- >>
- means function call
- R
- accessing structure field
- W
- modifying structure fields
- I
- iterating throug AllAnemys?, with denoted method
main.c:
main:
> MoveEnemys? ();
init.c:
clear_out_arrays_for_fresh_game
> ClearEnemys? ( ) ;
PrepareStartOfNewCharacter?
> ShuffleEnemys?( i );
ThouArtDefeated?
> MoveEnemys? ();
ThouHastWon?
> MoveEnemys? ();
automap.c:
show_automap_data_sdl:
R: (Status, type, is_friendly, pos)
I: Enemy bot = &AllEnemys?[i];
bullet.c:
MoveActiveSpells?
> DamageEnemy?
I: Enemy bot = &AllEnemys?[j];
handle_flash_effects
I: Enemy bot = &AllEnemys?[j];
check_bullet_enemy_collisions
> DamageEnemy?
I: Enemy bot = &AllEnemys?[j];
CheckBlastCollisions?
I: Enemy bot = &AllEnemys?[j];
influ.c:
UpdateMouseMoveTargetAccordingToEnemy?
R: Status, pos, is_friendly,
check_tux_enemy_collision
R: Status, type, pos, purewait
W: pos, purewait
I: Enemy bot = &AllEnemys?[i];
GetLivingDroidBelowMouseCursor?
R: Status, pos, animation_phase
PerformTuxAttackRaw?
> DamageEnemy?
I: Enemy bot = &AllEnemys?[i];
check_for_droids_to_attack_or_talk_with
R: is_friendly,
handle_player_examine_command
R: dialog_section_name, type
handle_player_talk_command
R: type, is_friendly
handle_player_firstaid_command
R: type, is_friendly, energy
W: energy
character.c:
InitiateNewCharacter?
> ShuffleEnemys?( Me .pos.z );
chat.c:
ExecuteChatExtra?
W: is_friendly, combat_state, energy, CompletelyFixed?, follow_tux
I: AllEnemys?[i]
PrepareMultipleChoiceDialog?
R: type
ProcessThisChatOption?
R: is_friendly
DoChatFromChatRosterData?
R: combat_state
W: combat_state, persuing_given_course, has_greeted_influencer
DialogPartnersTurnToEachOther?
R: pos
W: speed, current_angle
ChatWithFriendlyDroid?
R: dialog_section_name
create_and_blit_droid_description
R: short_description_text, energy, type, pos, is_friendly
light.c:
update_light_list
R: Status, pos
map.c:
respawn_level
R: pos, type, stick_to_waypoint_system_by_default
W: energy, Status, phase, animation_phase, animation_type, is_friendly, combat_state, has_greeted_influencer, state_timeout
I: Enemy bot = &AllEnemys?[i];
CountNumberOfDroidsOnShip?
R: type
I: AllEnemys?[i].type
ReviveAllDroidsOnShip?
R: type, stick_to_waypoint_system_by_default
W: energy, Status, has_greeted_influencer, combat_state, state_timeout, animation_phase, ammo_left
I: Enemy bot = &AllEnemys?[i];
GetThisLevelsSpecialForces?
R: Status, CompletelyFixed?, marker, max_distance_to_home, is_friendly
W: pos, will_rush_tux, dialog_section_name, short_description_text, attack_run_only_when_direct_line
type, pos, Status, SpecialForce?, stick_to_waypoint_system_by_default
I: AllEnemys?[ FreeAllEnemysPosition? ].*;
GetThisLevelsDroids?
R: Status
W: type, pos, Status, on_death_drop_item_code, ammo_left, stick_to_waypoint_system_by_default,
dialog_section_name, short_description_text
I: AllEnemys? [ FreeAllEnemysPosition? ]
MoveLevelDoors?
R: Status,pos
GetCrew?
> ClearEnemys? ();
mission.c:
CheckIfMissionIsComplete?
R: Status, energy, marker, is_friendly, pos, type
I: AllEnemys?[Robot_Counter]
skills.c:
DoSkill?
R: is_friendly, type
W: energy
sound_effects.c:
play_death_sound_for_bot
R: type
takeover.c:
Takeover
R: type, energy, maxenergy, on_death_drop_item_code, pos, stick_to_waypoint_system_by_default
W: energy, is_friendly, has_been_taken_over, combat_state, marker
text.c:
R: is_friendly
W: TextVisibleTime?, TextToBeDisplayed?
view.c:
R: Status, pos, energy, is_friendly, virt_pos
set_rotation_index_for_this_robot
W: last_phase_change, previous_phase
ThisEnemyNeedsToBeBlitted?
> MakeSureEnemyIsInsideHisLevel? ( &(AllEnemys?[Enum] ) ) );
ShowCombatScreenTexts?:
I: AllEnemys? [ k ]
insert_enemies_into_blitting_list:
I: ThisRobot? = & ( AllEnemys? [ i ] ) ;
menu.c:
Cheatmenu:
I: &AllEnemys?[i];
misc.c:
Armageddon:
I:AllEnemys?[i].energy = -10;
saveloadgame.c:
LoadGame?:
W: memcpy( &(AllEnemys?) , EnemyRawDataPointer? , sizeof ( enemy ) * MAX_ENEMYS_ON_SHIP );
>><<