示例#1
0
void psCreationManager::UploadChar( bool verify )
{
    RaceDefinition* race = GetRace( selectedRace );
    if ( !race )
        return;

    csString firstname;
    csString lastname;

    // Separate names
    firstname = selectedName.Slice(0,selectedName.FindFirst(' '));
    if (selectedName.FindFirst(' ') != SIZET_NOT_FOUND)
        lastname = selectedName.Slice(selectedName.FindFirst(' ')+1,selectedName.Length());
    else
        lastname.Clear();

    // Make BIO
    pawsSummaryWindow* summary = (pawsSummaryWindow*)PawsManager::GetSingleton().FindWidget("Summary");
    pawsMultiLineTextBox* btext = (pawsMultiLineTextBox*) summary->FindWidget("text_birth");
    pawsMultiLineTextBox* ltext = (pawsMultiLineTextBox*) summary->FindWidget("text_life");

    csString bio;
    bio += btext->GetText();
    bio += ltext->GetText();

    psCharUploadMessage upload( verify, firstname.GetDataSafe(), lastname.GetDataSafe(),
                                selectedRace, selectedGender, choicesMade, motherMod, fatherMod,
                                lifeEventsMade, selectedFace, selectedHairStyle, selectedBeardStyle,
                                selectedHairColour, selectedSkinColour, bio.GetDataSafe(), path.GetDataSafe() );

    upload.SendMessage();
}
示例#2
0
void Kingdom::UpdateRecruits(void)
{
    recruits.SetHero1(world.GetFreemanHeroes(GetRace()));
    recruits.SetHero2(world.GetFreemanHeroes());

    if(recruits.GetID1() == recruits.GetID2()) world.UpdateRecruits(recruits);
}
示例#3
0
bool Mob::CombatRange(Mob* other)
{
	if(!other)
		return(false);

	float size_mod = GetSize();
	float other_size_mod = other->GetSize();

	if(GetRace() == 49 || GetRace() == 158 || GetRace() == 196) //For races with a fixed size
		size_mod = 60.0f;
	else if (size_mod < 6.0)
		size_mod = 8.0f;

	if(other->GetRace() == 49 || other->GetRace() == 158 || other->GetRace() == 196) //For races with a fixed size
		other_size_mod = 60.0f;
	else if (other_size_mod < 6.0)
		other_size_mod = 8.0f;

	if (other_size_mod > size_mod)
	{
		size_mod = other_size_mod;
	}

	// this could still use some work, but for now it's an improvement....

	if (size_mod > 29)
		size_mod *= size_mod;
	else if (size_mod > 19)
		size_mod *= size_mod * 2;
	else
		size_mod *= size_mod * 4;


	// prevention of ridiculously sized hit boxes
	if (size_mod > 10000)
		size_mod = size_mod / 7;

	if (DistNoRoot(*other) <= size_mod)
	{
		return true;
	}
	return false;
}
示例#4
0
// This is a testing formula for AC, the value this returns should be the same value as the one the client shows...
// ac1 and ac2 are probably the damage migitation and damage avoidance numbers, not sure which is which.
// I forgot to include the iksar defense bonus and i cant find my notes now...
// AC from spells are not included (cant even cast spells yet..)
int32 Client::CalcAC()
{
	// new formula
	int avoidance = (acmod() + ((GetSkill(SkillDefense) + itembonuses.HeroicAGI / 10) * 16) / 9);
	if (avoidance < 0) {
		avoidance = 0;
	}
	int mitigation = 0;
	if (m_pp.class_ == WIZARD || m_pp.class_ == MAGICIAN || m_pp.class_ == NECROMANCER || m_pp.class_ == ENCHANTER) {
		//something is wrong with this, naked casters have the wrong natural AC
//		mitigation = (spellbonuses.AC/3) + (GetSkill(DEFENSE)/2) + (itembonuses.AC+1);
		mitigation = (GetSkill(SkillDefense) + itembonuses.HeroicAGI / 10) / 4 + (itembonuses.AC + 1);
		//this might be off by 4..
		mitigation -= 4;
	}
	else {
//		mitigation = (spellbonuses.AC/4) + (GetSkill(DEFENSE)/3) + ((itembonuses.AC*4)/3);
		mitigation = (GetSkill(SkillDefense) + itembonuses.HeroicAGI / 10) / 3 + ((itembonuses.AC * 4) / 3);
		if (m_pp.class_ == MONK) {
			mitigation += GetLevel() * 13 / 10;    //the 13/10 might be wrong, but it is close...
		}
	}
	int displayed = 0;
	displayed += ((avoidance + mitigation) * 1000) / 847;	//natural AC
	//Iksar AC, untested
	if (GetRace() == IKSAR) {
		displayed += 12;
		int iksarlevel = GetLevel();
		iksarlevel -= 10;
		if (iksarlevel > 25) {
			iksarlevel = 25;
		}
		if (iksarlevel > 0) {
			displayed += iksarlevel * 12 / 10;
		}
	}
	// Shield AC bonus for HeroicSTR
	if (itembonuses.HeroicSTR) {
		bool equiped = CastToClient()->m_inv.GetItem(MainSecondary);
		if (equiped) {
			uint8 shield = CastToClient()->m_inv.GetItem(MainSecondary)->GetItem()->ItemType;
			if (shield == ItemTypeShield) {
				displayed += itembonuses.HeroicSTR / 2;
			}
		}
	}
	//spell AC bonuses are added directly to natural total
	displayed += spellbonuses.AC;
	AC = displayed;
	return (AC);
}
示例#5
0
Recruits & Kingdom::GetRecruits(void)
{
    // update hero1
    if(Heroes::UNKNOWN == recruits.GetID1() || (recruits.GetHero1() && !recruits.GetHero1()->isFreeman()))
	recruits.SetHero1(world.GetFreemanHeroes(GetRace()));

    // update hero2
    if(Heroes::UNKNOWN == recruits.GetID2() || (recruits.GetHero2() && !recruits.GetHero2()->isFreeman()))
	recruits.SetHero2(world.GetFreemanHeroes());

    if(recruits.GetID1() == recruits.GetID2()) world.UpdateRecruits(recruits);

    return recruits;
}
示例#6
0
bool psCreationManager::IsAvailable(int id, int gender)
{
    RaceDefinition* race = GetRace(id);
    if (!race)
        return false;

    if (gender==PSCHARACTER_GENDER_NONE)
        return race->maleAvailable; //If neutral gender, check if male gender is available
    else if (gender==PSCHARACTER_GENDER_FEMALE)
        return race->femaleAvailable;
    else if (gender==PSCHARACTER_GENDER_MALE)
        return race->maleAvailable;

    return false;
}
示例#7
0
// This is a testing formula for AC, the value this returns should be the same value as the one the client shows...
// ac1 and ac2 are probably the damage migitation and damage avoidance numbers, not sure which is which.
// I forgot to include the iksar defense bonus and i cant find my notes now...
// AC from spells are not included (cant even cast spells yet..)
int32 Client::CalcAC() {

	// new formula
	int avoidance = (acmod() + (GetSkill(SkillDefense)*16)/9);
	if (avoidance < 0)
		avoidance = 0;

	int mitigation = 0;
	if (m_pp.class_ == WIZARD || m_pp.class_ == MAGICIAN || m_pp.class_ == NECROMANCER || m_pp.class_ == ENCHANTER) {
		//something is wrong with this, naked casters have the wrong natural AC
//		mitigation = (spellbonuses.AC/3) + (GetSkill(DEFENSE)/2) + (itembonuses.AC+1);
		mitigation = GetSkill(SkillDefense)/4 + (itembonuses.AC+1);
		//this might be off by 4..
		mitigation -= 4;
	} else {
//		mitigation = (spellbonuses.AC/4) + (GetSkill(DEFENSE)/3) + ((itembonuses.AC*4)/3);
		mitigation = GetSkill(SkillDefense)/3 + ((itembonuses.AC*4)/3);
		if(m_pp.class_ == MONK)
			mitigation += GetLevel() * 13/10;	//the 13/10 might be wrong, but it is close...
	}
	int displayed = 0;
	displayed += ((avoidance+mitigation)*1000)/847;	//natural AC

	//Iksar AC, untested
	if (GetRace() == IKSAR) {
		displayed += 12;
		int iksarlevel = GetLevel();
		iksarlevel -= 10;
		if (iksarlevel > 25)
			iksarlevel = 25;
		if (iksarlevel > 0)
			displayed += iksarlevel * 12 / 10;
	}

	//spell AC bonuses are added directly to natural total
	displayed += spellbonuses.AC;

	AC = displayed;
	return(AC);
}
示例#8
0
void GenPlayer(Player *ThisPlayer)
{
	printw("Please input your name\n");
	echo();
	getstr(ThisPlayer->PName);
	noecho();
	clear();
	GetRace(ThisPlayer);
	clear();
	GetClass(ThisPlayer);
	clear();
	RollPlayer(ThisPlayer);
	DescribePlayer(ThisPlayer);
	printw("%s ", ThisPlayer->PDescript);
	refresh();
	getch();
	InitInv(&ThisPlayer->PInventory);
	clear();
	ThisPlayer->PlayerOut = '@';
	ThisPlayer->PlayerPos.X = 15;
	ThisPlayer->PlayerPos.Y = 15;
};
示例#9
0
bool Mob::CombatRange(Mob* other)
{
	if(!other)
		return(false);

	float size_mod = GetSize();
	float other_size_mod = other->GetSize();

	if(GetRace() == 49 || GetRace() == 158 || GetRace() == 196) //For races with a fixed size
		size_mod = 60.0f;
	else if (size_mod < 6.0)
		size_mod = 8.0f;

	if(other->GetRace() == 49 || other->GetRace() == 158 || other->GetRace() == 196) //For races with a fixed size
		other_size_mod = 60.0f;
	else if (other_size_mod < 6.0)
		other_size_mod = 8.0f;

	if (other_size_mod > size_mod)
	{
		size_mod = other_size_mod;
	}

	// this could still use some work, but for now it's an improvement....

	if (size_mod > 29)
		size_mod *= size_mod;
	else if (size_mod > 19)
		size_mod *= size_mod * 2;
	else
		size_mod *= size_mod * 4;


	// prevention of ridiculously sized hit boxes
	if (size_mod > 10000)
		size_mod = size_mod / 7;

	float _DistNoRoot = DistanceSquared(m_Position, other->GetPosition());

	if (GetSpecialAbility(NPC_CHASE_DISTANCE)){

		bool DoLoSCheck = true;
		float max_dist = static_cast<float>(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 0));
		float min_dist = static_cast<float>(GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 1));

		if (GetSpecialAbilityParam(NPC_CHASE_DISTANCE, 2))
			DoLoSCheck = false; //Ignore line of sight check

		if (max_dist == 1)
			max_dist = 250.0f; //Default it to 250 if you forget to put a value

		max_dist = max_dist * max_dist;

		if (!min_dist)
			min_dist = size_mod; //Default to melee range
		else
			min_dist = min_dist * min_dist;

		if ((DoLoSCheck && CheckLastLosState()) && (_DistNoRoot >= min_dist && _DistNoRoot <= max_dist))
			SetPseudoRoot(true);
		else
			SetPseudoRoot(false);
	}

	if (_DistNoRoot <= size_mod)
	{
		return true;
	}
	return false;
}
示例#10
0
//==============================================================================
void GameServer::HandleExamine_(const QVariantMap& request, QVariantMap& response)
{
  auto id = request["id"].toInt();
  if (!id
      || idToActor_.count(id) == 0)
  {
    WriteResult_(response, EFEMPResult::BAD_ID);
    return;
  }

  Actor* actor = idToActor_[id];
  response["type"] = TypeToString[actor->GetType()];
  if (actor->GetType() != EActorType::ITEM
      && actor->GetType() != EActorType::PROJECTILE)
  {
    auto m = dynamic_cast<Creature*>(actor);
    response["health"] = m->GetHealth();
    response["maxHealth"] = m->GetMaxHealth();
  }

  if (response["health"] <= 0
      && response["type"] != "item"
      && response["type"] != "projectile")
  {
    WriteResult_ (response, EFEMPResult::BAD_ID);
    return;
  }

  if (actor->GetType() == EActorType::MONSTER)
  {
    auto m = dynamic_cast<Monster*>(actor);
    response["mobType"] = m->GetName();
    response["race"] = m->GetRace();
    QVariantList items;

    for (auto& a : m->items)
    {
      QVariantMap item;
      item["id"] = a->GetId();
      item["name"] = a->Getname();
      item["type"] = a->GetTypeItem();
      item["class"] = a->GetClass();
      item["subtype"] = a->GetSubtype();
      item["weight"] = a->GetWeight();
      items << item;
    }

    response["inventory"] = items;

    QVariantMap stats;

    for (auto i = StringToStat.begin(); i != StringToStat.end(); i++)
    {
      stats[i.key()] = m->GetStatValue(i.value());
    }

    response["stats"] = stats;
  }

  if (actor->GetType() == EActorType::ITEM)
  {
    auto m = dynamic_cast<Item*>(actor);
    QVariantMap item;
    item["name"] = m->Getname();
    item["type"] = m->GetTypeItem();
    item["class"] = m->GetClass();
    item["subtype"] = m->GetSubtype();
    item["weight"] = m->GetWeight();
    response["item"] = item;
  }

  if (actor->GetType() == EActorType::PLAYER)
  {
    auto p = dynamic_cast<Player*>(actor);
    response["login"] = p->GetLogin();

    QVariantList items;
    for (auto& a : p->items_)
    {
      QVariantMap item;
      item["id"] = a->GetId();
      item["name"] = a->Getname();
      item["type"] = a->GetTypeItem();
      item["class"] = a->GetClass();
      item["subtype"] = a->GetSubtype();
      item["weight"] = a->GetWeight();
      items << item;
    }

    response["inventory"] = items;

    QVariantMap slots_;

    for (auto i = SlotToString.begin(); i != SlotToString.end(); i++)
    {
      Item* item_ = p->GetSlot(i.value());
      if (item_
          && item_->GetId() != -1)
      {
          QVariantMap item;
          item["id"] = item_->GetId();
          item["name"] = item_->Getname();
          item["type"] = item_->GetTypeItem();
          item["class"] = item_->GetClass();
          item["subtype"] = item_->GetSubtype();
          item["weight"] = item_->GetWeight();
          slots_[i.key()] = item;
      }
    }
    response["slots"] = slots_;

    QVariantMap stats;
    for (auto i = StringToStat.begin(); i != StringToStat.end(); i++)
    {
      stats[i.key()] = p->GetStatValue(i.value());
    }
    response["stats"] = stats;
  }

  response["x"] = actor->GetPosition().x;
  response["y"] = actor->GetPosition().y;
  response["id"] = actor->GetId();
}
示例#11
0
//==============================================================================
void GameServer::HandleLook_(const QVariantMap& request, QVariantMap& response)
{
  auto sid = request["sid"].toByteArray();
  Player* p = sidToPlayer_[sid];

  QVariantList rows;

  auto pos = p->GetPosition();
  response["x"] = pos.x;
  response["y"] = pos.y;

  int x = GridRound(pos.x);
  int y = GridRound(pos.y);

  int xDelta = (screenColumnCount_ - 1) / 2;
  int yDelta = (screenRowCount_ - 1) / 2;

  int minX = x - xDelta;
  int maxX = x + xDelta;
  int minY = y - yDelta;
  int maxY = y + yDelta;

  QVariantList actors;
  std::unordered_set<Actor*> actorsInArea;

  for (int j = minY; j <= maxY; j++)
  {
    QVariantList row;
    for (int i = minX; i <= maxX; i++)
    {
      row.push_back(QString(levelMap_.GetCell(i, j)));
      auto& actorsInCell = levelMap_.GetActors(i, j);
      for (auto& a: actorsInCell)
      {
        actorsInArea.insert(a);
      }
    }
    rows.push_back(row);
  }

  for (auto& a : actorsInArea)
  {
    QVariantMap actor;
    actor["type"] = TypeToString[a->GetType()];
    actor["x"] = a->GetPosition().x;
    actor["y"] = a->GetPosition().y;
    actor["id"] = a->GetId();

    if (actor["type"] == "monster")
    {
      auto m = dynamic_cast<Monster*>(a);
      actor["mobType"] = m->GetName();
    }

    if (actor["type"] != "item"
        && actor["type"] != "projectile")
    {
      auto m = dynamic_cast<Creature*>(a);
      actor["health"] = m->GetHealth();
      actor["maxHealth"] = m->GetMaxHealth();
      actor["race"] = m->GetRace();
    }

    if (actor["type"] == "item")
    {
      actor["name"] = dynamic_cast<Item*>(a)->Getname();
    }

    if (actor["type"] == "projectile")
    {
      actor["name"] = "fireball_projectile";
    }

    if (actor["health"] <= 0
        && (actor["type"] == "monster"))
    {
      Creature* b = dynamic_cast<Creature*>(a);
      idToActor_.erase(b->GetId());
      levelMap_.RemoveActor(b);
      actors_.erase(std::remove(actors_.begin(), actors_.end(), b), actors_.end());
      delete b;
      b = nullptr;
    }

    if (actor["type"] == "projectile"
        || actor["type"] == "item"
        || actor["health"] > 0)
    {
      actors << actor;
    }
  }

  response["map"] = rows;
  response["actors"] = actors;
}
示例#12
0
void psCreationManager::HandleTraitData( MsgEntry* me )
{
    psCharCreateTraitsMessage msg(me);
    iDocumentSystem* xml = psengine->GetXMLParser ();
    csRef<iDocument> doc = xml->CreateDocument();

    const char* error = doc->Parse(msg.GetString().GetData());
    if ( error )
    {
        Error2("Error in XML: %s", error );
        return;
    }

    csRef<iDocumentNode> root = doc->GetRoot();
    if(!root)
    {
        Error1("No XML root in Trait Data");
        return;
    }
    csRef<iDocumentNodeIterator> iter1 = root->GetNode("traits")->GetNodes("trait");

    // Build the traits list
    while ( iter1->HasNext() )
    {
        csRef<iDocumentNode> node = iter1->Next();

        Trait *t = new Trait;
        t->Load( node );

        traits.Push(t);
    }

    TraitIterator iter2 = GetTraitIterator();
    while ( iter2.HasNext() )
    {
        Trait * t = iter2.Next();
        t->next_trait = GetTrait(t->next_trait_uid);
        if (t->next_trait != NULL)
        {
           t->next_trait->prev_trait = t;
        }
    }

    // Insert into the custom location structure all top trait
    TraitIterator iter3 = GetTraitIterator();
    while ( iter3.HasNext() )
    {
        Trait * t = iter3.Next();
        // Check for top trait
        if (t->prev_trait == NULL)
        {
            RaceDefinition * race = GetRace(t->raceID);
            if (race != NULL)
            {
                if (t->gender == PSCHARACTER_GENDER_NONE)
                {
                    race->location[t->location][PSCHARACTER_GENDER_MALE].Push(t); // still needed?
                    race->location[t->location][PSCHARACTER_GENDER_FEMALE].Push(t); // still needed?
                    race->location[t->location][PSCHARACTER_GENDER_NONE].Push(t);
                }
                else
                {
                    race->location[t->location][t->gender].Push(t);
                }
            }
            else
            {
                Error3("Failed to insert trait '%s' into location table for race %d.\n",t->name.GetData(),t->raceID);
            }
        }
    }
}
示例#13
0
void Client::CheckQuests(const char* zonename, const char * message, int32 npc_id, uint16 item_id, Mob* other)
{
	bool ps = false;
	bool tt = false;
	bool ti = false;
	bool tt2 = false;
	bool ti2 = false;
	bool stt = false;
	bool std = false;
	bool td = false;
	bool sta = false;
	bool ta = false;
	bool sti = false;
	bool stf = false;
	bool tf = false;
	bool tk = false;
	bool stk = false;
	bool levelcheck = false;
	int8 fac = GetFactionLevel(GetID(),other->GetNPCTypeID(), GetRace(), GetClass(), DEITY_AGNOSTIC, other->CastToNPC()->GetPrimaryFaction(), other);
	FILE * pFile;
  long lSize;
  char * buffer;
  char filename[255];
  #ifdef WIN32
  snprintf(filename, 254, "quests\\%i.qst", npc_id);
  #else
  snprintf(filename, 254, "quests/%i.qst", npc_id);
  #endif
  adverrorinfo = 940;
  if ((pFile=fopen(filename,"rb")))
  {
		#ifdef DEBUG
		printf("Reading quests from %s\n", filename);
		#endif
  }
  else {
		#ifdef DEBUG
		printf("Error: No quests file found for %s\n", filename);
		#endif
		return;
  }
  if (pFile==NULL) exit (1);

  // obtain file size.
  fseek (pFile , 0 , SEEK_END);
  lSize = ftell (pFile);
  rewind (pFile);

  adverrorinfo = 941;
  // allocate memory to contain the whole file.
  buffer = (char*) malloc (lSize);
  if (buffer == NULL) exit (2);

  // copy the file into the buffer.
  fread (buffer,1,lSize,pFile);
  fclose(pFile);
  Seperator3 sep3(buffer);
  for(int i=0; i < 2048; ++i)
  {
//  printf("Temp: %s\n", sep3.arghz[i]);
	char * command;
	char * temp;
	temp = sep3.arghz[i];
	if (temp == NULL) return;
	Seperator sep(temp);
	Seperator4 sep4(temp);
	command = sep4.arghza[0];
	command = strupr(command);
#ifdef DEBUG
	cout<<sep.argplus[0]<<endl;
#endif
	if (!IsCommented(temp))
	{
	if (strstr(command,"END_FILE") != NULL || command == NULL)
	{
		break;
	}
	if (ti2 || tt2 || tf || td || ta) {
		char lvl[5];
		sprintf(lvl, "%i", this->GetLevel());
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARRACE%", GetRaceName(this->GetRace())));
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARLEVEL%", lvl));
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARCLASS%", GetEQClassName(this->GetClass(), 50)));
		char * nmessage = strreplace(sep4.arghza[1],"%CHARNAME%", this->GetName());
		nmessage[strlen(nmessage) - 1] = '\0';
		if (ti2 || tt2 || ta)
		{
			other->CastToNPC()->FaceTarget(this, true);
		}
		if ((fac == 7 || fac == 6) && (ti2 || tt2))
		{
			entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
			break;
		}
		else if (strstr(command,"FACTION_CHECK") != NULL) {
			int8 fac2 = atoi(sep.arg[1]);
			if ((fac2 <= 5 && fac > fac2) || (fac2 == 6 && fac == 8))
			{
				entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
				break;
			}
			ps = true;
		}
		else if (strstr(command,"SAY") != NULL) {
			entity_list.NPCMessage(this, false, 400, 0, "%s says, '%s'", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"EMOTE") != NULL) {
			cout<<"Emoting!"<<endl;
			entity_list.NPCMessage(this, false, 400, 0, "%s %s", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"TEXT") != NULL) {
			entity_list.NPCMessage(this, false, 400, 0, "%s", nmessage);
			ps = true;
		}
		else if (strstr(command,"SHOUT") != NULL) {
			entity_list.NPCMessage(this, false, 0, 13, "%s shouts, '%s'", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"SPAWN_ITEM") != NULL) {
			this->SummonItem(atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"ADD_HATELIST") != NULL) {
			other->CastToNPC()->AddToHateList(this, 100);
			ps = true;
		}
		else if (strstr(command,"DEPOP") != NULL) {
			other->CastToNPC()->Depop();
			ps = true;
		}
#ifdef GUILDWARS
		else if (strstr(command,"CITYTAKE") != NULL) {
			if(IsClient() && GuildDBID() != 0)
			{
				if(target->CastToNPC()->GetGuildOwner() == GuildDBID())
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You are a member of the guild that owns this city, why would you want to conquere it?'", other->GetName(), nmessage);				
				}
				else if(!IsAttackAllowed(other))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You cannot conquere an allied city.'", other->GetName(), nmessage);				
				}
				else if(database.CityDefense(zone->GetZoneID(),0))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'This city still has men standing, I will not surrender!'", other->GetName(), nmessage);				
				}
				else if(database.SetCityGuildOwned(GuildDBID(),other->GetNPCTypeID()))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You have won, I surrender to you.'", other->GetName(), nmessage);	
			zone->SetGuildOwned(GuildDBID());
			zone->Repop();			
				}
			}
			ps = true;
		}
#endif
		else if (strstr(command,"SPAWN_NPC") != NULL) {
				adverrorinfo = 751;
				const NPCType* tmp = 0;
				adverrorinfo = 752;
				int16 grid = atoi(sep.arg[2]);
				int8 guildwarset = atoi(sep.arg[3]);
				if ((tmp = database.GetNPCType(atoi(sep.arg[1]))))
				{
					adverrorinfo = 753;
					NPC* npc = new NPC(tmp, 0, other->GetX(), other->GetY(), other->GetZ(), heading);
					adverrorinfo = 754;
					npc->AddLootTable();
					adverrorinfo = 755;
					entity_list.AddNPC(npc,true,true);
					adverrorinfo = 756;
					Sleep(200);
					if(npc != 0)
					{
					if(grid > 0)
						npc->AssignWaypoints(grid);
					adverrorinfo = 757;
#ifdef GUILDWARS
					if(guildwarset > 0 && guildwarset == 1 && GuildDBID() > 0)
						npc->SetGuildOwner(GuildDBID());
#endif
					adverrorinfo = 758;
					npc->SendPosUpdate();
					}
			}
			ps = true;
		}
		else if (strstr(command,"LEVEL_CHECK") != NULL) 
      { 
         int8 Level1 = atoi(sep.arg[1]); 
         int8 Level2 = atoi(sep.arg[2]); 
         int8 Levelp = this->GetLevel(); 
          
         if(Level2 == 0 || Level2 == NULL){ 
            //Min Level 
            if(Level1 > Levelp) 
            { 
               //not high enough to talk too 
               break; 
            } 
         } 
         else{ 
            //Level Range 
            if(Level1 < Levelp && Level2 < Levelp) 
            { 
               //not in the req level range 
               break; 
            } 
         } 
         levelcheck = true; 
      }
		else if (strstr(command,"CUMULATIVE_FLAG") != NULL) {
			other->flag[50] = other->flag[50] + 1;
			ps = true;
		}
		else if (strstr(command,"NPC_FLAG") != NULL) {
			other->flag[atoi(sep.arg[1])] = atoi(sep.arg[2]);
			ps = true;
		}
		else if (strstr(command,"PLAYER_FLAG") != NULL) {
			this->flag[atoi(sep.arg[1])] = atoi(sep.arg[2]);
			ps = true;
		}
		else if (strstr(command,"EXP") != NULL) {
			this->AddEXP (atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"LEVEL") != NULL) {
			this->SetLevel(atoi(sep.arg[1]), true);
			ps = true;
		}
		else if (strstr(command,"SAFEMOVE") != NULL) {
			this->MovePC(zone->GetShortName(),database.GetSafePoint(zone->GetShortName(),"x"),database.GetSafePoint(zone->GetShortName(),"y"),database.GetSafePoint(zone->GetShortName(),"z"),false,false);
			ps = true;
		}
		else if (strstr(command,"RAIN") != NULL) {
			zone->zone_weather = atoi(sep.arg[1]);
			APPLAYER* outapp = new APPLAYER;
			outapp = new APPLAYER;
			outapp->opcode = OP_Weather;
			outapp->pBuffer = new uchar[8];
			memset(outapp->pBuffer, 0, 8);
			outapp->size = 8;
			outapp->pBuffer[4] = atoi(sep.arg[1]); // Why not just use 0x01/2/3?
			entity_list.QueueClients(this, outapp);
			delete outapp;
			ps = true;
		}
		else if (strstr(command,"SNOW") != NULL) {
			zone->zone_weather = atoi(sep.arg[1]) + 1;
			APPLAYER* outapp = new APPLAYER;
			outapp = new APPLAYER;
			outapp->opcode = OP_Weather;
			outapp->pBuffer = new uchar[8];
			memset(outapp->pBuffer, 0, 8);
			outapp->size = 8;
			outapp->pBuffer[0] = 0x01;
			outapp->pBuffer[4] = atoi(sep.arg[1]);
			entity_list.QueueClients(this, outapp);
			delete outapp;
			ps = true;
		}
		else if (strstr(command,"GIVE_CASH") != NULL) {
			this->AddMoneyToPP(atoi(sep.arg[1]),true);
			ps = true;
		} 
		else if (strstr(command,"GIVE_ITEM") != NULL) { 
			int16 ItemID = atoi(sep.arg[1]); 
			sint8 ItemCharges = atoi(sep.arg[2]); 
			this->SummonItem(ItemID, ItemCharges); 
			ps = true; 
		} 
		else if (strstr(command,"CAST_SPELL") != NULL) {
			other->CastSpell(atoi(sep.arg[1]),this->GetID());
			ps = true;
		}
		else if (strstr(command,"PVP") != NULL) {
			if (strstr(strupr(sep.arg[1]),"ON") != NULL)
				this->CastToClient()->SetPVP(true);
			else
				this->CastToClient()->SetPVP(false);
			ps = true;
		}
		/*else if (strstr(command,"CHANGEFACTION") != NULL) {
			if ((sep.IsNumber(1)) && (sep.IsNumber(2))) {
				this->CastToClient()->SetFactionLevel2(this->CastToClient()->CharacterID(),atoi(sep.arg[1]), this->CastToClient()->GetClass(), this->CastToClient()->GetRace(), this->CastToClient()->GetDeity(), atoi(sep.arg[2]));
				this->CastToClient()->Message(0,BuildFactionMessage(GetCharacterFactionLevel(atoi(sep.arg[1])),atoi(sep.arg[1])));
			}
			else
			{
				cout << "Error in script!!!!!  Bad CHANGEFACTION Line! " << endl;
			}
			ps = true;
		}*/
		else if (strstr(command,"DO_ANIMATION") != NULL) {
			other->DoAnim(atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"ADDSKILL") != NULL) {
			if (sep.IsNumber(1) && sep.IsNumber(2) && (atoi(sep.arg[2]) >= 0 || atoi(sep.arg[2]) <= 252) && (atoi(sep.arg[1]) >= 0 && atoi(sep.arg[1]) < 74)) {
				this->AddSkill(atoi(sep.arg[1]), atoi(sep.arg[2]));
			}
			else
				cout << "Error in script!!!! Bad ADDSKILL line!" << endl;
			ps = true;
		}
		else if (strstr(command,"FLAG_CHECK") != NULL)
		{
			if (this->flag[atoi(sep.arg[1])] == 0)
				break;
			else
				this->flag[atoi(sep.arg[1])] = 0;
			ps = true;
		}
		else if (strstr(command,"CHANCE") != NULL)
		{
			if (rand()%100 > atoi(sep.arg[1]))
				break;
			ps = true;
		}
	}
	if (IsEnd(temp)) 
	{
		tt = false; tt2 = false; stt = false; ti = false; ti2 = false; sti = false; tk = false;	td = false; std = false; ta = false; sta = false; tf = false; stf = false; stk = false; 
	}
		if (strstr(command,"TRIGGER_ATTACK") != NULL)
		{
			if (strstr(message,"%%ATTACK%%") != NULL) {
				adverrorinfo = 943;
				ta = true;
			}
			else { sta = true; }
		}
		else if (strstr(command,"TRIGGER_DEATH") != NULL)
		{
			if (strstr(message,"%%DEATH%%") != NULL)
			{
				td = true;
			}
			else { std = true; }
		}
		else if (strstr(command,"TRIGGER_KILLED") != NULL)
		{
			if (strstr(message,"%%KILLED%%") != NULL)
			{
				tk = true;
			}
			else { stk = true; }
		}
		else if (strstr(command,"TRIGGER_FLAGS") != NULL)
		{
			int8 flag1 = atoi(sep.arg[1]);
			int8 flag2 = atoi(sep.arg[2]);
			int8 flag3 = atoi(sep.arg[3]);
			int8 flag4 = atoi(sep.arg[4]);
			if (flag1 == 50)
			{
				if (other->flag[50] >= atoi(sep.arg[2]))
				{
					tf = true;
					other->flag[50] = 0;
				}
				else
					stf = true;
			}
			else
			{
				if (ta || tt || ti)
					stf = true;
				else if (flag1 > 0 && other->flag[flag1] == 0)
					stf = true;
				else if (flag2 > 0 && other->flag[flag2] == 0)
					stf = true;
				else if (flag3 > 0 && other->flag[flag3] == 0)
					stf = true;
				else if (flag4 > 0 && other->flag[flag4] == 0)
					stf = true;
				else
				{
					tf = true;
					if (flag1 > 0)
						other->flag[flag1] = 0;
					if (flag2 > 0)
						other->flag[flag2] = 0;
					if (flag3 > 0)
						other->flag[flag3] = 0;
				if (flag4 > 0)
							other->flag[flag4] = 0;
				}
			}
		}
		else if (strstr(command,"TRIGGER_ITEM") != NULL) {
			if (!ta && !tt && !ti)
			{
				if ((uint16)item_id == atoi(sep4.arghza[1]))
				{
					ti = true; ti2 = true;
				}
				else { sti = true; }
			}
			else
			{
				printf("TRIGGER_ITEM Error at line %d: missing left curly bracket\n", i);
				return;
			}
		}
		else if (strstr(command,"TRIGGER_TEXT") != NULL)
		{
			if (strstr(message,"%%DEATH%%") == NULL && strstr(message,"%%ITEM%%") == NULL && strstr(message,"%%ATTACK%%") == NULL && strstr(message,"%%KILLED%%") == NULL && Dist(other) <= 50) {
				char* tmp = new char[strlen(message)+1];
				strcpy(tmp, message);
				strupr(tmp);
				if (strstr(tmp,strupr(sep4.arghza[1])) != NULL)
				{
					tt2 = true; tt = true;
				}
				else
				{
					stt = true;
				}
				delete tmp;
			}
			else if (strstr(message,"%%DEATH%%") != NULL || strstr(message,"%%item%%") != NULL || strstr(message,"%%attack%%")) { stt = true; }
			else if (!ps) { printf("TRIGGER_TEXT Error at line %d: Not in NPC_Script\n", i); return; }
			else
			{
				printf("TRIGGER_TEXT Error at line %d: missing left curly bracket\n", i);
				return;
			}
		}
	/*#ifdef WIN32
		delete command;
		delete temp;
	#endif*/
}
}
	if (!ps && item_id != 0)
	{
		entity_list.NPCMessage(this,true,200,0,"%s has no use for this item.",other->GetName());
		SummonItem(item_id);
	}
	delete buffer;
}
示例#14
0
bool Client::CastDiscipline(uint8 disc_id, uint8 level_to_use)
{
    uint8 current_level = GetLevel();
    if(current_level > 60)
        current_level = 60;

    if(level_to_use > current_level || level_to_use == 0)
        return false;

    // reuse_timer is in seconds, ability_timer is in milliseconds.
    uint32 reuse_timer = 0, ability_timer = 0, string = 0;
    int16 spellid = 0;

    switch(disc_id)
    {
    case disc_aggressive:
        reuse_timer = 1620 - (current_level - level_to_use) * 60;
        ability_timer = 180000;
        spellid = 4498;
        string = DISCIPLINE_AGRESSIVE;

        break;
    case disc_precision:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 180000;
        spellid = 4501;
        string = DISCIPLINE_PRECISION;

        break;
    case disc_defensive:
        reuse_timer = 900 - (current_level - level_to_use) * 60;
        ability_timer = 180000;
        spellid = 4499;
        string = DISCIPLINE_DEFENSIVE;

        break;
    case disc_evasive:
        reuse_timer = 900 - (current_level - level_to_use) * 60;
        ability_timer = 180000;
        spellid = 4503;
        string = DISCIPLINE_EVASIVE;

        break;
    case disc_ashenhand:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        spellid = 4508;
        string = DISCIPLINE_ASHENHAND;

        break;
    case disc_furious:
        reuse_timer = 3600 - (current_level - level_to_use) * 60;
        ability_timer = 9000;
        if(GetBaseClass() == WARRIOR)
            spellid = 4674;
        else if(GetBaseClass() == MONK)
            spellid = 4509;
        else if(GetBaseClass() == ROGUE)
            spellid = 4673;
        string = DISCIPLINE_FURIOUS;

        break;
    case disc_stonestance:
        reuse_timer = 720 - (current_level - level_to_use) * 60;
        ability_timer = 12000;
        if(GetBaseClass() == MONK)
            spellid = 4510;
        else if(GetBaseClass() == BEASTLORD)
            spellid = 4671;
        string = DISCIPLINE_STONESTANCE;

        break;
    case disc_thunderkick:
        reuse_timer = 420 - (current_level - level_to_use) * 60;
        spellid = 4511;
        string = DISCIPLINE_THUNDERKICK;

        break;
    case disc_fortitude:
        reuse_timer = 3600 - (current_level - level_to_use) * 60;
        ability_timer = 8000;
        if(GetBaseClass() == WARRIOR)
            spellid = 4670;
        else if(GetBaseClass() == MONK)
            spellid = 4502;
        string = DISCIPLINE_FORTITUDE;

        break;
    case disc_fellstrike:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 12000;
        if(GetBaseClass() == WARRIOR)
            spellid = 4675;
        else if(GetBaseClass() == MONK)
            spellid = 4512;
        else if(GetBaseClass() == ROGUE)
            spellid = 4676;
        else if(GetBaseClass() == BEASTLORD)
            spellid = 4678;
        string = DISCIPLINE_FELLSTRIKE;

        break;
    case disc_hundredfist:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 15000;
        if(GetBaseClass() == MONK)
            spellid = 4513;
        else if(GetBaseClass() == ROGUE)
            spellid = 4677;
        string = DISCIPLINE_HUNDREDFIST;

        break;
    case disc_charge:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 14000;
        if(GetBaseClass() == WARRIOR)
            spellid = 4672;
        else if(GetBaseClass() == ROGUE)
            spellid = 4505;
        string = DISCIPLINE_CHARGE;

        break;
    case disc_mightystrike:
        reuse_timer = 3600 - (current_level - level_to_use) * 60;
        ability_timer = 10000;
        spellid = 4514;
        string = DISCIPLINE_MIGHTYSTRIKE;

        break;
    case disc_nimble:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 12000;
        spellid = 4515;
        string = DISCIPLINE_NIMBLE;

        break;
    case disc_silentfist:
        reuse_timer = 540 - (current_level - level_to_use) * 60;
        spellid = 4507;
        if(GetRace() == IKSAR)
            string = DISCIPLINE_SILENTFIST_IKSAR;
        else
            string = DISCIPLINE_SILENTFIST;

        break;
    case disc_kinesthetics:
        reuse_timer = 1800 - (current_level - level_to_use) * 60;
        ability_timer = 18000;
        spellid = 4517;
        string = DISCIPLINE_KINESTHETICS;

        break;
    case disc_holyforge:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 120000;
        spellid = 4500;
        string = DISCIPLINE_HOLYFORGE;

        break;
    case disc_sanctification:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 10000;
        spellid = 4518;
        string = DISCIPLINE_SANCTIFICATION;

        break;
    case disc_trueshot:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 120000;
        spellid = 4506;
        string = DISCIPLINE_TRUESHOT;

        break;
    case disc_weaponshield:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 15000;
        spellid = 4519;
        if(GetGender() == 0)
            string = DISCIPLINE_WPNSLD_MALE;
        else if(GetGender() == 1)
            string = DISCIPLINE_WPNSLD_FEMALE;
        else
            string = DISCIPLINE_WPNSLD_MONSTER;

        break;
    case disc_unholyaura:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        spellid = 4520;
        string = DISCIPLINE_UNHOLYAURA;

        break;
    case disc_leechcurse:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 15000;
        spellid = 4504;
        string = DISCIPLINE_LEECHCURSE;

        break;
    case disc_deftdance:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 10000;
        spellid = 4516;
        string = DISCIPLINE_DEFTDANCE;

        break;
    case disc_puretone:
        reuse_timer = 4320 - (current_level - level_to_use) * 60;
        ability_timer = 120000;
        spellid = 4586;
        string = DISCIPLINE_PURETONE;

        break;
    case disc_resistant:
        reuse_timer = 3600 - (current_level - level_to_use) * 60;
        ability_timer = 60000;
        spellid = 4585;
        string = DISCIPLINE_RESISTANT;

        break;
    case disc_fearless:
        reuse_timer = 3600 - (current_level - level_to_use) * 60;
        ability_timer = 11000;
        spellid = 4587;
        string = DISCIPLINE_FEARLESS;

        break;
    default:
        Log.Out(Logs::General, Logs::Discs, "Invalid disc id %d was passed to CastDiscipline.", disc_id);
        return false;
    }

    if(string > 0 && IsDisc(spellid))
    {
        entity_list.MessageClose_StringID(this, false, 50, CC_User_Disciplines, string, GetName());
        p_timers.Start(pTimerDisciplineReuseStart, reuse_timer);
        if(ability_timer > 0)
        {
            disc_ability_timer.SetTimer(ability_timer);
        }
        else
        {
            Log.Out(Logs::General, Logs::Discs, "Disc %d is an instant effect", disc_id);
        }

        SetActiveDisc(disc_id, spellid);
        SpellFinished(spellid, this);
    }
    else
    {
        Log.Out(Logs::General, Logs::Discs, "Disc: %d Invalid stringid or spellid specified.", disc_id);
        return false;
    }

    EQApplicationPacket *outapp = new EQApplicationPacket(OP_DisciplineChange, sizeof(ClientDiscipline_Struct));
    ClientDiscipline_Struct *d = (ClientDiscipline_Struct*)outapp->pBuffer;
    d->disc_id = disc_id;
    QueuePacket(outapp);
    safe_delete(outapp);

    return true;
}