Author Topic: Adding Planet Slots Through A Trait  (Read 1214 times)

ZZGashi

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Adding Planet Slots Through A Trait
« on: July 03, 2012, 07:53:59 AM »
I have been attempting to create a new trait that will add more slots to a planet when it is colonized. I added the script part to planet.as under the onOwnerChanger part. How do I link that to the Traits.xml to get it working properly? Or am I doing it wrong and should go a different route, such as writing a new function in Traits.as?

Thank-you for your time.

seronis

  • Distracted
  • ***
  • Posts: 338
  • Karma: +25/-0
    • View Profile
    • Steam Profile Link
Re: Adding Planet Slots Through A Trait
« Reply #1 on: July 03, 2012, 08:38:30 AM »
Here ya go. Current its set up in planet.as so that a new race with the racial trait will add 3 slots to the planet and this can be done up to twice. Numbers should be obvious in how to tweak. If not just ask
Any code/mods I post on this site should be considered Public Domain. Borrow it, steal it, shred it into little pieces to your hearts content. I dont require credit but I appreciate bug fixes and suggestions.

ZZGashi

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Adding Planet Slots Through A Trait
« Reply #2 on: July 03, 2012, 09:32:00 AM »
Here ya go. Current its set up in planet.as so that a new race with the racial trait will add 3 slots to the planet and this can be done up to twice. Numbers should be obvious in how to tweak. If not just ask

Thanks, but that is not what I was wanting. It is like the terraforming in the GA mod, which is what I am using.

seronis

  • Distracted
  • ***
  • Posts: 338
  • Karma: +25/-0
    • View Profile
    • Steam Profile Link
Re: Adding Planet Slots Through A Trait
« Reply #3 on: July 03, 2012, 12:58:43 PM »
GAs teraforming uses what i did 'basically'. Just grab the stats which has 4 floats as subvalues for a given stat name.  Use the four floats as whatever you want. Default usage is metal/elec/advp/food i think but its  whatever you want.  Its the technique in the file i posted thats important and shows you how to tie in the trait so that its important to the teraforming.
Any code/mods I post on this site should be considered Public Domain. Borrow it, steal it, shred it into little pieces to your hearts content. I dont require credit but I appreciate bug fixes and suggestions.

Azalrion

  • Delusional
  • ****
  • Posts: 1325
  • Karma: +147/-1
  • Memory Murderer
    • View Profile
Re: Adding Planet Slots Through A Trait
« Reply #4 on: July 03, 2012, 12:59:59 PM »
Seronis has pretty much got what you want actually, he's just done it in an overly complicated manner. You would do what he has done using the if check to check if the empire has the trait and then add slots, you do however also need add in a check for when an empire with the trait loses the planet and the new empire doesn't have the trait to remove the slot count otherwise you're going to be able to abuse it like mad.

Heres just a pseudo-code version for adding:

Code: [Select]
if (to.isValid() && !to is null && to.hasTrait("New Trait")) {
       //Do add stuff here
}

Won't work fully, needs some tweaking on the if check to make sure its only applied when it has not be applied before, and you'd need a version that removes it when the from empire has the trait. At this point you don't need to check if the from empire and the to empire have the trait as space will never have it and there is no direct take over between empires at the moment.

Then you just create a new trait in traits.xml and use the name specified there instead of "New Trait".
GA - Mod Team
GA Forums

seronis

  • Distracted
  • ***
  • Posts: 338
  • Karma: +25/-0
    • View Profile
    • Steam Profile Link
Re: Adding Planet Slots Through A Trait
« Reply #5 on: July 03, 2012, 01:58:45 PM »
...overly complicated manner....
=-)

Figure if i was doing a quick 3 minute tutorial id make it somewhat 'real world' and put some limits and features (like allowing a planet to be improved more than once and having an adjustable improvement rate per instance).  The code i posted also keeps track of how many slots have been added, so when that value is zero you know the planet hasn't been improved before.
Any code/mods I post on this site should be considered Public Domain. Borrow it, steal it, shred it into little pieces to your hearts content. I dont require credit but I appreciate bug fixes and suggestions.

ZZGashi

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Adding Planet Slots Through A Trait
« Reply #6 on: July 03, 2012, 10:20:03 PM »
Thanks for the replies, it makes more sense what was going on with that code. I am not exactly all that well versed in the scripting language Star Ruler uses, yet. I was already using the the has trait tag function, but I was not sure if I was linking everything up wrong, or if was the other part of the code. So it seems it is the code needs to be a little more complex than I first thought.

Anyhow, thanks again.