Пример #1
0
BOOL SellFromBase(int32_t iPlr, C4Object *pBaseObj, C4ID id, C4Object *pSellObj)
  {
  C4Object *pThing;
  // Valid checks
  if (!ValidPlr(iPlr)) return FALSE;
  if (!pBaseObj || !ValidPlr(pBaseObj->Base)) return FALSE;
	if (~Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_Sell) return FALSE;
  // Base owner eliminated
  if (Game.Players.Get(pBaseObj->Base)->Eliminated)
    {
    StartSoundEffect("Error",false,100,pBaseObj); 
    sprintf(OSTR,LoadResStr("IDS_PLR_ELIMINATED"),Game.Players.Get(pBaseObj->Base)->GetName());
    GameMsgPlayer(OSTR,iPlr); return FALSE;
    }
  // Base owner hostile
  if (Hostile(iPlr,pBaseObj->Base))
    {
    StartSoundEffect("Error",false,100,pBaseObj); 
    sprintf(OSTR,LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBaseObj->Base)->GetName());
    GameMsgPlayer(OSTR,iPlr); return FALSE;
    }
	// check validity of sell object, if specified
	if (pThing = pSellObj)
		if (!pThing->Status || pThing->Contained != pBaseObj)
			pThing = NULL;
  // Get object from home pBaseObj via selected id, if no or an anvalid thing has been specified
	if (!pThing)
		if (!(pThing=pBaseObj->Contents.Find(id))) return FALSE;
	// check definition NoSell
	if (pThing->Def->NoSell) return FALSE;
  // Sell object (pBaseObj owner gets the money)
  return Game.Players.Get(pBaseObj->Base)->Sell2Home(pThing); 
  }
Пример #2
0
/*  Function: MatSysGetTeamFill
    
	Parameters:
	plr - A player of the team whose fill level should be returned.
	Key - The material id.

	Returns:
	The combined fill level of all team members. */
global func MatSysGetTeamFill(int plr, id Key) {
	var fill = 0;
	for(var count = GetPlayerCount(), i = 0; i < count; i++) {
		var p = GetPlayerByIndex(i);
		if(!Hostile(plr, p))
			fill += MatSysGetFill(p, Key);
	}
	return fill;
}
Пример #3
0
protected func Initialize()
{
  _inherited();
  // Alle Verbündeten des Besitzers speichern
  for(var i=0, l=0 ; i < GetPlayerCount() ; i++)
    if(GetPlayerByIndex(i) > -1)
      if(!Hostile(GetOwner(), i))
        {
        Local(l) = i+1;
        l++;
        }
}
Пример #4
0
/*  Function: MatSysDoTeamFill
    Changes the fill level for a given team/id.
    
	Parameters:
	change - The amount of change.
	plr    - A player of the team whose fill level should be changed.
	Key    - The material id.

	Returns:
	The actual change. */
global func MatSysDoTeamFill(int change, int plr, id Key) {
	var orig = change;
	// first, try the given player
	change -= MatSysDoFill(change, plr, Key, true);
	// then, loop through the other players
	for(var count = GetPlayerCount(), i = 0; i < count && change != 0; i++) {
		var p = GetPlayerByIndex(i);
		if(!Hostile(plr, p)) {
			change -= MatSysDoFill(change, p, Key);
		}
	}
	var actual = orig - change;
	MatSysMessage(actual, Key);
	return actual;
}
Пример #5
0
protected func ActivateEntrance(object obj)
{
	if (this->~IsBase() && this->~CanBlockEnemies())
	{
		var for_plr = obj->GetOwner();
		if (Hostile(GetOwner(), for_plr))
		{
			Sound("Error", false, 100, for_plr);
			PlayerMessage(for_plr, "$TxtNoEntryEnemy$", GetPlayerName(GetOwner()));
			return false;
		}
	}
	if (ActIdle()) 
		SetAction("OpenDoor");
	return true;
}
Пример #6
0
BOOL Buy2Base(int32_t iPlr, C4Object *pBase, C4ID id, BOOL fShowErrors)
	{
	C4Object *pThing;
	// Validity
	if (!ValidPlr(iPlr)) return FALSE;
	if (!pBase || !ValidPlr(pBase->Base)) return FALSE;
	if (~Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_Buy) return FALSE;
	// Base owner hostile
	if (Hostile(iPlr,pBase->Base))
		{
		if (!fShowErrors) return FALSE;
		StartSoundEffect("Error",false,100,pBase); 
		sprintf(OSTR,LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBase->Base)->GetName());
		GameMsgPlayer(OSTR,iPlr); return FALSE;
		}
	// buy
	if (!(pThing=Game.Players.Get(pBase->Base)->Buy(id, fShowErrors, iPlr, pBase))) return FALSE;
	// Object enter target object
	pThing->Enter(pBase);
	// Success
	return TRUE;
	}
Пример #7
0
func ChkIncinerate()
{
  while(Var(0)=FindObject(0,-6,-6,12,12,OCF_Prey(),0,0,NoContainer(),Var())) 
    if(Hostile(GetOwner(),GetOwner(Var()))) if(!OnFire(Var())) Incinerate(Var(0));
  return(1);
}
Пример #8
0
static void
Intro (void)
{
    if (LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE)
    {
        NPCPhrase (OUT_TAKES);

        SET_GAME_STATE (BATTLE_SEGUE, 0);
        return;
    }

    GetShofixtiName ();

    if (GET_GAME_STATE (SHOFIXTI_STACK2) > 2)
    {
        NPCPhrase (FRIENDLY_HELLO);

        Friendly ((RESPONSE_REF)0);
    }
    else
    {
        BYTE NumVisits;

        NumVisits = GET_GAME_STATE (SHOFIXTI_VISITS);
        if (GET_GAME_STATE (SHOFIXTI_KIA))
        {
            switch (NumVisits++)
            {
            case 0:
                NPCPhrase (HOSTILE_KATANA_1);
                break;
            case 1:
                NPCPhrase (HOSTILE_KATANA_2);
                break;
            case 2:
                NPCPhrase (HOSTILE_KATANA_3);
                break;
            case 3:
                NPCPhrase (HOSTILE_KATANA_4);
                --NumVisits;
                break;
            }
        }
        else
        {
            switch (NumVisits++)
            {
            case 0:
                NPCPhrase (HOSTILE_TANAKA_1);
                break;
            case 1:
                NPCPhrase (HOSTILE_TANAKA_2);
                break;
            case 2:
                NPCPhrase (HOSTILE_TANAKA_3);
                break;
            case 3:
                NPCPhrase (HOSTILE_TANAKA_4);
                break;
            case 4:
                NPCPhrase (HOSTILE_TANAKA_5);
                break;
            case 5:
                NPCPhrase (HOSTILE_TANAKA_6);
                break;
            case 6:
                NPCPhrase (HOSTILE_TANAKA_7);
                break;
            case 7:
                NPCPhrase (HOSTILE_TANAKA_8);
                --NumVisits;
                break;
            }
        }
        SET_GAME_STATE (SHOFIXTI_VISITS, NumVisits);

        Hostile ((RESPONSE_REF)0);
    }
}