![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Архивный участник
Join Date: Sep 2005
Posts: 198
|
First sorry if this is in wrong section, wasn't sure where to put it because if we solve it, it will become a server mod and Tutorial.
----------------------------------------------------------------------- Ok, I have been bugged by this error ever since C4 came out, and because i can't find the "ItemOwned bug" posted in the server red message topic and increasing the max spawn count seems to be a bad work around, IE random_respawn spawning all the NPCs, is not very random. I have done some very little testing (because my dev server is locked in storage while they fix my house after the flood) but i noticed that if i lock all players out until the NPC server finishes loading. I do not get any errors about this. So i figured I could narrow it down to the ON_NPC_DELETED Handel. After decompiling it and fixing a few names to match the proper push_event/push_const's i came out with this [EXAMPLE NPCPOS] Code:
npcmaker_ex_begin [TeritoryName] name=[MakerName] ai=[random_spawn] maximum_npc=1 npc_ex_begin [NPC1] pos=anywhere total=1 respawn=60sec respawn_rand=20sec npc_ex_end npc_ex_begin [NPC2] pos=anywhere total=1 respawn=60sec respawn_rand=20sec npc_ex_end npc_ex_begin [NPC3] pos=anywhere total=1 respawn=60sec respawn_rand=20sec npc_ex_end npcmaker_ex_end Code:
EventHandler ON_NPC_DELETED(deleted_def,i0,i1,i2,maker0,def0)
{
//Decreases the npc_makers spawned total value (myself.total) and sets i0 to the new value
i0 = myself->DecreaseTotal(1);
//Decreases the count of spawned NPCs for the npc_ex_begin line (npc_count)
deleted_def->DecCount(1);
// picks a random number between 0 and myself.def_count, def_count being the number of npc_ex lines in the npcmaker (0 based) and settingthe value to i1
i1 = gg->Rand(myself.def_count);
//Gets the spawn info for the selected npc_ex index
def0 = myself->GetSpawnDefine(i1);
//Checks that the define is rean and in not null
if( gg->IsNull(def0) == 0 )
{
//If it is good it see what the difference is between the total and the current spawned from that define******
i2 = ( def0.total - def0.npc_count );
//if its greater then 0 continue
if( i2 > 0 )
{
//increases the counter for the npcmaker
if( myself->IncreaseTotal(i2) )
{
//increases the counter for that define
def0->IncCount(i2);
//spawns the ammount in i2 at there normal respawn time
def0->Spawn(i2,def0.respawn_time);
}
}
}
}
now you might have noticed the *******'s Thats the line i think is wrong. Cause it looks like it seeing how many are spawned of the selected SpawnDefine and not how many npcs are spawned in the actual npcmaker or myself.total and myself.npc_count So i have come up with this new AI and would like some feedback on my theory Code:
EventHandler ON_NPC_DELETED(deleted_def,i0,i1,i2,maker0,def0)
{
i0 = myself->DecreaseTotal(1);
deleted_def->DecCount(1);
i1 = gg->Rand(myself.def_count);
def0 = myself->GetSpawnDefine(i1);
if( gg->IsNull(def0) == 0 )
{
i2 = ( myself.maximum_npc - myself.total );
if( i2 > 0 )
{
if( myself->IncreaseTotal(i2) )
{
def0->IncCount(i2);
def0->Spawn(i2,def0.respawn_time);
}
}
}
}
hope you can see what im getting at, i wrote this while i was thinking about it ![]() UPDATE 1=========== I opened L2NPC in a hex editor and found a refrence to "mMaximumNPC maximun_npc" all in an area with other what looks like maker functions. so now i need someone who can help me find the ID for that value so i can change the push_event/push_const in the AI |
|
|
|
|