Certain creatures like mi-go’s or cyborgs have “Parrot” as a special attack, where they spout randomly selected lines. Is it possible to actually have some of these lines trigger more “intelligently” or based on context?
Ex. certain lines are only “parroted” upon the creature attacking, fleeing, getting hurt, killing an enemy, spotting an enemy, etc. Lines that do not require context, however, will still follow vanilla “parrot” behavior.
I know Mi-gos are just repeating whatever they hear like they’re supposed to, but I’m using “parrot” as a special attack for humanoid enemies to give them dialogue, so they’re more “human” when it comes to them being talkative.
Anything needs clarification about this question, let me know. Might not have articulated this well, and I apologize.
Don’t NPC’s already have this function? I mean if a player has a friendly NPC nearby it’ll call their wounds out to the player.
I haven’t played from the Feb. 28th version on, so I don’t know if they added lines for being hurt and such, but so far I’ve noticed Mi-gos just do whatever they want whenever they want, and just scream any line they’re programmed to.
(Fun Fact: Mi-Gos are annoying in the fact that they can actually replicate the report of a gun, making sleeping all that more annoying in a lab).
NPCs having context sensitive statements is the result of my going through the NPC AI code and adding a lot of context sensitive speech.
The parrot() special attack is a randomly chosen special attack that chooses a random bit of speech to parrot. If you wanted it to be context sensitive, you’d have to change a fair bit of logic in monmove.cpp. I haven’t really looked at monmove.cpp, so I can’t say more than that.
The monmove.cpp is all about creature turns like walking and attacking.
Somewhere at the monmove.cpp
bool monster::attack_at( const tripoint &p )
{
if( p.z != posz() ) {
return false; // TODO: Remove this
}
if( p == g->u.pos() ) {
melee_attack( g->u );
return true;
}
if( const auto mon_ = g->critter_at<monster>( p, is_hallucination() ) ) {
monster &mon = *mon_;
// Don't attack yourself.
if( &mon == this ) {
return false;
}
// With no melee dice, we can't attack, but we had to process until here
// because hallucinations require no melee dice to destroy.
if( type->melee_dice <= 0 ) {
return false;
}
auto attitude = attitude_to( mon );
// MF_ATTACKMON == hulk behavior, whack everything in your way
if( attitude == A_HOSTILE || has_flag( MF_ATTACKMON ) ) {
melee_attack( mon );
return true;
}
return false;
}
npc *const guy = g->critter_at<npc>( p );
if( guy && type->melee_dice > 0 ) {
// For now we're always attacking NPCs that are getting into our
// way. This is consistent with how it worked previously, but
// later on not hitting allied NPCs would be cool.
melee_attack( *guy );
return true;
}
// Nothing to attack.
return false;
}
Yes, CPPs are hardcoded codes and are not modifiable with simple jsoning method.