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

Author Topic: Hint: mouse target self  (Read 2838 times)

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Hint: mouse target self
« on: Jan 22, 12, 04:59:19 PM »

This more of a little tip than a tutorial. In clean game you can only target yourself by pressing 'Tab' key, which makes you target nearest target. If you want to be able to click on your character to target it, just follow these few simple steps.


1. Open server scripted named E_InputHandlerClassMethods


2. In the method HE_PreContextMenuServerMouseEvent add following line after the first if statement. So this
Code: [Select]
  if targets.length > 0
    target = targets[1]
    Debug( "Found target: " + target + "." )
    if target == None
      // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
  else
    Debug( "No heroic targets found." )
    target = mEvent.MouseTarget
    if target == None
    // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
    Debug( "Found game target: " + target + "." )
  .
will look like this
 
Code: [Select]
if targets.length > 0
    target = targets[1]
    Debug( "Found target: " + target + "." )
    if target == None
      // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
  else
    Debug( "No heroic targets found." )
    target = mEvent.MouseTarget
    if target == None
    // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
    Debug( "Found game target: " + target + "." )
  .
  if target = source
  // target self
    call client source %E_TargetCircle.E_UpdateTargetCircle(target)
    return true
  .

Compile, Submit, Close


3. Logout and log back in. That's it, it should work now.
Logged

piluve

  • Developer
  • *
  • Posts: 25
  • Spain Development
    • View Profile
Re: Hint: mouse target self
« Reply #1 on: Mar 22, 12, 04:38:20 PM »

Yes thatīs cool but thereīs a problem...

I can atack me  ??? ??? ??? ???


There is any suggestion tu fix it?

regards

AW:can you type the full code (E_InputHandlerClassMethods) i changed one thing but now I canīt compile it  ::) ::)



« Last Edit: Mar 22, 12, 04:43:22 PM by piluve »
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: Hint: mouse target self
« Reply #2 on: Mar 22, 12, 04:48:03 PM »

You can try to add an if statement so that a damaging spell won't be cast on yourself :)

Logged

piluve

  • Developer
  • *
  • Posts: 25
  • Spain Development
    • View Profile
Re: Hint: mouse target self
« Reply #3 on: Mar 22, 12, 04:59:10 PM »

Ok iīll try it tomorrow .

AW:and please if you can send my de code of (E_InputHandlerClassMethods) i changed one thing and now i cantīredo...

regards
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: Hint: mouse target self
« Reply #4 on: Mar 23, 12, 01:11:34 AM »

Sure, I'll send you the code as soon as I'm on my developer machine ;)
Logged

piluve

  • Developer
  • *
  • Posts: 25
  • Spain Development
    • View Profile
Re: Hint: mouse target self
« Reply #5 on: Mar 23, 12, 02:09:30 AM »

Ok thx!!!
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: Hint: mouse target self
« Reply #6 on: Mar 23, 12, 02:30:02 PM »

sorry, I almost forgot about you.

it's the E_InputHandlerClassMethods script after the self-target modification...

Code: [Select]
#define debug
method HE_PreContextMenuServerMouseEvent( mEvent references Class _MouseEvent ) as Boolean
  Debug( "Got callback." )
 
  source as NodeRef = mEvent.MouseEventSource
  target as NodeRef
 
  var targets = mEvent._HeroicMouseTargets
  if targets.length > 0
    target = targets[1]
    Debug( "Found target: " + target + "." )
    if target == None
      // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
  else
    Debug( "No heroic targets found." )
    target = mEvent.MouseTarget
    if target == None
    // no target, so clear targeting
      source.SetClickTarget( 0 )
      call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      return true
    .
    Debug( "Found game target: " + target + "." )
  .
  if target = source
  // target self
    call client source %E_TargetCircle.E_UpdateTargetCircle(target)
    return true
  .
  // display target circle to source
  where target
    is kindof TS_PlayerAccount
      where target is kindof _PlayerAccount
        char as NodeRef of Class TS_PlayerCharacter = target.GetMyChar()
//        if not char.E_isDead
//          Debug( "...that is NOT dead." )
          if HasMethod( source, "SetClickTarget" )
            Debug( "Calling SetClickTarget()." )
            source.SetClickTarget( target )
          .
          call client source %E_TargetCircle.E_UpdateTargetCircle( target )
//        else
//          Debug( "...that is dead." )
//          call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
//        .
      .
    .
    is kindof TS_NonPlayerCharacter
//      if not target.E_isDead
//        Debug( "...that is NOT dead." )
       if HasMethod( source, "SetClickTarget" )
          Debug( "Calling SetClickTarget()." )
          source.SetClickTarget( target )
        .
        call client source %E_TargetCircle.E_UpdateTargetCircle( target )
//      else
//        Debug( "...that is dead." )
//        call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
//      .
    .
    default
      if HasMethod( source, "SetClickTarget" )
        Debug( "Calling SetClickTarget()." )
        source.SetClickTarget( 0 )
            call client source %E_TargetCircle.E_UpdateTargetCircle( 0 )
      .
    .
  .
 
  return false
.

function IssueTargetUpdate( account as ID, target as NodeRef of Class TS_CommonCharacter )
.

function Debug( msg as String )
  #if debug
  $Debug.SendNotifyDebugMessage( "Input", msg )
  #endif
.
Logged

piluve

  • Developer
  • *
  • Posts: 25
  • Spain Development
    • View Profile
Re: Hint: mouse target self
« Reply #7 on: Mar 23, 12, 03:09:18 PM »

Ok thank you and continue with that fantastic tutorials :)
Logged

Zasdman

  • General Accounts
  • *
  • Posts: 5
    • View Profile
Re: Hint: mouse target self
« Reply #8 on: Apr 14, 12, 12:16:26 AM »

Had it working but now it does not... I will have to go through all the code again. But Thanks for Posting this!
Logged