> cat /wizhelp/wizcoding3
> _
======================================================================== Wizard Coding 3: Creating NPCs ======================================================================== Bring your areas to life with NPCs. BASIC HOSTILE NPC: ed tutorial/guard.py ```python from lib.models.entity import NPC def load(): """Create a guard NPC.""" guard = NPC( name="castle guard", description="A stern guard in shining armor.", short_description="A guard stands here watchfully.", max_hp=800, weapon_class=40, armor_class=30, level=15 ) # Make hostile guard.aggressive = True guard.pursues = True return guard ``` FRIENDLY NPC WITH DIALOGUE: ed tutorial/merchant.py ```python from lib.models.entity import NPC class Merchant(NPC): def __init__(self): super().__init__( name="friendly merchant", description="A jolly merchant with many wares.", short_description="A merchant smiles at you.", max_hp=500, level=10 ) self.aggressive = False def on_greet(self, player): """Called when player enters.""" player.message(f"{self.name} says: Welcome, {player.name}!") def load(): return Merchant() ``` TESTING NPCS: load tutorial/guard kill guard # Test combat load tutorial/merchant look merchant # Examine NPC PROPERTIES: - aggressive: Attacks on sight - pursues: Follows fleeing players - wanders: Moves randomly - max_hp: Hit points - weapon_class: Attack power - armor_class: Defense ========================================================================
> _