Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API Example script
Author Message
eferz98 Offline
Posting Freak
*****

Posts: 3,069
Joined: Feb 2012
Post: #21
RE: API Example script
(27-12-2012 11:52 AM)Topper42 Wrote:  Yeah that is not so cool, but i can't possibily test my "Example" script with every other script that is around and this goes for the other script writers too.

Duly noted and I totally understand. Besides its only partially hidden and can be clicked around Maelstrom Tool. I only used that as an example because it was the first one I saw. However on the right most partition of that picture, it clearly demonstrates that the UI is being obstructed by a native in-game element (the base selection column) and not from another user's third-party script.

I guess in this particular case it would be more intuitive if the button were "attached" to the window that shows the base's resource, defense, and offense. But, still it would be nice to have a way to at least avoid the in-game elements.

[Image: I6Xeh.gif][Image: ho5UK.jpg]
27-12-2012 04:14 PM
 Search   Quote 
FRISH Offline
Posting Freak
*****

Posts: 2,415
Joined: Feb 2012
Post: #22
RE: API Example script
(27-12-2012 04:49 PM)eferz98 Wrote:  
(27-12-2012 04:44 PM)FRISH Wrote:  Btw, you're awesome.

Thanks. You're not so bad yourself.

D:

[Image: utEo2eW.jpg]
(This post was last modified: 27-12-2012 04:55 PM by FRISH.)
27-12-2012 04:42 PM
 Search   Quote 
FRISH Offline
Posting Freak
*****

Posts: 2,415
Joined: Feb 2012
Post: #23
RE: API Example script
Btw, you're awesome.

[Image: utEo2eW.jpg]
27-12-2012 04:44 PM
 Search   Quote 
eferz98 Offline
Posting Freak
*****

Posts: 3,069
Joined: Feb 2012
Post: #24
RE: API Example script
(27-12-2012 04:44 PM)FRISH Wrote:  Btw, you're awesome.

Thanks. You're not so bad yourself.

[Image: I6Xeh.gif][Image: ho5UK.jpg]
27-12-2012 04:49 PM
 Search   Quote 
KRS_LAN Offline
Senior Member
****

Posts: 482
Joined: Apr 2012
Post: #25
RE: API Example script
These repair time calculations don't make much sense to me.

Why is a completely destroyed unit (which isn't included in battle) omitted from the calculations and a unit which is partially damaged when entering battle has it's repair time calculated based on it's max health rather than starting health?

[Image: R68BbSE.jpg]
cncscripts.com
(This post was last modified: 27-12-2012 04:58 PM by KRS_LAN.)
27-12-2012 04:56 PM
 Visit this user's website   Search   Quote 
Topper42 Offline
Developer
***

Posts: 248
Joined: Dec 2011
Post: #26
RE: API Example script
(27-12-2012 03:10 PM)Peluski17 Wrote:  In your advanced script it showed that you were able to calculate possible loot or resources obtained from that simulation. Does this information come from the data after the simulation has finished or did you have to do something like get the combat report?

Everything is calculated with the informations that are provided by the API.
(This post was last modified: 27-12-2012 05:14 PM by Topper42.)
27-12-2012 05:14 PM
 Search   Quote 
Topper42 Offline
Developer
***

Posts: 248
Joined: Dec 2011
Post: #27
RE: API Example script
(27-12-2012 04:42 PM)FRISH Wrote:  
(27-12-2012 04:49 PM)eferz98 Wrote:  
(27-12-2012 04:44 PM)FRISH Wrote:  Btw, you're awesome.

Thanks. You're not so bad yourself.

D:

What are you talking about? Is this in any kind related to this thread?
27-12-2012 05:17 PM
 Search   Quote 
Topper42 Offline
Developer
***

Posts: 248
Joined: Dec 2011
Post: #28
RE: API Example script
(27-12-2012 04:14 PM)eferz98 Wrote:  
(27-12-2012 11:52 AM)Topper42 Wrote:  Yeah that is not so cool, but i can't possibily test my "Example" script with every other script that is around and this goes for the other script writers too.

Duly noted and I totally understand. Besides its only partially hidden and can be clicked around Maelstrom Tool. I only used that as an example because it was the first one I saw. However on the right most partition of that picture, it clearly demonstrates that the UI is being obstructed by a native in-game element (the base selection column) and not from another user's third-party script.

I guess in this particular case it would be more intuitive if the button were "attached" to the window that shows the base's resource, defense, and offense. But, still it would be nice to have a way to at least avoid the in-game elements.

Please understand that the API Example Script is more a tutorial how to code scripts and use our API and not a perfect script. It will only be updated if the API changes. I think that all other scripts will learn from it and adapt some functions.This scripts will take care of their ui.

You can't avoid the in game elments, they all are designed in that way to use all the space they've got and i'm not even start talking about the minimal resolution. The scripts screw the normal ui design by adding stuff that is not supposed to be there and this is not good at all for the ui, this always mean that there will be ui bugs nobody could think of. And i think this is the responsibility of the scripter to solve them.

I actually had the Upgrade button in the city area above the trade button but it is way more complicated to add a button there and the code could break really easy on patches.
27-12-2012 05:33 PM
 Search   Quote 
Topper42 Offline
Developer
***

Posts: 248
Joined: Dec 2011
Post: #29
RE: API Example script
(27-12-2012 04:56 PM)KRS_LAN Wrote:  These repair time calculations don't make much sense to me.

Why is a completely destroyed unit (which isn't included in battle) omitted from the calculations and a unit which is partially damaged when entering battle has it's repair time calculated based on it's max health rather than starting health?

I calculate in my Example Script alway the full repair costs of a unit. This is way i need the max health and not the start health.

A unit with end health == 0 is not excluded it just has the damageRatio = 1 which means full repair costs.

Code:
if (unitStartHealth != unitEndHealth) // check if unit has got damage
    {    
        var damageRatio = 1;
        if (unitEndHealth > 0) // if unit is destroyed in combat use full repair costs
        {
            if (unitMaxHealth != -1)
            {
                damageRatio = (unitMaxHealth - (unitEndHealth/16)) / unitMaxHealth;
            }
        }
27-12-2012 05:40 PM
 Search   Quote 
KRS_LAN Offline
Senior Member
****

Posts: 482
Joined: Apr 2012
Post: #30
RE: API Example script
(27-12-2012 05:40 PM)Topper42 Wrote:  A unit with end health == 0 is not excluded it just has the damageRatio = 1 which means full repair costs.

Thanks for the reply, but that's not at all what I said.

"a completely destroyed unit (which isn't included in battle)".

So this means units which have a start health of 0.

Anyway, I think I have solved it myself. The game ignores these units all together along with units which are disabled.

[Image: R68BbSE.jpg]
cncscripts.com
27-12-2012 06:00 PM
 Visit this user's website   Search   Quote 


Forum Jump:


User(s) browsing this thread: