Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ibanix

Pages: [1]
1
Scripting / Re: Passing variables / returning string value
« on: April 06, 2013, 02:42:06 PM »
Right, but I don't seem to have an ifdefined() option in angelscript. Or do I?

2
Scripting / Re: Passing variables / returning string value
« on: April 05, 2013, 08:56:31 PM »
Well, if you declare a float without setting an initial value, and then try to use it (for example, f_to_s() ), this happens:

Code: [Select]
S Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet.as: Compiling float tradeResource(Empire@, Object@, State@, const string@, float, float, TradeMode)
 line: 600, col: 1
AS Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet.as: 'foobar' is not initialized.
 line: 603, col: 25

I didn't really need to use it other than debugging, so I've moved on, but it still would be nice to know. In most other languages I work with, checking for null value is easy enough.

Thanks for all your help Azalrion! I may have more questions in the future =)

3
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 10:47:32 PM »
Turns out it didn't like

Code: [Select]
if (foodBuffer is null) { print ("foodBuffer is null"); }

Because of:

Code: [Select]
S Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet.as: No conversion from '<null handle>' to 'float' available.
 line: 639, col: 21

Tho I'm not sure now how you'd check that a float has any value...

4
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 02:03:26 PM »
I have to go to work, but I should note I have entries in both structures.txt and structure_effects.txt for those - and the first one is a built-in from SR.

5
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 02:02:30 PM »
Actually return null gave me an error about conversion from null to a string. I used return "no_value" and it went away.

Interestingly, now I get this:

Note: Diplomacy strings will still have gaps - fillDiplomacyStringGaps() not implemented
Loading effects: Game Data/Effects/effects.txt
Loading effects: Game Data/Effects/remnant_effects.txt
Loading effects: Game Data/Effects/struct_effects.txt
Game Data/Effects/struct_effects.txt(122) error E007: No function with matching parameter list (Event@)
 Function: "planet::popEcoInit"
Game Data/Effects/struct_effects.txt(125) error E007: No function with matching parameter list (Event@)
 Function: "planet::empEcoInit"
Loading effects: Game Data/Effects/system_effects.txt

6
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 01:57:05 PM »
Oh, heh, I turned on versioning in my editor and it isn't suffixing the files with .bak

7
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 01:51:14 PM »
Well, I did find this:


AS Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet(0).as: Compiling string statDemandName(const string@)
 line: 868, col: 1
AS Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet(0).as: Not all paths return a value
 line: 868, col: 47
AS Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet(0).as: Compiling string statBufferName(const string@)
 line: 878, col: 1
AS Server Error in C:\Program Files (x86)\Star Ruler\Game Data\scripts\server\planet(0).as: Not all paths return a value
 line: 878, col: 47

8
Scripting / Re: Passing variables / returning string value
« on: April 04, 2013, 12:38:16 PM »
I've got verbose mode on, I just don't get any output after the usual setup and init functions  :-\

I'm attaching my entire planet.as file for context. My issues are around line 635.

My goal here is to replace the galactic bank with a on-demand system; when a planet needs a resource it updates the relevant "Demand" variable, and if a planet with extra resources to trade notices a positive value in the demand variable, it adds to the "buffer"; when a planet with demand sees free resources in the buffer, it takes from the buffer.




9
Scripting / Re: Passing variables / returning string value
« on: April 03, 2013, 11:19:12 PM »
Well if it wasn't obvious, this is inside planet.as - which I'm trying to modify - and with

Code: [Select]
string@ statBufferName(const string@ statName) { ... }

Nothing happens - I can tell because I get no output in the console, and I have many other debug statements which will output when this sucessfully executes.

If I use

Code: [Select]
string statBufferName(const string@ statName) { ... }

string bufferName = statBufferName(statName);

It works, but I have later issues trying to use emp.getStat(bufferName).

So:

1)Am I wrong in using an object reference in return for my helper function?

2) Is there some way for me to get useful error messages when working inside planet.as, particularly the tick() functions? If the code is wrong, it just fails to work as expected, I don't get any useful errors in console output.

10
Scripting / Passing variables / returning string value
« on: April 03, 2013, 10:52:31 PM »
What am I doing wrong here?

Code: [Select]
const string@ strOre = "Ore", strDamage = "Damage", strMass = "mass";
const string@ strMtl = "Metals", strMine = "MineM", strMtlGen = "MtlG";
const string@ strElc = "Electronics", strElcGen = "ElcG";
const string@ strAdv = "AdvParts", strAdvGen = "AdvG", strFoodGen = "FudGe";
const string@ strFood = "Food", strGoods = "Guds", strLuxuries = "Luxs";
const string@ strMtlBuffer = "Metal_Buffer", strElecBuffer = "Electronics_Buffer", strAdvBuffer = "AdvancedParts_Buffer", strFoodBuffer = "Food_Buffer";
const string@ strMtlEmpDemand = "Metal_Demand", strElecEmpDemand = "Electronics_Demand", strAdvEmpDemand = "AdvancedParts_Demand", strFoodEmpDemand = "Food_Demand";

...

float tradeResource(Empire@ emp, Object@ obj, State@ state, const string@ statName, float amount, float tradeEff, TradeMode mode) {

...
      string@ bufferName = statBufferName(statName);

...

}

// Take statName, return buffer string name
string@ statBufferName(const string@ statName) {

if (statName == strMtl) { return strMtlBuffer; }
if (statName == strElc) { return strElecBuffer; }
if (statName == strAdv) { return strAdvBuffer; }
if (statName == strFood) { return strFoodBuffer; }

}


The above won't excute (and the log file won't show me what the error is :/ ).
Any ideas?




11
Scripting / Re: Empire Script Data
« on: April 02, 2013, 01:57:44 PM »
Funny, I was just looking at this myself.

I actually want to know how to set variables/effects on empires (including player empires) when they are first created, how do I do that?

12
Scripting / Re: planet.as function question
« on: March 30, 2013, 09:29:36 PM »
Ok, I'm an idiot. Those are for the other three AI's homeworlds. DERRRR.  :-[

13
Scripting / Re: planet.as function question
« on: March 30, 2013, 08:41:16 PM »
I wanted to understand how the .val/.max/.required/.inCargo worked, so I stuck this inside planet.as tick() function:

Code: [Select]
float FoodVal = obj.getState(strFood).val;
float FoodMax = obj.getState(strFood).max;
float FoodReq = obj.getState(strFood).required;
float FoodCargo = obj.getState(strFood).inCargo;

string@ debug_out = f_to_s(FoodVal, 0);
debug_out += " / ";
debug_out += f_to_s(FoodMax,0);
debug_out += " / ";
debug_out += f_to_s(FoodReq,0);
debug_out += " / ";
debug_out += f_to_s(FoodCargo,0);

print(debug_out);

I get results like so:

1520 / 2181 / 0 / 0
1520 / 2181 / 0 / 0
1520 / 2181 / 0 / 0
1898 / 2146 / 0 / 0
1507 / 2181 / 0 / 0
1507 / 2181 / 0 / 0
1507 / 2181 / 0 / 0
1895 / 2146 / 0 / 0
1494 / 2181 / 0 / 0
1494 / 2181 / 0 / 0
1494 / 2181 / 0 / 0
1892 / 2146 / 0 / 0
1481 / 2181 / 0 / 0
1481 / 2181 / 0 / 0
1481 / 2181 / 0 / 0
1889 / 2146 / 0 / 0
1469 / 2181 / 0 / 0
1469 / 2181 / 0 / 0
1469 / 2181 / 0 / 0


by comparison with the planet economy window (default game, no mods), every 4th output - it should be obvious which - are correct, and the others are not.

Why is this so?

14
Scripting / Re: planet.as function question
« on: March 30, 2013, 05:16:07 PM »
But wouldn't that be reflected in the .max attribute? If not, what does .max actually define?

15
Scripting / planet.as function question
« on: March 29, 2013, 11:29:52 PM »
I don't understand the reason for the freeCargoSpace and state.inCargo variables used here. I thought state.val and state.max were the current and maximum values for the state (and therefore, the resource involved). This is on the planet so it isn't cargo space on a ship. What are those variables for?

Code: [Select]
float getResourceWeight(State@ state, float freeCargoSpace, float tradeToPct) {
if(abs(state.max) < 0.01f)
return 0.f;
float pct = (state.val + state.inCargo) / (state.max + state.inCargo + freeCargoSpace);
if(pct > 0.5f)
return (1.f/tradeToPct) * (pct - tradeToPct); // Always positive
else if(pct < 0.5f)
return (-1.f/tradeToPct) * (tradeToPct - pct); // Always negative
else
return 0;
}


16
Star Ruler Discussion / Re: How to decrease/increase component size
« on: March 28, 2013, 03:27:15 PM »
Holding the shift key will give you increments of .25 (or .13 in GA).

17
Star Ruler Discussion / Go big. Really, really big.
« on: March 28, 2013, 12:59:52 AM »
So I decided to take a break from various modding (mainly for my own fun) and actually *play a game* of SR. Now, one of the things that has bothered me is that the early stages of the game always start with:

1) Build 10-100x Scouts
2) Wait for scouts to land
3) Pick best worlds/systems, tag with Auto-Colonize
4) Spam colony ships

Rinse, repeat. Part of the reason this works is that the system are unrealistically close - the default spacing value puts star systems around 10-15 AU from each other. In real life, Pluto is over 30 AU from the sun! The game might be more interesting if systems were more widely spaced.

So cranked the value up to 300AU and tried again. Better, but mostly the same as before, just slower starting. So I went for broke - I bypassed the max value in the GUI and set the spacing value to 2500000 by hand - that's 2500 AU spacing. 5000 systems, spiral galaxy, go! My system choked on this for a minute and then dumped me into a new game.

First observation: The engine does not like this large of a zoom out/in range. At close-up on a system you will get camera jitter; by the time the system fills the screen, the engine gives up and most of the system details vanish. You can avoid this by keeping the system view reasonably small. It still works.

Second observation: This scale will really give you a sense of how huge the galaxy is. Individual systems are entirely not visible at full zoom out. Even when zoomed in enough to lose the gas background you will still not see systems. They are TINY. Distances are HUGE.

I made 100 Scouts for auto explore, sent them out, and turned speed up to 10x to wait and see what I found. The first scout didn't get to a system until THIRTY MINUTES of in-game clock time had passed. By this point I had colonized my other starting system planets, gotten up to about 3 in most technologies, and had said 'hell with it', build colony ships, and send them randomly out to unknown systems.

My first new colonies didn't happen until nearly 1h of in-game time. It takes a long time for a default colony ship to go 15,000 AU. D:

I'm now up to 6.5h of in-game time. My farthest colony has barely made it a quarter-way to the galaxy core - I started on an outer edge. The scouts I sent to the other side of the galaxy back in the beginning are still out there... somewhere. I have around 100 planets, 1000 ships entirely of scouts and colony ships (no pirates or rements for simplicity).

No sign of the AI players. Technology levels all reached 10 some time ago, and ring worlds should be soon. I had to switch over to metal focus because almost all my colonies ran out of metal, and for whatever reason asteroid belts have not spawned. Assaulting the AI is going to be a hell of a challenge - I will need huge tankers to hold the fuel and ammo I need to get a fleet to target, and then grab a foot hold system and build the hell out of it.

Anyone else try anything on this massive a scale?

18
Scripting / Re: GUI star temp not seeming to work
« on: March 28, 2013, 12:34:55 AM »
The code in the previous post now works. I think I forgot to hit 'save' on one of the files in my editor.  :P

19
Scripting / Re: GUI star temp not seeming to work
« on: March 27, 2013, 12:11:51 AM »
Strike that last. I have no idea what I did, but it works now.

20
Scripting / Re: GUI star temp not seeming to work
« on: March 27, 2013, 12:08:29 AM »
Doh!

Ok, so I added this to resources.xml:

Code: [Select]
<resource name="StarTempK">
<alwaysVisible/>
</resource>

I have this in map_generation.as:

Code: [Select]
// Star Tempature in K
// Stored as State@ for later GUI use
State@ tempK = obj.getState("StarTempK");
tempK.max = starDesc.Temperature;
tempK.val = tempK.max;

and finally this in gui.as:

Code: [Select]
// Star Temp ... I hope
if (star !is null) {
  float starTemp = 0.f, starMax = 0.f, temp = 0.f;
if (obj.getStateVals("StarTempK", starTemp, starMax, temp, temp)) {
   mo_text += combine("\n", "Temperature: ", "#c:c69c6d#", standardize_nice(starTemp), "K#c#");
  }

}

... and I still fail to init the map on some sort of map prep error.

21
Scripting / Re: GUI star temp not seeming to work
« on: March 26, 2013, 11:06:45 PM »
Wow, this is annoying. Assuming that "Temp K" wasn't being set, I tried to set it myself in map_generation.as:


Code: [Select]
float placeholder = 0.f;
Object@ objStar = star.toObject();
objStar.setStateVals("Temp K", starDesc.Temperature, placeholder, placeholder, placeholder);

Still no go. How does this s*ht work?

22
Scripting / Re: GUI star temp not seeming to work
« on: March 26, 2013, 10:30:10 PM »
If I run the following code:

Code: [Select]
if (star !is null) {
uint numStates = obj.getStateCount();
for (uint i = 0; i < numStates; ++i) {
     string@ somestate = obj.getStateName(i);
     string@ output = combine("Statename: ", "\"", somestate, "\"");
       warning(output);
}
}


I get this output:

Code: [Select]
Statename: "Damage"
Statename: "H3"
Statename: "Temp K"

23
Scripting / Re: GUI star temp not seeming to work
« on: March 26, 2013, 10:15:08 PM »
If I use getStateName(int) and run through the numbers, it comes back as "Temp K".


24
Scripting / GUI star temp not seeming to work
« on: March 26, 2013, 07:07:23 PM »
I wanted to have the mouseover show the star's temp, so I added this inside gui.as ...

Code: [Select]
// Star Temp ... I hope
if (star !is null) {
float starTemp = 0.f, temp = 0.f;
if (obj.getStateVals("Temp K", starTemp, temp, temp, temp)) {
mo_text +=  combine("\n", "Tempature: ", "#c:c69c6d#", standardize_nice(starTemp), "K#c#");
}

}


And no joy. What am I doing wrong here?

25
Galactic Armory / Re: Debug help needed: H3 mining bonus
« on: March 26, 2013, 02:43:51 PM »
Thank you!

26
Galactic Armory / Debug help needed: H3 mining bonus
« on: March 26, 2013, 02:36:14 PM »
So I'm trying to add "isotope rich" and "isotope poor" conditions to Jovian type planets for better/worse H3 mining.

I'm getting these errors (?) in the system console:

Code: [Select]
Formula Error:
Too many values in formula
'vH3Rate'

Fromula Error:
Too many values in formula
'vH3Store'

Here are my changes:

PlanetTypes.xml:
Code: [Select]
<cond id="h3_rich" type="positive">
<tags>gas</tags>
<hook func="GAplanetaryConditions::modH3Rate" arg0="1.5" /> <!-- Implemented in GAplanetaryConditions.as -->
<desc>#PCD_h3_rich</desc>
</cond>

<cond id="h3_poor" type="negative">
<tags>gas</tags>
<hook func="GAplanetaryConditions::modH3Rate" arg0="0.5" /> <!-- Implemented in GAplanetaryConditions.as -->
<desc>#PCD_h3_poor</desc>
</cond>

GAplanetaryConditions.as:
Code: [Select]
const string@ strH3Rate = "vH3Rate";
void modH3Rate(subSystem@ subSys, const string@ name, float Factor) {
if(name == strH3Rate && subSys.type.hasTag(strStruct)) {
float rate = subSys.getVariable(strH3Rate);
if(rate > 0)
subSys.setVariable(strH3Rate, rate * Factor);
}
}

structures.txt (change made):

Code: [Select]
System: HeliumRefinery
Name: #SS_HELIUMREFINERY_NAME
Description: #SS_HELIUMREFINERY_DESC
Appearance: GeneralBuilding

Available: Techs.Chemistry.Level > 3
Level: Techs.Chemistry.Level
Size: Scale
Durability: 500 * Size * pow(LEVEL_GAIN_CURVE, Level) * PLANET_STRUCT_MULT
Mass: 400 * Size * pow(LEVEL_GAIN_CURVE, Level)

Tags: Structure
Tied To: Chemistry 4

Costs: Metals[200 * Size * pow(COST_INC_CRV, Level)], Electronics[80 * Size * pow(COST_INC_CRV, Level)], AdvParts[80 * Size * pow(COST_INC_CRV, Level)]
Complexity: 1 * STRUCT_COMPLX_MULT

vWorkers: Size * 600000
vH3Rate: Size * 3.2 * (pow(LEVEL_GAIN_CURVE, Level) + RES_BASE_FACT) * RES_GEN_MULT * 0.5
vH3Store: Size * 100 * pow(LEVEL_GAIN_CURVE, Level)

Provides: RefineHE3 with
Rate[vH3Rate]

Provides: StructFuelStorage with
Amount[vH3Store] //was Size * 750 *

Requires:
To Run:
Workers[vWorkers]

Hints: Workers[vWorkers * -1], Fuel[vH3Store], FuelFab[vH3Rate], HP[Durability]


Any ideas?

28
Scripting / Re: How to make some planets visually larger?
« on: March 23, 2013, 11:57:08 PM »
Fffuuuuuu

 :)

29
Scripting / How to make some planets visually larger?
« on: March 23, 2013, 08:02:09 PM »
Hello! Hope SR modding isn't *that* dead.

Want to make certain planets (gas giants) look visually large, much more so than other planet sizes. Is this a script change (pRad / pVol) or a model change?

Thanks!
-ibanix

30
Star Ruler Discussion / Fuel and Tankers
« on: March 20, 2013, 01:29:29 PM »
Hi there, new player.

I'm having a little trouble with fuel tankers. I'd like to be able to design them and then have them keep back from my fleet, with my ships going to the tanker (and not a planet) to top off as needed. Is this possible? Right now my tankers fly every which way to top off ships, and my ships still go to a planet even if a tanker is closer.

Thanks!



Pages: [1]