Aller au contenu

Photo

Discussion of Conversation Object on death scripts


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I have lots of conversations that fire off of the OnDeath events of NPCs in my upcoming module. I want to make sure that the object that is starting the conversation is not dead and not a dominated, summoned, or henchman, animal companion, or familiar type object.  Here is the code I use to do that:



object oKiller=GetLastKiller();
object oLeader = GetFactionLeader(oKiller);


while ((GetIsDead(oLeader))||
  (GetAssociateType(oLeader)!=ASSOCIATE_TYPE_NONE))
 {
 oLeader=GetNextFactionMember(oKiller,FALSE);
 }


Are there any thoughts or comments on how to improve this? 

#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages

void main()
{
object oKiller=GetLastKiller();

if ( GetIsWhatever( oKiller ) )
{
	return; // if it's whatever, bail out as its one of the criteria you want to avoid
}
// Do your convo here

// no idea why faction leader and GetNextFactionMember
// get faction members ( TRUE parameter does PC only, FALSE includes NPC's and associates )
// but this would on the death of whoever, run the code "do something towards them" on entire party that is not disabled or henchmen 
object oFacMem = GetFirstFactionMember(oKiller, TRUE);	
while(GetIsObjectValid(oFacMem))
{
  if ( GetIsWhatever(oFacMem ) )
{
   // do something towards them
}
  oFacMem = GetNextFactionMember(oKiller, TRUE); // can only use AFTER GetFirstFactionMember
}



put these at the top of the script or in a library ( CSLGetIsIncapacitated is in _CSLCore_Info.nss )



int CSLGetIsIncapacitated(object oCreature, int bImmobilized = FALSE,  int bCheckCharmed = FALSE, int bCheckBlindness = FALSE, int bCheckCognizant = TRUE, int bCheckFallen = TRUE, int bCheckParalyzed = TRUE)
{
	if ( GetIsDead( oCreature ) ) { return TRUE; }
	if ( GetCurrentHitPoints(oCreature) < 1 ) { return TRUE; }
	
	if ( bCheckFallen && GetLocalInt( oCreature, "CSL_KNOCKDOWN" ) ) { return TRUE; }
	
	effect eEffect;
	eEffect = GetFirstEffect(oCreature);
	while (GetIsEffectValid(eEffect))
	{
		if (
			bCheckParalyzed && (
			GetEffectType(eEffect) == EFFECT_TYPE_PARALYZE ||
			GetEffectType(eEffect) == EFFECT_TYPE_CUTSCENE_PARALYZE ||
			GetEffectType(eEffect) == EFFECT_TYPE_TIMESTOP  )
		)
		{ 
			return TRUE;
		}
		
		if ( bCheckCognizant && ( 
			GetEffectType(eEffect) == EFFECT_TYPE_CONFUSED ||
			GetEffectType(eEffect) == EFFECT_TYPE_DAZED ||
			GetEffectType(eEffect) == EFFECT_TYPE_FRIGHTENED ||
			GetEffectType(eEffect) == EFFECT_TYPE_INSANE ||
			GetEffectType(eEffect) == EFFECT_TYPE_MESMERIZE ||
			GetEffectType(eEffect) == EFFECT_TYPE_PETRIFY ||
			GetEffectType(eEffect) == EFFECT_TYPE_SLEEP ||
			GetEffectType(eEffect) == EFFECT_TYPE_STUNNED
			 )
		)
		{ 
			return TRUE;
		}
		
		
		if ( bCheckBlindness && ( GetEffectType(eEffect) == EFFECT_TYPE_BLINDNESS ) )
		{
			return TRUE;
		}
		
		if ( bImmobilized && ( GetEffectType(eEffect) == EFFECT_TYPE_ENTANGLE || GetEffectType(eEffect) == EFFECT_TYPE_CUTSCENEIMMOBILIZE || GetLocalInt( oCreature, "CSL_KNOCKDOWN" ) ) )
		{
			return TRUE;
		}
		
		if ( bCheckCharmed && ( GetEffectType(eEffect) == EFFECT_TYPE_CHARMED || ( GetEffectType(eEffect) == EFFECT_TYPE_DOMINATED && !GetLocalInt( oCreature, "SCSummon" ) ) ) )
		{
			return TRUE;
		}
		eEffect = GetNextEffect(oCreature);
	}
	return FALSE;
}


int GetIsWhatever( object oAssoc )
{
	if ( GetIsDead( oAssoc ) )
	{
		return FALSE;
	}

	// catches those bleeding out and almost dead
	if ( GetCurrentHitPoints(oAssoc) < 1 )
	{
		return FALSE;
	}

	// this is probably not needed, but will support AI variables properly this way
	int nPlot = GetLocalInt(oAssoc, "NW_ASSOCIATE_MASTER");
	if ( nPlot & 0x00010000 ) // CSL_ASC_MODE_DYING
	{
		return FALSE;
	}
	
	
	// makes sure they are not a familiar, henchman, summon, etc.
	if ( GetAssociateType( oAssoc ) != ASSOCIATE_TYPE_NONE )
	{
		return FALSE;
	}
	
	
	
	// catches anything that makes them out of control
	if ( CSLGetIsIncapacitated(oAssoc, TRUE  TRUE, FALSE, TRUE, FALSE, TRUE) )
	{
		return FALSE;
	}
	
	return TRUE;


}