spawn areas
I got basic spawn areas working
Here's the sql table : Code:
CREATE TABLE `spawnarea` ( spawn areas are rects, you define their bounds with the ( x1, y1, z1 ) and ( x2, y2 , z2 ) points spawngroupID is the id of a spawngroup, add in the spawngroup the monsters you want to spawn in the area each mob is defined by a spawn entry, ( spawngroupID, npcid, chance ) tweak the chance of each npc to tweak the population of each npc type in the area maxpop defines the maximum numbers of npcs who can roam in the area npcs will spawn randomly in the area and roam randomly in the area like the roaming grid type but it doesnt use grids anymore I think it can be improved in many ways, we had already discussions, and maybe areas could be polygons instead of rects, use areas for other purposes like quests etc ... |
updates
here are the updates to do : ( based on 24-05-2004 source )
first : download this : spawnarea.zip it contains spawnarea.cpp and spawnarea.h add these files in your project zone folder, and add them to your zone project then do the following changes ( there is a lot ) and compile : in attack.cpp : line 1885 : after : Code:
killer = tempkiller; Quote:
in command.cpp : line 2521 : replace : Code:
NPC* npc = new NPC(tmp, 0, c->GetX(), c->GetY(), c->GetZ(), c->GetHeading()); Code:
NPC* npc = new NPC(tmp, 0, 0, c->GetX(), c->GetY(), c->GetZ(), c->GetHeading()); in MobAI.cpp : line 1048 : replace : Code:
else if (roamer) Code:
else if (roamer || this->CastToNPC()->spawn_area) replace : Code:
if (gridno > 0) Code:
if ( (gridno > 0) || ( this->CastToNPC()->spawn_area ) ) before : Code:
int8 ranmax = cur_wp; Code:
if ( this->CastToNPC()->spawn_area ) { in npc.cpp : line 58 : replace : Code:
NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float heading, bool IsCorpse) Code:
NPC::NPC(const NPCType* d, Spawn2* in_respawn, SpawnArea* in_area, float x, float y, float z, float heading, bool IsCorpse) after : Code:
NPCTypedata = new NPCType; Code:
spawn_area = in_area; line 914 : after : Code:
if (respawn2 != 0) { Code:
if (spawn_area) { replace : Code:
NPC* npc = new NPC(npc_type, 0, in_x, in_y, in_z, in_heading/8); Code:
NPC* npc = new NPC(npc_type, 0, 0, in_x, in_y, in_z, in_heading/8); in npc.h : line 29 : after : Code:
#include "spawn2.h" Code:
#include "spawnarea.h" line 44 : replace : Code:
NPC(const NPCType* data, Spawn2* respawn, float x, float y, float z, float heading, bool IsCorpse = false); Code:
NPC(const NPCType* data, Spawn2* respawn, SpawnArea* area, float x, float y, float z, float heading, bool IsCorpse = false); line 157 : after : Code:
Spawn2* respawn2; Code:
SpawnArea* spawn_area; in spawn2.cpp : line 99 : replace : Code:
NPC* npc = new NPC(tmp, this, x, y, z, heading); Code:
NPC* npc = new NPC(tmp, this, 0, x, y, z, heading); in spells.cpp : line 5312 : replace : Code:
NPC* npc = new NPC(npc_type, 0, Code:
NPC* npc = new NPC(npc_type, 0, 0, line 6094 : replace : Code:
NPC* horse = new NPC(npc_type, 0, GetX(), GetY(), GetZ(), GetHeading()); Code:
NPC* horse = new NPC(npc_type, 0, 0, GetX(), GetY(), GetZ(), GetHeading()); in zone.cpp : line 383 : after : Code:
spawn_group_list = new SpawnGroupList(); Code:
spawnarea_list = new SpawnAreaList(); 2 lines below : replace : Code:
if (!database.PopulateZoneLists(short_name, &zone_point_list, spawn_group_list)) Code:
if (!database.PopulateZoneLists(short_name, &zone_point_list, spawn_group_list, spawnarea_list)) line 699 : before : Code:
list<timers*>::iterator iterator1 = TimerList.begin(); Code:
spawnarea_list->Process(); line 779 : after : Code:
bool Zone::Depop() { Code:
spawnarea_list->Depop(); after : Code:
entity_list.Message(0, 0, "<SYSTEM_MSG>:Zone REPOP IMMINENT"); Code:
spawnarea_list->Repop(); replace : Code:
bool Database::PopulateZoneLists(const char* zone_name, LinkedList<ZonePoint*>* zone_point_list, SpawnGroupList* spawn_group_list) { Code:
bool Database::PopulateZoneLists(const char* zone_name, LinkedList<ZonePoint*>* zone_point_list, SpawnGroupList* spawn_group_list, SpawnAreaList* spawnarea_list ) { after : Code:
{ Code:
query = 0; replace : Code:
npc_loaded[i] = new NPC(&gmspawntype_dump[npc_dump[i].gmspawntype_index], tmp, npc_dump[i].x, npc_dump[i].y, npc_dump[i].z, npc_dump[i].heading, npc_dump[i].corpse); Code:
npc_loaded[i] = new NPC(&gmspawntype_dump[npc_dump[i].gmspawntype_index], tmp, 0, npc_dump[i].x, npc_dump[i].y, npc_dump[i].z, npc_dump[i].heading, npc_dump[i].corpse); replace : Code:
npc_loaded[i] = new NPC(crap, tmp, npc_dump[i].x, npc_dump[i].y, npc_dump[i].z, npc_dump[i].heading, npc_dump[i].corpse); Code:
npc_loaded[i] = new NPC(crap, tmp, 0, npc_dump[i].x, npc_dump[i].y, npc_dump[i].z, npc_dump[i].heading, npc_dump[i].corpse); in zone . h : line 53 : after : Code:
#ifndef GUILDWARS Code:
SpawnAreaList* spawnarea_list; in database.h : line 51 : after : Code:
class Spawn2; Code:
class SpawnArea; replace : Code:
bool PopulateZoneLists(const char* zone_name, LinkedList<ZonePoint*>* zone_point_list, SpawnGroupList* spawn_group_list); Code:
bool PopulateZoneLists(const char* zone_name, LinkedList<ZonePoint*>* zone_point_list, SpawnGroupList* spawn_group_list, SpawnAreaList* spawnarea_list); in parser.cpp : line 738 : replace : Code:
NPC* npc = new NPC(tmp, 0, atof(arglist[3]), atof(arglist[4]), atof(arglist[5]), mob->CastToClient()->GetHeading()); Code:
NPC* npc = new NPC(tmp, 0, 0, atof(arglist[3]), atof(arglist[4]), atof(arglist[5]), mob->CastToClient()->GetHeading()); |
Wow Sandy, sounds awesome!
I will give it a try. Would be awesome if this eventually got added to CVS. |
Sweet, this'll make zones a lot less repetitive and boring if used right.
|
Good work Sandy.
|
Hi
anyone know if this works? and does it break anything else? and can we use this and the normal(or 2 grid) system at same time? thanks. |
All times are GMT -4. The time now is 02:30 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.