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

Author Topic: [Resolved] Referencing a player noderef.  (Read 1290 times)

Cincinnati

  • World Owners
  • ****
  • Posts: 31
    • View Profile
[Resolved] Referencing a player noderef.
« on: Jun 05, 13, 07:15:09 AM »

If a player was to activate an ability on the client side, how do I reference that player through methods?

say I have a method on class Foo_abilities

method FooattackClassMethod(Attacker as Noderef of Class Foo_CommonCharacter)
//logic
//logic
.


At what point can I pull the player in as Attacker, and how?


I'm lost on this.

Thanks,
Cincinnati
« Last Edit: Jul 03, 13, 04:11:26 PM by HE-Cooper »
Logged

Cincinnati

  • World Owners
  • ****
  • Posts: 31
    • View Profile
Re: Referencing a player noderef.
« Reply #1 on: Jun 05, 13, 11:13:13 AM »

Duh,

getMyAccount()

I'm an idiot, thank you Wiki!
Logged

Cincinnati

  • World Owners
  • ****
  • Posts: 31
    • View Profile
Re: Referencing a player noderef.
« Reply #2 on: Jun 05, 13, 03:36:57 PM »

Still a bit confused.

Lets break it down:

//Action is mapped to right mouse click
//Client clicks mouse to activate action
//It fires a raycast to produce a noderef = Target
//Then rolls a random Float for critical.

So:

method MyAttackClassMethod()
  Target as Noderef = me.MyRaycastClassMethod()
  Dodged as Boolean = me.MyDodgeClassMethod(Target as Noderef of Class Foo_CommonCharacter)
  Critical as Boolean = me.MyCriticalClassMethod(Attacker as Noderef of Class Foo_CommonCharacter)

My question is how do I pull the Attacker Noderef when the Client activates the action?
I understand that the action could pass some data but I don't understand how activating an ability can reference the class I need.

All help is appreciated.
Cincy
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Referencing a player noderef.
« Reply #3 on: Jun 05, 13, 04:10:09 PM »

If you are trying to get the client _playerCharacter (i.e. the _playerCharacter for the player executing the client), there are multiple ways to do this.  One way is  "SYSTEM.INFO.PLAYERCHARACTER.GetMyCharacter()".  That may not be exact syntax but something very similar.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

Thazager

  • General Accounts
  • *
  • Posts: 1156
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Referencing a player noderef.
« Reply #4 on: Jun 05, 13, 08:22:06 PM »

Each account also has a unique ID number. This number can be used to find the character on client or server side. A unique number is also given to each NPC that currently exists. There are a few ways of getting this number, depending whether its on client side or server side.

This is how I get the player account and character on client side.
  acct as NodeRef of Class E_playerAccount = GetAccountID()
  char as NodeRef of Class E_playerCharacter = acct.GetMyCharacter()

I use this for server side.
  acct as NodeRef of Class E_playerAccount = accountID
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()

On server side the account can be passed into the function, or pulled directly from the caller of the function.
  acct as NodeRef of Class _playerAccount = SYSTEM.REMOTE.CLIENT
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()

On the server side is a script that comes with the basic engine called cmdAbility which calls functions in E_AbilityClassMethods that have functions for finding the target and applying damage.

There are also some external functions that can help find players / NPCs / targets
WhereIsPlayer(targID, areaID, instanceID)
GetTargetsInBox( playerSensitive as Boolean, npcSensitive as Boolean, boxCenter as Vector3, boxWidth as Float, boxHeight as Float, boxDepth as Float ) as List of NodeRef
GetTargetsInSphere( playerSensitive as Boolean, npcSensitive as Boolean, sphereCenter as Vector3, sphereRadius as Float ) as List of NodeRef
GetTargetsInCone( playerSensitive as Boolean, npcSensitive as Boolean, coneBase as Vector3, coneAngularWidth as Float, coneDirection as Vector3, coneDistance as Float ) as List of NodeRef
and others.
Logged