HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with this spell please. Code provided.

09-16-2010, 07:55 PM#1
syrathia
Never mind. I changed the spell to use a HandleTable instead and found a few others errors i cleaned up. Left post as a reference.
Old


A long time ago on i think TheHelper.net forums i came a across a BlinkMove ability written by emiljr.

I have been reworking it practice my vJass (ZINC in this case) skills.

The below code looks alright to me and no outstanding errors are visible in jEdit (w/ Vex's mode of course) but I get the error that is pasted after. The highlighted line in jasshelper is yellow

The rest of the code compiles fine when i don't import the BlinkMove library

Zinc Code

Code:
//! zinc
library BlinkMove requires EventData, AutoIndex
{

    // Order ID of your ability
    constant integer SPELL_ID = 'A00A';
    // Adjust to taste
    constant real DISTANCE_PER_LEVEL = 300.0; 
    constant real END_DISTANCE = 200.0; // Blink this close to the end point
    // Will work at most once every this many seconds
    constant integer COOLDOWN = 4;
    // Effects to show on start and end points
    constant string EFFECT_START = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl";
    constant string EFFECT_END = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl";

    //set this higher if you are allowing more users of this ability than 1 per player
    constant integer MAX_BLINKERS = bj_MAX_PLAYERS;
    // Leave as is
    integer ORDER_SMART;
    integer ORDER_ATTACK;
    
    data blinkers[MAX_BLINKERS];
   
    struct data
    {
        unit caster;
        integer cd;
        timer t;
        boolean active = true;
        integer unitIndex;
        
        
        method cooldown()
        {
            cd = cd -1;
        }
        
        static method create(unit u) -> data
        {
            data d = data.allocate();
            d.caster = u;
            d.cd = COOLDOWN;
            d.t = CreateTimer();
            d.unitIndex = GetUnitId(u);
            return data;
        }
        
        static method onDestroy()
        {
            DestroyTimer(t);
        }
        
    }

    function GetBlinkerData(integer id) -> data
    {
        data ret = 0;
        integer i;
        
        for (0 <= i < MAX_BLINKERS)
        {
            if (blinkers[i] != 0)
            {
                if (blinkers[i].unitIndex == id)
                {
                    ret = blinkers[i];
                    break;
                }
            }
        }
        return ret;
    }
    
    // The unit needs the spell and must have been ordered to move or attack-move (Right-click or "A")
    // Additionally, it only works once every COOLDOWN seconds
    function MoveConds() -> boolean
    {
        unit u = GetTriggerUnit();
        data d = GetBlinkerData(GetUnitId(u));
        if (d == 0) //The ordered unit doesnt have the ability
        {
            return false;
        }
        else if (d.cd > 0 || !d.active) //still on cd or deactivated for last order
        {
            return false;
        }
        //now lets check the order since we know we have a blinker 
        return GetIssuedOrderId() == ORDER_SMART || GetIssuedOrderId() == ORDER_ATTACK;
    }

    
    function MoveActions()
    {
        EventData ed = EventData.create();
        unit u = ed.u;
        real d = ed.distanceXY();
        real a = ed.angle();
        real maxDist = DISTANCE_PER_LEVEL * GetUnitAbilityLevel(u, SPELL_ID);
        real tx = 0.0;
        real ty = 0.0;
        data dat = GetBlinkerData(GetUnitData(u));
        
        dat.cd = COOLDOWN;
    
        DestroyEffect(AddSpecialEffect(EFFECT_START, ed.x, ed.y)); // Eye-candy starting point
        d = d - END_DISTANCE; // This close to the end point
        if (d > maxDist) // but respect the maximum distance 
        {
            d = maxDist;
        }    
        
        tx = ed.x + d * Cos(a); // Point that is nearly there
        ty = ed.y + d * Sin(a);
        DestroyEffect(AddSpecialEffect(EFFECT_END, tx, ty)); // Eye-candy target point
        SetUnitPosition(u, tx, ty);
        
        dat.active = false;
        if (GetIssuedOrderId() == ORDER_SMART) // ...and order the unit to (attack-)move the rest
        {
            IssuePointOrder(u, "move", ed.tx, ed.ty);
        }
        else
        {
            IssuePointOrder(u, "attack", ed.tx, ed.ty);
        }
        dat.active = true;
    }
    
    //Only call this on the intial learning of the spell
    function LearnConds() -> boolean
    {    
        return GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID) == 1;
    }
    
    //Create the data struct and attach it to its timer and start the cd timer
    function LearnActions()
    {
        integer i;
        unit u = GetTriggerUnit();
        for (0 <= i < MAX_BLINKERS)
        {
            if (blinkers[i] == 0)
            {
                blinkers[i] = data.create(u);
                TimerStart(blinkers[i].t, 1, true, function blinkers[i].cooldown);
                break;
            }
        }    
        
        debug 
        {
            //If we iterated through the whole loop then we are trying to add a new blinker beyond the max....
            if (i == MAX_BLINKERS)
            {
                BJDebugMsg("ERROR: Trying to add a new blinker over the max.");
            }
        }
    }
    
    function onInit()
    {
        trigger learn = CreateTrigger();
        trigger move = CreateTrigger();
        ORDER_SMART = OrderId("smart");
        ORDER_ATTACK = OrderId("attack");
        
        TriggerRegisterAnyUnitEventBJ(learn, EVENT_PLAYER_HERO_SKILL ); //A unit learns a skill
        TriggerAddCondition(learn, Condition(function LearnConds));
        TriggerAddAction(learn, function LearnActions);
        
        TriggerRegisterAnyUnitEventBJ(move, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER); // A unit is issued an order targeting a point
        TriggerAddCondition(move, Condition(function MoveConds));
        TriggerAddAction(move, function MoveActions);
    
    }
}
//! endzinc



Error Msg


Error Msg:
Line 184: Wrong [size] definition

Error Code:
constant string BlinkBack___SFXBB="Abilities\\Spells\\Orc\\AncestralSpirit\\AncestralSpiritCaster.mdl"
constant string BlinkBack___SFXAOE="Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl"
constant string BlinkBack___SFXATTACH="origin"
constant attacktype BlinkBack___ATKTYPE=ATTACK_TYPE_HERO
constant damagetype BlinkBack___DMGTYPE=DAMAGE_TYPE_FIRE
group BlinkBack___BBGROUP=CreateGroup()
player BlinkBack___BBPLAYER
//endglobals from BlinkBack
//globals from BlinkMove:
constant boolean LIBRARY_BlinkMove=true
constant integer BlinkMove___SPELL_ID='A00A'
constant real BlinkMove___DISTANCE_PER_LEVEL=300.0
constant real BlinkMove___END_DISTANCE=200.0
constant integer BlinkMove___COOLDOWN=4
constant string BlinkMove___EFFECT_START="Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
constant string BlinkMove___EFFECT_END="Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
constant integer BlinkMove___MAX_BLINKERS=bj_MAX_PLAYERS
integer BlinkMove___ORDER_SMART
integer BlinkMove___ORDER_ATTACK
BlinkMove___data array BlinkMove___blinkers[BlinkMove___MAX_BLINKERS]
//endglobals from BlinkMove
//globals from GroupUtils: