Really odd thing happening with two almost identical scripts

So, as I’m working on my new sci fi themed module I have a situation where a robot enters a trigger, says a line, there’s a sound, and then it attacks the party. I have two triggers for this to make sure this situation happens.

Now, here’s the odd thing. If the robot enters its trigger, everything works exactly Iike I intended. However, if the PC enters the other trigger, everything happens as it should EXCEPT the robot doesn’t say its line. Why is that? Here are the two scripts. First the one with the robot entering his trigger, and the second is where the line isn’t spoken, where the PC enters another trigger:

#include "ginc_actions"

//In this script everything works as it's intended

void main()
{

object oEnter = GetEnteringObject();
object oRobot = GetObjectByTag("l_robot");
object oPC = GetFirstPC();
object oDoor = GetObjectByTag("doorprroom");

if(!GetGlobalInt("freefromprison")) return;

if(IsInConversation(oPC)) return;

if(oEnter!=oRobot) return;

if(GetGlobalInt("DoneDroid")) return;

SetGlobalInt("DoneDroid",1);

SetLocked(oDoor,FALSE);


object oIP = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ", GetLocation(oPC));
								//	do not remove this space	^ 	
	string sWave = "robotvoice";	// <--- sound file name

	DelayCommand(0.2f, AssignCommand(oIP, PlaySound(sWave, TRUE)));	
	SetPlotFlag(oIP, FALSE);
	DestroyObject(oIP, 0.3f);
	
AssignCommand(oRobot,SpeakString("Alert! Prisoners escaping!"));	

DelayCommand(0.5, AssignCommand(oPC,SpeakString("Appears the hacking didn't last very long.")));

StandardAttack(oRobot, oPC);

}
#include "ginc_actions"

//In this script the line with AssignCommand(oRobot,SpeakString("Alert! Prisoners escaping!")); doesn't happen

void main()
{

object oEnter = GetEnteringObject();
object oRobot = GetObjectByTag("l_robot");
object oPC = GetFirstPC();
object oDoor = GetObjectByTag("doorprroom");

if(!GetGlobalInt("freefromprison")) return;

if(IsInConversation(oPC)) return;

if(oEnter!=oPC) return;

if(GetGlobalInt("DoneDroid")) return;

SetGlobalInt("DoneDroid",1);

SetLocked(oDoor,FALSE);


object oIP = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ", GetLocation(oPC));
								//	do not remove this space	^ 	
	string sWave = "robotvoice";	// <--- sound file name

	DelayCommand(0.2f, AssignCommand(oIP, PlaySound(sWave, TRUE)));	
	SetPlotFlag(oIP, FALSE);
	DestroyObject(oIP, 0.3f);
	
AssignCommand(oRobot,SpeakString("Alert! Prisoners escaping!"));	

DelayCommand(0.5, AssignCommand(oPC,SpeakString("Appears the hacking didn't last very long.")));

StandardAttack(oRobot, oPC);

}

It might be a distance related issue. If the robot is too far away, you won’t see what it’s speaking.
Try adding a volume parameter like so:

AssignCommand(oRobot,SpeakString("Alert! Prisoners escaping!", TALKVOLUME_SHOUT));
1 Like

@travus - Thanks, I’ll try that. The trigger is a bit far away from the robot when this happens actually, so it sounds logical. But, I thought it would be visible in the chat window even if the distance is long. Well, I’ll try this.

EDIT: Yep, that made it work. Thanks, @travus!

1 Like