HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: [1] 2

Author Topic: stealth/invis  (Read 7494 times)

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
stealth/invis
« on: Feb 23, 13, 11:02:58 PM »

Beginner level script.

This will let you make your character invisible or stealthy.

From the basic window tutorial
Make basic window here. This is a base window and will be used in many of my Tutorials. It uses the GUI pics from textures that all engines have. This can be skipped if you have the basic window already from another tutorial.

_______________________________________________________________
In script MiscUtils add function

Code: [Select]
// center window on screen
public function centerWindow(win references NodeRef of Class GUIControl)
  screen as Vector3 = GetViewPortSize()
  win.position.x = ((screen.x - win.size.x) / 2)
  win.position.y = ((screen.y - win.size.y) / 2)
.
_______________________________________________________________
In the DOM, create a new (client side) class
name = TMP_Stealth
archtype = guicontrol
add a parent to the class, TMP_Window

click open script

In new (client side) script TMP_Stealth

Code: [Select]
// create stealth window
shared function Start()
  var win = getStealthClass()
  if win <> None
    DestroyNode( win )
  .
  win = CreateNodeFromPrototype("TMP_Stealth")
  win.build = true
  MiscUtils:centerWindow(win)
.

// check for color changes
method _onSliderValueChange(args references Class GUIValueChangeEvent)
  myslide as NodeRef of Class GUISlider = args.source
  newPosition as Float = args.value
  Alpha as Float = (newPosition + 10) / 20   // calc 0.0 - 1.0 values

  when myslide.parent.name
    is "stealthSlider"
      var pc = GetPlayerCharacterNode()
      pc["DiffuseColor"] = "#1,1,1,"+Alpha    // set alpha value
      var lbl = me.getPercentLabel()
      lbl.text = ftos(Truncate(Alpha*100))+"%"
    .
  .
.

//=================================================================================================
function getStealthClass() as NodeRef of Class TMP_Stealth
  return FindGUIControlByName(None, "game.TMP_Stealth")
.

method getPercentLabel() as NodeRef of Class GUILabel
  return FindGUIControlByName(me, "percent")
.

_______________________________________________________________
In new (XML) script TMP_Stealth

Code: [Select]
<createControlType inheritFrom='TMP_Window' class='TMP_Stealth' type='TMP_Stealth' description='invis settings' treePath='CleanEngine' name="TMP_Stealth">
  <size x="200" y="50"/>
  <defaultStatePresentation>
    <color r="0" g="0" b="0"/>
  </defaultStatePresentation>
  <_label name="title" text="Stealth" justification="CENTER">
    <position x="50"/>
    <defaultStatePresentation>
      <color r="1" g="0" b="0"/>
    </defaultStatePresentation>
  </_label>
  <_slider name="stealthSlider">
    <position x="10" y="20"/>
    <set name="TMP_Stealth.stealthSlider.thumb">
      <position x="165"/>
      <set name='TMP_Stealth.stealthSlider.thumb' attribute='pos' value="10"/>
    </set>
  </_slider>
  <_label name="percent" text="100%" justification="CENTER">
    <position x="70" y="30"/>
    <size x="60"/>
    <defaultStatePresentation>
      <color r="1" g="0" b="0"/>
    </defaultStatePresentation>
    <autoCenter horizontal="true"/>
  </_label>
</createControlType>

_______________________________________________________________
In (client side) script E_PlayerAccountClassMethods under the chatwindow

Code: [Select]
        TMP_StealthClassMethods:Start()
« Last Edit: May 30, 15, 10:17:57 PM by Thazager »
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: stealth/invis
« Reply #1 on: Feb 24, 13, 03:40:56 AM »

Not bad, although your use of "FindGUIControlByName" is assuming that the gui is in the "game" layer, so that would need to be set in the creation of the gui.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: stealth/invis
« Reply #2 on: Feb 24, 13, 11:01:31 AM »

Thazager ,
I wanted to appreciate and thank you for all your hard works to making all these tutorials .

I wish i had time to create some too, Keep it up man .
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: stealth/invis
« Reply #3 on: Feb 24, 13, 06:53:55 PM »

Not bad, although your use of "FindGUIControlByName" is assuming that the gui is in the "game" layer, so that would need to be set in the creation of the gui.
Agreed, will add it.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Viper155

  • World Owners
  • ****
  • Posts: 73
    • View Profile
Re: stealth/invis
« Reply #4 on: Feb 25, 13, 02:47:25 PM »

Is this a skill for players to use or just a slider that they can toggle on and off?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: stealth/invis
« Reply #5 on: Feb 25, 13, 07:24:40 PM »

The tutorial creates a basic slider, whch makes it a beginner's tutorial. The stealth / invis is there as an added bonus for how to make your character less visible on screen. The slider also lets you see what the min/max settings can be, rather than just a set value with an on/off button toggle. But you can set it up any way you like in your game.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Voarsh

  • General Accounts
  • *
  • Posts: 56
    • View Profile
Re: stealth/invis
« Reply #6 on: Jan 10, 14, 11:27:42 AM »

How do I add: add 1 _label, 1 _slider (to the GUI properties?)
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: stealth/invis
« Reply #7 on: Jan 10, 14, 02:04:59 PM »

To add something to the GUI properties,

With the GUI Editor open, and the TMP_Stealth open on the properties panel. Select the TMP_Stealth, then click on the GUI Editor panel, and look for _label in the list. Double click _label and this will add it to the TMP_Stealth. Then  click on TMP_Stealth again to select it as the parent. Then find and double click _slider to add it also. Now both items will have the parent TMP_Stealth.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

Voarsh

  • General Accounts
  • *
  • Posts: 56
    • View Profile
Re: stealth/invis
« Reply #8 on: Jan 11, 14, 08:58:41 AM »

Hi,

Thanks. We added it. We added the slider, but couldn't seem to "activate it" so we could see it. Somehow we've broken something and now we only see the logo of HeroEngine, and other is loading (except the character selection area).

If you manage to load say, Fantasy Lands, it loads, but the player can't move...

We've removed the GUI code, I believe the class we created for the tutorial, but things are broken now.
See screenshot.

- update
The default weapon that comes with HeroCloud, doesn't show - sometimes the screen is blank, with the character visible.
Currently I can visit one of the rooms, but cannot move or see my weapon:
« Last Edit: Jan 11, 14, 01:08:11 PM by Voarsh »
Logged

Voarsh

  • General Accounts
  • *
  • Posts: 56
    • View Profile
Re: stealth/invis
« Reply #9 on: Jan 11, 14, 05:11:23 PM »

Resolved. :)
Logged

iiParadox

  • World Owners
  • ****
  • Posts: 1
    • View Profile
Re: stealth/invis
« Reply #10 on: Jan 23, 14, 02:20:53 AM »

I have the same issue, what did you do to fix this?
Logged

Voarsh

  • General Accounts
  • *
  • Posts: 56
    • View Profile
Re: stealth/invis
« Reply #11 on: Jan 24, 14, 04:25:03 PM »

We sorted it by removing the affected GUI, and removed the class.

There were a few class errors, which you may have and you can find/fix them using the console window.
Logged

Strata

  • World Owners
  • ****
  • Posts: 29
  • I eat textures
    • View Profile
Re: stealth/invis
« Reply #12 on: Jan 25, 14, 07:26:12 AM »

idk if im just a retard but when i made TMP_Stealth in the gui it poped up on the side and wouldn't let me add or do anything to it not even see the properties. It also doesn't show up in my gui editor but when i try and make it agian it says to edit the existing one lol.
Logged
I eat textures

Strata

  • World Owners
  • ****
  • Posts: 29
  • I eat textures
    • View Profile
Re: stealth/invis
« Reply #13 on: Jan 26, 14, 11:02:13 AM »

im having the black screen problem to here is the error log. what did you do to fix it exactly?
Logged
I eat textures

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile
Re: stealth/invis
« Reply #14 on: Jan 26, 14, 06:08:22 PM »

This error is one that pops up occasionally. It has to do with the F5 hotkey for modifying other areas/things. Not part of any of the tutorials. I think there was a fix for it, possibly in this section Fixes.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685
Pages: [1] 2