Esempio n. 1
0
Monster::Monster(MonsterClass *specy):
    Being(OBJECT_MONSTER),
    mSpecy(specy),
    mTargetListener(&monsterTargetEventDispatch),
    mOwner(NULL),
    mCurrentAttack(NULL)
{
    LOG_DEBUG("Monster spawned! (id: " << mSpecy->getId() << ").");

    setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER);

    /*
     * Initialise the attribute structures.
     */
    const AttributeManager::AttributeScope &mobAttr =
        attributeManager->getAttributeScope(MonsterScope);

    for (AttributeManager::AttributeScope::const_iterator it = mobAttr.begin(),
         it_end = mobAttr.end(); it != it_end; ++it)
    {
        mAttributes.insert(std::pair< unsigned int, Attribute >
                           (it->first, Attribute(*it->second)));
    }

    /*
     * Set the attributes to the values defined by the associated monster
     * class with or without mutations as needed.
     */

    int mutation = specy->getMutation();

    for (AttributeMap::iterator it2 = mAttributes.begin(),
         it2_end = mAttributes.end(); it2 != it2_end; ++it2)
    {
        double attr = 0.0f;

        if (specy->hasAttribute(it2->first))
        {
            attr = specy->getAttribute(it2->first);

            setAttribute(it2->first,
                  mutation ?
                  attr * (100 + (rand()%(mutation << 1)) - mutation) / 100.0 :
                  attr);
        }
    }

    setSize(specy->getSize());
    setGender(specy->getGender());

    // Set positions relative to target from which the monster can attack
    int dist = specy->getAttackDistance();
    mAttackPositions.push_back(AttackPosition(dist, 0, LEFT));
    mAttackPositions.push_back(AttackPosition(-dist, 0, RIGHT));
    mAttackPositions.push_back(AttackPosition(0, -dist, DOWN));
    mAttackPositions.push_back(AttackPosition(0, dist, UP));

    // Load default script
    loadScript(specy->getScript());
}
bool PlayerProfileEntity::mapping(picojson::object &object) {
	if (object["gender"].is<int>()) {
		setGender(object["gender"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "gender");
		return false;
	}
	if (object["age"].is<int>()) {
		setAge(object["age"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "age");
		return false;
	}
	if (object["address"].is<int>()) {
		setAddress(object["address"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "address");
		return false;
	}
	if (object["blood"].is<int>()) {
		setBlood(object["blood"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "blood");
		return false;
	}
	if (object["constellation"].is<int>()) {
		setConstellation(object["constellation"].get<int>());
	} else {
		log(LogConst::jsonBadMappingError.c_str(), "constellation");
		return false;
	}
	return true;
}
Esempio n. 3
0
Spawn::Spawn(Spawn* s, uint16_t id) : Item(tSpawn, id)
{
    setName(s->name());
    setLastName(s->lastName());
    Item::setPoint(s->x(), s->y(), s->z());
    setPetOwnerID(s->petOwnerID());
    setLight(s->light());
    setGender(s->gender());
    setDeity(s->deity());
    setRace(s->race());
    setClassVal(s->classVal());
    setHP(s->HP());
    setMaxHP(s->maxHP());
    setGuildID(s->guildID());
    setLevel(s->level());
    for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment(i));
    setEquipment(tUnknown1, SlotEmpty);
    setTypeflag(s->typeflag());
    setGM(s->gm());
    setNPC(s->NPC());
    setAnimation(s->animation());
    setDeltas(s->deltaX(), s->deltaY(), s->deltaZ());
    setHeading(s->heading(), s->deltaHeading());
    setConsidered(s->considered());

    // the new copy will own the spawn track list
    m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList = s->m_spawnTrackList;
    s->m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 4
0
//----------------------------------------------------------------------
// Spawn
Spawn::Spawn()
  : Item(tSpawn, 0)
{
  m_name = "fake";
  setNPC(SPAWN_NPC_UNKNOWN);

  Item::setPos(0, 0, 0);
  setDeltas(0, 0, 0);
  setHeading(0, 0);
  setAnimation(0);
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setGuildID(0xffff);
  setGuildTag(NULL);
  setLevel(0);
  setTypeflag(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);

  // just clear the considred flag since data would be outdated
  setConsidered(false);

  // finally, note when this update occurred.
  updateLast();
}
Esempio n. 5
0
Spawn::Spawn(uint16_t id, 
	     int16_t x, int16_t y, int16_t z,
	     int16_t deltaX, int16_t deltaY, int16_t deltaZ,
	     int8_t heading, int8_t deltaHeading,
	     uint8_t animation) 
  : Item(tSpawn, id)
{
  // apply the unknown mob values
  m_name = "unknown";
  setNPC(SPAWN_NPC_UNKNOWN);

  // set what is known
  setPos(x, y, z);
  setDeltas(deltaX, deltaY, deltaZ);
  setHeading(heading, deltaHeading);
  setAnimation(animation);
  
  // initialize what isn't to 0
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setLevel(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);
  setTypeflag(0);
  setConsidered(false);

  // turn on auto delete for the track list
  m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 6
0
Spawn::Spawn(Spawn& s, uint16_t id)
  : Item(tSpawn, id)
{
  setName(s.name());
  setLastName(s.lastName());
  Item::setPoint(s.x(), s.y(), s.z());
  setPetOwnerID(s.petOwnerID());
  setLight(s.light());
  setGender(s.gender());
  setDeity(s.deity());
  setRace(s.race());
  setClassVal(s.classVal());
  setHP(s.HP());
  setMaxHP(s.maxHP());
  setGuildID(s.GuildID());
  setLevel(s.level());
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s.equipment(i));
  setEquipment(tUnknown1, 0);
  setTypeflag(s.typeflag());
  setNPC(s.NPC());
  setAnimation(s.animation());
  setDeltas(s.deltaX(), s.deltaY(), s.deltaZ());
  setHeading(s.heading(), s.deltaHeading());
  setConsidered(s.considered());

  // the new copy will own the spawn track list
  m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList = s.m_spawnTrackList;
  s.m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList.setAutoDelete(true);
}
Esempio n. 7
0
void player::makeAIPlayer()
{
    int testInt;

    //gender
    testInt = rand() % 2;
    char compGender;
    if(testInt == 0)
    {
        compGender = 'M';
    }
    else
    {
        compGender = 'F';

    }
    setGender(compGender);

    //name
    std::string boyNames[3] = {"Terry", "Bill", "Alex"};
    std::string girlNames[3] = {"Nicole", "Lisa", "Aphrodite"};
    testInt = rand() % 3;
    if(compGender == 'M')
    {
        setName(boyNames[testInt]);
    }
    else
    {
        setName(girlNames[testInt]);
    }
}
Esempio n. 8
0
void TotemSummon::Load(CreatureProto* proto, Unit* owner, LocationVector & position, uint32 spellid, int32 summonslot)
{
	Summon::Load(proto, owner, position, spellid, summonslot);

	TotemDisplayIdEntry* totemdisplay = TotemDisplayIdStorage.LookupEntry(creature_info->Male_DisplayID);
	uint32 displayID = 0;

	if(totemdisplay != NULL)
	{
		switch(owner->getRace())
		{
			case RACE_DRAENEI:
				displayID = totemdisplay->DraeneiId;
				break;

			case RACE_TROLL:
				displayID = totemdisplay->TrollId;
				break;

			case RACE_ORC:
				displayID = totemdisplay->OrcId;
				break;
		}
	}

	if(displayID == 0)
		displayID = creature_info->Male_DisplayID;

	// Set up the creature.
	SetMaxPower(POWER_TYPE_FOCUS, owner->getLevel() * 30);
	SetPower(POWER_TYPE_FOCUS, owner->getLevel() * 30);
	setLevel(owner->getLevel());
	setRace(0);
	setClass(1);
	setGender(2);
	SetPowerType(1);
	SetBaseAttackTime(MELEE, 2000);
	SetBaseAttackTime(OFFHAND, 2000);
	SetBoundingRadius(1.0f);
	SetCombatReach(1.0f);
	SetDisplayId(displayID);
	SetNativeDisplayId(creature_info->Male_DisplayID);
	SetCastSpeedMod(1.0f);
	SetUInt32Value(OBJECT_FIELD_DYNAMIC_FLAGS, 0);

	InheritSMMods(owner);

	for(uint8 school = 0; school < SCHOOL_COUNT; school++)
	{
		ModDamageDone[ school ] = owner->GetDamageDoneMod(school);
		HealDoneMod[ school ] = owner->HealDoneMod[ school ];
	}

	m_aiInterface->Init(this, AITYPE_TOTEM, MOVEMENTTYPE_NONE, owner);
	DisableAI();
}
void QFacebookGraphUser::requestDone(bool ok) {
    if(ok)
    {
        QVariantMap map = result();
        QVariantMap::const_iterator i;
        for (i = map.constBegin(); i != map.constEnd(); ++i)
        {
            if(i.key() == "name" )
                setName(i.value().toString());
            if(i.key() == "hometown")
                setHometown(i.value().toMap());
            if(i.key() == "last_name")
                setLastName(i.value().toString());
            if(i.key() == "birthday")
                setBirthday(i.value().toString());
            if(i.key() == "education") {
                QFacebookGraphCommonEducationModel *edu = new QFacebookGraphCommonEducationModel();
                for (int j = 0; j < i.value().toList().size(); ++j) {
                    edu->populate(i.value().toList().at(j).toMap());
                    m_education.append(edu);
                    edu = new QFacebookGraphCommonEducationModel();
                }
            }
            if(i.key() == "work") {
                QFacebookGraphCommonWorkModel *work = new QFacebookGraphCommonWorkModel();
                for (int j = 0; j < i.value().toList().size(); ++j) {
                    work->populate(i.value().toList().at(j).toMap());
                    m_work.append(work);
                    work = new QFacebookGraphCommonWorkModel();
                }
            }
            if(i.key() == "first_name")
                setFirstName(i.value().toString());
            if(i.key() == "gender")
                setGender(i.value().toString());
            if(i.key() == "id")
                setFbid(i.value().toString());
            if(i.key() == "link")
                setLink(i.value().toString());
            if(i.key() == "locale")
                setLocale(i.value().toString());
            if(i.key() == "location")
                setLocation(i.value().toMap());
            if(i.key() == "middle_name")
                setMiddleName(i.value().toString());
            if(i.key() == "timezone")
                setTimezone(i.value().toLongLong());
            if(i.key() == "updated_time")
                setUpdatedtime(i.value().toString());
            if(i.key() == "verified")
                setVerified(i.value().toBool());
        }

        emit modelPopulated();
    }
}
Esempio n. 10
0
/******************************************************************************
 * Student()
 * 	This constructor will receive the student's name, id, phone number, age,
 * 		class standing, gpa and create a student object with that info
 *****************************************************************************/
Student::Student(	string	studentName,		//The Student's Name
					int		studentId,			//The Student's ID
					long long	studentPhoneNum,	//The Student's Phone Number
		   	   	   	int		studentAge,			//The Student's Age
		   	   	   	char	studentGender,		//The Student's Gender
		   	   	   	string	studentClass,		//The Student's Class Standing
		   	   	   	double	studentGPA)			//The Student's GPA
{
	setName(studentName);
	setID(studentId);
	setPhoneNumber(studentPhoneNum);
	setAge(studentAge);
	setGender(studentGender);
	setClassStanding(studentClass);
	setGPA(studentGPA);
}
Esempio n. 11
0
void PlayerEditGender::onKeyDown(Event::Keyboard* event)
{
    switch (event->keyCode())
    {
        case SDLK_ESCAPE:
            Game::getInstance()->popState();
            break;
        case SDLK_RETURN:
            Game::getInstance()->player()->setGender(_gender);
            Game::getInstance()->popState();
            break;
        case SDLK_LEFT:
        case SDLK_RIGHT:
            setGender(_gender);
            break;
    }
}
Esempio n. 12
0
    void RaceDialog::onOpen()
    {
        WindowModal::onOpen();

        updateRaces();
        updateSkills();
        updateSpellPowers();

        mPreviewImage->setRenderItemTexture(nullptr);

        mPreview.reset(nullptr);
        mPreviewTexture.reset(nullptr);

        mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem));
        mPreview->rebuild();
        mPreview->setAngle (mCurrentAngle);

        mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture()));
        mPreviewImage->setRenderItemTexture(mPreviewTexture.get());
        mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));

        const ESM::NPC& proto = mPreview->getPrototype();
        setRaceId(proto.mRace);
        setGender(proto.isMale() ? GM_Male : GM_Female);
        recountParts();

        for (unsigned int i=0; i<mAvailableHeads.size(); ++i)
        {
            if (Misc::StringUtils::ciEqual(mAvailableHeads[i], proto.mHead))
                mFaceIndex = i;
        }

        for (unsigned int i=0; i<mAvailableHairs.size(); ++i)
        {
            if (Misc::StringUtils::ciEqual(mAvailableHairs[i], proto.mHair))
                mHairIndex = i;
        }

        mPreviewDirty = true;

        size_t initialPos = mHeadRotate->getScrollRange()/2+mHeadRotate->getScrollRange()/10;
        mHeadRotate->setScrollPosition(initialPos);
        onHeadRotate(mHeadRotate, initialPos);

        MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mRaceList);
    }
Esempio n. 13
0
void PlayerEditGender::init()
{
    if (_initialized) return;
    State::init();

    setFullscreen(false);
    setModal(true);

    Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
    int bgX = bgPos.x();
    int bgY = bgPos.y();

    auto bg = new UI::Image("art/intrface/charwin.frm");
    bg->setPosition(bgPos + Point(236, 0));

    _maleImage = new UI::ImageList((std::vector<std::string>){
                                    "art/intrface/maleoff.frm",
                                    "art/intrface/maleon.frm"
                                }, bgX+260, bgY+2);
    _maleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onMaleButtonPress(dynamic_cast<Event::Mouse*>(event)); });

    _femaleImage = new UI::ImageList((std::vector<std::string>){
                                                            "art/intrface/femoff.frm",
                                                            "art/intrface/femon.frm"
                                                            }, bgX+310, bgY+2);
    _femaleImage->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onFemaleButtonPress(dynamic_cast<Event::Mouse*>(event)); });

    auto doneBox = new UI::Image("art/intrface/donebox.frm");
    doneBox->setPosition(bgPos + Point(250, 42));

    auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45);
    auto font3_b89c28ff = ResourceManager::getInstance()->font("font3.aaf", 0xb89c28ff);
    doneLabel->setFont(font3_b89c28ff);

    auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45);
    doneButton->addEventHandler("mouseleftclick", [this](Event::Event* event){ this->onDoneButtonClick(dynamic_cast<Event::Mouse*>(event)); });

    addUI(bg);
    addUI(doneBox);
    addUI(doneButton);
    addUI(doneLabel);
    addUI(_maleImage);
    addUI(_femaleImage);
    setGender(Game::getInstance()->player()->gender());
}
Esempio n. 14
0
        void PlayerEditGender::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(false);
            setModal(true);

            Point bgPos = Point((Game::getInstance()->renderer()->size() - Point(640, 480)) / 2);
            int bgX = bgPos.x();
            int bgY = bgPos.y();

            auto bg = new UI::Image("art/intrface/charwin.frm");
            bg->setPosition(bgPos + Point(236, 0));

            _maleImage = new UI::ImageList((std::vector<std::string>){
                                            "art/intrface/maleoff.frm",
                                            "art/intrface/maleon.frm"
                                        }, bgX+260, bgY+2);
            _maleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onMaleButtonPress, this, std::placeholders::_1));

            _femaleImage = new UI::ImageList((std::vector<std::string>){
                                                                    "art/intrface/femoff.frm",
                                                                    "art/intrface/femon.frm"
                                                                    }, bgX+310, bgY+2);
            _femaleImage->mouseClickHandler().add(std::bind(&PlayerEditGender::onFemaleButtonPress, this, std::placeholders::_1));

            auto doneBox = new UI::Image("art/intrface/donebox.frm");
            doneBox->setPosition(bgPos + Point(250, 42));

            auto doneLabel = new UI::TextArea(_t(MSG_EDITOR, 100), bgX+281, bgY+45);
            doneLabel->setFont("font3.aaf", {0xb8, 0x9c, 0x28, 0xff});

            auto doneButton = new UI::ImageButton(UI::ImageButton::Type::SMALL_RED_CIRCLE, bgX+260, bgY+45);
            doneButton->mouseClickHandler().add(std::bind(&PlayerEditGender::onDoneButtonClick, this, std::placeholders::_1));

            addUI(bg);
            addUI(doneBox);
            addUI(doneButton);
            addUI(doneLabel);
            addUI(_maleImage);
            addUI(_femaleImage);
            setGender(Game::getInstance()->player()->gender());
        }
Esempio n. 15
0
/******************************************************************************
 * MathStudent()
 * 	This copy constructor will read in a Math Student Object, and do a deep
 * 		copy to the math student  object being created
 *****************************************************************************/
MathStudent::MathStudent(const MathStudent &anotherMathStudent)
												//Another Math Student
{
#ifdef TEST
cout << "Copy Constructor is Called" << endl << endl;
#endif
	setName(anotherMathStudent.getName());
	setID(anotherMathStudent.getID());
	setPhoneNumber(anotherMathStudent.getPhoneNumber());
	setAge(anotherMathStudent.getAge());
	setGender(anotherMathStudent.getGender());
	setClassStanding(anotherMathStudent.getClassStanding());
	setGPA(anotherMathStudent.getGPA());
	setZipCode(anotherMathStudent.getZipCode());

	setAddress(anotherMathStudent.address);
	setCity(anotherMathStudent.city);
	setState(anotherMathStudent.state);
}
Esempio n. 16
0
void Spawn::update(const spawnStruct* s)
{
  if (m_name.find(Spawn_Corpse_Designator) == -1)
  {
    setName(s->name);
    setLastName(s->lastName);
  }

  setPos(s->x >> 3, s->y >> 3, s->z >> 3);
  setPetOwnerID(s->petOwnerId);
  setLight(s->light);
  setGender(s->gender);
  setDeity(s->deity);
  setRace(s->race);
  setClassVal(s->class_);
  setHP(s->curHp);
  //setMaxHP(s->maxHp);
  setMaxHP(s->curHp); //maxHp is no longer part of the struct
  setGuildID(s->guildID);
  setLevel(s->level);
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment[i]);
  setEquipment(tUnknown1, 0);

  setTypeflag(s->bodytype);
  setGM(s->gm);

  // If it is a corpse with Unknown (NPC) religion.
  if ((s->NPC == SPAWN_PC_CORPSE) && (s->deity == DEITY_UNKNOWN))
    setNPC(SPAWN_NPC_CORPSE); // it's a dead monster
  else
    setNPC(s->NPC); // otherwise it is what it is

  setAnimation(s->animation);

  // only non corpses and things with animation != 66 move
  if (!isCorpse() && (s->animation != 66))
  {
    setDeltas(s->deltaX >> 2, s->deltaY >> 2, s->deltaZ >> 2);
    setHeading(s->heading, s->deltaHeading);
  }
Esempio n. 17
0
/******************************************************************************
 * copyFrom()
 * 	This method receive a Math Student Object, then copy the info from that
 * 		math student object to the Math Student Object call the function
 *****************************************************************************/
void MathStudent::copyFrom(MathStudent anotherMathStudent)	//Another Math Student
{
#ifdef TEST
cout << "Copy From(deep copy) is Called" << endl << endl;
#endif
	setName(anotherMathStudent.getName());
	setID(anotherMathStudent.getID());
	setPhoneNumber(anotherMathStudent.getPhoneNumber());
	setAge(anotherMathStudent.getAge());
	setGender(anotherMathStudent.getGender());
	setClassStanding(anotherMathStudent.getClassStanding());
	setGPA(anotherMathStudent.getGPA());
	setZipCode(anotherMathStudent.getZipCode());

	delete[] address;
	delete[] city;
	delete[] state;

	setAddress(anotherMathStudent.address);
	setCity(anotherMathStudent.city);
	setState(anotherMathStudent.state);
}
Esempio n. 18
0
void PlayerEditGender::onFemaleButtonPress(Event::Mouse* event)
{
    setGender(GENDER::FEMALE);
}
Esempio n. 19
0
	/**
	 * Construct the person specifying their names and gender
	 * @param   forename   The person's forename
	 * @param   surname    The person's surname
	 * @param   gender     The person's gender ('M' or 'F')
	 */
	Person::Person(string forename, string surname, char gender) :
	forename(forename),
	surname(surname)
	{
		setGender(gender); // Gender must be validated first
	}
Esempio n. 20
0
bool Creature::Load(CreatureSpawn *spawn, uint32 mode, MapInfo *info)
{
	m_spawn = spawn;
	proto = CreatureProtoStorage.LookupEntry(spawn->entry);
	if(!proto)
		return false;
	creature_info = CreatureNameStorage.LookupEntry(spawn->entry);
	if(!creature_info)
		return false;
	
	spawnid = spawn->id;

	m_walkSpeed = m_base_walkSpeed = proto->walk_speed; //set speeds
	m_runSpeed = m_base_runSpeed = proto->run_speed; //set speeds
	m_flySpeed = proto->fly_speed;

	//Set fields
	SetUInt32Value(OBJECT_FIELD_ENTRY,proto->Id);
	SetFloatValue(OBJECT_FIELD_SCALE_X,proto->Scale);
	
	//SetUInt32Value(UNIT_FIELD_HEALTH, (mode ? long2int32(proto->Health * 1.5)  : proto->Health));
	//SetUInt32Value(UNIT_FIELD_BASE_HEALTH, (mode ? long2int32(proto->Health * 1.5)  : proto->Health));
	//SetUInt32Value(UNIT_FIELD_MAXHEALTH, (mode ? long2int32(proto->Health * 1.5)  : proto->Health));
	uint32 health = proto->MinHealth + RandomUInt(proto->MaxHealth - proto->MinHealth);
	if(mode)
		health = long2int32(double(health) * 1.5);
	SetUInt32Value(UNIT_FIELD_HEALTH, health);
	SetUInt32Value(UNIT_FIELD_MAXHEALTH, health);
	SetUInt32Value(UNIT_FIELD_BASE_HEALTH, health);

	SetUInt32Value(UNIT_FIELD_POWER1,proto->Mana);
	SetUInt32Value(UNIT_FIELD_MAXPOWER1,proto->Mana);
	SetUInt32Value(UNIT_FIELD_BASE_MANA,proto->Mana);
	
	// Whee, thank you blizz, I love patch 2.2! Later on, we can randomize male/female mobs! xD
	// Determine gender (for voices)
	//if(spawn->displayid != creature_info->Male_DisplayID)
	//	setGender(1);   // Female
	
	uint32 model;
	uint32 gender = creature_info->GenerateModelId(&model);
	setGender(gender);

	SetUInt32Value(UNIT_FIELD_DISPLAYID,model);
	SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID,model);
	SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,proto->MountedDisplayID);

    //SetUInt32Value(UNIT_FIELD_LEVEL, (mode ? proto->Level + (info ? info->lvl_mod_a : 0) : proto->Level));
	SetUInt32Value(UNIT_FIELD_LEVEL, proto->MinLevel + (RandomUInt(proto->MaxLevel - proto->MinLevel)));
	if(mode && info)
		ModUnsigned32Value(UNIT_FIELD_LEVEL, info->lvl_mod_a);

	for(uint32 i = 0; i < 7; ++i)
		SetUInt32Value(UNIT_FIELD_RESISTANCES+i,proto->Resistances[i]);

	SetUInt32Value(UNIT_FIELD_BASEATTACKTIME,proto->AttackTime);
	SetFloatValue(UNIT_FIELD_MINDAMAGE, (mode ? proto->MinDamage * 1.5f  : proto->MinDamage));
	SetFloatValue(UNIT_FIELD_MAXDAMAGE, (mode ? proto->MaxDamage * 1.5f  : proto->MaxDamage));

	SetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME,proto->RangedAttackTime);
	SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,proto->RangedMinDamage);
	SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,proto->RangedMaxDamage);

	SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, proto->Item1SlotDisplay);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, proto->Item2SlotDisplay);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, proto->Item3SlotDisplay);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, proto->Item1Info1);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_01, proto->Item1Info2);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_02, proto->Item2Info1);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_03, proto->Item2Info2);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_04, proto->Item3Info1);
	SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_05, proto->Item3Info2);

	SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, spawn->factionid);
	SetUInt32Value(UNIT_FIELD_FLAGS, spawn->flags);
	SetUInt32Value(UNIT_NPC_EMOTESTATE, spawn->emote_state);
	SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, proto->BoundingRadius);
	SetFloatValue(UNIT_FIELD_COMBATREACH, proto->CombatReach);
	original_emotestate = spawn->emote_state;
	// set position
	m_position.ChangeCoords( spawn->x, spawn->y, spawn->z, spawn->o );
	m_spawnLocation.ChangeCoords(spawn->x, spawn->y, spawn->z, spawn->o);
	m_aiInterface->setMoveType(spawn->movetype);	
	m_aiInterface->m_waypoints = objmgr.GetWayPointMap(spawn->id);

	m_faction = dbcFactionTemplate.LookupEntry(spawn->factionid);
	if(m_faction)
	{
		m_factionDBC = dbcFaction.LookupEntry(m_faction->Faction);
		// not a neutral creature
		if(!(m_factionDBC->RepListId == -1 && m_faction->HostileMask == 0 && m_faction->FriendlyMask == 0))
		{
			GetAIInterface()->m_canCallForHelp = true;
		}
	}


//SETUP NPC FLAGS
	SetUInt32Value(UNIT_NPC_FLAGS,proto->NPCFLags);

	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR ) )
		m_SellItems = objmgr.GetVendorList(GetEntry());

	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER ) )
		_LoadQuests();

	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TAXIVENDOR) )
		m_TaxiNode = sTaxiMgr.GetNearestTaxiNode( m_position.x, m_position.y, m_position.z, GetMapId() );

	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_TRAINER_PROF))
		mTrainer = objmgr.GetTrainer(GetEntry());

	if ( HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER ) )
		auctionHouse = sAuctionMgr.GetAuctionHouse(GetEntry());

//NPC FLAGS
	 m_aiInterface->m_waypoints=objmgr.GetWayPointMap(spawn->id);

	//load resistances
	for(uint32 x=0;x<7;x++)
		BaseResistance[x]=GetUInt32Value(UNIT_FIELD_RESISTANCES+x);
	for(uint32 x=0;x<5;x++)
		BaseStats[x]=GetUInt32Value(UNIT_FIELD_STAT0+x);

	BaseDamage[0]=GetFloatValue(UNIT_FIELD_MINDAMAGE);
	BaseDamage[1]=GetFloatValue(UNIT_FIELD_MAXDAMAGE);
	BaseOffhandDamage[0]=GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE);
	BaseOffhandDamage[1]=GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE);
	BaseRangedDamage[0]=GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE);
	BaseRangedDamage[1]=GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE);
	BaseAttackType=proto->AttackType;

	SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);   // better set this one
	SetUInt32Value(UNIT_FIELD_BYTES_0, spawn->bytes);
	SetUInt32Value(UNIT_FIELD_BYTES_2, spawn->bytes2);

////////////AI
	
	// kek
	for(list<AI_Spell*>::iterator itr = proto->spells.begin(); itr != proto->spells.end(); ++itr)
	{
		m_aiInterface->addSpellToList(*itr);
	}
	//m_aiInterface->m_canCallForHelp = proto->m_canCallForHelp;
	//m_aiInterface->m_CallForHelpHealth = proto->m_callForHelpHealth;
	m_aiInterface->m_canFlee = proto->m_canFlee;
	m_aiInterface->m_FleeHealth = proto->m_fleeHealth;
	m_aiInterface->m_FleeDuration = proto->m_fleeDuration;

	//these fields are always 0 in db
	GetAIInterface()->setMoveType(0);
	GetAIInterface()->setMoveRunFlag(0);
	
	// load formation data
	if( spawn->form != NULL )
	{
		m_aiInterface->m_formationLinkSqlId = spawn->form->fol;
		m_aiInterface->m_formationFollowDistance = spawn->form->dist;
		m_aiInterface->m_formationFollowAngle = spawn->form->ang;
	}
	else
	{
		m_aiInterface->m_formationLinkSqlId = 0;
		m_aiInterface->m_formationFollowDistance = 0;
		m_aiInterface->m_formationFollowAngle = 0;
	}

//////////////AI

	myFamily = dbcCreatureFamily.LookupEntry(creature_info->Family);

	
// PLACE FOR DIRTY FIX BASTARDS
	// HACK! set call for help on civ health @ 100%
	if(creature_info->Civilian >= 1)
		m_aiInterface->m_CallForHelpHealth = 100;
 
 //HACK!
	if(m_uint32Values[UNIT_FIELD_DISPLAYID] == 17743 ||
		m_uint32Values[UNIT_FIELD_DISPLAYID] == 20242 ||
		m_uint32Values[UNIT_FIELD_DISPLAYID] == 15435 ||
		(creature_info->Family == UNIT_TYPE_MISC))
	{
		m_useAI = false;
	}

	/* more hacks! */
	if(proto->Mana != 0)
		SetPowerType(POWER_TYPE_MANA);
	else
		SetPowerType(0);

	has_combat_text = objmgr.HasMonsterSay(GetEntry(), MONSTER_SAY_EVENT_ENTER_COMBAT);
	has_waypoint_text = objmgr.HasMonsterSay(GetEntry(), MONSTER_SAY_EVENT_RANDOM_WAYPOINT);
	m_aiInterface->m_isGuard = isGuard(GetEntry());

	m_aiInterface->getMoveFlags();

	/* creature death state */
	if(proto->death_state == 1)
	{
		uint32 newhealth = m_uint32Values[UNIT_FIELD_HEALTH] / 100;
		if(!newhealth)
			newhealth = 1;
		SetUInt32Value(UNIT_FIELD_HEALTH, 1);
		m_limbostate = true;
		bInvincible = true;
		SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DEAD);
	}
	m_invisFlag = proto->invisibility_type;
	if( spawn->stand_state )
		SetStandState( (uint8)spawn->stand_state );

	return true;
}