HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Logic question - targeting  (Read 378 times)

Thazager

  • General Accounts
  • *
  • Posts: 1119
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Logic question - targeting
« on: Jan 26, 18, 08:11:11 PM »

This code is called when a player dies, and a list of clients is needed to send the FX. (unchanged since 2009 original code)

 Subject is a noderef, yet its added to a list of IDs ?


I am getting an error :   "In function RemoteCallClient: player not found:9223372092080021780", this is because the list returning is not a list of IDs, but a list of noderefs. So, when I check against the player account ID, it wont skip the player because its not storing the actual account ID. Its storing this noderef --> "QueryRemoteInterestSet 9223372088254021580"

(funny thing is it didn't give this error before)


in MiscUtils (server side), written in 2009,

Code: [Select]
public function QueryRemoteInterestSet( subject as NodeRef, interestSet references List of ID )
  // determine the "remote interest set" for the given subject, i.e. the connected players
  // within spatial proximity of the subject and/or other servers with a proxy of this node
  $SPATIALAWARENESS_AREA._SAS_QueryBySubject( subject, interestSet )   
  loop i from interestSet.length to 1 by -1
    observer as NodeRef = interestSet[ i ]
   
    if( ( observer != None ) and not ( observer is kindof _PlayerAccount ) )
      remove interestSet at i
    .
  .
 
  where subject is kindof _PlayerAccount
    add back subject to interestSet                        // <---- add noderef to IDs?
    println("QueryRemoteInterestSet "+subject)
  .
.

In E_commoncharacter (server side), also 2009

Code: [Select]
method ApplyLife() as Boolean
  if not me.E_isDead
    return false
  .
  me.E_isDead = false
  me.E_hitPoints = 100
  me._TeleportCharacter( me.GetRezzPosition(), me.GetRezzRotation() )
  where me is kindof E_playerCharacter
    target as Class _Target
    target._tgtID = me.GetMyAccount()
    clients as List of ID
    MiscUtils:QueryRemoteInterestSet(me.GetInterestSetSubjectNode(), clients)
    foreach c in clients
      $FXSYSTEM.SendFxToClient(c, 10, target, target)
    .
  .
  return true
.

Logged
Heroes and Villains Lead programmer/scripter
Exile Online Lead programmer/scriptor

ToY-Krun

  • General Accounts
  • *
  • Posts: 669
  • Support Volunteer
    • View Profile
Re: Logic question - targeting
« Reply #1 on: Jan 28, 18, 07:43:19 PM »

the noderef is automatically converted to an id, and vice verse, at least in this type of situation.

if you're comparing a nodref (subject) to a list of potentials (the list of ids) the noderef pointer is the same as the ID, and so forth.  However for an ID to be converted to a noderef, it has to be a valid and loaded node of that ID, otherwise the result would be Null.  ID = noderef and noderef = ID are both valid convertions.  the exception is that you cannot say a list of ID = a list of Noderef and vice verse, the conversion only works individually.

The noderef is valid (shown by the valid number/id in the error), whats invalid is its being referenced using the wrong class most likely. 

Make sure "subject" is a _playerAccount node and not the playerCharacter node.   only an account ID will match up to the interestSet list.

you could add in a block like this to check and see what the "subject" is:

foreach c in GetClassesOnNode(subject)
   println(c)
.
and/or
println(GetPrimaryClassOnNode(subject))
« Last Edit: Jan 28, 18, 07:48:15 PM by ToY-Krun »
Logged

ToY-Krun

  • General Accounts
  • *
  • Posts: 669
  • Support Volunteer
    • View Profile
Re: Logic question - targeting
« Reply #2 on: Jan 28, 18, 10:23:44 PM »

Thaz, a bit more on this.... 

I'm not positive whats going on here, but I'll run through the possibilities.. maybe that'll help ?

Lets look at the interestSet first:
I'll add some comments

Code: [Select]
public function QueryRemoteInterestSet( subject as NodeRef, interestSet references List of ID )
  // determine the "remote interest set" for the given subject, i.e. the connected players
  // within spatial proximity of the subject and/or other servers with a proxy of this node
  *InterestSet is referenced, so its changeable.  its passed in empty, and populated by this next sas query:
  $SPATIALAWARENESS_AREA._SAS_QueryBySubject( subject, interestSet )   
  *now we loop through the list of ID's provided by the SAS query (account nodes within SAS range)
  loop i from interestSet.length to 1 by -1
    *reference this ID "I", as a noderef and see if its valid.. if not, its an invalid/out of date entry in the SAS
    observer as NodeRef = interestSet[ i ]
    *If the node does not = none, and is NOT a player account node, remove it from the interest set.
    *it was probably an npc.... so we dont want it in the list
    if( ( observer != None ) and not ( observer is kindof _PlayerAccount ) )
      remove interestSet at i
    .
  .
  *If subject is a player account... and by the way this wont work if its not
  where subject is kindof _PlayerAccount
    *Add the playerAccount in question to the list, because we're collecting a list of clients in SAS range and
    *that includes the account in question... Assuming that the SAS query ignored the calling account
    add back subject to interestSet                        // <---- add noderef to IDs?
    *Adding a noderef to a list of ID's converts the noderef to an ID , using less memory than a list of noderefs
    println("QueryRemoteInterestSet "+subject)
  .
.

And this code is an exact match to mine, hasnt been changed.
So the problem isnt here..

Lets take the code in commonPlayer:ApplyLife()

Code: [Select]
MiscUtils:QueryRemoteInterestSet(me.GetInterestSetSubjectNode(), clients)
you'll find that there are two versions of GetInterestSetSubjectNode()
one in E_CommonCharacter, and one in E_PlayerCharacter....
As best i can recollect at least...

The one in CommonCharacter returns the player node
The one in PlayerCharacter returns the account node....
If the player node is passed into QueryRemoteInterestSet() , it shouldnt work..
Make sure its the account node being returned by GetInterestSetSubjectNode()

you can test that by checking the ID given in your error msg :
Quote
"In function RemoteCallClient: player not found:9223372092080021780"

in the console type \sn 9223372092080021780   
and see what type of node that is. it should be an account node.

As to why it didnt do this before... I would double check any recent changes in scripts/classes/prototypes.
Have you begun using a Custom player character or account class other than the E_ character specs?

Thazager

  • General Accounts
  • *
  • Posts: 1119
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Logic question - targeting
« Reply #3 on: Jan 29, 18, 12:26:45 PM »

We are still using the base E_scripts for many parts of code since they were originally working.

add:
Left it for the weekend, no changes, came back today and no error.
« Last Edit: Jan 29, 18, 12:53:38 PM by Thazager »
Logged
Heroes and Villains Lead programmer/scripter
Exile Online Lead programmer/scriptor

ToY-Krun

  • General Accounts
  • *
  • Posts: 669
  • Support Volunteer
    • View Profile
Re: Logic question - targeting
« Reply #4 on: Jan 30, 18, 06:49:03 AM »

Lol, i hate it when that happens.  good that its not throwing an error, but I always want to know what caused the error :P