This is nothing fancy, just a big list of newly available objects and functions that are not yet documented in the wiki. The number at the start is the bot version it was added in. Thanks to Dismayed for the changelog summary :)

2698    Added "isAvailable" to HeroBean object (returns true if hero is not busy and either mayor or idle)

2695    Eliminated MapCastles(x,y,r) [use more flexible CastleInRectangle(x1,y1,x2,y2) instead]

2693    Renamed updateDetailInfo() to UpdateDetailInfo()

2683    Renamed stateName() to StateName() (the function converts numeric castle's "state" property to name)

2676    Added 2 additional (optional) boolean parameters to CastlesInRectangle():
        5th parameter is whether to omit NPCs from results (default: Yes)
        6th parameter is whether to return array indexed by castle id (Yes) or zero-based (No) (default: No)

        Example:
        list = CastlesInRectangle(123, 234, 156, 274, false, true) // include NPCs into results, and also use castle id as index
        id = GetFieldId(142, 255)
        castle = list[id] // this works because of 6th parameter in CastlesInRectangle() call set to true
        ifgosub castle found // same as "ifgosub castle != null found"

2670    Added ResetMap function allowing to clear cached map data (used by rescanmap/rescanrec):
        Example 1:
        a = ResetMap(x,y,radius)       // resets circular area with center at x,y
        
        Example 2:
        a = ResetMap(x,y,width,height) // resets rectangular area with start at x,y
        In both examples, "a" is dummy variable (will be assigned null).2670    

        Added support for city.x and city.y (returning x and y coordinates of the city)
        Example: 
        x = GetX(city.fieldId) // x-coordinate of the city
        x = city.x // simpler way to do the same

2669    GetFieldType(str) - converts valley name to type
        GetFieldName(integer) - converts valley type to name
        FindField(cx, cy, distance, fieldType, [fieldLevel]) - returns array of fields within specified distance from cx,cy
        x = GetX(city.fieldId)
        y = GetY(city.fieldId)

2668    Resource objects can now be auto-converted to string as needed
        For example:
        echo city.myArmies[0].resource // outputs human-readable string representing resources carried by first army
    
        Renamed getResources() to GetResources()

2662    Added support for haunted castle items and increased army sizes (to be further refined)
        Reserved resources now include amount needed to do 1-time comforting if city has non-zero grievance

2651    Added support for array constructors (nested arrays constructors are fully supported)
        Example:
        colors = [ "green", "red", "yellow" ]
        fruits = [ "pear", "apple", "banana" ]
        echo colors[1] // outputs "red"
        echo fruits[0] // outputs "pear"
        str = colors[1] + " " + fruits[1]
        echo "I like " + str + "s" // outputs "I like red apples"

        Added support for object constructors (nested object constructors are fully supported)
        message = { user:"bucks", text:"What's wrong with you?" }
        execute "whisper " + message.user + " " + message.text

        Added support for unary -, + and ! (not)
        a = -2 < 3 // true
        b = !a // false
        text = "some text"
        xx = !text // false

        Added date() function
        d = date(2012, 9, 24, 10, 30) // note, months are counted from 0,output below is for EST time zone
        echo d.toString() // outputs "Wed Oct 24 10:30:00 GMT-0400 2012"
        echo d.toUTCString() // outputs "Wed Oct 24 14:30:00 2012 UTC"

2650    Changed first letter to capital in the following functions
        TroopBeanToString, GetTroops, GetFortifications

        Renamed "getFoodConsumeRate" to "foodConsumeRate" in troop bean
        Example: Find food consumtpion for a specified troop string
        mytroops = GetTroops("a:30k,b:40k,w:1,p:1,sw:1") // convert troop string to TroopBean object
        ifgoto mytroops continue
        echo "Error in troop string"
        end
        echo "Food consumption of " + TroopBeanToString(mytroops, ",") + " is " + mytroops.foodConsumeRate + " per hour"
        echo "Food consumption per 1 minute is " + mytroops.foodConsumption(60)

2644    Renamed FieldIdToCompareString() to FieldIdToCoords()

        Added "coords" property support to field beans
        field = city.fields[0]
        echo "Field 1 is " + field.name + ", coordinates are: " + FieldIdToCoords(field.id) // outputs "Field 1 is Forest, coordinates are: 123,456"
        echo "Field 1 is " + field.name + ", coordinates are: " + GetX(field.id) + "," + GetY(field.id) // same output
        echo "Field 1 is " + field.name + ", coordinates are: " + field.coords // same output

2643    - these functions (all use field id as parameter) renamed to start with upper-case letter:
        GetLevel, GetType, GetZoneName, GetX, GetY

        - added MapDistance(x1, y1, x2, y2) function returning distance between (x1,y1) an (x2,y2) on the map

2635    New BuyPrice() and SellPrice() functions use up to 3 parameters: resource, amount, method
        resource (required): 0 - food, 1 - wood, 2 - stone, 3 - iron
        amount (optional, default = 1): desired amount of resource
        method (optional, default = 0): 0 - "now", 1 - "average" (see explanation below)
        Method 0 ("now" - default) returns the price to buy or sell the specified amount of resources without waiting.
        Method 1 ("average") returns average price needed to buy or sell the specified amount of resources
        BuyPrice(resource) is same as m_context.buyPrice(resource)
        SellPrice(resource) is same as m_context.sellPrice(resource)

2634    Added "return" (same as "gosubreturn")

        Added support for "NaN" (special constant representing "not a number" value) and isNaN() function
        a = NaN
        b = a + 2
        echo isNaN(b) // outputs "true"

        Added support for "Infinity" (special constant representing infinitly large number) and isFinite() function
        a = 0
        b = 2 / a // division by zero!
        echo isFinite(b) // outputs "false"

2631    Added support for various map-related functions in expressions (function availability and exact names/parameters are subject to change!)

        Example 1 (prints list of up to 10 enemies, unsorted):
        enemies = SearchEnemyCastles(10)
        i = 0
        label loop1
        ifgoto i >= enemies.length exit
        castle = enemies[i]
        i = i + 1
        echo "Enemy " + i + ":" fieldIdToCompareString(castle.id) castle.name castle.userName castle.allianceName castle.prestige castle.honor
        goto loop1
        label exit

        Example 2 (prints info for a specific map coordinates, uses cached info, if available)
        x = 123
        y = 456
        id = GetFieldId(x,y)
        label notyet
        castle = GetDetailInfo(id, true)
        ifgoto castle == null notyet
        echo "lord=" + castle.userName "alliance=" + castle.allianceName "R=" + castle.relation

2630    Added support for "<>" operator (same as "!=") in expressions

        Added inline support for the following math functions:
        abs(), acos(), asin(), atan(), atan2(), cos(), sin(), tan(),
        exp(), pow(), log(),
        ceil(), floor(), round(), max(), min()
        random(), sqrt()

        Added access to the following constants:
        PI, E, SQRT1_2 (square root of 2 divided by 2), SQRT2 (square root of 2)
        LN2 (logarithm of 2), LN10 (logarithm of 10), LOG10E (base 10 ogarithm of E), LOG2E (base 2 logarithm of E)

        Added support for various resource-related functions and constants
        res = RESOURCETYPE_WOOD
        echo "Resource type " + res + " is for " + ResourceNames[res]

2629    Variables can hold value of any time (number, string, array/function/oibject reference)
        Expressions are supported in ifgoto/ifgosub

        Example 1: Simple math
        a = 2
        b = 3
        c = a + b // c is 5 now
        c = c + 1 // c is 6 now
        d = (a + b) (c - 1)
        echo a b c d // outputs 2 3 6 25

        Example 2: String operations
        text1 = "Hello"
        text2 = "world"
        result = text1 + ", " + text2 + "!"
        len = result.length
        echo result // outputs "Hello, world!"
        echo len // 13
        echo result.indexOf("o") // 4

        Example 3: References:
        echo "List of heroes in " + m_city.cityManager.name + ":"
        heroes = m_city.cityManager.heroes
        i = 0
        count = heroes.length
        ifgoto i>=count done // note, round brackets are optional and spaces between operands are not required
        label loop1
        i = i + 1
        echo i + ". " + heroes[i].name
        goto loop1
        label done

        Example 4: Function references
        ask = m_context.buyPrice // note, buyPrice is a function!
        res = 0
        label resloop
        echo "Current " + ResourceNames[res] + " price is " + ask(res)
        res = res + 1

        Added "execute" command allowing to run arbitrary command with custom parameters, e.g.
        execute "buy food " + amount + " " + price // buy 5m food @ 22.5

        Added "end" command (terminates script)

2607    Allow to check city/player (account) buffs from scripts:
        m_city.cityManager.hasBuff(XXX) // true if city has buff XXX applied
        m_context.hasBuff(XXX) // true if we have buff XXX applied
        m_context.buff(XXX) // returns BuffBean object or null if buff XXX is not applied
        m_city.cityManager.buff(XXX) // returns BuffBean object or null if buff XXX is not applied

        Example 1: Checking if city has buff applied
        ifgoto ( m_city.cityManager.hasBuff(ForceopenclosegateBuff ) == true ) gatesforced

        Example 2: Accessing individual player (account) buff properties
        echo m_context.buff(StopTroopsUpkeepBuff).descName
        // the above would print "No food for your troops will be consumed under this status." if buff is applied

        m_context.truced // true if account is truced (including server merge truce)
        m_context.inTruceCooldown // true if account is in truce cooldown

2606    Recognize "null" as valid value in scripts

2603    m_context.marketReady() // set to false after (re)login, becomes true after market prices for all 4 resources are refreshed
        m_context.marketReady() // set to false after (re)login, becomes true after market prices for all 4 resources are refreshed
        m_context.findFirstCity() // "main" city object
        New functions (not all possible parameters are shown):
        m_city.cityManager.comfortingNeeds(1).needAmount // amount of food needed to do disaster relief
        m_city.cityManager.comfortingNeeds(2).needAmount // amount of food needed to do praying

2600    Added disaster relief/praying factor access via scripts (m_city.cityManager.PRFactor)
        Added display of food amount needed for disaster relief/praying and current PR factor

2595    IsHeroInCastle() now supports hero-strings
        ifgoto ( m_city.IsHeroInCastle(any:att>200) == true ) found
        Added "is_researching" (returns true if there is a research going on)


ScriptObjects

Unsorted (last edited 2014-06-11 18:36:07 by Inanna)