Ejemplo n.º 1
0
/* comefrom: DoDisasters */
ScenarioDisaster(void)
{
  int x, y;

  switch (DisasterEvent) {
    case 1:			/* Dullsville */
      break;
    case 2: 			/* San Francisco */
      if (DisasterWait == 1) MakeEarthquake();
      break;
    case 3:			/* Hamburg */
      DropFireBombs();
      break;
    case 4:			/* Bern */
      break;
    case 5: 			/* Tokyo */
      if (DisasterWait == 1) MakeMonster();
      break;
    case 6: 			/* Detroit */
      break;
    case 7: 			/* Boston */
      if (DisasterWait == 1) MakeMeltdown();
      break;
    case 8:			/* Rio */
      if ((DisasterWait % 24) == 0) MakeFlood();
      break;
  }
  if (DisasterWait) DisasterWait--;
  else DisasterEvent = 0;
}
Ejemplo n.º 2
0
//=========================================================
// TryMakeMonster-  check that it's ok to drop a monster.
//=========================================================
void CMonsterMaker::TryMakeMonster( void )
{
	if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
	{// not allowed to make a new one yet. Too many live ones out right now.
		return;
	}

	if ( !m_flGround )
	{
		// set altitude. Now that I'm activated, any breakables, etc should be out from under me. 
		TraceResult tr;

		UTIL_TraceLine ( pev->origin, pev->origin - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr );
		m_flGround = tr.vecEndPos.z;
	}

	Vector mins = pev->origin - Vector( 34, 34, 0 );
	Vector maxs = pev->origin + Vector( 34, 34, 0 );
	maxs.z = pev->origin.z;
	mins.z = m_flGround;

	CBaseEntity *pList[2];
	int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER );
	if ( count )
	{
		// don't build a stack of monsters!
		return;
	}

	if (m_fSpawnDelay)
	{
		// If I have a target, fire. (no locus)
		if ( !FStringNull ( pev->target ) )
		{
			// delay already overloaded for this entity, so can't call SUB_UseTargets()
			FireTargets( STRING(pev->target), this, this, USE_TOGGLE, 0 );
		}

//		ALERT(at_console,"Making Monster in %f seconds\n",m_fSpawnDelay);
		SetThink(&CMonsterMaker:: MakeMonsterThink );
		SetNextThink( m_fSpawnDelay );
	}
	else
	{
//		ALERT(at_console,"No delay. Making monster.\n",m_fSpawnDelay);
		CBaseMonster* pMonst = MakeMonster();

		// If I have a target, fire! (the new monster is the locus)
		if ( !FStringNull ( pev->target ) )
		{
			FireTargets( STRING(pev->target), pMonst, this, USE_TOGGLE, 0 );
		}
	}
}
Ejemplo n.º 3
0
/* comefrom: Simulate */
DoDisasters(void)
{ 
  /* Chance of disasters at lev 0 1 2 */
  static short DisChance[3] = { 10*48, 5*48, 60}; 
  register short x;

  if (FloodCnt) FloodCnt--;
  if (DisasterEvent) 
    ScenarioDisaster();

  x = GameLevel;
  if (x > 2) x = 0;

  if (NoDisasters) return;		/*post*/
  if (!Rand(DisChance[x])) {
    x = Rand(8);
    switch (x) {
    case 0:
    case 1:
      SetFire();
      break;
    case 2:
    case 3:
      MakeFlood();
      break;
    case 4:
      break;
    case 5:
      MakeTornado();
      break;
    case 6:
      MakeEarthquake();
      break;
    case 7:
    case 8:
      if (PolluteAverage > /* 80 */ 60) MakeMonster();
      break;
    }
  }
}
Ejemplo n.º 4
0
//=========================================================
// MakerThink - creates a new monster every so often
//=========================================================
void CMonsterMaker :: MakerThink ( void )
{
	pev->nextthink = gpGlobals->time + m_flDelay;

	MakeMonster();
}
Ejemplo n.º 5
0
//=========================================================
// CyclicUse - drops one monster from the monstermaker
// each time we call this.
//=========================================================
void CMonsterMaker::CyclicUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	MakeMonster();
}
Ejemplo n.º 6
0
/* comefrom: processEvent */
doKeyDown(SimView *view, short charCode)
{
  LastKeys[0] = LastKeys[1];
  LastKeys[1] = LastKeys[2];
  LastKeys[2] = LastKeys[3];
  LastKeys[3] = tolower(charCode);

  if (strcmp(LastKeys, "fund") == 0) {
    Spend(-10000);
    PunishCnt++;				/* punish for cheating */
    if (PunishCnt == 5) {
      PunishCnt = 0;
      MakeEarthquake();
    }
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "fart") == 0) {
    MakeSound("city", "Explosion-High");
    MakeSound("city", "Explosion-Low");
    MakeFire();
    MakeFlood();
    MakeTornado();
    MakeEarthquake();
    MakeMonster();
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "nuke") == 0) {
    int i, j;
    MakeSound("city", "Explosion-High");
    MakeSound("city", "Explosion-Low");
    for (i = 0; i < WORLD_X; i++) {
      for (j = 0; j < WORLD_Y; j++) {
	short tile = Map[i][j] & LOMASK;
	if ((tile >= RUBBLE) &&
	    ((tile < CHURCH - 4) ||
	     (tile > CHURCH + 4))) {
	  if ((tile >= HBRIDGE && tile <= VBRIDGE) ||
	      (tile >= BRWH && tile <= LTRFBASE + 1) ||
	      (tile >= BRWV && tile <= BRWV + 2) ||
	      (tile >= BRWXXX1 && tile <= BRWXXX1 + 2) ||
	      (tile >= BRWXXX2 && tile <= BRWXXX2 + 2) ||
	      (tile >= BRWXXX3 && tile <= BRWXXX3 + 2) ||
	      (tile >= BRWXXX4 && tile <= BRWXXX4 + 2) ||
	      (tile >= BRWXXX5 && tile <= BRWXXX5 + 2) ||
	      (tile >= BRWXXX6 && tile <= BRWXXX6 + 2) ||
	      (tile >= BRWXXX7 && tile <= BRWXXX7 + 2)) {
	    Map[i][j] = RIVER;
	  } else {
	    Map[i][j] = TINYEXP + ANIMBIT + BULLBIT + Rand(2);
	  }
	}
      }
    }
    LastKeys[0] = '\0';
  } else if (strcmp(LastKeys, "stop") == 0) {
    heat_steps = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "will") == 0) {
    int i;
    int n = 500;
    for (i = 0; i < n; i++) {
      int x1 = Rand(WORLD_X - 1);
      int y1 = Rand(WORLD_Y - 1);
      int x2 = Rand(WORLD_X - 1);
      int y2 = Rand(WORLD_Y - 1);
      short temp =
	Map[x1][y1];
      Map[x1][y1] =
	Map[x2][y2];
      Map[x2][y2] =
	temp;
    }
    Kick();
  } else if (strcmp(LastKeys, "bobo") == 0) {
    heat_steps = 1;
    heat_flow = -1;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "boss") == 0) {
    heat_steps = 1;
    heat_flow = 1;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "mack") == 0) {
    heat_steps = 1;
    heat_flow = 0;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "donh") == 0) {
    heat_steps = 1;
    heat_flow = -1;
    heat_rule = 1;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "patb") == 0) {
    heat_steps = 1;
    heat_flow = Rand(40) - 20;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "lucb") == 0) {
    heat_steps = 1;
    heat_flow = Rand(1000) - 500;
    heat_rule = 0;
    LastKeys[0] = '\0';
    Kick();
  } else if (strcmp(LastKeys, "olpc") == 0) {
    Spend(-1000000);
  }

  switch (charCode) {
    
    case 'X':
    case 'x': {
      short s = view->tool_state;
      if (++s > lastState) {
	s = firstState;
      }
      setWandState(view, s);
      break;
    }

    case 'Z':
    case 'z': {
      short s = view->tool_state;
      if (--s < firstState) {
	  s = lastState;
      }
      setWandState(view, s);
      break;
    }

    /***** shift wand state to bull dozer *****/
    case 'B':
    case 'b':
    case 'B'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, dozeState);
      break;
    }

    /***** shift wand state to roads *****/
    case 'R':
    case 'r':
    case 'R'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, roadState);
      break;
    }

    /***** shift wand state to power *****/
    case 'P':
    case 'p':
    case 'P'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, wireState);
      break;
    }

    /***** shift wand state to transit *****/
    case 'T':
    case 't':
    case 'T'-'@': {
      if (view->tool_state_save == -1) {
	view->tool_state_save = view->tool_state;
      }
      setWandState(view, rrState);
      break;
    }

#if 0
    /***** shift wand state to query *****/
    case 'Q':
    case 'q':
    case 'Q'-'@': {
      if (view->tool_state_save == -1)
	view->tool_state_save = view->tool_state;
      setWandState(view, queryState);
      break;
    }
#endif

    case 27: {
      SoundOff();
      break;
    }

  }
}
//=========================================================
// MakeMonsterThink- a really trivial think function
//=========================================================
void CMonsterMaker::MakeMonsterThink( void )
{
	MakeMonster();
}
//=========================================================
// TryMakeMonster-  check that it's ok to drop a monster.
//=========================================================
void CMonsterMaker::TryMakeMonster( void )
{
	if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
	{// not allowed to make a new one yet. Too many live ones out right now.
		return;
	}
	
	CBaseEntity* pTemp;
	if (pev->noise){	// AJH	dynamic origin for monstermakers
		pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise),this);
		if (pTemp)
		{
			pev->vuser1 = pTemp->pev->origin;
		//	ALERT(at_debug,"DEBUG: Monstermaker setting dynamic position %f %f %f \n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z);
		}
	}else{
		pev->vuser1=pev->origin;
	}	
	
	if (pev->noise1)
	{	//AJH dynamic offset for monstermaker
		Vector vTemp =CalcLocus_Position(this, NULL, STRING(pev->noise1));
		pev->vuser1 = pev->vuser1 + vTemp;
	//	ALERT(at_debug,"DEBUG: Monstermaker dynamic offset is %f %f %f\n",vTemp.x,vTemp.y,vTemp.z);
	//	ALERT(at_debug,"DEBUG: Monstermaker position now %f %f %f \n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z);
	}

	if (pev->noise2){	// AJH	dynamic angles for monstermakers
		pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise2),this);
		if (pTemp)	pev->vuser2=pTemp->pev->angles;
	//	ALERT(at_debug,"DEBUG: Monstermaker setting angles to %f %f %f\n",pWhere->pev->angles.x,pWhere->pev->angles.y,pWhere->pev->angles.z);
	}else{
		pev->vuser2=pev->angles;
	}

	if (pev->noise3){	// AJH	dynamic velocity for monstermakers
		pTemp = UTIL_FindEntityByTargetname(NULL,STRING(pev->noise3),this);
		if (pTemp)	pev->vuser3 = pTemp->pev->velocity;
	//	ALERT(at_debug,"DEBUG: Monstermaker setting velocity to %f %f %f\n",pWhere->pev->velocity.x,pWhere->pev->velocity.y,pWhere->pev->velocity.z);
	
	}

//	ALERT(at_debug,"DEBUG: Montermaker spawnpoint set to %f, %f, %f\n", pWhere->pev->origin.x,pWhere->pev->origin.y,pWhere->pev->origin.z);
	

	if ( !m_flGround )
	{
		// set altitude. Now that I'm activated, any breakables, etc should be out from under me. 
		TraceResult tr;

		UTIL_TraceLine ( pev->vuser1, pev->vuser1 - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr );
		m_flGround = tr.vecEndPos.z;
	}

	Vector mins = pev->vuser1 - Vector( 34, 34, 0 );
	Vector maxs = pev->vuser1 + Vector( 34, 34, 0 );
	maxs.z = pev->vuser1.z;
	mins.z = m_flGround;

	CBaseEntity *pList[2];
	int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER );
	if ( !SF_MONSTERMAKER_FORCESPAWN&&count )
	{
		// don't build a stack of monsters!
		return;
	}

	if (m_fSpawnDelay)
	{
		// If I have a target, fire. (no locus)
		if ( !FStringNull ( pev->target ) )
		{
			// delay already overloaded for this entity, so can't call SUB_UseTargets()
			FireTargets( STRING(pev->target), this, this, USE_TOGGLE, 0 );
		}

//		ALERT(at_console,"Making Monster in %f seconds\n",m_fSpawnDelay);
		SetThink(&CMonsterMaker:: MakeMonsterThink );
		SetNextThink( m_fSpawnDelay );
	}
	else
	{
//		ALERT(at_console,"No delay. Making monster.\n",m_fSpawnDelay);
		CBaseMonster* pMonst = MakeMonster();

		// If I have a target, fire! (the new monster is the locus)
		if ( !FStringNull ( pev->target ) )
		{
			ALERT(at_debug,"DEBUG: Monstermaker fires target %s locus is child\n",STRING(pev->target));
			FireTargets( STRING(pev->target), pMonst, this, USE_TOGGLE, 0 );
		}
	}
}