Exemple #1
0
void Dungeon::game_turn()
{

	Character *c;
	if (PC::instance()->is_alive()) {
		queue_pc_turn();
	}

	while (PC::instance()->is_alive() &&
		(c = event_queue.remove_shift()) &&
		(c != PC::instance())) {
		int next = ((NPC*)c)->get_next_location(floors.at(active_floor));
		move_npc((NPC *)c, next);

		add_event((1000 / c->get_speed()), c);
	}
	IO_handler::instance()->display_dungeon();
	if (PC::instance()->is_alive() && c == PC::instance()) {
		IO_handler::instance()->handle_input();
	}
}
int CharacterScriptInterface:: Division(lua_State * l_)
{
	Character* character = static_cast< Character* >( lua_touserdata( l_, 1 ) );
	float x= lua_tonumber(l_,2);
	float y= lua_tonumber(l_, 3);

	ValfirleToken::CreateData data;
	data.Position = LVector3(x,y,1.f);
	data.WeaponLevel = 1;
	data.WeaponType = WEAPON_VALFIRLE_TOKEN;
	ValfirleToken *pBoss = ValfirleToken::create(&data);
	pBoss->setDirection(character->getDirection());
	//pBoss->setVelocity(LVector3(5,4,1.f));
	pBoss->setInvincibleFrame(50);
	pBoss->setScore(1);
	pBoss->setLife(100);
	pBoss->setDefPosition(LVector3(x,y,1.f));
	
//	printf("分裂\n");
	return 0;
}
Exemple #3
0
void TriPickDemo::onResetDevice()
{
	HR(m_FX->OnResetDevice());
	HR(m_pCharacter->GetEffect()->OnResetDevice());
	//Aspect ratio rely on the size of back buffer 
	//Back buffer will change when user change window size, so we need to reset project matrix.
	float w = (float)md3dPP.BackBufferWidth;
	float h = (float)md3dPP.BackBufferHeight;

	g_Camera->setLens(D3DX_PI * 0.25f, w / h, 0.1f, 1000.0f);

}
Exemple #4
0
void undoLastMove(Character & paladin, stack<std::shared_ptr<Memento>> & checkPoints)
{
	if (not checkPoints.empty())
	{
		paladin.restore(checkPoints.top() );
		checkPoints.pop();
	}
	else
	{
		cout << "No checkpoints to restore character state!" << endl;
	}
}
Exemple #5
0
void Character::spell_change_sex (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;
  Affect af;

  if (victim->has_affect(sn))
    return;
  af.type = sn;
  af.duration = 10 * lvl;
  af.location = APPLY_SEX;
  do {
    af.modifier = number_range (0, 2) - victim->sex;
  }
  while (af.modifier == 0);
  af.bitvector = 0;
  victim->affect_to_char(&af);
  victim->send_to_char ("You feel different.\r\n");
  if (this != victim)
    send_to_char ("Ok.\r\n");
  return;
}
Exemple #6
0
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    
    using RBSpace::Character;
    Character *ch = new Character;
    ch->getStr();
    ch->getStr2();
    
    delete ch;
    ch = NULL;

    DLog("test:%s", "zruibin\n");
    
    testASM001();

    // RBSpace::testHttpClient(); //测试curl
    RBSpace::threadTest(); //测试多线程

    return 0;
}
Exemple #7
0
void Character::spell_colour_spray (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;
  static const sh_int dam_each[] = {
    0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    30, 35, 40, 45, 50, 55, 55, 55, 56, 57,
    58, 58, 59, 60, 61, 61, 62, 63, 64, 64,
    65, 66, 67, 67, 68, 69, 70, 70, 71, 72,
    73, 73, 74, 75, 76, 76, 77, 78, 79, 79
  };

  lvl = std::min (lvl, (int) (sizeof (dam_each) / sizeof (dam_each[0]) - 1));
  lvl = std::max (0, lvl);
  int dam = number_range (dam_each[lvl] / 2, dam_each[lvl] * 2);
  if (victim->saves_spell (lvl))
    dam /= 2;

  damage (this, victim, dam, sn);
  return;
}
void TaskWaitForAction::run(double deltaTime)
{
	// Glotz Ghost reacts if its in fov

	//Wenn er gesehen wird, geht er auf den Character los
	if( fov->isCharacterSeen(character) )
	{
		deactivate();
		parent->childTerminated(this,true);
		return;
	}

	//Prüft ob der Spieler nah genug dran ist um Leben zu verlieren
	Character *player = CharacterManager::instance()->getCharacter("Player");
	if((character->getPosition() - player->getPosition()).getLength() <= GHOST_PLAYER_DIST)
	{
		// Player dies
		PlayerMoveComponent *movComp = getComponent<PlayerMoveComponent>(player);
		movComp->loseHealth(5);
	}
}
int script::offerSkills(lua_State *L)
{
	const int n = lua_gettop(L);
	if (n < 4)
		return 0;
	Character *c = (Character *)lua_touserdata(L, 1);
	Entity *e = (Entity *)lua_touserdata(L, 2);
	size_t sz;
	const char *text = lua_tolstring(L, 3, &sz);
	bool spells = lua_toboolean(L, 4);

	std::vector<SkillInfo *> skills;
	for (int i = 5; i <= n; i++) {
		SkillInfo *si = SkillInfo::getById((unsigned)lua_tonumber(L, i));
		if (si)
			skills.push_back(si);
	}

	Server::sendSkillList(c->getSession(), e, sz, text, skills, spells);
	return 0;
}
Exemple #10
0
bool ChatHandler::HandleAppearCommand(uint8* args)
{
    wowWData data;

    if(!*args)
        return false;

	Character *pChar = getCurrentCharByName(args);
	if (pChar)
	{
		uint16 c=pChar->getMapId();
		float x=pChar->getPositionX();
		float y=pChar->getPositionY();
		float z=pChar->getPositionZ();
		Message(pChar,"appear to");

		smsg_NewWorld(m_pClient, c,x,y,z);
	}

    return true;
}
Exemple #11
0
	// Initializeaza primele personaje, variabilele pentru cutremur si camerele.
	void init() {
		if (!special_mode) {
			main_character = new Character(MAIN_ACTIVE, main_slope, obj_build, quad);
			second_character = new Character(SECOND_ACTIVE, second_slope, obj_build, quad);
		}
		else {
			main_character = new Character(MAIN_SPECIAL, main_slope, obj_build, quad);
			second_character = new Character(SECOND_SPECIAL, second_slope, obj_build, quad);
		}
		characters.push_back(main_character);
		characters.push_back(second_character);

		x_quake = -1;
		amplitude = 0;
		frequency = 0;
		srand(time(NULL));
		stop = false;

		cam_index = 0;
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams.push_back(new lab::Camera());
		cams[1]->set(glm::vec3(10, 1, quad->getSize() - 10), glm::vec3(43, 30, 30), glm::vec3(0, 1, 0));
		cams[3]->set(glm::vec3(quad->getSize() - 10, 1, quad->getSize() - 10), glm::vec3(56, 40, 30), glm::vec3(0, 1, 0));
		cams[6]->set(glm::vec3(50, 100, 50), glm::vec3(49, 0, 49), glm::vec3(0, 100, 50));
		cams[6]->rotateFPSoX(-1.0f);

		delete cams[0];
		delete cams[2];
		delete cams[4];
		delete cams[5];
		cams[0] = main_character->getFpsCam();
		cams[2] = second_character->getFpsCam();
		cams[4] = main_character->getTpsCam();
		cams[5] = second_character->getTpsCam();
	}
bool KeyboardCharacterMover::impact(Character &character)
{
// Store character velocity
    m_characterVelocityY = character.m_velocityY;

//Check rebound in y axis
    if(m_physic.checkRebound(character.m_velocityY))
    {
        ServiceLocator::GetAudio()->playSound("impact.ogg", 100, false);
        character.m_damagesFilter.setAlpha(100);
        character.m_damagesFilter.setActive(true);

        if(m_characterVelocityY <= 700)
            character.getLife().removeLife(m_characterVelocityY * 1/30 * (100 - character.getProperty(Property::Protection)) / 100);

        if(m_characterVelocityY > 700 && m_characterVelocityY <= 1000)
            character.getLife().removeLife(m_characterVelocityY * 1/20 * (100 - character.getProperty(Property::Protection)) / 100);

        if(m_characterVelocityY > 1000)
            character.getLife().removeLife(m_characterVelocityY * 1/12 * (100 - character.getProperty(Property::Protection)) / 100);

        return true;
    }

//If there's no rebound
    else if(m_characterVelocityY > 0)
    {
        m_flying = false;
        character.m_velocityY = 0;
        return false;
    }

    return false;
}
Exemple #13
0
static void handleGivePermission(Character *player, std::string &args)
{
    Character *other;

    // get the arguments
    std::string character = getArgument(args);
    std::string strPermission = getArgument(args);

    // check all arguments are there
    if (character.empty() || strPermission.empty())
    {
        say("Invalid number of arguments given.", player);
        say("Usage: @givepermission <character> <permission class>", player);
        return;
    }

    // check if its to effect the player
    if (character == "#")
    {
        other = player;
    }
    else
    {
        // check for valid player
        other = gameHandler->getCharacterByNameSlow(character);
        if (!other)
        {
            say("Invalid character", player);
            return;
        }
    }

    unsigned char permission = PermissionManager::getMaskFromAlias(strPermission);

    if (permission == 0x00)
    {
        say ("Unknown permission class: "+strPermission, player);
        return;
    }

    if (permission & other->getAccountLevel())
    {
        say(player->getName()+" already has the permission "+strPermission, player);
    }
    else
    {
        permission += other->getAccountLevel();
        // change the player's account level
        other->setAccountLevel(permission);
        accountHandler->changeAccountLevel(other, permission);

        // log transaction
        std::string msg = "User gave right " + strPermission + " to " + other->getName();
        accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SETGROUP, msg);
        say("You gave " + other->getName() +
            " the rights of a " + strPermission, player);
        say("Congratulations, " + player->getName() +
            " gave you the rights of a " + strPermission, other);
    }
}
Exemple #14
0
static void handleTakeSpecial(Character *player, std::string &args)
{
    std::string character = getArgument(args);
    std::string special = getArgument(args);
    if (character.empty() || special.empty())
    {
        say("Invalid amount of arguments given.", player);
        say("Usage: @takespecial <character> <special>", player);
        return;
    }

    Character *other;
    if (character == "#")
        other = player;
    else
        other = gameHandler->getCharacterByNameSlow(character);

    if (!other)
    {
        say("Invalid character, or player is offline.", player);
        return;
    }

    int specialId;
    if (utils::isNumeric(special))
        specialId = utils::stringToInt(special);
    else
        specialId = specialManager->getId(special);

    if (specialId <= 0)
    {
        say("Invalid special.", player);
        return;
    }
    if (!other->takeSpecial(specialId))
    {
        say("Character does not have special.", player);
        return;
    }
}
bool CanUseSkill(Client* client)
{
	Character* chr = client->chr;

	if ( chr->dead() )
	{
		private_say_above(chr, chr, "I am dead and cannot do that.");
		return false;
	}
	else if ( chr->skill_ex_active() || chr->casting_spell() )
	{
		private_say_above(chr, chr,"I am already performing another action.");
		return false;
	}
	else if ( poltime() < chr->disable_skills_until )
	{
		send_sysmessage(client, "You must wait to perform another action.");
		return false;
	}
	else if ( chr->frozen() || chr->paralyzed() )
	{
		private_say_above(chr, chr, "I am frozen and cannot do that.");
		return false;
	}

	return true;
}
Exemple #16
0
bool CoordinateUtil::isInFOV(Character &source, Character &target, Direction direction,
                             float fovAngleR, float fovDistance)
{
    // Get the Sprite positions
    Vector2f sourceCenter(source.getSize().x / 2, source.getSize().y / 2);
    Vector2f targetCenter(target.getSize().x / 2, target.getSize().y / 2);


    // Transform the target position into the source's coordinate space
    //cout << "-----" << endl;
    //cout << PRINT_V(targetCenter) << endl;
    targetCenter = target.getSprite()->toGlobal(targetCenter);
    //cout << PRINT_V(targetCenter) << endl;
    targetCenter = source.getSprite()->toLocal(targetCenter);

    // Perform the FOV check
    bool insideFOV = false;
    float distance = getDistance(sourceCenter, targetCenter);
    // TODO multiply distance my scale of source
    //cout << PRINT_V(sourceCenter) << " -> " << PRINT_V(targetCenter) << " = ";
    //cout << distance << endl;
    if(distance <= fovDistance)
    {
        // Check the angle between the source and the target
        float angleR = atan2(targetCenter.y - sourceCenter.y, targetCenter.x - sourceCenter.x);

        // TODO: Only works if source if facing left
        if(direction == Left)
            angleR += M_PI;
        if(angleR <= fovAngleR || angleR >= M_PI_2 - fovAngleR)
            insideFOV = true;
    }

    return insideFOV;
}
Character* chooseCharacter() {
	Character* character;

	cout << " Character Special Powers: " << endl;
	cout << endl;
	cout << " Samurai: returns from the dead! " << endl;
	cout << " Knight: gains 20 extra attack points! " << endl;
	cout << " Zombie: returns from the dead! " << endl;
	cout << " Ghost: gains 20 extra health points! " << endl;
	cout << endl;
	cout << " What character do you want to play as: (S)amurai, (K)night, (Z)ombie or (G)host: ";

	char name;
	cin >> name;
	while (name != 'S' && name != 'K' && name != 'Z' && name != 'G')
	{
		cout << " That is an incorrect choice. Try again! ";
		cin >> name;
	}
	if (name == 'S') {
		character = new Samurai;
		character->addCharacter();
		return character;
	}
	if (name == 'K') {
		character = new Knight;
		character->addCharacter();
		return character;
	}
	if (name == 'Z') {
		character = new Zombie;
		character->addCharacter();
		return character;
	}
	if (name == 'G') {
		character = new Ghost;
		character->addCharacter();
		return character;
	}
}
Exemple #18
0
void DataService::recallChar(const char *name, int priv, Character *c)
{
	lock();
	auto cs = characters->find(name);
	if (cs != characters->end()) {
		Character *t = cs->second->getCharacter();
		if (t->getPrivilegeLevel() > priv) {
			unlock();
			throw E_INVALID;
		}
		{
			LockedChar tc = t;
			Map *m = tc->getMap();
			Server::leaveMap(cs->second);
			m->removeEntity(tc.get());
		}
		{
			LockedChar lc = c;
			Map *m = lc->getMap();
			t->setMap(m);
			t->changedMap(m);
			t->setX(lc->getX());
			t->setY(lc->getY());
			m->addEntity(t, 3);
		}
	}
	else {
		unlock();
		throw E_NOEXIST;
	}
	unlock();
}
void setView_Scroll(sf::View &view, Character &character, gameMap &map)
{
    float height = view.getSize().y;
    float width  = view.getSize().x;
    float maxW = map.getWidth()*(map.getTile(0).getTileDims().x);
    float maxH = map.getHeight()*(map.getTile(0).getTileDims().y);
    float newX = 0;
    float newY = 0;

    if(character.getPosition().x < width/2)
    {
        newX = width/2;
    }else if(character.getPosition().x > maxW - width/2)
    {
        newX  = maxW - width/2;
    }else
    {
        newX = round(character.getPosition().x);
    }
        if(character.getPosition().y < height/2)
    {
        newY = height/2;
    }else if(character.getPosition().y > maxH - height/2)
    {
        newY  = maxH - height/2;
    }else
    {
        newY = round(character.getPosition().y);
    }
    view.setCenter(newX, newY);
}
Exemple #20
0
void Character::findVisible(){
	Character* chr;
	int cLook = lookDir->getIndex();
	int dLook;
	int dx, dy;
	Hit* hit;
	Ray* ray;
	Vertex* origin;
	Vertex* vert = model->getModelWrapper(HEAD)->getModel()->getCenter();
	Vertex* cVert;
	Coordinate* cCoord;
	Vector* vec;
	for(size_t i = 1; i < 3; i++){
		for(size_t j = 0; j < map->getCharacterSize(i); j++){
			chr = map->getCharacter(i, j);	
			cCoord = chr->getCoord();		
			dLook = abs(cLook - dirTo(cCoord)->getIndex());	
			if(dLook <= 1 || dLook == 7){
				dx = abs(loc->get(X) - cCoord->get(X));
				dy = abs(loc->get(Y) - cCoord->get(Y));
				if(dx + dy < 50){
					origin = new Vertex(vert->get(X) + loc->get(X),
							vert->get(Y), vert->get(Z) + loc->get(Y));
					cVert = chr->getCharModel()->getModelWrapper(TORSO)->getModel()->getCenter();
					vec = new Vector(cVert->get(X) + cCoord->get(X) - origin->get(X),
							cVert->get(Y) - origin->get(Y),
							cVert->get(Z) + cCoord->get(Y) - origin->get(Z));	
					ray = new Ray(origin, vec);
					hit = HitDetection::hitDetect(ray, 0, false);			
					if(hit->getType() < HIT_OBJECT && hit->getCoord() == cCoord){
						seen.insert(chr);
						chr->setVisible(VISIBLE);
					}
					delete ray;
					delete hit;
				}
			}
		}
	}
}
Exemple #21
0
int init_resources(void) {
	try{
		player.moveLeft(9);
		player.moveForward(7);
		player.rotateX(-M_PI*3/4);
		player.rotateY(M_PI/12);
		player.addForce(gravity*-1);

		player.loadObj("crazy.o");
		cube.loadObj("cube.o");
		cube2.loadObj("cube.o");

		setupBuffers(player);
		setupBuffers(cube);
		setupBuffers(cube2);

		addObjectToShader(&cube);
		addObjectToShader(&cube2);
		bool c1 = cube.loadShaders(vertexShaderFileName, fragmentShaderFileName),
			 c2 = cube2.loadShaders(vertexShaderFileName, fragmentShaderFileName);
		Vector3 pos = cube2.getPosition()+ Vector3(0.5f, 3.5f, 1.5f);
		cube2.setPosition(pos);
		//cube2.setRotation(Vector3(30*M_PI/180, 0, 40*M_PI/180));
		return c1 * c2;
	}catch(int i){
		return 0;
	}
}
Exemple #22
0
void Character::spell_charm_person (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;
  Affect af;

  if (victim == this) {
    send_to_char ("You like yourself even better!\r\n");
    return;
  }

  if (victim->is_affected (AFF_CHARM)
    || is_affected (AFF_CHARM)
    || lvl < victim->level || victim->saves_spell (lvl))
    return;

  if (victim->master)
    victim->stop_follower();
  victim->add_follower(this);
  af.type = sn;
  af.duration = number_fuzzy (lvl / 4);
  af.location = 0;
  af.modifier = 0;
  af.bitvector = AFF_CHARM;
  victim->affect_to_char(&af);
  act ("Isn't $n just so nice?", NULL, victim, TO_VICT);
  if (this != victim)
    send_to_char ("Ok.\r\n");
  return;
}
Exemple #23
0
/** Returns the Unicode point for a given DVI character. */
UInt32 PhysicalFontImpl::unicode (UInt32 c) const {
	if (type() == MF)
		return Font::unicode(c);
	Character chr = decodeChar(c);
	if (type() == PFB) {
		// try to get the Unicode point from the character name
		string glyphname = glyphName(c);
		UInt32 codepoint;
		if (!glyphname.empty() && (codepoint = Unicode::psNameToCodepoint(glyphname)) != 0)
			return codepoint;
		if (c <= 0x1900)  // does character code c fit into Private Use Zone U+E000?
			return 0xe000+c;
//		Message::wstream() << "can't properly map PS character '" << glyphname << "' (0x" << hex << c << ") to Unicode\n";
		// If we get here, there is no easy mapping. As for now, we use the character code as Unicode point.
		// Although quite unlikely, it might collide with properly mapped characters.
		return Unicode::charToCodepoint(c);
	}
	if (chr.type() == Character::NAME || chr.number() == 0)
		return Unicode::charToCodepoint(chr.number());

	if (_localCharMap) {
		if (UInt32 mapped_char = _localCharMap->valueAt(chr.number()))
			return mapped_char;
	}
	// No Unicode equivalent found in the font file.
	// Now we should look for a smart alternative but at the moment
	// it's sufficient to simply choose a valid unused codepoint.
	return Unicode::charToCodepoint(chr.number());
}
Exemple #24
0
void render::render_SkillMenu(Character& chara, int curPos){
    std::vector<Skill> skills = chara.getSkillList();

    clear();
    texture.loadFromFile(FRAME_SIDE, ren);
    texture.render(ren, 0, 0);

    Point offset;
    offset.m_x = getmaxx() / 2;
    offset.m_y = getmaxy() / 2;

    SDL_Color textColor = {0xD8, 0xC6, 0x91};

    //Print Title
    texture.loadFromRenderedText("Skills", textColor, ren, font_comic50);
    texture.render(ren, offset.m_x - texture.getWidth() / 2, 5);

    for (unsigned int i = 0; i < skills.size(); i++){
        texture.loadFromRenderedText(skills[i].getName().c_str(), textColor, ren, font_comic16);
        texture.render(ren, 20, 100 + i * texture.getHeight());
    }

    if(!skills.empty()){
        //Print Selected Options
        textColor = { 0xF4, 0xF0, 0xDD };
        texture.loadFromRenderedText(skills[0].getName().c_str(), textColor, ren, font_comic16);
        texture.render(ren, 20, 100);
        textColor = {0xD8, 0xC6, 0x91};

        char tmp[100];
        //Print Informations
        sprintf(tmp, "Name : %s", skills[0].getName().c_str());
        texture.loadFromRenderedText(tmp, textColor, ren, font_comic16);
        texture.render(ren, getmaxx() * 0.35, 100);

        sprintf(tmp, "Description :");
        texture.loadFromRenderedText(tmp, textColor, ren, font_comic16);
        texture.render(ren, getmaxx() * 0.35, 130);

        unsigned int xoff = (getmaxx() - 260) / 13;
        unsigned int i;
        for(i = xoff; skills[0].getDescription().size() > i; i += xoff){
            texture.loadFromRenderedText(skills[0].getDescription().substr(i - xoff, xoff).c_str(), textColor, ren, font_comic16);
            texture.render(ren, getmaxx() * 0.35 + 20, 150 + (i / xoff - 1) * 20);
        }

        texture.loadFromRenderedText(skills[0].getDescription().substr(i - xoff, skills[0].getDescription().size()).c_str(), textColor, ren, font_comic16);
        texture.render(ren, getmaxx() * 0.35 + 20, 150 + (i / xoff - 1) * 20);
    }

    update();
}
Exemple #25
0
void display( )
{
	switch( DisplayMode )
	{
	case GAME:
	{
		glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
		drawLightPosition();
		//drawCoordinateSystem();

		// Note that drawing order has consequences for 'transparancy'
		background->draw();
		for (int i = 0; i < numberOfRidges; i++)
		{
			mountains[i].draw();
		}
		groundfloor->draw();
		
		if (toggleBoss)
			boss.draw();

		glDisable(GL_DEPTH_TEST);
		for (auto &projectile : projectiles) {
			projectile.draw();
		}
		glEnable(GL_DEPTH_TEST);

        character.draw();
		for (auto &enemy : enemies) {
			enemy.draw();
		}
		break;
	}
    case MESH:
    {
        glEnable(GL_LIGHTING);
        glPushMatrix();
		//David:
        //glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
        //glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
		//hoofd
		//glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
		//glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
        meshes[meshIndex].drawSmooth();
        glPopMatrix();
        glDisable(GL_LIGHTING);
        break;
    }
	default:
		break;
	}
}
Exemple #26
0
  Character* Character::create_from(STATE, String* str, Fixnum* byte) {
    native_int i = byte->to_native();
    native_int size = str->byte_size();

    if(i < 0 || i >= size) return nil<Character>();

    OnigEncodingType* enc = str->encoding()->get_encoding();
    uint8_t* p = str->byte_address() + i;
    uint8_t* e = str->byte_address() + str->byte_size();

    int c = Encoding::precise_mbclen(p, e, enc);

    if(!ONIGENC_MBCLEN_CHARFOUND_P(c)) return nil<Character>();

    int n = ONIGENC_MBCLEN_CHARFOUND_LEN(c);
    if(i + n > size) return nil<Character>();

    Character* chr = Character::create(state, (const char*)p, n);
    chr->encoding(state, str->encoding());

    return chr;
  }
Exemple #27
0
void Character::spell_bless (int sn, int lvl, void *vo)
{
  Character *victim = (Character *) vo;
  Affect af;

  if (victim->position == POS_FIGHTING || victim->has_affect(sn))
    return;
  af.type = sn;
  af.duration = 6 + lvl;
  af.location = APPLY_HITROLL;
  af.modifier = lvl / 8;
  af.bitvector = 0;
  victim->affect_to_char(&af);

  af.location = APPLY_SAVING_SPELL;
  af.modifier = 0 - lvl / 8;
  victim->affect_to_char(&af);
  victim->send_to_char ("You feel righteous.\r\n");
  if (this != victim)
    send_to_char ("Ok.\r\n");
  return;
}
void Handler_PUSER_SET_LV(int *myID, std::string* str)
{
	SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance();
	SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance();

	SET_USER_LV::CONTENTS setuserlvContents;
	setuserlvContents.ParseFromString(*str);

	Scoped_Rlock SW(&chars->srw);

	for (int i = 0; i < setuserlvContents.data_size(); ++i)
	{
		auto setuserlv = setuserlvContents.data(i);
		int id = setuserlv.id();
		int lv = setuserlv.lv();
		int maxHp = setuserlv.maxhp();
		int power = setuserlv.power();
		int expUp = setuserlv.expup();
		int maxexp = setuserlv.maxexp();

		Character* lvUpChar = chars->find(id);
		if (lvUpChar->getID() == *myID)
			printf("- 레벨 업을 하였습니다!!\n");

		if (lvUpChar == NULL)
		{
			printf("나 나오면 안돼는데 나옴?");
			exit(0);
		}
		else
		{
			lvUpChar->setExpUp(expUp);
			lvUpChar->setLv(lv, maxHp, power, maxexp);
			
			printf("★ 유저 %s 님께서 레벨이 %d로 올랐습니다!!\n", lvUpChar->getName().c_str(), id, lv);
		}
	}

}
Exemple #29
0
void ConnectionCharacterintegration::test_external_op()
{
    // Dispatching a Talk external op from the character should result in
    // it being passed on to the world.

    m_character->linkExternal(m_connection);

    Atlas::Objects::Operation::Talk op;
    op->setFrom(m_character->getId());

    m_connection->externalOperation(op, *m_connection);

    // BaseWorld::message should have been called from Enitty::sendWorld
    // with the Talk operation, modified to have TO set to the character.
    ASSERT_TRUE(m_BaseWorld_message_called.isValid());
    ASSERT_EQUAL(m_BaseWorld_message_called->getClassNo(),
                 Atlas::Objects::Operation::TALK_NO);
    ASSERT_TRUE(!m_BaseWorld_message_called->isDefaultTo());
    ASSERT_EQUAL(m_BaseWorld_message_called->getTo(), m_character->getId());
    ASSERT_NOT_NULL(m_BaseWorld_message_called_from);
    ASSERT_EQUAL(m_BaseWorld_message_called_from, m_character);
}
Exemple #30
0
void Hero::takeAll()
{
    ObjectWeakPtrs objects;
    if (Simulator::get().listObjectsAt(
            getX(),
            getY(),
            getZ(),
            &objects))
    {
        ItemSharedPtrs items;
        std::for_each(
            objects.begin(), objects.end(), [&items](const ObjectWeakPtr& o)
            {
                ObjectSharedPtr object = o.lock();
                if (object->getObjectType() & OBJECT_TYPE_CHARACTER)
                {
                    Character* target = (Character*)object.get();
                    if (target->getHp() == 0)
                    {
                        items.reserve(items.size() + target->getItems().size());
                        items.insert(items.end(), target->getItems().begin(), target->getItems().end());
                        target->removeAllItems();
                    }
                }
                else if (object->getObjectType() & OBJECT_TYPE_CHEST)
                {
                    Chest* target = (Chest*)object.get();
                    items.reserve(items.size() + target->getItems().size());
                    items.insert(items.end(), target->getItems().begin(), target->getItems().end());
                    target->removeAllItems();
                }
            });

        if (!items.empty())
        {
            WindowSharedPtr w(new Window());
            w->setHorizontalAlign(Window::HorizontalAlign::CENTER);
            w->setVerticalAlign(Window::VerticalAlign::BOTTOM);
            w->setTitle("Added To Inventory");
            w->setMaxWidth(50);

            bool first = true;
            for_each(items.begin(), items.end(),
                     [w, &first] (const ItemSharedPtr& item)
                     {
                         if (!first)
                         {
                             w->printEndLine();
                         }
                         first = false;
                         w->print(Colors::WHITE(), item->getName());
                     });

            WindowManager::get().popup(w, 5);

            addItems(items);
        }
    }
}