Chaosforge Forum

  • May 18, 2024, 11:45
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: About traits, doc needed  (Read 4292 times)

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
About traits, doc needed
« on: April 02, 2013, 02:35 »

My need right now is to know what argument to call for a function.
I want something like :

player.hpmax = "ironmanlevel"*10+"myvalue"

Thing is, I don't know what I must put in place of "ironman".
Or if possible, instead of ironmanlevel*10, the amount of HP granted by ironman.
Logged

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: About traits, doc needed
« Reply #1 on: April 02, 2013, 04:45 »

To check for traits you would call player:get_trait( traits["trait_id"].nid ).  That returns an int corresponding to how many levels of that trait a player has.

But one look at your code tells me that whatever you are trying to do you are going about it the wrong way.  The player's max HP can be modified outside of the ironman trait.  Tell us what you are thinking, and keep in mind that outside of a TC you are limited in what you can do with traits, klasses, and other similar objects.
Logged

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
Re: About traits, doc needed
« Reply #2 on: April 02, 2013, 04:56 »

I intend to modify the player's max HP without erasing the bonus maxhealth granted by whatever he already has, which is what am doing right now (using player.hpmax = "value").

Quote
player:get_trait(traits["trait_id"].nid)
What is nid?
Logged

yaflhdztioxo

  • Programmer
  • Local Inquisitor
  • Captain
  • *
  • *
  • Offline Offline
  • Posts: 298
  • Lost Sole
    • View Profile
Re: About traits, doc needed
« Reply #3 on: April 02, 2013, 05:12 »

nid would be the numeric ID, which is what the pascal engine underneath the lua tends to use to index things.  We've tried to remove most mandatory references to it since you can always look up the prototype by text id but apparently we've missed thataone.  Don't worry too much about it; it's functionally equivalent to the text id in most cases.

To modify the player's max HP without modifying their existing bonuses or demerits I would suggest simply adding or subtracting from it.  hpmax = hpmax + 10.  No need to complicate matters if you just want to add or remove a few points.
Logged

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
Re: About traits, doc needed
« Reply #4 on: April 02, 2013, 05:35 »

It wouldn't work for me since I want to change what the maxHP "would have been" instead of what it is.
ie : instead of 50 + ironman*2 + 10(my value), I want it to become 10(my value)+ironman*2.
As if the player had a klass that starts with less HP, except the change happens during gameplay.

What is ironman's nID btw? I don't think I need the others but that would be nice to reference them as well.
Nevermind, not needed at all indeed.
« Last Edit: April 02, 2013, 05:59 by SPTX »
Logged

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: About traits, doc needed
« Reply #5 on: April 03, 2013, 04:51 »

The ironman bonus is actually
Code: [Select]
math.floor(0.2 * player.hpnom)
although I think AoHu is the only thing that changes hpnom.

I have to agree with yaf about adding and subtracting hp instead of setting it, especially if you want to later reverse the affect.  Remember that there are items that can affect hpmax, and nothing is keeping track of them.  You can calculate the target value you want, and then keep track of the delta so you can reverse it later.
Logged

SPTX

  • Sergeant
  • *
  • Offline Offline
  • Posts: 77
  • Lost Soul
    • View Profile
Re: About traits, doc needed
« Reply #6 on: April 03, 2013, 06:35 »

When it will be finished, the mod won't allow stats-changing items, so setting the maxhp shouldn't cause issues. I'll keep that in mind for future reference though.
Logged
Pages: [1]