The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
attacker question
Author Message
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #1
attacker question
Is correct something like that?

FOR X 0 <eval <attacker>-1>
IF (<attacker.<dLOCAL.X>.isnpc>)
attacker.<dLOCAL.X>.remove
ENDIF

ENDFOR

Or is better to achieve the uid and remove it from the attackers list OUTSIDE the for cycle to prevent some problems with the amount of attackers?
05-21-2015 10:18 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: attacker question
Depends on the situation, if you are going to prevent npcs to joining this list or if you want to remove an specific uid in certain cases...

When you are looping on something you are going to decrease it's better to do a reversed loop because if you remove 2 attackers in the loop when you reach 2 last cycles it will throw error:

Code:
for x <eval <attacker>-1> 0
IF (<attacker.<dLOCAL.X>.isnpc>)
  attacker.<dLOCAL.X>.remove
endif
endfor

You can alternatively remove an uid with some previous check: attacker.delete <uid>

Code:
ON=@HitTry
if (<src.npc>)
attacker.delete <src>
return 1
endif

Or you can alternatively just block it's inserction on the list:

Code:
ON=@CombatAdd // this will force npc (if you are using the trigger on an npc to try to add it again in the next tick)
if (<src.npc>)
return 1
endif

Altought I don't know what do you want ... if you just want NPCs to not be attacked the very best method is to ignore them so Sphere won't try to add them each time it should, hence less code will be run:

Code:
ON=@CombatAdd
if (<src.npc>)
argn2=1
endif
05-21-2015 06:03 PM
Find all posts by this user Like Post Quote this message in a reply
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #3
RE: attacker question
I am experiencing that the target system works great within players but it's not working well with NPC (most of time the target switch between more NPCs).
So the idea is to keep only one NPC in the attackers list and remove this one if i decide to attack a different one.

I am not sure if this is a problem related to sphere or to the scrips, I just would like to check and see what happen.
05-21-2015 07:53 PM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #4
RE: attacker question
NPCs have the same way to check who is going to be their next target:
local.threat = 0
local.dist = 65535

attacker is dead = skip
attacker is ignored = skip
if (action =ranged skill (archery/throwing..)
if ( distance < serv.archerymindist || distance > serv.archerymaxdist )
skip
endif
if ( attacker = current_target) // not sure why this one exists, may I remove it
skip
endif
endif
attacker dist > 14 = skip //max dist view (screen size)
!CanSeeLos attacker = skip

if (npcai & npc_ai_threat && attacker.threat > local.threat)
target = attacker
elseif ( dist < local.dist )
local.dist = <dist>
target = attacker
endif

Not using SphereScript 100% but enough to show you how does it work right now.

So if you are encountering problems, which may be related to this, just post here a better explanation of whats happening and under which circumstances.
05-21-2015 08:26 PM
Find all posts by this user Like Post Quote this message in a reply
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #5
RE: attacker question
The problem is related when a player attacks more than a one monster. Seems the players cannot stick on a single target but he attack based on range etc.
I use an attackers ignore script to avoid this environment and it works great in a combat between players but not with players and monsters mixed together or only monsters.
As I told you, I am not sure if this is a sphere fault or there are some lacks on my script...

That's why I would like to keep only one monster at time in the attackers list to check.
05-22-2015 06:18 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)