Ejemplo n.º 1
0
void
nsa_ucount(struct nsa_parser *p)
{
  List *newtoks = list_create(LIST_DOUBLE);
  struct nsa_token *t;
  for (t = list_first(p->toks); t; t = list_next(p->toks))
    {
      if (t->type == NSA_T_GRAPHEME)
	{
	  if (grapheme_num(t))
	    {
	      struct nsa_token *c = new_token();
	      struct nsa_token *la2 = la2_trap(newtoks,p);
	      int nkids = 1;
	      if (la2)
		++nkids;
	      c->d.c = new_count();
	      c->type = NSA_T_COUNT;
	      c->children = new_children(nkids);
	      if (la2)
		{
		  c->children[0] = la2;
		  c->children[1] = t;
		}
	      else
		c->children[0] = t;
	      
	      *c->d.c = *nsa_parse_count(grapheme_num(t),la2 ? -1 : 1);
	      list_add(newtoks,c);
	      if (grapheme_unit(t))
		{
		  struct nsa_token *tu = create_unit(p, grapheme_unit(t), NULL);
		  if (tu)
		    list_add(newtoks,tu);
		  else
		    fprintf(stderr,"unknown unit in count-unit grapheme `%s'\n",
			    nsa_grapheme_text(t));
		}
	    }
	  else if (!newtoks->last
		   || ((struct nsa_token*)list_last(newtoks))->type != NSA_T_UNIT)
	    list_add(newtoks,create_unit(p, (const char *)nsa_grapheme_text(t), t));
	  else
	    list_add(newtoks,t);
	}
      else
	list_add(newtoks,t);
    }
  list_free(p->toks,NULL);
  p->toks = newtoks;
}
Ejemplo n.º 2
0
static void recruit_dracoids(unit * dragon, int size)
{
    faction *f = dragon->faction;
    region *r = dragon->region;
    const struct item *weapon = NULL;
    order *new_order = NULL;
    unit *un = create_unit(r, f, size, get_race(RC_DRACOID), 0, NULL, NULL);

    fset(un, UFL_ISNEW | UFL_MOVED);

    name_unit(un);
    change_money(dragon, -un->number * 50);
    equip_unit(un, get_equipment("recruited_dracoid"));

    setstatus(un, ST_FIGHT);
    for (weapon = un->items; weapon; weapon = weapon->next) {
        const weapon_type *wtype = weapon->type->rtype->wtype;
        if (wtype && (wtype->flags & WTF_MISSILE)) {
            setstatus(un, ST_BEHIND);
        }
        new_order = create_order(K_STUDY, f->locale, "'%s'",
            skillname(weapon->type->rtype->wtype->skill, f->locale));
    }

    if (new_order != NULL) {
        addlist(&un->orders, new_order);
    }
}
Ejemplo n.º 3
0
int sp_shadowcall(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    battle *b = fi->side->battle;
    region *r = b->region;
    unit *mage = fi->unit;
    attrib *a;
    int force = (int)(get_force(power, 3) / 2);
    unit *u;
    const char *races[3] = { "shadowbat", "nightmare", "vampunicorn" };
    const race *rc = rc_find(races[rng_int() % 3]);
    message *msg;

    u = create_unit(r, mage->faction, force, rc, 0, NULL, mage);
    setstatus(u, ST_FIGHT);

    set_level(u, SK_WEAPONLESS, (int)(power / 2));
    set_level(u, SK_STAMINA, (int)(power / 2));
    u->hp = u->number * unit_max_hp(u);

    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);

    make_fighter(b, u, fi->side, is_attacker(fi));
    msg =
        msg_message("sp_shadowcall_effect", "mage amount race", mage, u->number,
        u_race(u));
    message_all(b, msg);
    msg_release(msg);
    return level;
}
Ejemplo n.º 4
0
void save_special_items(unit *usrc)
{
    unit *u;
    region *r = usrc->region;
    faction *fm = get_monsters();
    static const race *rc_ghost;
    static int cache;

    if (rc_changed(&cache)) {
        rc_ghost = get_race(RC_TEMPLATE);
    }
    for (u = r->units; u; u = u->next) {
        if (u->faction == fm) {
            give_special_items(u, &usrc->items);
            return;
        }
    }
    u = create_unit(r, fm, 1, rc_ghost, 0, NULL, NULL);
    unit_setname(u, unit_getname(usrc));
    if (usrc->number > 1) {
        /* some units have plural names, it would be neat if they aren't single: */
        scale_number(u, 2);
    }
    set_racename(&u->attribs, "ghost");
    give_special_items(u, &usrc->items);
}
Ejemplo n.º 5
0
//--------- Begin of function FirmMarket::hire_caravan ---------//
//
short FirmMarket::hire_caravan(char remoteAction)
{
	if( !can_hire_caravan() )
		return 0;

	//---------------------------------------//

	Nation *nationPtr = nation_array[nation_recno];

	if(!remoteAction && remote.is_enable())
	{
		// packet structure : <firm recno>
		short *shortPtr = (short *) remote.new_send_queue_msg(MSG_F_MARKET_HIRE_CARA, sizeof(short));
		*shortPtr = firm_recno;
		return 0;
	}

	//---------- add the unit now -----------//

	int unitRecno = create_unit( UNIT_CARAVAN );

	UnitCaravan* unitCaravan = (UnitCaravan*)unit_array[unitRecno];

	unitCaravan->loyalty = 100;
	unitCaravan->set_stop( 1, loc_x1, loc_y1, COMMAND_AUTO );

	//---------- deduct cash for the caravan's cost ----------//

	if(unitCaravan)
		return unitCaravan->sprite_recno;
	else
		return 0;
}
Ejemplo n.º 6
0
unit *addplayer(region * r, faction * f)
{
    unit *u;
    const char * name;

    assert(r->land);
    if (rpeasants(r) < PEASANT_MIN) {
        rsetpeasants(r, PEASANT_MIN + rng_int() % (PEASANT_MAX - PEASANT_MIN));
    }

    assert(f->units == NULL);
    faction_setorigin(f, 0, r->x, r->y);
    u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
    u->thisorder = default_order(f->locale);
    unit_addorder(u, copy_order(u->thisorder));
    name = config_get("rules.equip_first");
    if (!equip_unit(u, name ? name : "first_unit")) {
        /* give every unit enough money to survive the first turn */
        i_change(&u->items, get_resourcetype(R_SILVER)->itype, maintenance_cost(u));
    }
    u->hp = unit_max_hp(u) * u->number;
    fset(u, UFL_ISNEW);
    if (f->race == get_race(RC_DAEMON)) {
        race_t urc;
        const race *rc;
        do {
            urc = (race_t)(rng_int() % MAXRACES);
            rc = get_race(urc);
        } while (rc == NULL || urc == RC_DAEMON || !playerrace(rc));
        u->irace = rc;
    }
    f->lastorders = 0;
    return u;
}
Ejemplo n.º 7
0
static fighter *summon_allies(const fighter *fi, const race *rc, int number) {
    attrib *a;
    unit *mage = fi->unit;
    side *si = fi->side;
    battle *b = si->battle;
    region *r = b->region;
    message *msg;
    unit *u =
        create_unit(r, mage->faction, number, rc, 0, NULL, mage);
    leave(u, true);
    unit_setstatus(u, ST_FIGHT);
    
    u->hp = u->number * unit_max_hp(u);
    
    if (mage->flags & UFL_ANON_FACTION) {
        u->flags |= UFL_ANON_FACTION;
    }
    
    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);
    
    msg = msg_message("sp_wolfhowl_effect", "mage amount race", mage, u->number, rc);
    message_all(b, msg);
    msg_release(msg);

    return make_fighter(b, u, si, is_attacker(fi));
}
Ejemplo n.º 8
0
faction *gm_addfaction(const char *email, plane * p, region * r)
{
  attrib *a;
  unit *u;
  faction *f = calloc(1, sizeof(faction));

  assert(p != NULL);

  /* GM faction */
  a_add(&f->attribs, make_key(atoi36("quest")));
  f->banner = _strdup("quest faction");
  f->name = _strdup("quest faction");
  f->passw = _strdup(itoa36(rng_int()));
  if (set_email(&f->email, email) != 0) {
    log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
  }
  f->race = new_race[RC_TEMPLATE];
  f->age = 0;
  f->lastorders = turn;
  f->alive = true;
  f->locale = default_locale;
  f->options =
    want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN);
  {
    faction *xist;
    int id = atoi36("gm00") - 1;
    do {
      xist = findfaction(++id);
    } while (xist);

    f->no = id;
    addlist(&factions, f);
    fhash(f);
  }

  /* generic permissions */
  a = a_add(&f->attribs, a_new(&at_permissions));
  if (a) {
    attrib *ap = (attrib *) a->data.v;
    const char *keys[] =
      { "gmterf", "gmtele", "gmgive", "gmskil", "gmtake", "gmmsgr", "gmmsgu",
        "gmgate", 0 };
    const char **key_p = keys;
    while (*key_p) {
      add_key(&ap, atoi36(*key_p));
      ++key_p;
    }
    a_add(&ap, make_atgmcreate(resource2item(r_silver)));

    a->data.v = ap;
  }

  /* one initial unit */
  u = create_unit(r, f, 1, new_race[RC_TEMPLATE], 1, "quest master", NULL);
  u->irace = new_race[RC_GNOME];

  return f;
}
Ejemplo n.º 9
0
//---- Begin of function CampaignEastWest::stage_28_create_game ----//
//
// Vars defined in event functions before calling this function:
//
// None
//
int CampaignEastWest::stage_28_create_game()
{
	init_random_plot(0);		// no plot

	//------- create objects and vars --------//

	if( !stage_28_create_nation() )
		return 0;

	//----- create independent towns ------//

	Battle::create_independent_town(5+misc.random(3));

	//---- create the player force and peasants ----//

	create_troop(PLAYER_NATION_RECNO, 16, 50 ); 		// 50-average combat level

	Nation* playerNation = nation_array[PLAYER_NATION_RECNO];

	Unit* kingUnit = unit_array[ playerNation->king_unit_recno ];

	//---- create a group of peasants with the player's nationality ---//

	int unitId = race_res[playerNation->race_id]->civilian_unit_id;
	int peasantCount = 25 + misc.random(6);

	for( int i=0 ; i<peasantCount ; i++ )
	{
		create_unit( PLAYER_NATION_RECNO, unitId, RANK_SOLDIER,
						 kingUnit->next_x_loc(), kingUnit->next_y_loc(),
						 kingUnit->next_x_loc(), kingUnit->next_y_loc() );
	}

	//------ init stage 1 vars -------//

	stage_28_init_vars();

	//---- generate plants and other objects on the map -----//

	world.gen_rocks();		// generate mountains

	world.generate_map2();

	//------- create additional raw sites ----------//

	create_raw_site();

	// ----- create royal units ------//

	create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO);

	//------ plot create game --------//

	(this->*plot_create_game_FP)();

	return 1;
}
Ejemplo n.º 10
0
bool Building::create_building(){
	bool build_success=create_cube_large(x,y,z);
	if(build_success){
		create_unit();
	}else{
		std::cerr<<"Building::build() fail"<<std::endl;
	}
	return build_success;
}
Ejemplo n.º 11
0
int CReqAvenue2HttpTransfer::CreateTransferObjs()
{
	TS_XLOG(XLOG_DEBUG,"CReqAvenue2HttpTransfer::%s\n",__FUNCTION__);

	map<string,SA2HSoUnit>::iterator iter;
	for(iter = sm_mapSo.begin(); iter != sm_mapSo.end(); ++iter)
	{
		string strSoName = iter->first;
		/* if m_mapUnitBySoName has the SoName, don't create class instance */
		map<string,SA2HTransferUnit>::iterator iterMap = m_mapUnitBySoName.find(strSoName);
		if(iterMap == m_mapUnitBySoName.end())
		{				
			create_a2h_obj create_unit = iter->second.pFunCreate;
			destroy_a2h_obj destroy_unit = iter->second.pFunDestroy;
			
			IRequestAvenueHttpTransfer* pTransferObj = create_unit();
	        if(pTransferObj == NULL)
	        {
	            TS_XLOG(XLOG_ERROR,"CReqAvenue2HttpTransfer::%s, create object failed, SoName[%s]\n",__FUNCTION__,strSoName.c_str());
	            continue;
	        }
			
			string strTemp = pTransferObj->GetPluginSoInfo();
			TS_XLOG(XLOG_DEBUG,"CReqAvenue2HttpTransfer::%s, GetPluginSoInfo(), [%s]\n",__FUNCTION__, strTemp.c_str());
			m_mapSoInfoBySoName.insert(make_pair(strSoName,strTemp));

			SA2HTransferUnit oSTUnit(strSoName,pTransferObj, destroy_unit);			

			vector<string> vecTemp;
			pTransferObj->GetServiceMessageId(vecTemp);
			vector<string>::iterator iterTemp;
			for(iterTemp=vecTemp.begin();iterTemp!=vecTemp.end();++iterTemp)
			{
				TS_XLOG(XLOG_TRACE,"CReqAvenue2HttpTransfer::%s, srvMsgId[%s]\n",__FUNCTION__, (*iterTemp).c_str());
				vector<string> vecSplit;
				boost::algorithm::split( vecSplit, (*iterTemp), boost::algorithm::is_any_of(","),boost::algorithm::token_compress_on);  
				if( vecSplit.size() == 2 )
				{
					SServiceMsgId msgIdentify(atoi(vecSplit[0].c_str()),atoi(vecSplit[1].c_str()));
					oSTUnit.vecSrvMsgId.push_back(msgIdentify);
					m_mapTransferUnit.insert(make_pair(msgIdentify,oSTUnit));
				}
			}
			m_mapUnitBySoName.insert(make_pair(strSoName,oSTUnit));
			
			iter->second.nLoadNum++;
		}
		else
		{
			continue;
		}
	}

	return 0;
}
Ejemplo n.º 12
0
/**************************************************************************
  Create a new unit.
**************************************************************************/
Unit *api_actions_create_unit(Player *pplayer, Tile *ptile, Unit_Type *ptype,
		  	      int veteran_level, City *homecity,
			      int moves_left)
{
  if (ptype == NULL
      || ptype < unit_type_array_first() || ptype > unit_type_array_last()) {
    return NULL;
  }

  return create_unit(pplayer, ptile, ptype, veteran_level,
		     homecity ? homecity->id : 0, moves_left);
}
Ejemplo n.º 13
0
/** Drachen und Seeschlangen können entstehen */
void spawn_dragons(void)
{
    region *r;
    faction *monsters = get_or_create_monsters();

    for (r = regions; r; r = r->next) {
        unit *u;

        if (fval(r->terrain, SEA_REGION) && rng_int() % 10000 < 1) {
            u = create_unit(r, monsters, 1, get_race(RC_SEASERPENT), 0, NULL, NULL);
            fset(u, UFL_ISNEW | UFL_MOVED);
            equip_unit(u, get_equipment("monster_seaserpent"));
        }

        if ((r->terrain == newterrain(T_GLACIER)
            || r->terrain == newterrain(T_SWAMP)
            || r->terrain == newterrain(T_DESERT))
            && rng_int() % 10000 < (5 + 100 * chaosfactor(r))) {
            if (chance(0.80)) {
                u = create_unit(r, monsters, nrand(60, 20) + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL);
            }
            else {
                u = create_unit(r, monsters, nrand(30, 20) + 1, get_race(RC_DRAGON), 0, NULL, NULL);
            }
            fset(u, UFL_ISNEW | UFL_MOVED);
            equip_unit(u, get_equipment("monster_dragon"));

            log_debug("spawning %d %s in %s.\n", u->number,
                LOC(default_locale,
                rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL));

            name_unit(u);

            /* add message to the region */
            ADDMSG(&r->msgs,
                msg_message("sighting", "region race number", r, u_race(u), u->number));
        }
    }
}
Ejemplo n.º 14
0
//--------- Begin of function UnitArray::add_unit ---------//
//
// <int> unitId               - the id. of the unit
// <int> nationRecno          - the recno of the nation that the unit belongs to
// [int] rankId					- rank id. of the unit (none for non-human unit)
// [int] unitLoyalty			   - loyalty of the unit  (none for non-human unit)
// [int] startXLoc, startYLoc - the starting location of the unit
//										  (if startXLoc < 0, this is a unit for hire, and is not a unit of the game yet. init_sprite() won't be called for this unit)
//										  (default: -1, -1)
// [int] remoteAction			- whether this is a remote action or not.
//
// return : <int> - the recno of the unit added.
//
int UnitArray::add_unit(int unitId, int nationRecno, int rankId, int unitLoyalty, int startXLoc, int startYLoc)
{
	//-------- create and initialize Unit -------//

	Unit* unitPtr = create_unit(unitId);

	//----------- add to SpriteArray ------------//

	unitPtr->init(unitId, nationRecno, rankId, unitLoyalty, startXLoc, startYLoc);

	//-------------------------------------------//

	return unitPtr->sprite_recno;
}
Ejemplo n.º 15
0
static int createunit_handle(trigger * t, void *data)
{
    /* call an event handler on createunit.
     * data.v -> ( variant event, int timer )
     */
    createunit_data *td = (createunit_data *)t->data.v;
    if (td->r != NULL && td->f != NULL) {
        create_unit(td->r, td->f, td->number, td->race, 0, NULL, NULL);
    }
    else {
        log_error("could not perform createunit::handle()\n");
    }
    unused_arg(data);
    return 0;
}
Ejemplo n.º 16
0
static void get_villagers(region * r, unit * u)
{
  unit *newunit;
  message *msg = msg_message("encounter_villagers", "unit", u);
  const char *name = LOC(u->faction->locale, "villagers");

  r_addmessage(r, u->faction, msg);
  msg_release(msg);

  newunit =
    create_unit(r, u->faction, rng_int() % 20 + 3, u->faction->race, 0, name,
    u);
  leave(newunit, true);
  fset(newunit, UFL_ISNEW | UFL_MOVED);
  equip_unit(newunit, get_equipment("random_villagers"));
}
Ejemplo n.º 17
0
static void guardian_faction(plane * pl, int id)
{
    region *r;
    faction *f = findfaction(id);

    if (!f) {
        f = calloc(1, sizeof(faction));
        f->banner = _strdup("Sie dienen dem großen Wyrm");
        f->passw = _strdup(itoa36(rng_int()));
        set_email(&f->email, "*****@*****.**");
        f->name = _strdup("Igjarjuks Kundschafter");
        f->race = get_race(RC_ILLUSION);
        f->age = turn;
        f->locale = get_locale("de");
        f->options =
            want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) |
            want(O_DEBUG);

        f->no = id;
        addlist(&factions, f);
        fhash(f);
    }
    if (f->race != get_race(RC_ILLUSION)) {
        assert(!"guardian id vergeben");
        exit(0);
    }
    f->lastorders = turn;
    f->alive = true;
    for (r = regions; r; r = r->next)
        if (getplane(r) == pl && rterrain(r) != T_FIREWALL) {
            unit *u;
            freset(r, RF_ENCOUNTER);
            for (u = r->units; u; u = u->next) {
                if (u->faction == f)
                    break;
            }
            if (u)
                continue;
            u = create_unit(r, f, 1, get_race(RC_GOBLIN), 0, NULL, NULL);
            set_string(&u->name, "Igjarjuks Auge");
            i_change(&u->items, it_find("roi"), 1);
            set_order(&u->thisorder, NULL);
            fset(u, UFL_ANON_FACTION);
            set_money(u, 1000);
        }
}
Ejemplo n.º 18
0
/** handles the "orcish" curse that makes units grow like old orks
 * This would probably be better handled in an age-function for the curse,
 * but it's now being called by randomevents()
 */
static void orc_growth(void)
{
  region *r;
  for (r = regions; r; r = r->next) {
    unit *u;
    for (u = r->units; u; u = u->next) {
      static bool init = false;
      static const curse_type *ct_orcish = 0;
      curse *c = 0;
      if (!init) {
        init = true;
        ct_orcish = ct_find("orcish");
      }
      if (ct_orcish)
        c = get_curse(u->attribs, ct_orcish);

      if (c && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY)
        && !fval(u, UFL_HERO)) {
        int n;
        int increase = 0;
        int num = get_cursedmen(u, c);
        double prob = curse_geteffect(c);
        const item_type * it_chastity = it_find("ao_chastity");

        if (it_chastity) {
            num -= i_get(u->items, it_chastity); 
        }
        for (n = num; n > 0; n--) {
          if (chance(prob)) {
            ++increase;
          }
        }
        if (increase) {
          unit *u2 = create_unit(r, u->faction, increase, u_race(u), 0, NULL, u);
          transfermen(u2, u, u2->number);

          ADDMSG(&u->faction->msgs, msg_message("orcgrowth",
              "unit amount race", u, increase, u_race(u)));
        }
      }
    }
  }
}
Ejemplo n.º 19
0
int sp_summon_alp(struct castorder *co)
{
  unit *alp, *opfer;
  region *r = co_get_region(co);
  unit *mage = co->magician.u;
  int cast_level = co->level;
  spellparameter *pa = co->par;
  const struct race *rc = get_race(RC_ALP);
  struct faction *f = get_monsters();
  struct message *msg;

  opfer = pa->param[0]->data.u;

  /* Der Alp gehört den Monstern, darum erhält der Magier auch keine
   * Regionsberichte von ihm.  Er erhält aber später eine Mitteilung,
   * sobald der Alp sein Opfer erreicht hat.
   */
  alp = create_unit(r, f, 1, rc, 0, NULL, NULL);
  set_level(alp, SK_STEALTH, 7);
  setstatus(alp, ST_FLEE);      /* flieht */

  {
    attrib *a = a_add(&alp->attribs, a_new(&at_alp));
    alp_data *ad = (alp_data *) a->data.v;
    ad->mage = mage;
    ad->target = opfer;
  }

  {
    /* Wenn der Alp stirbt, den Magier nachrichtigen */
    add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage,
        "trigger_alp_destroy", MSG_EVENT, ML_INFO));
    /* Wenn Opfer oder Magier nicht mehr existieren, dann stirbt der Alp */
    add_trigger(&mage->attribs, "destroy", trigger_killunit(alp));
    add_trigger(&opfer->attribs, "destroy", trigger_killunit(alp));
  }
  msg = msg_message("summon_alp_effect", "mage alp target", mage, alp, opfer);
  r_addmessage(r, mage->faction, msg);
  msg_release(msg);

  return cast_level;
}
Ejemplo n.º 20
0
int sp_wolfhowl(struct castorder * co)
{
  fighter * fi = co->magician.fig;
  int level = co->level;
  double power = co->force;
  battle *b = fi->side->battle;
  region *r = b->region;
  unit *mage = fi->unit;
  attrib *a;
  message *msg;
  int force = (int)(get_force(power, 3) / 2);
  const race * rc = new_race[RC_WOLF];
  if (force>0) {
    unit *u =
      create_unit(r, mage->faction, force, rc, 0, NULL, mage);
    leave(u, true);
    setstatus(u, ST_FIGHT);

    set_level(u, SK_WEAPONLESS, (int)(power / 3));
    set_level(u, SK_STAMINA, (int)(power / 3));
    u->hp = u->number * unit_max_hp(u);
    
    if (fval(mage, UFL_ANON_FACTION)) {
      fset(u, UFL_ANON_FACTION);
    }

    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);

    make_fighter(b, u, fi->side, is_attacker(fi));
  }
  msg =
    msg_message("sp_wolfhowl_effect", "mage amount race", mage, force, rc);
  message_all(b, msg);
  msg_release(msg);

  return level;
}
Ejemplo n.º 21
0
static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype,
    unit **victim, int v_r_flags, const char *v_shiptype) {
    terrain_type *vterrain;
    ship_type *st_boat = NULL;
    race *rc;
    faction *f;

    setup_piracy();
    vterrain = get_or_create_terrain("terrain1");
    fset(vterrain, v_r_flags);
    *victim = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, vterrain));
    assert(*victim);

    if (v_shiptype) {
        st_boat = st_get_or_create(v_shiptype);
        u_set_ship(*victim, test_create_ship((*victim)->region, st_boat));
        free(st_boat->coasts);
        st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
        st_boat->coasts[0] = vterrain;
        st_boat->coasts[1] = 0;
    }

    *pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(NULL), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
    fset(rc, p_rc_flags);
    assert(f && *pirate);

    if (p_shiptype) {
        st_boat = st_get_or_create(p_shiptype);
        u_set_ship(*pirate, test_create_ship((*pirate)->region, st_boat));
        free(st_boat->coasts);
        st_boat->coasts = (struct terrain_type **)calloc(2, sizeof(struct terrain_type *));
        st_boat->coasts[0] = vterrain;
        st_boat->coasts[1] = 0;
    }

    f->locale = get_or_create_locale("de");
    (*pirate)->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36((*victim)->faction->no));
}
Ejemplo n.º 22
0
int sp_shadowknights(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    unit *u;
    battle *b = fi->side->battle;
    region *r = b->region;
    unit *mage = fi->unit;
    attrib *a;
    int force = (int)fmax(1, get_force(power, 3));
    message *msg;

    u =
        create_unit(r, mage->faction, force, get_race(RC_SHADOWKNIGHT), 0, NULL,
        mage);
    unit_setstatus(u, ST_FIGHT);

    u->hp = u->number * unit_max_hp(u);

    if (mage->flags & UFL_ANON_FACTION) {
        u->flags |= UFL_ANON_FACTION;
    }

    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);

    make_fighter(b, u, fi->side, is_attacker(fi));

    msg = msg_message("sp_shadowknights_effect", "mage", mage);
    message_all(b, msg);
    msg_release(msg);

    return level;
}
Ejemplo n.º 23
0
void age_undead(unit * u)
{
  region *r = u->region;
  int n = 0;

  /* untote, die einer partei angehoeren, koennen sich
   * absplitten, anstatt sich zu vermehren. monster
   * untote vermehren sich nur noch */

  if (u->number > UNDEAD_MIN && !is_monsters(u->faction)
    && rng_int() % 100 < UNDEAD_BREAKUP) {
    int m;
    unit *u2;

    n = 0;
    for (m = u->number; m; m--) {
      if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION)
        ++n;
    }
    u2 = create_unit(r, get_monsters(), 0, get_race(RC_UNDEAD), 0, NULL, u);
    make_undead_unit(u2);
    transfermen(u, u2, u->number - n);
  }
}
Ejemplo n.º 24
0
bool command_executor::execute_command(const hotkey_command&  cmd, int /*index*/, bool press)
{
	// hotkey release handling
	if (!press) {
		switch(cmd.id) {
			// release a scroll key, un-apply scrolling in the given direction
			case HOTKEY_SCROLL_UP:
				scroll_up(false);
				break;
			case HOTKEY_SCROLL_DOWN:
				scroll_down(false);
				break;
			case HOTKEY_SCROLL_LEFT:
				scroll_left(false);
				break;
			case HOTKEY_SCROLL_RIGHT:
				scroll_right(false);
				break;
			default:
				return false; // nothing else handles a hotkey release
		}

		return true;
	}

	// hotkey press handling
	switch(cmd.id) {
		case HOTKEY_SCROLL_UP:
			scroll_up(true);
			break;
		case HOTKEY_SCROLL_DOWN:
			scroll_down(true);
			break;
		case HOTKEY_SCROLL_LEFT:
			scroll_left(true);
			break;
		case HOTKEY_SCROLL_RIGHT:
			scroll_right(true);
			break;
		case HOTKEY_CYCLE_UNITS:
			cycle_units();
			break;
		case HOTKEY_CYCLE_BACK_UNITS:
			cycle_back_units();
			break;
		case HOTKEY_ENDTURN:
			end_turn();
			break;
		case HOTKEY_UNIT_HOLD_POSITION:
			unit_hold_position();
			break;
		case HOTKEY_END_UNIT_TURN:
			end_unit_turn();
			break;
		case HOTKEY_LEADER:
			goto_leader();
			break;
		case HOTKEY_UNDO:
			undo();
			break;
		case HOTKEY_REDO:
			redo();
			break;
		case HOTKEY_TERRAIN_DESCRIPTION:
			terrain_description();
			break;
		case HOTKEY_UNIT_DESCRIPTION:
			unit_description();
			break;
		case HOTKEY_RENAME_UNIT:
			rename_unit();
			break;
		case HOTKEY_SAVE_GAME:
			save_game();
			break;
		case HOTKEY_SAVE_REPLAY:
			save_replay();
			break;
		case HOTKEY_SAVE_MAP:
			save_map();
			break;
		case HOTKEY_LOAD_GAME:
			load_game();
			break;
		case HOTKEY_TOGGLE_ELLIPSES:
			toggle_ellipses();
			break;
		case HOTKEY_TOGGLE_GRID:
			toggle_grid();
			break;
		case HOTKEY_STATUS_TABLE:
			status_table();
			break;
		case HOTKEY_RECALL:
			recall();
			break;
		case HOTKEY_LABEL_SETTINGS:
			label_settings();
			break;
		case HOTKEY_RECRUIT:
			recruit();
			break;
		case hotkey::HOTKEY_REPEAT_RECRUIT:
			repeat_recruit();
			break;
		case HOTKEY_SPEAK:
			speak();
			break;
		case HOTKEY_SPEAK_ALLY:
			whisper();
			break;
		case HOTKEY_SPEAK_ALL:
			shout();
			break;
		case HOTKEY_CREATE_UNIT:
			create_unit();
			break;
		case HOTKEY_CHANGE_SIDE:
			change_side();
			break;
		case HOTKEY_KILL_UNIT:
			kill_unit();
			break;
		case HOTKEY_PREFERENCES:
			preferences();
			break;
		case HOTKEY_OBJECTIVES:
			objectives();
			break;
		case HOTKEY_UNIT_LIST:
			unit_list();
			break;
		case HOTKEY_STATISTICS:
			show_statistics();
			break;
		case HOTKEY_STOP_NETWORK:
			stop_network();
			break;
		case HOTKEY_START_NETWORK:
			start_network();
			break;
		case HOTKEY_LABEL_TEAM_TERRAIN:
			label_terrain(true);
			break;
		case HOTKEY_LABEL_TERRAIN:
			label_terrain(false);
			break;
		case HOTKEY_CLEAR_LABELS:
			clear_labels();
			break;
		case HOTKEY_SHOW_ENEMY_MOVES:
			show_enemy_moves(false);
			break;
		case HOTKEY_BEST_ENEMY_MOVES:
			show_enemy_moves(true);
			break;
		case HOTKEY_DELAY_SHROUD:
			toggle_shroud_updates();
			break;
		case HOTKEY_UPDATE_SHROUD:
			update_shroud_now();
			break;
		case HOTKEY_CONTINUE_MOVE:
			continue_move();
			break;
		case HOTKEY_SEARCH:
			search();
			break;
		case HOTKEY_HELP:
			show_help();
			break;
		case HOTKEY_CHAT_LOG:
			show_chat_log();
			break;
		case HOTKEY_USER_CMD:
			user_command();
			break;
		case HOTKEY_CUSTOM_CMD:
			custom_command();
			break;
		case HOTKEY_AI_FORMULA:
			ai_formula();
			break;
		case HOTKEY_CLEAR_MSG:
			clear_messages();
			break;
		case HOTKEY_LANGUAGE:
			change_language();
			break;
		case HOTKEY_REPLAY_PLAY:
			play_replay();
			break;
		case HOTKEY_REPLAY_RESET:
			reset_replay();
			break;
		case HOTKEY_REPLAY_STOP:
			stop_replay();
			break;
		case HOTKEY_REPLAY_NEXT_TURN:
			replay_next_turn();
			break;
		case HOTKEY_REPLAY_NEXT_SIDE:
			replay_next_side();
			break;
		case HOTKEY_REPLAY_NEXT_MOVE:
			replay_next_move();
			break;
		case HOTKEY_REPLAY_SHOW_EVERYTHING:
			replay_show_everything();
			break;
		case HOTKEY_REPLAY_SHOW_EACH:
			replay_show_each();
			break;
		case HOTKEY_REPLAY_SHOW_TEAM1:
			replay_show_team1();
			break;
		case HOTKEY_REPLAY_SKIP_ANIMATION:
			replay_skip_animation();
			break;
		case HOTKEY_REPLAY_EXIT:
			replay_exit();
			break;
		case HOTKEY_WB_TOGGLE:
			whiteboard_toggle();
			break;
		case HOTKEY_WB_EXECUTE_ACTION:
			whiteboard_execute_action();
			break;
		case HOTKEY_WB_EXECUTE_ALL_ACTIONS:
			whiteboard_execute_all_actions();
			break;
		case HOTKEY_WB_DELETE_ACTION:
			whiteboard_delete_action();
			break;
		case HOTKEY_WB_BUMP_UP_ACTION:
			whiteboard_bump_up_action();
			break;
		case HOTKEY_WB_BUMP_DOWN_ACTION:
			whiteboard_bump_down_action();
			break;
		case HOTKEY_WB_SUPPOSE_DEAD:
			whiteboard_suppose_dead();
			break;
		case HOTKEY_SELECT_HEX:
			select_hex();
			break;
		case HOTKEY_DESELECT_HEX:
			deselect_hex();
			break;
		case HOTKEY_MOVE_ACTION:
			move_action();
			break;
		case HOTKEY_SELECT_AND_ACTION:
			select_and_action();
			break;
		case HOTKEY_ACCELERATED:
			toggle_accelerated_speed();
			break;
		case LUA_CONSOLE:
			lua_console();
			break;
		case HOTKEY_ZOOM_IN:
			zoom_in();
			break;
		case HOTKEY_ZOOM_OUT:
			zoom_out();
			break;
		case HOTKEY_ZOOM_DEFAULT:
			zoom_default();
			break;
		case HOTKEY_MAP_SCREENSHOT:
			map_screenshot();
			break;
		case HOTKEY_QUIT_TO_DESKTOP:
			quit_confirmation::quit_to_desktop();
			break;
		case HOTKEY_QUIT_GAME:
			quit_confirmation::quit_to_title();
			break;
		default:
			return false;
	}
	return true;
}
Ejemplo n.º 25
0
struct unit *test_create_unit(struct faction *f, struct region *r)
{
  unit *u = create_unit(r, f, 1, f?f->race:rc_find("human"), 0, 0, 0);
  return u;
}
Ejemplo n.º 26
0
static void get_allies(region * r, unit * u)
{
  unit *newunit = NULL;
  const char *name;
  const char *equip;
  int number;
  message *msg;

  assert(u->number);

  switch (rterrain(r)) {
    case T_PLAIN:
      if (!r_isforest(r)) {
        if (get_money(u) / u->number < 100 + rng_int() % 200)
          return;
        name = "random_plain_men";
        equip = "random_plain";
        number = rng_int() % 8 + 2;
        break;
      } else {
        if (eff_skill(u, SK_LONGBOW, r) < 3
          && eff_skill(u, SK_HERBALISM, r) < 2
          && eff_skill(u, SK_MAGIC, r) < 2) {
          return;
        }
        name = "random_forest_men";
        equip = "random_forest";
        number = rng_int() % 6 + 2;
      }
      break;

    case T_SWAMP:
      if (eff_skill(u, SK_MELEE, r) <= 1) {
        return;
      }
      name = "random_swamp_men";
      equip = "random_swamp";
      number = rng_int() % 6 + 2;
      break;

    case T_DESERT:
      if (eff_skill(u, SK_RIDING, r) <= 2) {
        return;
      }
      name = "random_desert_men";
      equip = "random_desert";
      number = rng_int() % 12 + 2;
      break;

    case T_HIGHLAND:
      if (eff_skill(u, SK_MELEE, r) <= 1) {
        return;
      }
      name = "random_highland_men";
      equip = "random_highland";
      number = rng_int() % 8 + 2;
      break;

    case T_MOUNTAIN:
      if (eff_skill(u, SK_MELEE, r) <= 1 || eff_skill(u, SK_TRADE, r) <= 2) {
        return;
      }
      name = "random_mountain_men";
      equip = "random_mountain";
      number = rng_int() % 6 + 2;
      break;

    case T_GLACIER:
      if (eff_skill(u, SK_MELEE, r) <= 1 || eff_skill(u, SK_TRADE, r) <= 1) {
        return;
      }
      name = "random_glacier_men";
      equip = "random_glacier";
      number = rng_int() % 4 + 2;
      break;

    default:
      return;
  }

  newunit =
    create_unit(r, u->faction, number, u->faction->race, 0,
    LOC(u->faction->locale, name), u);
  equip_unit(newunit, get_equipment(equip));

  u_setfaction(newunit, u->faction);
  set_racename(&newunit->attribs, get_racename(u->attribs));
  if (u_race(u)->flags & RCF_SHAPESHIFT) {
    newunit->irace = u->irace;
  }
  if (fval(u, UFL_ANON_FACTION))
    fset(newunit, UFL_ANON_FACTION);
  fset(newunit, UFL_ISNEW);

  msg = msg_message("encounter_allies", "unit name", u, name);
  r_addmessage(r, u->faction, msg);
  msg_release(msg);
}
Ejemplo n.º 27
0
Archivo: chaos.c Proyecto: stm2/server
static void chaos(region * r)
{
    if (rng_int() % 100 < 8) {
        switch (rng_int() % 3) {
        case 0:                  /* Untote */
            if (!fval(r->terrain, SEA_REGION)) {
                unit *u = random_unit(r);
                if (u && playerrace(u_race(u))) {
                    ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u));
                    u_setfaction(u, get_monsters());
                    u_setrace(u, get_race(RC_GHOUL));
                }
            }
            break;
        case 1:                  /* Drachen */
            if (random_unit(r)) {
                int mfac = 0;
                unit *u;
                switch (rng_int() % 3) {
                case 0:
                    mfac = 100;
                    u =
                        create_unit(r, get_monsters(), rng_int() % 8 + 1,
                        get_race(RC_FIREDRAGON), 0, NULL, NULL);
                    break;
                case 1:
                    mfac = 500;
                    u =
                        create_unit(r, get_monsters(), rng_int() % 4 + 1,
                        get_race(RC_DRAGON), 0, NULL, NULL);
                    break;
                default:
                    mfac = 1000;
                    u =
                        create_unit(r, get_monsters(), rng_int() % 2 + 1,
                        get_race(RC_WYRM), 0, NULL, NULL);
                    break;
                }
                if (mfac)
                    set_money(u, u->number * (rng_int() % mfac));
                fset(u, UFL_ISNEW | UFL_MOVED);
            }
            break;
        case 2:                  /* Terrainveränderung */
            if (!fval(r->terrain, FORBIDDEN_REGION)) {
                if (!fval(r->terrain, SEA_REGION)) {
                    direction_t dir;
                    for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
                        region *rn = rconnect(r, dir);
                        if (rn && fval(rn->terrain, SEA_REGION))
                            break;
                    }
                    if (dir != MAXDIRECTIONS) {
                        ship *sh = r->ships;
                        unit **up;

                        while (sh) {
                            ship *nsh = sh->next;
                            double dmg =
                                config_get_flt("rules.ship.damage.atlantis",
                                0.50);
                            damage_ship(sh, dmg);
                            if (sh->damage >= sh->size * DAMAGE_SCALE) {
                                remove_ship(&sh->region->ships, sh);
                            }
                            sh = nsh;
                        }

                        for (up = &r->units; *up;) {
                            unit *u = *up;
                            if (u_race(u) != get_race(RC_SPELL) && u->ship == 0 && !canfly(u)) {
                                ADDMSG(&u->faction->msgs, msg_message("tidalwave_kill",
                                    "region unit", r, u));
                                remove_unit(up, u);
                            }
                            if (*up == u)
                                up = &u->next;
                        }
                        ADDMSG(&r->msgs, msg_message("tidalwave", "region", r));

                        while (r->buildings) {
                            remove_building(&r->buildings, r->buildings);
                        }
                        terraform_region(r, newterrain(T_OCEAN));
                    }
                }
                else {
                    direction_t dir;
                    for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
                        region *rn = rconnect(r, dir);
                        if (rn && fval(rn->terrain, SEA_REGION))
                            break;
                    }
                    if (dir != MAXDIRECTIONS) {
                        terraform_region(r, chaosterrain());
                    }
                }
            }
        }
    }
}
Ejemplo n.º 28
0
Archivo: oc_east1.cpp Proyecto: 7k2/7k2
//---- Begin of function CampaignEastWest::stage_1_create_game ----//
//
// Vars defined in event functions before calling this function:
//
// None
//
int CampaignEastWest::stage_1_create_game()
{
    // ###### begin Gilbert 9/4 ########//
    init_random_plot(0);		// no plot
    // ###### end Gilbert 9/4 ########//

    if( !stage_1_create_nation() )
        return 0;

    if( !stage_1_create_town() )
        return 0;

    if( !stage_1_create_firm() )
        return 0;

    //------ create monsters ---------//

    int unitCountArray[MAX_CAMPAIGN_DIFFICULTY] = { 6, 10, 22, 31, 42 };

    create_troop(STAGE_1_MONSTER_NATION_RECNO, unitCountArray[campaign_difficulty-1] );

    if( unit_group.size() > 0 )		// when a troop is created successfully in create_troop(), unit_group will keep the created units
    {
        //--- create a unit for building

        Unit* unitPtr = unit_group.get_unit(1);
        int   xLoc = unitPtr->cur_x_loc();
        int   yLoc = unitPtr->cur_y_loc();

        int unitRecno = create_unit( STAGE_1_MONSTER_NATION_RECNO,
                                     unitPtr->unit_id, RANK_SOLDIER, xLoc, yLoc, xLoc, yLoc );
    }

    //------ init stage 1 vars -------//

    stage_1_init_vars();

    //---- generate plants and other objects on the map -----//

    world.gen_rocks();		// generate mountains

    world.generate_map2();

    //------- create additional raw sites ----------//

    create_raw_site();

    //------- init relationship -------//

    stage_1_init_relation();

    // ####### begin Gilbert 9/4 ########//
    // ----- create royal units ------//

    create_royal_units(CAMPAIGN_PLAYER_NATION_RECNO);
    // ####### end Gilbert 9/4 ########//

    //------ plot create game --------//

    // ###### begin Gilbert 28/3 ########//
    (this->*plot_create_game_FP)();
    // ###### end Gilbert 28/3 ########//

    return 1;
}
Ejemplo n.º 29
0
//-------- Begin of function Battle::create_pregame_object --------//
//
// Initialize pre-game objects - towns, sites, independent towns.
//
void Battle::create_pregame_object()
{
	#define CREATE_UNIT_AREA_WIDTH     16
	#define CREATE_UNIT_AREA_HEIGHT    16

	// ###### begin Gilbert 24/10 ######//
	const int dispProgress = 1;
	const int maxGenMapSteps = 100;
	const int newWorldSection = 1;
	vga_front.unlock_buf();

	int curGenMapSteps = 0;
	if( dispProgress )
	{
		vga_front.lock_buf();
		game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection);
		vga_front.unlock_buf();
	}
	// ###### end Gilbert 24/10 ######//

	//------- create nation and units --------//

	int 		nationRecno, unitId, rankId, xLoc, yLoc, townRecno;
	int		kingUnitRecno;
	int		noSpaceFlag=0;
	Nation*  nationPtr;

	for( nationRecno=1 ; nationRecno<=nation_array.size() ; nationRecno++ )
	{
		if( nation_array.is_deleted(nationRecno) )
			continue;

		nationPtr = nation_array[nationRecno];

		//--------- create town -----------//

		townRecno = create_town( nationRecno, nationPtr->race_id, xLoc, yLoc );

		if( !townRecno )
		{
			noSpaceFlag = 1;
			break;
		}

		//------- create military camp -------//

		Town* townPtr = town_array[townRecno];

		int firmRecno = firm_array.build_firm(townPtr->loc_x1+6, townPtr->loc_y1,
							 nationRecno, FIRM_CAMP, race_res[nationPtr->race_id]->code);

		if( !firmRecno )
		{
			noSpaceFlag = 1;
			break;
		}

		firm_array[firmRecno]->complete_construction();

		//--------- create units ----------//

		unitId = race_res[nationPtr->race_id]->basic_unit_id;

		kingUnitRecno = create_unit(townRecno, unitId, RANK_KING);

		if( kingUnitRecno )
		{
			nation_array[nationRecno]->set_king(kingUnitRecno, 1);		// 1-this is the first king of the nation
			firm_array[firmRecno]->assign_overseer(kingUnitRecno);	// assign the king as the overseer of the command base
		}
		else
		{
			noSpaceFlag = 1;
			break;
		}

		//----- create skilled units if config.random_start_up is 1 -----//

		if( config.random_start_up )
		{
			int createCount = (50-townPtr->population)/3;		// the less population the villager has the more mobile units will be created

			for( int i=0 ; i<createCount ; i++ )
			{
				if( misc.random(2)==0 )
					unitId = race_res[nationPtr->race_id]->basic_unit_id;
				else
					unitId = race_res[ misc.random(MAX_RACE)+1 ]->basic_unit_id;

				if( misc.random(3)==0 )
					rankId = RANK_GENERAL;
				else
					rankId = RANK_SOLDIER;

				if( !create_unit(townRecno, unitId, rankId) )
					break;
			}
		}

		//------ create mines near towns in the beginning -----//

		if( config.start_up_has_mine_nearby && !nationPtr->is_ai() )
			site_array.create_raw_site(0, townRecno);
	}

	//--- if there is no space for creating new town/firm or unit, delete the unprocessed nations ---//

	if( noSpaceFlag )
	{
		for( ; nationRecno<=nation_array.size() ; nationRecno++ )
			nation_array.del_nation(nationRecno);		// no space for creating a town for the nation, so we have to delete the nation
	}

	// ###### begin Gilbert 24/10 ########//
	curGenMapSteps += 10;			// 10
	if( dispProgress )
	{
		vga_front.lock_buf();
		game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection);
		vga_front.unlock_buf();
	}
	// ###### end Gilbert 24/10 ######//

	//---- init the type of active monsters in this game ----//

	monster_res.init_active_monster();
	// ###### begin Gilbert 24/10 ########//
	curGenMapSteps += 5;			// 15
	if( dispProgress )
	{
		vga_front.lock_buf();
		game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection);
		vga_front.unlock_buf();
	}
	// ###### end Gilbert 24/10 ######//

	//------ create independent towns -------//

	//### begin alex 27/8 ###//
	int startUpIndependentTown = config.start_up_independent_town;
	//int startUpRawSite = config.start_up_raw_site;
	int startUpMonsterFirm = 10;
	int i, j, raceId;

	site_array.generate_raw_site(config.start_up_raw_site);
	// ###### begin Gilbert 24/10 ########//
	curGenMapSteps += 10;			// 25
	if( dispProgress )
	{
		vga_front.lock_buf();
		game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection);
		vga_front.unlock_buf();
	}

	int targetStep = maxGenMapSteps;
	// ###### end Gilbert 24/10 ######//

	int maxLoopCount = startUpIndependentTown + startUpMonsterFirm;

	for(j=0, i=1; j<maxLoopCount; j++, i++)
	{
		if(startUpIndependentTown)
		{
			//------ create independent towns -------//
			raceId = i%MAX_RACE+1;
			if(!create_town( 0, raceId, xLoc, yLoc ) )
			{
				startUpIndependentTown = 0;
				break;
			}
			// ##### begin Gilbert 24/10 #######//
			else
				startUpIndependentTown--;
			// ###### end Gilbert 24/10 ########//
		}

		if(startUpMonsterFirm)
		{
			//------- create mosnters --------//
			if(config.monster_type != OPTION_MONSTER_NONE)
			{
				monster_res.generate(1);
				startUpMonsterFirm--;
			}
			else
				startUpMonsterFirm = 0;
		}

		if(!(startUpIndependentTown+startUpMonsterFirm))
			break;

		// ###### begin Gilbert 24/10 ########//
		if( dispProgress )
		{
			vga_front.lock_buf();
			game.disp_gen_map_status( curGenMapSteps + j*(targetStep-curGenMapSteps)/maxLoopCount, maxGenMapSteps, newWorldSection);
			vga_front.unlock_buf();
		}
		// ###### end Gilbert 24/10 ######//
	}
	//#### end alex 27/8 ####//

	// ###### begin Gilbert 24/10 ########//
	// finish
	curGenMapSteps = targetStep;		// 100
	if( dispProgress )
	{
		vga_front.lock_buf();
		game.disp_gen_map_status( curGenMapSteps, maxGenMapSteps, newWorldSection);
		vga_front.unlock_buf();
	}
	// ###### end Gilbert 24/10 ######//

	vga_front.lock_buf();
}
Ejemplo n.º 30
0
/** Untote können entstehen */
void spawn_undead(void)
{
    region *r;
    faction *monsters = get_monsters();

    for (r = regions; r; r = r->next) {
        int unburied = deathcount(r);
        static const curse_type *ctype = NULL;

        if (!ctype)
            ctype = ct_find("holyground");
        if (ctype && curse_active(get_curse(r->attribs, ctype)))
            continue;

        /* Chance 0.1% * chaosfactor */
        if (r->land && unburied > r->land->peasants / 20
            && rng_int() % 10000 < (100 + 100 * chaosfactor(r))) {
            message *msg;
            unit *u;
            /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen.
             * Lieber sammeln lassen, bis sie mindestens 5% der Bevölkerung sind, und
             * dann erst auferstehen. */
            int undead = unburied / (rng_int() % 2 + 1);
            const race *rc = NULL;
            int i;
            if (r->age < 100)
                undead = undead * r->age / 100; /* newbie-regionen kriegen weniger ab */

            if (!undead || r->age < 20)
                continue;

            switch (rng_int() % 3) {
            case 0:
                rc = get_race(RC_SKELETON);
                break;
            case 1:
                rc = get_race(RC_ZOMBIE);
                break;
            default:
                rc = get_race(RC_GHOUL);
                break;
            }

            u = create_unit(r, monsters, undead, rc, 0, NULL, NULL);
            fset(u, UFL_ISNEW | UFL_MOVED);
            if ((rc == get_race(RC_SKELETON) || rc == get_race(RC_ZOMBIE))
                && rng_int() % 10 < 4) {
                equip_unit(u, get_equipment("rising_undead"));
            }

            for (i = 0; i < MAXSKILLS; i++) {
                if (rc->bonus[i] >= 1) {
                    set_level(u, (skill_t)i, 1);
                }
            }
            u->hp = unit_max_hp(u) * u->number;

            deathcounts(r, -undead);
            name_unit(u);

            log_debug("spawning %d %s in %s.\n", u->number,
                LOC(default_locale,
                rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL));
          msg = msg_message("undeadrise", "region", r);
          add_message(&r->msgs, msg);
          for (u = r->units; u; u = u->next)
              freset(u->faction, FFL_SELECT);
          for (u = r->units; u; u = u->next) {
              if (fval(u->faction, FFL_SELECT))
                  continue;
              fset(u->faction, FFL_SELECT);
              add_message(&u->faction->msgs, msg);
          }
          msg_release(msg);
        }
        else {
            int i = deathcount(r);
            if (i) {
                /* Gräber verwittern, 3% der Untoten finden die ewige Ruhe */
                deathcounts(r, (int)(-i * 0.03));
            }
        }
    }
}