• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

How do I change Cast Start Time through script?

Status
Not open for further replies.
  • Field Action - Attack Ground
  • Stats: Cast Start Time + (0.1500)
As you can see my AttackGround ability has an interval of 0.15.

I need to change this though. Right now the only way to do it seems to be to add a cooldown everytime I shoot and have 0.15 as the fastest possible shooting rate.

Here is a script I've made (haven't ever seen anyone else do this yet, anywhere):

JASS:
bool gt_onReload_Func (bool testConds, bool runActions) {
    unit    u       = EventUnit();
    int     cv      = FixedToInt(UnitGetCustomValue(u, c_uIndex));
    fixed cooldown  = UnitAbilityGetCooldown(u, ("AttackGround"), ("Abil/AttackGround"));
    
    if (cooldown < 0.0) {    
        UnitAbilityAddChargeUsed(u, ("AttackGround"), ("Abil/AttackGround"), -100.0);
        UnitAbilityAddCooldown(u, ("AttackGround"), ("Abil/AttackGround"), 1.25);
    }
    
    return true;
}
void gt_onReload_Init () {
    TriggerAddEventUnitAbility(gt_onReload, null, AbilityCommand(c_reloadAbility, 0), c_unitAbilStageExecute, false);
}

I can add charges and cooldown to the ability.

So for now I have to change the fire rate of attack ground by adding cooldown each time it is fired but this is an annoying way to do things because:
A. You can't que commands properly when doing it this way.
B. You can't cast the ability at all when the cooldown is applied, not until the cooldown is over.

JASS:
//--------------------------------------------------------------------------------------------------
// Fire projectiles at target point (hotkey = A).
//--------------------------------------------------------------------------------------------------
bool gt_onAbilityCommand_Func (bool testConds, bool runActions) {
    unit    u        = EventUnit();
    point   pt       = UnitGetPosition(u);
    point   ptB      = EventUnitTargetPoint();
    fixed   angle    = AngleBetweenPoints(pt, ptB);
    point   ptA      = PointWithOffsetPolar(pt, 0.75, angle);
    int     cv       = FixedToInt(UnitGetCustomValue(u, c_uIndex));
    actor   act;
    
    act = libNtve_gf_MainActorofUnit(u);
    libNtve_gf_PlayAnimation(act, c_animNameDefault, "Attack", 0, c_animTimeDefault);
    libNtve_gf_SetAnimationDuration(act, c_animNameDefault, 0.25);
    libNtve_gf_SetAnimationTimeScale(act, c_animNameDefault, 1.0);
    //libNtve_gf_MakeModelFaceAngle(libNtve_gf_MainActorofUnit(u), AngleBetweenPoints(UnitGetPosition(EventUnit()), OrderGetTargetPosition(EventUnitOrder())));
    ActorLookAtStart(act, "Chest", 100, 0.25, libNtve_gf_LookAtTargetFromPointWithZOffset(ptB, 0.5));
    UnitAbilityAddCooldown(u, ("AttackGround"), ("Abil/AttackGround"), 0.35);
    
    gf_WeaponFire(u, gv_uWeapon[cv], pt, ptB);
    return true;
}
//--------------------------------------------------------------------------------------------------
// Register the weapon fire ability.
void gt_onAbilityCommand_Init () {
    TriggerAddEventUnitAbility(gt_onAbilityCommand, null, AbilityCommand(c_projFireAbility, 0), c_unitAbilStageExecute, false);
}
//--------------------------------------------------------------------------------------------------

The above makes it fire every 0.5 seconds. Btw, that chest facing thing... I haven't been able to get that to work for me either...

Is there a behaviour, function, or anything else I can use to change the casting time for an ability? Surely there must exist some modifiers that speed up or slow down an ability, just like there is stuff to do the same for weapons (stimpack for example)?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Is there a behaviour, function, or anything else I can use to change the casting time for an ability? Surely there must exist some modifiers that speed up or slow down an ability, just like there is stuff to do the same for weapons (stimpack for example)?

Time scale I believe does this but be aware it speeds up the unit in every possible way.
 
Status
Not open for further replies.
Top