Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Computer to 'autocast'

Discussion in 'Triggers & Scripts' started by CaptainHero, Nov 8, 2014.

  1. CaptainHero

    CaptainHero

    Joined:
    Sep 30, 2012
    Messages:
    197
    Resources:
    1
    Spells:
    1
    Resources:
    1
    So yeah, i got some new buff spells, but however i still use all of the old ones. So now i want to create a system, so that PC players cast the dummy spells, whenever they 'attack', then checking if a valid target is in range and if it hasn't got the buff already (in this example its called bloodlust, later it won't).

    So i hope its clear that i can't just base it on bloodlust, since other buffs will be applied..

    The problem i'm now facing is that whenever the potential caster attacks and finds a valid target, he just freezes and waits till all potential targets drop dead or his health drop and the ai pulls the unit back...
    Well occasionally he does cast the spell and all looks good, but he will certainly freeze at one point.

    Any ideas why this might be the case?

    Is there already a working system on the hive? I did some research and all i could find was, base your buffs on buffs that wc3 already uses, and then the original autocast will work fine, well that won't do it for me..

    PS: The dummy spell is "channel" with the base/order id of holy light, and then another system spawns a dummy caster to cast "bloodlust"
    - no problems there

    Triggers
    • AIA Copy
      • Events
        • Unit - A unit Is attacked
      • Conditions
      • Actions
        • Set TempUnit = (Attacking unit)
        • Set tempPlayer = (Owner of TempUnit)
        • Set DBoolean = False
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (tempPlayer controller) Equal to Computer
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of TempUnit) Equal to Footman
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Mana of TempUnit) Greater than or equal to 140.00
                  • Then - Actions
                    • Set TempPoint = (Position of TempUnit)
                    • Set TempUnitGroup = (Units within 800.00 of TempPoint)
                    • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                      • Loop - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • ((Picked unit) has buff Bloodlust) Equal to False
                            • ((Picked unit) is alive) Equal to True
                            • ((Picked unit) is A structure) Equal to False
                            • ((Picked unit) is Mechanical) Equal to False
                            • ((Picked unit) is Magic Immune) Equal to False
                            • ((Picked unit) is A sapper) Equal to False
                            • ((Picked unit) is hidden) Equal to False
                            • (Percentage life of (Picked unit)) Less than 100.00
                            • Or - Any (Conditions) are true
                              • Conditions
                                • ((Picked unit) belongs to an ally of tempPlayer) Equal to True
                                • (Owner of (Picked unit)) Equal to tempPlayer
                          • Then - Actions
                            • Unit Group - Add (Picked unit) to TempUnitGroup2
                            • Set DBoolean = True
                          • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • DBoolean Equal to True
                      • Then - Actions
                        • Set TempUnit2 = (Random unit from TempUnitGroup2)
                        • Unit - Order TempUnit to Human Paladin - Holy Light TempUnit2
                      • Else - Actions
                  • Else - Actions
              • Else - Actions
          • Else - Actions
        • Set TempUnit = No unit
        • Set TempUnit2 = No unit
        • Unit Group - Remove all units from TempUnitGroup
        • Unit Group - Remove all units from TempUnitGroup2
        • Unit Group - Remove all units from TempUnitGroup3
        • Custom script: set udg_tempPlayer = null
        • Custom script: call DestroyGroup(udg_TempUnitGroup)
        • Custom script: call DestroyGroup(udg_TempUnitGroup2)
        • Custom script: call DestroyGroup(udg_TempUnitGroup3)
        • Custom script: call RemoveLocation( udg_TempPoint )
     
  2. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    780
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    A unit is attacked triggers when the attacker starts its attack animation, not when he actually deals damage. I would suggest you use some kind of damage detection system, there are a handful on the hive you can choose from.

    You dont need to remove all units from the groups; they are getting destroyed.
    You arent using TmpUnitGroup3, but I guess you forgot to remove that.
    Also combine the first three if/then/else statements.
     
  3. CaptainHero

    CaptainHero

    Joined:
    Sep 30, 2012
    Messages:
    197
    Resources:
    1
    Spells:
    1
    Resources:
    1
    But i like it like that. I don't want to add a passive ability when the unit deals damage with his basic attack, i do like my units casting spells. And when the ai thinks this is a good time to attack, then this should trigger "oh even better lets cast a spell instead!" Thats exactly what i want, however maybe the ai then aborts the spell and forces the unit to attack again, that could explain the freeze; the ai struggling to take control^^

    - good to know.
    - yeah had a version with all potential casters in a group but that made no sense, only made it more complicated
    - i want to add 9 more potential autocasting units with various spells and different mana costs later..
     
  4. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    780
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    Just create a dummy unit and make it cast the spell you want.