Example #1
0
global func BlackWhite()
{
	var pO;
	for(pO in FindObjects(Find_NoContainer()))
	{
		SetClrModulation(HSL(0,0,0),pO);
	}
Example #2
0
global func FxHitCheckDoCheck(object target, proplist effect)
{
    var obj;
    // rather search in front of the projectile, since a hit might delete the effect,
    // and clonks can effectively hide in front of walls.
    var oldx = target->GetX();
    var oldy = target->GetY();
    var newx = target->GetX() + target->GetXDir() / 10;
    var newy = target->GetY() + target->GetYDir() / 10;
    var dist = Distance(oldx, oldy, newx, newy);
    var is_human = GetPlayerType(target->GetController()) == C4PT_User;

    var shooter = effect.shooter;
    var live = effect.live;

    if (live)
        shooter = target;

    if (dist <= Max(1, Max(Abs(target->GetXDir()), Abs(target->GetYDir()))) * 2)
    {
        // We search for objects along the line on which we moved since the last check
        // and sort by distance (closer first).
        for (obj in FindObjects(Find_OnLine(oldx, oldy, newx, newy),
                                Find_NoContainer(),
                                Find_Layer(target->GetObjectLayer()),
                                Find_PathFree(target),
                                Sort_Distance(oldx, oldy)))
        {
            // Excludes
            if (!obj) continue; // hit callback of one object might have removed other objects
            if(obj == target) continue;
            if(obj == shooter) continue;
            if (is_human) {
                if (obj == g_windgen1) continue;
                if (obj == g_windgen2) continue;
                if (obj == g_windgen3) continue;
                if (obj == g_windmill) continue;
            }

            // Unlike in hazard, there is no NOFF rule (yet)
            // CheckEnemy
            //if(!CheckEnemy(obj,target)) continue;

            // IsProjectileTarget or Alive will be hit
            if (obj->~IsProjectileTarget(target, shooter) || obj->GetOCF() & OCF_Alive)
            {
                target->~HitObject(obj);
                if (!target)
                    return;
            }
        }
    }
    return;
}
Example #3
0
public func GetDescription(int plr)
{
	// Count active enemy clonks.
	var hostile_count = ObjectCount(Find_OCF(OCF_CrewMember), Find_NoContainer(), Find_Hostile(plr));
	var message;
	if (!hostile_count)
		message = "$MsgGoalFulfilled$";
	else
		message = Format("$MsgGoalUnfulfilled$", hostile_count);

	// Also report the remaining rounds.
	message = Format("%s|%s", message, CurrentRoundStr());

	return message;
}
Example #4
0
private func CheckStuck()
{
  var pClonk,iYChange,iX,iY;
  // Alle feststeckenden Clonks in der Nähe suchen
  for (pClonk in FindObjects(Find_InRect(-20,-20,40,40), Find_OCF(OCF_CrewMember),Find_NoContainer()))
  {
    iX=GetX(pClonk);
    iY=GetY(pClonk);
    while(Stuck(pClonk) && Inside(GetY(pClonk)-GetY(),-20,20))
    {
      if(!(iYChange=BoundBy(GetY(pClonk)-GetY(),-1,1))) iYChange=1;
      // Zur Sicherheit...
      if(!Inside(GetY(pClonk)+iYChange,-100,LandscapeHeight())) break;
      SetPosition(GetX(pClonk),GetY(pClonk)+iYChange,pClonk);
    }
    // verschieben fehlgeschlagen: rückgängig machen
    if(Stuck(pClonk)) SetPosition(iX,iY,pClonk);
  }
}
Example #5
0
global func CyclopsFindTarget(fx)
{
	// Consider hostile clonks, or all clonks if the AI does not have an owner.
	var hostile_criteria = Find_Hostile(fx.cyclops->GetOwner());
	if (fx.cyclops->GetOwner() == NO_OWNER)
		hostile_criteria = Find_Not(Find_Owner(fx.cyclops->GetOwner()));

	for (var target in FindObjects(Find_InRect(fx.guard_range.x,fx.guard_range.y,fx.guard_range.wdt,fx.guard_range.hgt), Find_OCF(OCF_CrewMember), hostile_criteria, Find_NoContainer(), Sort_Random()))
		if (PathFree(fx.cyclops->GetX(),fx.cyclops->GetY(),target->GetX(),target->GetY()))
			return target;

	// Nothing found.
	return;
}