示例#1
0
protected func Initialize() 
{ 
  // Zufällige Größe
  if (Random(5))
    DoCon(-Random(20) - 40);
  else
    DoCon(-Random(50) - 20);
  // Zufällige Form  
  SetAction("Grass");
  SetPhase(Random(2));
  if (!Random(20)) SetPhase(2);
  // Zufällige Richtung
  if (Random(2)) SetDir(DIR_Right);
  // Drehung nach Erdoberfläche
  var x_off = 18 * GetCon() / 100;
  var y_off = 15 * GetCon() / 100;
  var slope = GetSolidOffset(-x_off, y_off) - GetSolidOffset(x_off, y_off);
  SetR(slope);
  // Höhe anpassen
  while (!GBackSolid(0, 5))
    SetPosition(GetX(), GetY() + 1);
  // Gras bleibt hinter Bäumen
  MoveBehindTrees();
  ScheduleCall(0, "ListenToTime", 1);
}
示例#2
0
void CTelnetView::OnTextInput(const gchar* text)
{
	gsize l;
	gchar* _text = NULL;
	/* UAO input support */
	switch (m_UAO) {
		case 2:
			_text = uao250_u2b(text, strlen(text), &l);
			break;
		case 1:
			_text = uao241_u2b(text, strlen(text), &l);
			break;
		default:
			_text = g_convert(text, strlen(text), GetCon()->m_Site.m_Encoding.c_str(), "UTF-8", NULL, &l, NULL);
			break;
	}
	if( _text )
	{
		((CTelnetCon*)m_pTermData)->Send(_text, l);
		g_free(_text);
	}
	// clear the old selection
	// Workaround FIXME please
	if (!m_pTermData->m_Sel->Empty())
	{
		GdkEventButton t_PseudoEvent;
		t_PseudoEvent.x = 0;
		t_PseudoEvent.y = 0;
		t_PseudoEvent.type = GDK_BUTTON_PRESS;
		CTermView::OnLButtonDown(&t_PseudoEvent);
		CTermView::OnLButtonUp(&t_PseudoEvent);
	}
}
示例#3
0
文件: gpio.cpp 项目: gandy555/MTM_V3
void CGpio::SetAF(GPIO_GROUP group, int num, GPIO_AF af)
{
	volatile ULONG *pCON = (volatile ULONG *)GetCon(group);

	if(pCON == NULL) return;

	*pCON &= ~GPIO_AF2(num, 3);
	*pCON |= GPIO_AF2(num, af);
}
示例#4
0
func EnergyCheck()
{
	if(GetCon() < 100) return;
	
	// consuming - everything is alright
	if(GetEffect("ConsumePower", this))
		return true;
	// producing - nothing to change either
	if(GetEffect("ProducePower", this))
		return true;
	
	// neutral compensators don't do anything
	if(GetOwner() == NO_OWNER) return false;
	
	// are we needed?
	if(power_seconds > 0)
	{
		var s = GetPendingPowerAmount();
		if(s > 0)
		{
			// turn on, start the machines!
			AddEffect("ProducePower", this, 1, 36, this);
			return true;
		}
	}
	
	// fully charged
	if(power_seconds >= Compensator_max_seconds)
		return false;
	
	// can we leech power?
	var p = GetCurrentPowerBalance();
	
	// we have some play here?
	if(p >= Compensator_power_usage)
	{
		MakePowerConsumer(Compensator_power_usage);
		return true;
	}
	
	return false;
}
示例#5
0
global func FxPotionSupplyTimer(pTarget)
{
  if(!Random(50) || GetCon(pTarget) !=100) return();
	var i,p;
	for(i=0; i<ObjectCount(0,0,0,0,0,0,0,0,pTarget); ++i)
	{
		if(Contents(i, pTarget)->~IsPotion()) p++;
	}
	if(p>3) return(0);
  var rnd=Random(8);
  if(!rnd--) if(!FindContents(PFIR, pTarget)) CreateContents(PFIR, pTarget);
  if(!rnd--) if(!FindContents(PFIS, pTarget)) CreateContents(PFIS, pTarget);
  if(!rnd--) if(!FindContents(PHEA, pTarget)) CreateContents(PHEA, pTarget);
  if(!rnd--) if(!FindContents(PIMM, pTarget)) CreateContents(PIMM, pTarget);
  if(!rnd--) if(!FindContents(PMAN, pTarget)) CreateContents(PMAN, pTarget);
  if(!rnd--) if(!FindContents(PMON, pTarget)) CreateContents(PMON, pTarget);
  if(!rnd--) if(!FindContents(PSTO, pTarget)) CreateContents(PSTO, pTarget);
  if(!rnd--) if(!FindContents(PWIP, pTarget)) CreateContents(PWIP, pTarget);
  return(1);
}  
void CTelnetView::OnTextInput(const gchar* text)
{
	gsize l;
	gchar* _text = g_convert(text, strlen(text), GetCon()->m_Site.m_Encoding.c_str(), "UTF-8", NULL, &l, NULL);
	if( _text )
	{
		((CTelnetCon*)m_pTermData)->Send(_text, l);
		g_free(_text);
	}
	// clear the old selection
	// Workaround FIXME please
	if (!m_pTermData->m_Sel->Empty())
	{
		GdkEventButton t_PseudoEvent;
		t_PseudoEvent.x = 0;
		t_PseudoEvent.y = 0;
		t_PseudoEvent.type = GDK_BUTTON_PRESS;
		CTermView::OnLButtonDown(&t_PseudoEvent);
		CTermView::OnLButtonUp(&t_PseudoEvent);
	}
}
示例#7
0
文件: Script.c 项目: ev1313/gze
func SetGrowthStage() {
	if (growth >= 170) {
		SetCon(100 - (growth*3 - 340));
		if (GetCon() < 10) RemoveObject();
	} else {
		SetCon(Min(100, growth));
	}
	
	if (growth <= 90) {
		// go from hue 80 to hue 60  with con 0 - 90
		
		// turn number 0-90 into 0-20
		var huediff = (growth * 10) / 45;
		
		SetColorDw(HSL(80 - huediff, 250, 128));
	}
	if (growth > 90 && growth < 100) {
		// go from hue 60 to hue 0  within con 90-100
	
		// turn 90-100 into 0-10 into 0-60
		var huediff = (growth - 90) * 6;
		
		SetColorDw(HSL(60 - huediff, 250, 128));
	}
	if (growth >= 100 && growth <= 140) {
		SetColorDw(HSL(0, 250, 128));
	}

	if (growth > 120 && GetCategory() == 1) {
		Drop();
	}
	
	if (growth > 140) {
		var chng = growth - 140;
		SetColorDw(HSL(chng/2, 250 - chng, 128 - chng/2));
	}
}
示例#8
0
文件: Script.c 项目: Fulgen301/SGGP
func Effect()
{
  if(target)
  {
   if(!target->IsBusy())
   {
    return(1);
   }
  }
  if(GetMaterial(0,-20) == Material("Water"))
  {
   return(1);
  }
  if(GetCon() != 100)
  {
   return(1);
  }
//  if (type == 0)
//  {
	  CreateParticle("Fire", RandomX(-2, 2) - 34, -13, 0, RandomX(-6, -12), RandomX(40, 60), RGBa(255, RandomX(224, 255), 0, 128));
	  CreateParticle("Fire2", RandomX(-2, 2) - 34, -13, 0, RandomX(-8, -14), RandomX(40, 60), RGBa(255, 255, 255, 64));

	  CreateParticle("Fire", RandomX(-2, 2) + 10, -13, 0, RandomX(-6, -12), RandomX(40, 60), RGBa(255, RandomX(224, 255), 0, 128));
	  CreateParticle("Fire2", RandomX(-2, 2) + 10, -13, 0, RandomX(-8, -14), RandomX(40, 60), RGBa(255, 255, 255, 64));
	  return(1);
//  }
//  if (type == 1)
//  {
//	  CreateParticle("Fire", RandomX(-2, 2) - 34, -13, 0, RandomX(-6, -12), RandomX(40, 60), RGBa(0, RandomX(224, 255), 255, 128));
//	  CreateParticle("Fire2", RandomX(-2, 2) - 34, -13, 0, RandomX(-8, -14), RandomX(40, 60), RGBa(255, 255, 255, 64));
//
//	  CreateParticle("Fire", RandomX(-2, 2) + 10, -13, 0, RandomX(-6, -12), RandomX(40, 60), RGBa(0, RandomX(224, 255), 255, 128));
//	  CreateParticle("Fire2", RandomX(-2, 2) + 10, -13, 0, RandomX(-8, -14), RandomX(40, 60), RGBa(255, 255, 255, 64));
//	  return(1);
//  }
}
示例#9
0
func Decaying()
{
	if (GetCon()<20) RemoveObject(); else DoCon(-5);
	return true;
}
示例#10
0
文件: Object.c 项目: 772/openclonk
// Sets the completion of this to new_con.
global func SetCon(int new_con, int precision, bool grow_from_center)
{
	return DoCon(new_con - GetCon(), precision, grow_from_center);
}
示例#11
0
global func GetFloorY(object pObj) {
	return GetY(pObj) + (GetCon(pObj)*GetDefHeight(GetID(pObj)))/200;
}
示例#12
0
protected func Construction() {
	if(GetCon() < 100)
		SetCon(100);
}
示例#13
0
// Initially placed trees are smaller
func Initialize(...)
{
	SetCon(GetCon() / 2);
	return _inherited(...);
}
示例#14
0
// Yield 1-2 extra wood
func Split2Components(...)
{
	CreateContents(Wood);
	if (GetCon() > 25) CreateContents(Wood);
	return inherited(...);
}
示例#15
0
bool CTelnetView::OnKeyDown(GdkEventKey* evt)
{
	INFO("CTelnetView::OnKeyDown (keyval=0x%x, state=0x%x)", evt->keyval, evt->state);
	CTermCharAttr* pAttr = m_pTermData->GetLineAttr(
			m_pTermData->m_Screen[m_pTermData->m_CaretPos.y] );
	int x = m_pTermData->m_CaretPos.x;
	bool clear = true;
	bool reconnect = false;

	if( evt->keyval < 127 && GDK_MODIFIER_DOWN(evt->state, GDK_CONTROL_MASK))// Ctrl down
	{
		char ch = toupper(char(evt->keyval));
		if( ch >= '@' && ch <= '_'	&& !isdigit(ch) )
		{
			// clear the old selection
			if (!m_pTermData->m_Sel->Empty())
				ClearSelection();

			ch -= '@';
			GetCon()->SendRawString(&ch,1);
			return true;
		}
	}

	switch(evt->keyval)
	{
	case GDK_Left:
	case GDK_KP_Left:
		LeaveWrapper(GetCon(), pAttr, x);
		break;
	case GDK_Right:
	case GDK_KP_Right:
		EnterWrapper(GetCon(), pAttr, x);
		break;
	case GDK_Up:
	case GDK_KP_Up:
		GetCon()->SendString("\x1bOA");
		break;
	case GDK_Down:
	case GDK_KP_Down:
		GetCon()->SendString("\x1bOB");
		break;
	case GDK_BackSpace:
		if (GetCon()->DetectDBChar() && x > 0 && pAttr[x-1].GetCharSet() == CTermCharAttr::CS_MBCS2)
			GetCon()->SendString("\b\b");
		else
			GetCon()->SendString("\b");
		break;
	case GDK_Return:
	case GDK_KP_Enter:
		reconnect = GetCon()->IsClosed();
		GetCon()->SendString("\r");
		break;
	case GDK_Delete:
	case GDK_KP_Delete:
		if (GetCon()->DetectDBChar() && pAttr[x].GetCharSet() == CTermCharAttr::CS_MBCS1)
			GetCon()->SendString("\x1b[3~\x1b[3~");
		else
			GetCon()->SendString("\x1b[3~");
		break;
	case GDK_Insert:
	case GDK_KP_Insert:
		GetCon()->SendString("\x1b[2~");
		break;
	case GDK_Home:
	case GDK_KP_Home:
		GetCon()->SendString("\x1b[1~");
		break;
	case GDK_End:
	case GDK_KP_End:
		GetCon()->SendString("\x1b[4~");
		break;
//	case GDK_Prior:
	case GDK_Page_Up:
	case GDK_KP_Page_Up:
		GetCon()->SendString("\x1b[5~");
		break;
//	case GDK_Next:
	case GDK_Page_Down:
	case GDK_KP_Page_Down:
		GetCon()->SendString("\x1b[6~");
		break;
	case GDK_Tab:
		GetCon()->SendString("\t");
		break;
	case GDK_Escape:
		GetCon()->SendString("\x1b");
		break;
// F1-F12 keys
	case GDK_F1:
	case GDK_KP_F1:
		GetCon()->SendString("\x1bOP");
		break;
	case GDK_F2:
	case GDK_KP_F2:
		GetCon()->SendString("\x1bOQ");
		break;
	case GDK_F3:
	case GDK_KP_F3:
		GetCon()->SendString("\x1bOR");
		break;
	case GDK_F4:
	case GDK_KP_F4:
		GetCon()->SendString("\x1bOS");
		break;
	case GDK_F5:
		GetCon()->SendString("\x1b[15~");
		break;
	case GDK_F6:
		GetCon()->SendString("\x1b[17~");
		break;
	case GDK_F7:
	    GetCon()->SendString("\x1b[18~");
		break;
	case GDK_F8:
		GetCon()->SendString("\x1b[19~");
		break;
	case GDK_F9:
		GetCon()->SendString("\x1b[20~");
		break;
	case GDK_F10:
		GetCon()->SendString("\x1b[21~");
		break;
	case GDK_F11:
		GetCon()->SendString("\x1b[23~");
		break;
	case GDK_F12:
		GetCon()->SendString("\x1b[24~");
		break;
	default:
		clear = false;
	}

	// Only clear selection if we handled the key
	if (clear)
		ClearSelection();

	if (reconnect)
		GetCon()->Reconnect();

	return true;
}