6.2 KiB
title, type, weight
| title | type | weight |
|---|---|---|
| Commandes NPC | docs | 5 |
Le système NPC inclut 23 commandes admin et debug pour gérer et tester les NPCs.
Package: com.hypixel.hytale.server.npc.commands
Commandes de Spawn
/npc spawn
Fait apparaître un NPC à une position :
/npc spawn <npc_type> [position] [--role <role>] [--name <name>]
Arguments :
| Argument | Type | Description |
|---|---|---|
npc_type |
String | ID d'asset NPC |
position |
Position | Position de spawn (défaut: position du joueur) |
--role |
String | Remplacer le rôle par défaut |
--name |
String | Nom d'affichage personnalisé |
Exemples :
/npc spawn villager
/npc spawn guard ~ ~1 ~ --role patrol_guard
/npc spawn merchant --name "Bob le Marchand"
/npc despawn
Supprime un NPC :
/npc despawn <target>
Arguments :
| Argument | Type | Description |
|---|---|---|
target |
NPC | NPC cible (raycast ou sélecteur) |
/npc despawnall
Supprime tous les NPCs dans un rayon :
/npc despawnall [radius]
Arguments :
| Argument | Type | Description |
|---|---|---|
radius |
Float | Rayon en blocs (défaut: 50) |
Commandes d'Information
/npc info
Affiche les informations d'un NPC :
/npc info [target]
Sortie :
NPC Info: Villageois (villager_001)
Position: 100.5, 64.0, -200.3
Role: villager_role
State: IDLE
Health: 100/100
Target: None
Current Instruction: Wander
/npc list
Liste tous les NPCs :
/npc list [--radius <radius>] [--type <type>]
Arguments :
| Argument | Type | Description |
|---|---|---|
--radius |
Float | Rayon de recherche |
--type |
String | Filtrer par type de NPC |
/npc debug
Active/désactive la visualisation debug :
/npc debug <mode>
Modes :
| Mode | Description |
|---|---|
path |
Afficher le pathfinding |
sensors |
Afficher les portées des capteurs |
state |
Afficher l'état IA |
target |
Afficher le ciblage |
all |
Tout afficher |
off |
Désactiver le debug |
Commandes de Comportement
/npc role
Change le rôle du NPC :
/npc role <target> <role>
Exemples :
/npc role @nearest guard_role
/npc role @e[type=villager] merchant_role
/npc state
Force l'état du NPC :
/npc state <target> <state>
États :
/npc state @nearest IDLE
/npc state @nearest ATTACKING
/npc state @nearest FLEEING
/npc target
Définit la cible du NPC :
/npc target <npc> <target_entity>
Exemples :
/npc target @nearest @p
/npc target guard_01 @e[type=zombie,limit=1]
/npc cleartarget
Efface la cible du NPC :
/npc cleartarget <target>
Commandes de Mouvement
/npc moveto
Ordonne au NPC de se déplacer vers une position :
/npc moveto <target> <position>
Exemples :
/npc moveto @nearest ~ ~ ~10
/npc moveto guard_01 100 64 -200
/npc follow
Ordonne au NPC de suivre une entité :
/npc follow <npc> <target> [distance]
Exemples :
/npc follow @nearest @p 3.0
/npc stop
Arrête le mouvement du NPC :
/npc stop <target>
/npc patrol
Définit un chemin de patrouille :
/npc patrol <target> <point1> <point2> [point3...]
Exemples :
/npc patrol guard_01 0 64 0 10 64 0 10 64 10 0 64 10
/npc home
Définit la position d'origine du NPC :
/npc home <target> [position]
Commandes Blackboard
/npc blackboard get
Obtient une valeur du blackboard :
/npc blackboard get <target> <key>
Exemples :
/npc blackboard get @nearest alert_level
/npc blackboard get guard_01 home_position
/npc blackboard set
Définit une valeur du blackboard :
/npc blackboard set <target> <key> <value>
Exemples :
/npc blackboard set @nearest alert_level 1.0
/npc blackboard set @nearest is_hostile true
/npc blackboard clear
Efface le blackboard :
/npc blackboard clear <target> [key]
Commandes IA
/npc think
Force un cycle de décision IA :
/npc think <target>
/npc instruction
Force une instruction :
/npc instruction <target> <instruction>
Exemples :
/npc instruction @nearest flee
/npc instruction guard_01 attack
/npc sensor
Active/désactive un capteur :
/npc sensor <target> <sensor> <enabled>
Exemples :
/npc sensor @nearest visual false
/npc sensor @nearest audio true
Commandes de Faction
/npc faction
Définit la faction du NPC :
/npc faction <target> <faction>
Exemples :
/npc faction @nearest town_guard
/npc faction villager_01 merchants
/npc relation
Définit la relation entre factions :
/npc relation <faction1> <faction2> <relation>
Relations : ALLIED, FRIENDLY, NEUTRAL, UNFRIENDLY, HOSTILE
Exemples :
/npc relation guards bandits HOSTILE
/npc relation merchants town_guard ALLIED
Permissions des Commandes
| Commande | Permission |
|---|---|
/npc spawn |
hytale.command.npc.spawn |
/npc despawn |
hytale.command.npc.despawn |
/npc info |
hytale.command.npc.info |
/npc debug |
hytale.command.npc.debug |
/npc role |
hytale.command.npc.role |
/npc blackboard |
hytale.command.npc.blackboard |
Enregistrer des Commandes NPC Personnalisées
public class MyNPCCommand extends AbstractCommand {
public MyNPCCommand() {
super("npc custom", "Commande NPC personnalisée");
withRequiredArg("target", "NPC cible", ArgTypes.NPC_REF);
}
@Override
protected CompletableFuture<Void> execute(CommandContext ctx) {
NPCEntity npc = ctx.get("target");
// Logique personnalisée
return null;
}
}
// Enregistrer dans le setup du plugin
getCommandRegistry().register(new MyNPCCommand());
Bonnes Pratiques
{{< callout type="info" >}} Directives des Commandes :
- Utilisez des sélecteurs comme
@nearestpour cibler les NPCs - Les commandes debug sont précieuses pour tester l'IA
- Les commandes blackboard permettent la modification du comportement à l'exécution
- Utilisez les vérifications de permissions pour les commandes admin {{< /callout >}}