Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 12.04.2007, 22:35   #1
GMan
Архивный участник
 
Join Date: Sep 2005
Posts: 198
Default [Research] failed to increase total npc because of npc quota

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
This is for "class 2 random_spawn : default_maker"
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);
               }
          }
     }
}
I commented it as to what i think its doing, with how it reads i have guessed on what each name is for (again not even 1% sure about this)

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);
               }
          }
     }
}
The issue is i dont know how to get the npcmakers maximum_npc value, (maximum_npc is its name in the npcpos file but i sdont see it called anyware)

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
GMan is offline  
Old 12.04.2007, 22:59   #2
adriahu
Архивный участник
 
Join Date: Oct 2006
Posts: 47
Default

sometimes it is normal warning, for example for treasure chests and mimics in some places.
adriahu is offline  
Old 12.04.2007, 23:11   #3
GMan
Архивный участник
 
Join Date: Sep 2005
Posts: 198
Default

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
GMan is offline  
Old 13.04.2007, 07:20   #4
Ameron
Архивный участник
 
Join Date: May 2005
Posts: 85
Default

THe fix is very easy.
Just replace (def0.total - def0.npc_count) to (def0.total - i0)
Thx for this fix to Vaniok
Ameron is offline  
Old 16.04.2007, 02:27   #5
GMan
Архивный участник
 
Join Date: Sep 2005
Posts: 198
Default

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.
GMan is offline  
Old 16.04.2007, 09:31   #6
deathz0r
Архивный участник
 
Join Date: May 2005
Posts: 31
Default

Im pretty sure they are declared on the npc class.
deathz0r is offline  
Old 18.04.2007, 16:41   #7
GMan
Архивный участник
 
Join Date: Sep 2005
Posts: 198
Default

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
I left outthe if check as well but just commented it out incase you want to have it check that.. if so just uncomment and increase the line count.

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);
			}
		}
	}
To install just over write the ON_NPC_DELETED handel on the random_spawn class.

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.
GMan is offline  
Old 11.08.2007, 08:10   #8
rodier
Архивный участник
 
Join Date: May 2005
Posts: 979
Default hmm

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?
rodier is offline  
Old 11.08.2007, 09:47   #9
HF
Архивный участник
 
Join Date: Aug 2005
Posts: 1,531
Default

Quote:
Originally Posted by rodier View Post
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?
i sure what you have some different, because this "quot" error only for new class 2 spawns. You can have only "outsider" or "MakerLog (....)'... was dropped. npcpos(0) - 500 > z(-3128)" because it geodata problem.

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.
HF is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 19:52.