AtomicTorch Studio Forums

VoidExpanse => Modding info => Topic started by: BeLugh on August 02, 2014, 04:02:32 PM

Title: Got some problem with Requirements and XP
Post by: BeLugh on August 02, 2014, 04:02:32 PM
Hi, i would like to create a mod for mining and trading. So far i tried getting first changes done to see how it works. I had to realize that i was missing some stuff:

-is it possible to add requirements when mining ores with something like a tier 2 mining laser? I would like to have some ores only minable with better lasers.
(so far i tried to add requirements for the items, as well for the asteroids, but none of the requirements seemed to restrict at all)

-is it possible to add a requirement for items to check which class of ship hull you are using? (heavy frigate, light cruiser etc)?
As i would like to add better mining lasers for bigger ships

-would it be possible to have a skill in the skilltree which always adds a usable device slot in your ships?

-is there a file where i can change xp-rates? i could not find experience in any file so far

Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 02, 2014, 10:22:08 PM
1. No, but you can make it really hard to mine, so low level mining devices won't work on it. But we actually plan to implement that with mining system overhaul later on when we add more asteroid types and different mining devices for each particular type. Don't hold your breath, though as it will be in quite some time in the future as we would like to finish other things in the game first.

2. No. But you could probably implement it in scripts by cheching what kind of ship you have when mining and displaying a message like "You can't mine with that hull".

3. I am not entirely sure what you mean, but if you mean adding an extra device slot then no, since device slots are an inherent property of the hull.

4. Yes, you can change all XP rages in the scripts. Along with many more things.
Title: Re: Got some problem with Requirements and XP
Post by: Hammish on August 03, 2014, 12:29:42 AM
For #2, would it be possible to create a certification of sorts and then stick it on the hull as an effect, since that's possible now?  Then just create a new type of asteroid to mine.

Basically, instead of having a skill that grants the effect of use_good_mining_lasers, you stick that on an upgraded hull instead.  Then create Mining Laser Mk2 that requires use_good_mining_lasers so it can only be used on the proper ships, and make a version of the mining routine that just checks the new asteroid type against Mining Laser Mk2.  I think it should be possible to use an 'or' argument to modify the base mining script as well, even, so that both Mining Laser 1 and 2 are valid to hit normal asteroids.
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 03, 2014, 01:31:56 AM
Quote from: Hammish on August 03, 2014, 12:29:42 AM
For #2, would it be possible to create a certification of sorts and then stick it on the hull as an effect, since that's possible now?  Then just create a new type of asteroid to mine.
Oh, good idea. I think it should be possible. At least you could try :)
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 03, 2014, 02:06:21 AM
Thanks so much for the help! I did not think about taking a closer look at the scripts so far. I am still a beginner somehow at java but maybe i can get into it after a while.

About #3: yes i wanted to add activate another device slot additional to the ones activated by the hull.
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 03, 2014, 02:55:32 AM
A small note:
Not java, but java script. Javascript is much simpler than java and if you have basic concepts of programming you can learn js in a couple of days or so :)
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 03, 2014, 09:18:04 AM
Nice to hear :)

I was trying to make mining devices consuming energy, but i can only add a new effect , i cant add requirements.
None of the other energy consumptions existing would work in a single use energy consumption (except negative value from a consumable, which would still work if not enough energy is there for the mining laser).
Or where can i find the energy_consumption_xxxx_value 's?

Edit:
so far i found this one in calculateship:

    // ! important !
    // devices' energy consuming (and all other stuff about devices) is calculated in
    // device's script


    //-----------------
    // other electrics
    // in last order

    energy -= ship.GetFinalCacheValue(ship_id, "energy_consumption_generic") * timeMultiplier;


sooo i guess i have to take "energy" as the requirement i guess... i will try it now

i did not get it to work, i tried workign around with energy in the javascript file for miningmodule as well as with energy_consumption_generic in the mining device.xml
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 03, 2014, 08:06:22 PM
I think you need to add energy consumption on the device activation.

Basic idea would be:


if (has enough energy) {
    remove energy
    start mining
}


Thus, if the condition is fulfilled then the mining starts and some energy is consumed.

Btw, all API functions are available in our wiki: http://wiki.atomictorch.com/Main_Page but you probably already know that.
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 04, 2014, 11:33:48 AM
Thanks!
But i already got that idea :) i just did not know about the api's and the wiki.
Right now i am trying to cancel the mining when you do not have enough energy.... i just dont know how to make the oncancel work in that case :/ but i will go on trying
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 04, 2014, 06:40:48 PM
OnCancel is a function that is executed when the mining cancels externally such as you moving or getting shot.
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 04, 2014, 09:46:51 PM
Do you have any idea how i can make it cancel then? :/
For me it seems that the function i need to modify is not within the modable files. There is only the Onstart, which does not execute anything and the onFinished, which is already too late. Yesterday i took a closer look on several modable files. Many parts of the game are modable, but some core functions seem to be not available. For example none of the scripts contains the execution of the OnCancel, so i dont see which arrays are inside of it.

Is it possible for me to cancel the execution of the device somehow?
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 05, 2014, 12:06:43 AM
Okay, here's how I would do it.


OnStart:
if (ship has enough energy)
{
    decrease energy as needed
    set duration/cooldown time as normal
    set mining status (create a new variable) as "1" - meaning everything is okay
} else {
    set duration as 1 frame (instant)
    set mining status as "0", meaning fail
}

OnFinished:
if (mining status is "1")
{
    //then everything is okay
    add resources as normal
} else {
    notify user that mining failed because there is not enough energy
}


And that would basically do exactly what you described.

Hope it helps!
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 05, 2014, 12:45:19 AM
yeah that could work, that sounds reasonable. I really appreciate your help :) Thanks!
I will try it later when i get home.
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 05, 2014, 01:49:27 AM
No problem, glad to help! :)
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 05, 2014, 10:31:33 AM
Thanks so much Lurler :) I finally got it to work. It now only works when you have enough energy, and the energy to activate the mining laser is written in the mining devices. I can use the same way for many other ideas i had.

Lets see if i can get a mod up until sunday :)

Will you add experience for trading goods? for me it seems that the function which can be used to do this is not modable. I only found the scripts for setting up prices in Stations.js
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 05, 2014, 01:53:07 PM
I have tried to add more asteroids to have more diversity, as i want to use 16 resources to mine. The resources/ores are working great.
But when i add another asteroid it hangs on loading savegames/creating a new world

I found that the asteroids are created in systempresets.js

e.g. CSGen.CreateAsteroidsByPrefixes( args, {rock:10, ice:1}, 4, 1, 3 );

can you please tell me what the 4, 1 and 3 represents?
right now i would guess it has like 3 rings from the star. it places 10*3 rocky asteroids and 1x*3 in the inner or outer one.... and then 10*1 rocky 1*1 icy etc...

Can you please tell me if its possible to add more asteroids to the game, if yes what do i have to do after adding them to the asteroids folder with a new id?
Title: Re: Got some problem with Requirements and XP
Post by: Lurler on August 05, 2014, 07:18:22 PM
To answer your questions:
We'd like to add experience for trading but such system isn't yet possible. But will likely be added in the future.
As for how asteroids are generated, unfortunately I have no idea :)
Maybe someone else from the team can answer that here.
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 06, 2014, 12:48:16 AM
Do you know who coded the asteroid function? So i can ask him directly if he does not answer here.
I would really like to add more asteroids (i was going to have 10xrock 3xice 3xlava in total)
Title: Re: Got some problem with Requirements and XP
Post by: BeLugh on August 06, 2014, 02:20:54 PM
Adding more asteroids works, my msitake was that i had a typo in scale of asteroid 7 and i always tried to have at least asteroid 7 added... ;)

Btw i found the function for creating asteroids, its in CSGen