![]() |
|
|||||||
|
|
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 |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Oct 2006
Posts: 47
|
sometimes it is normal warning, for example for treasure chests and mimics in some places.
|
|
|
|
|
#3 |
|
Архивный участник
Join Date: Sep 2005
Posts: 198
|
not really cause the random_spawn is the one used for them and those are the ones that really got me interested in this, and if you watch the numbers are usually a lot higher then 1 and that would make since from my point of view because its trying to spawn say 6 more boxes when one dies so ill see numbers like [11/6] 11 becasue 1 gets spawned of 6, this also leads mw to thinking that raising the max NPC is bad, because in one i was looking up the maker was set to max of 6 NPCs but there where 4 npc lines with a total of 6 each so if i where to up the max to 24 then i would have 12 chests and 12 mimics in a small area meant for 6 NPC's
|
|
|
|
|
#4 |
|
Архивный участник
Join Date: May 2005
Posts: 85
|
THe fix is very easy.
Just replace (def0.total - def0.npc_count) to (def0.total - i0) Thx for this fix to Vaniok
|
|
|
|
|
#5 |
|
Архивный участник
Join Date: Sep 2005
Posts: 198
|
Hmm dies i0 contain the new total spawned??
If so, thank you very much I would still like to know how to find the numbers to use for variables. |
|
|
|
|
#6 |
|
Архивный участник
Join Date: May 2005
Posts: 31
|
Im pretty sure they are declared on the npc class.
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Sep 2005
Posts: 198
|
Well i was playing around and thinking about it, and noticed the when the handle starts by decreasing the count by 1 no matter what. So i figured that because of that, theres no need to see how many spawns are available, so i changed it to just spawn 1 no matter what. and now i share it
Code:
handler 1 115 // ON_NPC_DELETED variable_begin "deleted_def" "i0" "i1" "i2" "maker0" "def0" "myself" "_choiceN" "_code" "_from_choice" variable_end push_event // i0 push_const 260 add push_reg_sp fetch_i push_event // myself push_const 656 add fetch_i push_const 1 func_call 167837699 // func[DecreaseTotal] shift_sp -1 assign4 shift_sp -1 push_event // i1 push_const 264 add push_reg_sp fetch_i push_event // deleted_def push_const 672 add fetch_i push_const 1 func_call 234946564 // func[DecCount] shift_sp -1 assign4 shift_sp -1 push_event // i1 push_const 264 add push_reg_sp fetch_i push_event // gg push_const 632 add fetch_i push_event // myself push_const 656 add fetch_i // def_count push_const 140 add fetch_i4 func_call 218169344 // func[Rand] shift_sp -1 assign4 shift_sp -1 push_event // def0 push_const 664 add push_reg_sp fetch_i push_event // myself push_const 656 add fetch_i push_event // i1 push_const 264 add fetch_i4 func_call 167837696 // func[GetSpawnDefine] shift_sp -1 assign shift_sp -1 push_event // gg push_const 632 add fetch_i push_event // def0 push_const 664 add fetch_i func_call 218169355 // func[IsNull] shift_sp -1 push_const 0 equal branch_false L258758 L258757 // push_event // i2 // push_const 268 // add // push_reg_sp // fetch_i // push_event // def0 // push_const 664 // add // fetch_i // total // push_const 140 // add // fetch_i4 // push_event // def0 // push_const 664 // add // fetch_i // npc_count // push_const 144 // add // fetch_i4 // sub // assign4 // shift_sp -1 // push_event // i2 // push_const 268 // add // fetch_i4 // push_const 0 // greater // branch_false L258760 L258759 push_event // myself push_const 656 add fetch_i push_const 1 func_call 167837698 // func[IncreaseTotal] shift_sp -1 branch_false L258762 L258761 push_event // def0 push_const 664 add fetch_i push_const 1 func_call 234946563 // func[IncCount] shift_sp -1 shift_sp -1 push_event // def0 push_const 664 add fetch_i push_const 1 push_event // def0 push_const 664 add fetch_i // respawn_time push_const 148 add fetch_i4 func_call 235012096 // func[Spawn] shift_sp -2 shift_sp -1 L258762 L258760 L258758 handler_end and decompiled for easy view Code:
EventHandler ON_NPC_DELETED(deleted_def,i0,i1,i2,maker0,def0)
{
i0 = myself->DecreaseTotal(1);
deleted_def->DecCount(1);
i1 = gg->Rand(myself.total);
def0 = myself->GetSpawnDefine(i1);
if( gg->IsNull(def0) == 0 )
{
if( myself->IncreaseTotal(1) )
{
def0->IncCount(1);
def0->Spawn(1,def0.respawn_time);
}
}
}
I have not fully tested this but after randomly checking the NPC console i have not seen any more errors in the last 24 hours. |
|
|
|
|
#8 |
|
Архивный участник
Join Date: May 2005
Posts: 979
|
I make all changes to AI what I find here on PP but still have this problem on mob spawn position created with L2scriptMaker.. why?
|
|
|
|
|
#9 | |
|
Архивный участник
Join Date: Aug 2005
Posts: 1,531
|
Quote:
In my research: - Quot fix fix 99% problems with spawns and errors. - But somewhere leave problem. Maybe it npcpos error with maximum_npc. But i do fix it easy. I do increase this bug territory. Check logs and increase this value to required value. Last L2SM do scanning logs and fix npcpos.txt. |
|
|
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|