Got some problem with Requirements and XP

Started by BeLugh, August 02, 2014, 04:02:32 PM

BeLugh

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


Lurler

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.

Hammish

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.

Lurler

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 :)

BeLugh

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.

Lurler

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 :)

BeLugh

#6
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

Lurler

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.

BeLugh

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

Lurler

OnCancel is a function that is executed when the mining cancels externally such as you moving or getting shot.

BeLugh

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?

Lurler

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!

BeLugh

yeah that could work, that sounds reasonable. I really appreciate your help :) Thanks!
I will try it later when i get home.

Lurler


BeLugh

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