| 03-23-2006, 04:53 AM | #1 |
I'm working on a custom attack system. For the most part it works but some things like animation and unit dying and stuff isn't working just right. Here is the code: JASS:function Trig_Untitled_Trigger_001_Func001Func004A takes nothing returns nothing call RemoveUnit( GetEnumUnit() ) endfunction function Trig_Untitled_Trigger_001_Func001Func009A takes nothing returns nothing call RemoveUnit( GetEnumUnit() ) endfunction function attacks takes integer p, unit AttackingUnit, unit AttackedUnit returns nothing if GetPlayerController(GetOwningPlayer(AttackingUnit)) == MAP_CONTROL_USER then loop exitwhen udg_Moves[p] == true call PolledWait(udg_Main_Attack_Speed[p]) call StartTimerBJ( udg_CombatCheckTimer[GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))], false, 3.00 ) set udg_InCombat[GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))] = true call IssueTargetOrderBJ( AttackedUnit, "banish", AttackingUnit ) call SetUnitAnimation(AttackedUnit, "Attack" ) call UnitDamageTargetBJ( AttackingUnit, AttackedUnit, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL ) call PolledWait(0.50) call SetUnitAnimation(AttackedUnit, "Stand" ) call ForGroupBJ( GetUnitsOfPlayerAndTypeId(ConvertedPlayer(GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))), 'o001'), function Trig_Untitled_Trigger_001_Func001Func009A ) endloop else loop exitwhen udg_Moves[p] == true call PolledWait(2.00) call StartTimerBJ( udg_CombatCheckTimer[GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))], false, 3.00 ) set udg_InCombat[GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))] = true call SetUnitAnimation(AttackedUnit, "Attack" ) call UnitDamageTargetBJ( AttackingUnit, AttackedUnit, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL ) call PolledWait(0.50) call SetUnitAnimation(AttackedUnit, "Stand" ) call ForGroupBJ( GetUnitsOfPlayerAndTypeId(ConvertedPlayer(GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))), 'o001'), function Trig_Untitled_Trigger_001_Func001Func004A ) endloop endif set udg_Moves[p] = false endfunction |
| 03-23-2006, 03:59 PM | #2 |
You can use SetUnitAnimation on units that are dead, so if a unit dies of the UnitDamageTargetBJ, 0.5 sec after that you will set its animation to "stand". Simply add a check if the unit is dead before you set the animation. |
| 03-23-2006, 05:58 PM | #3 |
I had killed a unit and that dying unit continued to attack me as he faded away. Here is my new code, sadly its still not working right. When unit dies death animation is not instant and enemy unit is playing attack animation but my hero is. I want this to be as smooth just like the attack thats built in. Reason I need my own attack system done by triggers is cause I'm using a special formula to figure out damage and also I need to trigger dodge, parry and crit into it as certain spells can only be cast after certain events like dodge. JASS:function Trig_Untitled_Trigger_001_Func001Func004A takes nothing returns nothing call RemoveUnit( GetEnumUnit() ) endfunction function Trig_Untitled_Trigger_001_Func001Func009A takes nothing returns nothing call RemoveUnit( GetEnumUnit() ) endfunction function attacks takes integer p, unit AttackingUnit, unit AttackedUnit returns nothing if GetPlayerController(GetOwningPlayer(AttackingUnit)) == MAP_CONTROL_USER then loop if GetUnitStateSwap(UNIT_STATE_LIFE, AttackedUnit) == 0.00 then call IssueImmediateOrderBJ(AttackingUnit, "stop" ) call IssueImmediateOrderBJ(AttackedUnit, "death" ) set udg_Moves[p] = true endif if GetUnitStateSwap(UNIT_STATE_LIFE, AttackingUnit) == 0.00 then call IssueImmediateOrderBJ(AttackingUnit, "death" ) call IssueImmediateOrderBJ(AttackedUnit, "stop" ) set udg_Moves[p] = true endif exitwhen udg_Moves[p] == true call StartTimerBJ( udg_CombatCheckTimer[GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))], false, 3.00 ) set udg_InCombat[GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))] = true call IssueTargetOrderBJ( AttackedUnit, "banish", AttackingUnit ) call SetUnitAnimation(AttackedUnit, "Attack" ) call UnitDamageTargetBJ( AttackingUnit, AttackedUnit, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL ) call SetUnitAnimation(AttackedUnit, "Stand" ) call ForGroupBJ( GetUnitsOfPlayerAndTypeId(ConvertedPlayer(GetConvertedPlayerId(GetOwningPlayer(AttackingUnit))), 'o001'), function Trig_Untitled_Trigger_001_Func001Func009A ) call PolledWait(udg_Main_Attack_Speed[p]) endloop set udg_Moves[p] = false else loop if GetUnitStateSwap(UNIT_STATE_LIFE, AttackedUnit) == 0.00 then call IssueImmediateOrderBJ(AttackingUnit, "stop" ) call IssueImmediateOrderBJ(AttackedUnit, "death" ) set udg_Moves[p] = true endif if GetUnitStateSwap(UNIT_STATE_LIFE, AttackingUnit) == 0.00 then call IssueImmediateOrderBJ(AttackingUnit, "death" ) call IssueImmediateOrderBJ(AttackedUnit, "stop" ) set udg_Moves[p] = true endif exitwhen udg_Moves[p] == true call StartTimerBJ( udg_CombatCheckTimer[GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))], false, 3.00 ) set udg_InCombat[GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))] = true call SetUnitAnimation(AttackingUnit, "Attack" ) call UnitDamageTargetBJ( AttackingUnit, AttackedUnit, 5.00, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL ) call SetUnitAnimation(AttackingUnit, "Stand" ) call ForGroupBJ( GetUnitsOfPlayerAndTypeId(ConvertedPlayer(GetConvertedPlayerId(GetOwningPlayer(AttackedUnit))), 'o001'), function Trig_Untitled_Trigger_001_Func001Func004A ) call PolledWait(2.00) endloop set udg_Moves[p] = false endif endfunction Trigger: Melee
|
| 03-23-2006, 08:33 PM | #4 |
updated last post |
