本文整理汇总了C++中NPC::GetSwarmInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ NPC::GetSwarmInfo方法的具体用法?C++ NPC::GetSwarmInfo怎么用?C++ NPC::GetSwarmInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPC
的用法示例。
在下文中一共展示了NPC::GetSwarmInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TypesTemporaryPets
void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_override, uint32 duration_override, bool followme, bool sticktarg) {
AA_SwarmPet pet;
pet.count = 1;
pet.duration = 1;
pet.npc_id = typesid;
NPCType *made_npc = nullptr;
const NPCType *npc_type = database.LoadNPCTypesData(typesid);
if(npc_type == nullptr) {
//log write
Log.Out(Logs::General, Logs::Error, "Unknown npc type for swarm pet type id: %d", typesid);
Message(0,"Unable to find pet!");
return;
}
if(name_override != nullptr) {
//we have to make a custom NPC type for this name change
made_npc = new NPCType;
memcpy(made_npc, npc_type, sizeof(NPCType));
strcpy(made_npc->name, name_override);
npc_type = made_npc;
}
int summon_count = 0;
summon_count = pet.count;
if(summon_count > MAX_SWARM_PETS)
summon_count = MAX_SWARM_PETS;
static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = {
glm::vec2(5, 5), glm::vec2(-5, 5), glm::vec2(5, -5), glm::vec2(-5, -5),
glm::vec2(10, 10), glm::vec2(-10, 10), glm::vec2(10, -10), glm::vec2(-10, -10),
glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8)
};;
while(summon_count > 0) {
int pet_duration = pet.duration;
if(duration_override > 0)
pet_duration = duration_override;
//this is a little messy, but the only way to do it right
//it would be possible to optimize out this copy for the last pet, but oh well
NPCType *npc_dup = nullptr;
if(made_npc != nullptr) {
npc_dup = new NPCType;
memcpy(npc_dup, made_npc, sizeof(NPCType));
}
NPC* npca = new NPC(
(npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer
0,
GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f),
FlyMode3);
if (followme)
npca->SetFollowID(GetID());
if(!npca->GetSwarmInfo()){
auto nSI = new AA_SwarmPetInfo;
npca->SetSwarmInfo(nSI);
npca->GetSwarmInfo()->duration = new Timer(pet_duration*1000);
}
else{
npca->GetSwarmInfo()->duration->Start(pet_duration*1000);
}
//removing this prevents the pet from attacking
npca->GetSwarmInfo()->owner_id = GetID();
//give the pets somebody to "love"
if(targ != nullptr){
npca->AddToHateList(targ, 1000, 1000);
if (RuleB(Spells, SwarmPetTargetLock) || sticktarg)
npca->GetSwarmInfo()->target = targ->GetID();
else
npca->GetSwarmInfo()->target = 0;
}
//we allocated a new NPC type object, give the NPC ownership of that memory
if(npc_dup != nullptr)
npca->GiveNPCTypeData(npc_dup);
entity_list.AddNPC(npca, true, true);
summon_count--;
}
// The other pointers we make are handled elsewhere.
delete made_npc;
}
示例2: TemporaryPets
void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, uint32 duration_override, bool followme, bool sticktarg) {
//It might not be a bad idea to put these into the database, eventually..
//Dook- swarms and wards
PetRecord record;
if(!database.GetPetEntry(spells[spell_id].teleport_zone, &record))
{
Log.Out(Logs::General, Logs::Error, "Unknown swarm pet spell id: %d, check pets table", spell_id);
Message(13, "Unable to find data for pet %s", spells[spell_id].teleport_zone);
return;
}
AA_SwarmPet pet;
pet.count = 1;
pet.duration = 1;
for(int x = 0; x < MAX_SWARM_PETS; x++)
{
if(spells[spell_id].effectid[x] == SE_TemporaryPets)
{
pet.count = spells[spell_id].base[x];
pet.duration = spells[spell_id].max[x];
}
}
pet.duration += GetFocusEffect(focusSwarmPetDuration, spell_id) / 1000;
pet.npc_id = record.npc_type;
NPCType *made_npc = nullptr;
const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id);
if(npc_type == nullptr) {
//log write
Log.Out(Logs::General, Logs::Error, "Unknown npc type for swarm pet spell id: %d", spell_id);
Message(0,"Unable to find pet!");
return;
}
if(name_override != nullptr) {
//we have to make a custom NPC type for this name change
made_npc = new NPCType;
memcpy(made_npc, npc_type, sizeof(NPCType));
strcpy(made_npc->name, name_override);
npc_type = made_npc;
}
int summon_count = 0;
summon_count = pet.count;
if(summon_count > MAX_SWARM_PETS)
summon_count = MAX_SWARM_PETS;
static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = {
glm::vec2(5, 5), glm::vec2(-5, 5), glm::vec2(5, -5), glm::vec2(-5, -5),
glm::vec2(10, 10), glm::vec2(-10, 10), glm::vec2(10, -10), glm::vec2(-10, -10),
glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8)
};
while(summon_count > 0) {
int pet_duration = pet.duration;
if(duration_override > 0)
pet_duration = duration_override;
//this is a little messy, but the only way to do it right
//it would be possible to optimize out this copy for the last pet, but oh well
NPCType *npc_dup = nullptr;
if(made_npc != nullptr) {
npc_dup = new NPCType;
memcpy(npc_dup, made_npc, sizeof(NPCType));
}
NPC* npca = new NPC(
(npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer
0,
GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f),
FlyMode3);
if (followme)
npca->SetFollowID(GetID());
if(!npca->GetSwarmInfo()){
auto nSI = new AA_SwarmPetInfo;
npca->SetSwarmInfo(nSI);
npca->GetSwarmInfo()->duration = new Timer(pet_duration*1000);
}
else{
npca->GetSwarmInfo()->duration->Start(pet_duration*1000);
}
//removing this prevents the pet from attacking
npca->GetSwarmInfo()->owner_id = GetID();
//give the pets somebody to "love"
if(targ != nullptr){
npca->AddToHateList(targ, 1000, 1000);
if (RuleB(Spells, SwarmPetTargetLock) || sticktarg)
npca->GetSwarmInfo()->target = targ->GetID();
//.........这里部分代码省略.........
示例3: WakeTheDead
//.........这里部分代码省略.........
case PALADIN:
//SPECATK_TRIPLE
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 150 / 100;
make_npc->max_hp = make_npc->max_hp * 150 / 100;
make_npc->npc_spells_id = 8;
break;
case SHADOWKNIGHT:
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 150 / 100;
make_npc->max_hp = make_npc->max_hp * 150 / 100;
make_npc->npc_spells_id = 9;
break;
case RANGER:
strcpy(make_npc->special_abilities, "7,1");
make_npc->cur_hp = make_npc->cur_hp * 135 / 100;
make_npc->max_hp = make_npc->max_hp * 135 / 100;
make_npc->npc_spells_id = 10;
break;
case BARD:
strcpy(make_npc->special_abilities, "6,1");
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
make_npc->npc_spells_id = 11;
break;
case BEASTLORD:
strcpy(make_npc->special_abilities, "7,1");
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
make_npc->npc_spells_id = 12;
break;
case ROGUE:
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 / 100;
make_npc->cur_hp = make_npc->cur_hp * 110 / 100;
make_npc->max_hp = make_npc->max_hp * 110 / 100;
break;
case MONK:
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 / 100;
make_npc->cur_hp = make_npc->cur_hp * 135 / 100;
make_npc->max_hp = make_npc->max_hp * 135 / 100;
break;
case WARRIOR:
strcpy(make_npc->special_abilities, "7,1");
make_npc->max_dmg = make_npc->max_dmg * 150 / 100;
make_npc->cur_hp = make_npc->cur_hp * 175 / 100;
make_npc->max_hp = make_npc->max_hp * 175 / 100;
break;
default:
make_npc->npc_spells_id = 0;
break;
}
make_npc->loottable_id = 0;
make_npc->merchanttype = 0;
make_npc->d_melee_texture1 = 0;
make_npc->d_melee_texture2 = 0;
NPC* npca = new NPC(make_npc, 0, GetPosition(), FlyMode3);
if (!npca->GetSwarmInfo()){
AA_SwarmPetInfo* nSI = new AA_SwarmPetInfo;
npca->SetSwarmInfo(nSI);
npca->GetSwarmInfo()->duration = new Timer(duration * 1000);
}
else{
npca->GetSwarmInfo()->duration->Start(duration * 1000);
}
npca->GetSwarmInfo()->owner_id = GetID();
//give the pet somebody to "love"
if (target != nullptr){
npca->AddToHateList(target, 100000);
npca->GetSwarmInfo()->target = target->GetID();
}
//gear stuff, need to make sure there's
//no situation where this stuff can be duped
for (int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++) // (< 21) added MainAmmo
{
uint32 sitem = 0;
sitem = CorpseToUse->GetWornItem(x);
if (sitem){
const Item_Struct * itm = database.GetItem(sitem);
npca->AddLootDrop(itm, &npca->itemlist, 1, 1, 127, true, true);
}
}
//we allocated a new NPC type object, give the NPC ownership of that memory
if (make_npc != nullptr)
npca->GiveNPCTypeData(make_npc);
entity_list.AddNPC(npca, true, true);
//the target of these swarm pets will take offense to being cast on...
if (target != nullptr)
target->AddToHateList(this, 1, 0);
}