This site is in archival mode. A replacement is being developed. In the meantime, please use the PBW2 Forums for community discussions. The replacement software for this site will use a unified account system with PBW2, and any newly created threads will carry over.
Welcome to Spaceempires.net
Login or Register

Search
Modules
· Content
· Downloads
· Forums
· Game Info
· Image Gallery
· Links
· Shipyards
· Topics
· Staff

User Info
· Welcome, Anonymous
Membership:
· New: Astorre
· New Today: 0
· New Yesterday: 0
· Overall: 3155

People Online:
· Visitors: 536
· Members: 0
· Total: 536

  

Spaceempires.net :: Scripting Population Death :: View topic
Forum FAQ :: Search :: Memberlist :: Usergroups :: Profile :: Log in to check your private messages :: Log in


Scripting Population Death

 
Post new topic   Reply to topic    Spaceempires.net Forum Index -> SEV Modding Discussion
View previous topic :: View next topic  
Author Message
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Mon Nov 11, 2013 3:02 pm    Post subject: Scripting Population Death Reply with quote

Howdy guys,

This is something I've been meaning to do for a while now, namely having planets with conditions of "Unpleasant" or worse kill off some population each turn. So far I've been pretty successful by changing the external events script, planets lose a certain percentage of their population each turn and the worse the planets conditions are the worse the percentage loss (and they get pissed off about it too). The script also lets the player know via logs how many people have died on each planet. Having Environmental Studies tech researched even limits the damage involved here.

But I have two problems. First, I'd like to be able to reference whether an empire has chosen the racial traits "Environmental Resistance" or "Environmental Weakness". I can't find any function that allows me to do this.

The second problem is I can't seem to find a way to kill off a planets entire population, they always seem to stay at a minimum of 1M people. I've been using Sys_Change_Planet_Population to kill people, but even setting it to stupid amounts doesn't seem to overcome this issue.

Any ideas?


Back to top
ekolis
Virtual Guru


Joined: Aug 04, 2003
Location: Cincinnati, OH, USA

PostPosted: Mon Nov 11, 2013 8:23 pm    Post subject: Reply with quote

Hmm. There is a function, Does_Empire_Have_Racial_Trait, that checks for the presence of a racial trait, but that's for the data files. You'd think something that obvious would be available for the script code too, but I can't find it anywhere... Rolling Eyes

There is, however, a "Sys_Does_Empire_Have_Ability" function which you can use to check for the presence of an ability on an empire. If your racial trait doesn't already have an ability, assign it an unused AI tag and check for that. There doesn't seem to be any way to check for the ability amount on an empire, though, so if the positive and negative traits use the same ability, you'll need two AI tags.

As for the 1M minimum, I don't know; I've never encountered that before. Can you start a plague via script? Plagues can kill off all of a planet's population Very Happy


That's no space station - it's a spreadsheet!


Back to top
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Mon Nov 11, 2013 9:23 pm    Post subject: Reply with quote

ekolis wrote:
Hmm. There is a function, Does_Empire_Have_Racial_Trait, that checks for the presence of a racial trait, but that's for the data files. You'd think something that obvious would be available for the script code too, but I can't find it anywhere... Rolling Eyes

There is, however, a "Sys_Does_Empire_Have_Ability" function which you can use to check for the presence of an ability on an empire. If your racial trait doesn't already have an ability, assign it an unused AI tag and check for that. There doesn't seem to be any way to check for the ability amount on an empire, though, so if the positive and negative traits use the same ability, you'll need two AI tags.


Ah, I hadn't yet looked at AI Tags, but yeah that works really well! Now I've got the Environmental racial traits and tech doing more than just bolstering reproduction!

ekolis wrote:
As for the 1M minimum, I don't know; I've never encountered that before. Can you start a plague via script? Plagues can kill off all of a planet's population Very Happy


I did think about a plague, it would make sense that deadly conditions on a planet might well result in one and there's already a random event that causes one so it'd be easy enough to copy the code, but the problem is if the empire has a medical lab in the system or is a mechanical race it won't cause them to lose the planet.

Although thinking about it, it might not be such a bad idea because it would make sense that being mechanical might allow you to just about survive on a deadly world, as would a nearby medical lab. I'd still like to be able to wipe out a planet using scripts but I might just have to live with smacking them down with a level 5 plague instead.


Back to top
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Wed Nov 13, 2013 1:09 am    Post subject: Reply with quote

Well after many many hours of debugging, I'm finally happy (sort of) with it. Now bad colonies will give me something like this every turn:



It generates a random percentage (within a range depending on the conditions) for population death which is properly modified depending on whether you've taken Environmental Resistance/Weakness as racial traits, and is reduced a little for every level of Environmental Studies you've researched. The more people killed, the more the remaining population gets upset about it.

It also generates damage for harsh and deadly worlds, as a percentage of your planets total structure.

And if I get really screwed and end up with only 1M people left (or have a deadly world and no help from racial/tech and get really unlucky) it'll dump a level 5 plague on me.

I figure it's a way of making Environmental racial/tech picks more than just a means of boosting reproduction and it also makes using Radiation Bombs a viable strategy for a hit-and-run against enemy planets. Not to mention it makes intel attacks or random events that decrease planet conditions a real concern rather than just a minor annoyance.

I'm a very happy bunny right now.


Back to top
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Fri Jan 09, 2015 11:30 pm    Post subject: Reply with quote



Booyah! That's what you get if you let global warming get out of control.


Back to top
DXM
Space Emperor


Joined: Mar 20, 2012

PostPosted: Sun Jan 11, 2015 4:06 am    Post subject: Reply with quote

Where does one go to download this script? Smile

Back to top
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Sun Jan 11, 2015 5:43 am    Post subject: Reply with quote

I'll keep what I've done up here

And the source script for if you want to make your own changes or use it in your own mods.

It's built on top of Balance Mod 1.19j so if you have some BM saves you can just overwrite the BM files (make a backup first) and load your BM saves to compare.

Otherwise make a copy of the BM folder and overwrite the files in there, you'll have to start a new game to see what I've done in that case though.

While it's a bit of fun, starting a new game is going to be very difficult without additional changes (due to the lack of techs to offset pollution) and the AI has no idea how to handle it in any event and will probably end up destroying all their own worlds.


Last edited by Sabranan on Sun Jan 11, 2015 8:08 am; edited 1 time in total


Back to top
DXM
Space Emperor


Joined: Mar 20, 2012

PostPosted: Sun Jan 11, 2015 8:02 am    Post subject: Reply with quote

Thanks! Although, the second link doesn't work...

Back to top
Sabranan
Space Emperor


Joined: Apr 23, 2013

PostPosted: Sun Jan 11, 2015 8:08 am    Post subject: Reply with quote

I've edited the post, it should work now.

Back to top
DXM
Space Emperor


Joined: Mar 20, 2012

PostPosted: Sun Jan 11, 2015 12:55 pm    Post subject: Reply with quote

Awesome. Cool

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Spaceempires.net Forum Index -> SEV Modding Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
All logos and trademarks used on this site, all comments and stories posted for reading, all files hosted for download,
and all art work hosted for viewing are property of their respective owners; all the rest copyright 2003-2010 Nolan Kelly.
Syndicate news: SpaceEmpires.net News RSS Feed - Syndicate forums: SpaceEmpires.net Forums RSS Feed
Page Generation: 0.57 Seconds