Esempio n. 1
0
/** Creates a consruction menu for the calling object. This is supposed to be a crew member, 
	controlled by a player.
	@param producer the producer for which to create the production menu.
	@return a pointer to the created menu, or \c nil if failed.
*/
global func CreateConstructionMenu(object constructor, bool create_at_mouse_pos)
{
	// Safety checks.
	if (!this) return;
	if (!(GetOCF() & OCF_CrewMember)) return;
	if (!(this->~HasMenuControl())) return;

	// Create the menu controller.
	var controller = CreateObject(Library_ConstructionMenu);
	controller->SetMenuObject(this);
	this->SetMenu(controller);
	controller->SetCommander(constructor);
	
	if(create_at_mouse_pos)
	{
		var xy = GetPlayerCursorPos(constructor->GetOwner());
		if(xy)
			controller->SetPosition(xy[0],xy[1],true);
	}
	
	// Add all possible structures to the menu.
	controller->AddMenuStructures(constructor, this);
	
	// Show and return production menu.
	controller->Show();
	return controller;
}
Esempio n. 2
0
func CatchBlow(int iLevel, object pObj) {
	if (GetCategory(pObj) & C4D_Object && GetOCF(pObj) & OCF_Collectible && ObjectDistance(pObj)*10 < 8*Sqrt(GetDefWidth(GetID())*GetDefHeight(GetID())) ) {
		pObj->~Hit();
		// Reduces object speed by 90%
		if (pObj) {
			pObj->SetXDir(GetXDir()*5, 0, 100);
			pObj->SetYDir(GetYDir()*5, 0, 100);
		}
	}
	return _inherited(iLevel, pObj);
}
Esempio n. 3
0
public func RejectCollect(id idObj, object pObj)
{
  // Objekt ist Gold oder ein Sack voll Geld
  if(idObj != GOLD && idObj != MBAG) return();
  // Objekt wird von einem Clonk getragen
  if(Contained(pObj))
   if(GetOCF(Contained(pObj)) & OCF_CrewMember())
    {
    // Nicht für Banditen
    if(Contained(pObj)->~IsBandit()) return(Sound("Error", 1, 0, 0, GetOwner(pObj)+1));
    DoWealth(GetOwner(Contained(pObj)), GetValue(pObj));
    DoPoints(GetValue(pObj), GetOwner(Contained(pObj)));
    Sound("Cash", 1, 0,0, GetOwner(pObj));
    RemoveObject(pObj);
    return(1);
    }
}
Esempio n. 4
0
func FillCheck()
  {
  if(!Contained())
      if(Inside(GetR(), 20, 340))
        Hit();
    if(!(iTimer%5))
    {
    var iX = Sin(GetR(), RandomX(-4,4) );
    var iY = -Cos(GetR(), RandomX(-4,1) );
    if(!Contained())
      CreateParticle("NoGravSpark", iX, iY,0,0,RandomX(25, 55),RGBa(255,255,0,120));
    }
  iTimer++;
  if(iTimer>=17)
    {
    if(GetOCF(Contained()) & OCF_CrewMember())
      DoEnergy(+1, Contained());
    iTimer=0;
    }
  return(1);
  }
Esempio n. 5
0
global func DoDmg(int iDmg, int iType, object pTarget, int iPrecision, int dmgplayer, id idKillIcon, int iKillAttachment)
{
  //Existenz bestätigen
  if(!pTarget)
    if(!(pTarget = this))
      return;

  if(!iPrecision)
    iPrecision = 10;

  var dmg, dmgdealer = dmgplayer-1;

  if(dmgdealer < 0)
    dmgdealer = GetController(pTarget);

  var red = pTarget->~OnDmg(iDmg, iType);
  dmg = iDmg*(100-red)*iPrecision;

  if(!dmg || red == 100) return;

  //Killer setzen
  if(this && pTarget->GetOCF() & OCF_CrewMember || dmgplayer)
    SetKiller(dmgdealer, pTarget);

  if(GetOCF(pTarget) & OCF_CrewMember)
  {
    if(!idKillIcon && this)//Kein Killicon?
    {
      idKillIcon = this->~GetKillIcon();

      if(!idKillIcon)
        idKillIcon = GetID(this);

      if(idKillIcon->~IsClonk())
        idKillIcon = 0;      
    }
    if(!idKillIcon)
      {
        if(iType)
        {
          if(iType == DMG_Fire)
            idKillIcon = GSAM;
          else if(iType == DMG_Explosion)
            idKillIcon = BOOM;
          else if(iType == DMG_Energy)
            idKillIcon = ENAM;
          else if(iType == DMG_Bio)
            idKillIcon = GLOB;
          else if(iType == DMG_Projectile)
            idKillIcon = STAM;
        }
        else
          idKillIcon = KAMB;
      }

    pTarget->~KillIcon(idKillIcon);
    pTarget->~KillAttachment(iKillAttachment, true);
  }

  //Schaden machen
  var pFrom;
  if(pTarget != this)
    pFrom = this;
  if(!pFrom) pFrom = GetCrew(dmgdealer);

  //Wird gerade eingeblendet: Entfernen
  if(GetEffect("FadeIn4K", this))
  {
    EffectVar(0, this, GetEffect("FadeIn4K", this)) = 0;
    SetClrModulation(RGBa(255, 255, 255, 0), this);
  }

  pTarget->~LastDamageType(iType);
  pTarget->~OnHit(dmg/1000, iType, pFrom);
  if(GetCategory(pTarget) & C4D_Living)
    return DoEnergy(-dmg, pTarget, true, 0, dmgplayer);
  return DoDamage(dmg/1000, pTarget, 0, dmgplayer);
}