@Override
	public boolean okMessage(Environmental host, CMMsg msg)
	{
		if((!(host instanceof PhysicalAgent))||(msg.source()==null)||(recurseCounter.get()>2))
			return true;

		try 
		{
			// atomic recurse counter
			recurseCounter.addAndGet(1);
	
			final PhysicalAgent affecting = (PhysicalAgent)host;
	
			final List<DVector> scripts=getScripts();
			DVector script=null;
			boolean tryIt=false;
			String trigger=null;
			String[] t=null;
			int triggerCode=0;
			String str=null;
			for(int v=0;v<scripts.size();v++)
			{
				tryIt=false;
				script=scripts.get(v);
				if(script.size()<1)
					continue;
	
				trigger=((String)script.elementAt(0,1)).toUpperCase().trim();
				t=(String[])script.elementAt(0,2);
				triggerCode=getTriggerCode(trigger,t);
				switch(triggerCode)
				{
				case 42: // cnclmsg_prog
					if(canTrigger(42))
					{
						if(t==null)
							t=parseBits(script,0,"CCT");
						if(t!=null)
						{
							final String command=t[1];
							boolean chk=false;
							final int x=command.indexOf('=');
							if(x>0)
							{
								chk=true;
								boolean minorOnly = false;
								boolean majorOnly = false;
								for(int i=0;i<x;i++)
								{
									switch(command.charAt(i))
									{
									case 'S':
										if(majorOnly)
											chk=chk&&msg.isSourceMajor(command.substring(x+1)); 
										else
										if(minorOnly)
											chk=chk&&msg.isSourceMinor(command.substring(x+1)); 
										else
											chk=chk&&msg.isSource(command.substring(x+1)); 
										break;
									case 'T': 
										if(majorOnly)
											chk=chk&&msg.isTargetMajor(command.substring(x+1)); 
										else
										if(minorOnly)
											chk=chk&&msg.isTargetMinor(command.substring(x+1)); 
										else
											chk=chk&&msg.isTarget(command.substring(x+1)); 
										break;
									case 'O': 
										if(majorOnly)
											chk=chk&&msg.isOthersMajor(command.substring(x+1)); 
										else
										if(minorOnly)
											chk=chk&&msg.isOthersMinor(command.substring(x+1)); 
										else
											chk=chk&&msg.isOthers(command.substring(x+1)); 
										break;
									case '<':
										minorOnly=true;
										majorOnly=false;
										break;
									case '>':
										majorOnly=true;
										minorOnly=false;
										break;
									case '?':
										majorOnly=false;
										minorOnly=false;
										break;
									default: 
										chk=false; 
										break;
									}
								}
							}
							else
							if(command.startsWith(">"))
							{
								String cmd=command.substring(1);
								chk=msg.isSourceMajor(cmd)||msg.isTargetMajor(cmd)||msg.isOthersMajor(cmd);
							}
							else
							if(command.startsWith("<"))
							{
								String cmd=command.substring(1);
								chk=msg.isSourceMinor(cmd)||msg.isTargetMinor(cmd)||msg.isOthersMinor(cmd);
							}
							else
							if(command.startsWith("?"))
							{
								String cmd=command.substring(1);
								chk=msg.isSource(cmd)||msg.isTarget(cmd)||msg.isOthers(cmd);
							}
							else
								chk=msg.isSource(command)||msg.isTarget(command)||msg.isOthers(command);
							if(chk)
							{
								str="";
								if((msg.source().session()!=null)&&(msg.source().session().getPreviousCMD()!=null))
									str=" "+CMParms.combine(msg.source().session().getPreviousCMD(),0).toUpperCase()+" ";
								if((t[2].length()==0)||(t[2].equals("ALL")))
									tryIt=true;
								else
								if((t[2].equals("P"))&&(t.length>3))
								{
									if(match(str.trim(),t[3]))
										tryIt=true;
								}
								else
								for(int i=2;i<t.length;i++)
								{
									if(str.indexOf(" "+t[i]+" ")>=0)
									{
										str=(t[i].trim()+" "+str.trim()).trim();
										tryIt=true;
										break;
									}
								}
							}
						}
					}
					break;
				}
				if(tryIt)
				{
					final MOB monster=getMakeMOB(affecting);
					if(lastKnownLocation==null)
						lastKnownLocation=msg.source().location();
					if((monster==null)||(monster.amDead())||(lastKnownLocation==null))
						return true;
					final Item defaultItem=(affecting instanceof Item)?(Item)affecting:null;
					Item Tool=null;
					if(msg.tool() instanceof Item)
						Tool=(Item)msg.tool();
					if(Tool==null)
						Tool=defaultItem;
					String resp=null;
					if(msg.target() instanceof MOB)
						resp=execute(affecting,msg.source(),msg.target(),monster,Tool,defaultItem,script,str,newObjs());
					else
					if(msg.target() instanceof Item)
						resp=execute(affecting,msg.source(),msg.target(),monster,Tool,(Item)msg.target(),script,str,newObjs());
					else
						resp=execute(affecting,msg.source(),msg.target(),monster,Tool,defaultItem,script,str,newObjs());
					if((resp!=null)&&(resp.equalsIgnoreCase("CANCEL")))
						return false;
				}
			}
		}
		finally 
		{ 
			recurseCounter.addAndGet(-1); 
		}
		return true;
	}