100 likes | 228 Vues
This project outlines the transformation of the Vortigaunt NPC from a friendly ally to a chaotic monster that violently attacks players. The aim is to create a custom NPC using advanced AI systems alongside a robust damage system. Key challenges include navigating complex AI hierarchy and addressing latent constraints. The new Vortigaunt will feature ranged and melee attacks while maintaining its original healing abilities for the player. The damage inflicted on players will be filtered to ensure a balanced gameplay experience, with custom schedules implemented to trigger attacks based on player detection.
E N D
Mutant Monster Vortigaunt Ming Yang
Outline • Goal: • Crazy monster: vortigaunt • Custom NPC • Sub-system of AI • NPC vortigaunt • Damage system • Demo
Goal • To implement a crazy monster that attacks the player violently. • To implement a custom NPC based on custom modeling.
Challenges • The AI and NPC systems are huge. • The functionalities are distributed in the class hierarchy tree. Some latent constraints are hard to find.
Results • Convert the friendly ally monster vortigaunt into a crazy killer. • Create a custom NPC npc_cube based on Zach’s modeling (why it cannot think?)
NPC vortigaunt • Capable of range attack and melee attack, a loyal friend of the player that attacks the player’s enemy and heal the player. • Set the player to be the enemy of vortigaunt is forbidden. • The damage of vortigaunt’s attack to the player will be filtered.
Custom schedule • Detect the player and trigger the attack • Add modules in SelectSchedule(). • Implement 2 kinds of custom schedules: • SCHED_VORTIGAUNT_MELEE_ATTACK_PLAYER • SCHED_VORTIGAUNT_RANGE_DODGE
Damage System • Class CTakeDamageInfo wraps the damage info including the attacker, damage, damage force, damage position et al. • Attacker generates CTakeDamageInfo objects and calls the victim’s TakeDamage() to send the damage and the victim responses it in OnTakeDamage().
Damage filter • The damage sent to the player will be filtered in • CBasePlayer::TraceAttack • CBasePlayer::OnTakeDamage • CHL2_Player::PassesDamageFilter • CTeamplayRules will test if the attacker is teammate or ally. • g_pGameRules->FPlayerCanTakeDamage • CTeamplayRules::FPlayerCanTakeDamage
Demo • Run run_mod.bat • Test the npc with console commands: • Npc_create npc_vortigaunt • Npc_create npc_cube