| 08-03-2008, 03:47 AM | #1 |
The "caster" of this ability is supposed to charge at an enemy unit when issued an attack order to it. The problem is this: it does not charge when the target is right-clicked; I have to "A-left click" it for the effect to apply. How can I fix this? JASS:////////////////////////////////////////////////////////////////////////////// //BLOODLUST //============================================================================ //Effects: 1) When charging towards an enemy, the hero moves at a high // movement speed. // 2) Heals when kills an enemy by X; where X is a function of the // max HP of the killed unit. // 3) Attacks lower-HP targets quicker. ////////////////////////////////////////////////////////////////////////////// //CONSTANTS START// constant function BloodlustINT_AbilityIdCast takes nothing returns integer return 'A04P' endfunction constant function BloodlustINT_AbilityIdEffectMove takes nothing returns integer return 'A05B' //ITEM MOVE SPEED BONUS// endfunction constant function BloodlustINT_AbilityIdEffectAttack takes nothing returns integer return 'A05N' //ITEM ATTACK SPEED BONUS// endfunction constant function BloodlustINT_AbilityIdMarkerAttack takes nothing returns integer return 'A05I' endfunction constant function BloodlustR_HealPercentMultiplier takes nothing returns real return 0.15 endfunction constant function BloodlustR_TresholdPercentHP takes nothing returns real return 50.00 endfunction constant function BloodlustSTR_ModelNameFX1 takes nothing returns string return "" //FX FOR KILL HEAL// endfunction constant function BloodlustSND_FX1 takes nothing returns sound return gg_snd_AbilityBloodlustCharge1 //SOUND EFFECT OF CHARGE// endfunction constant function BloodlustSND_FX2 takes nothing returns sound return gg_snd_AbilityBloodlustCharge2 //SOUND EFFECT OF CHARGE// endfunction constant function BloodlustSND_FX3 takes nothing returns sound return gg_snd_AbilityBloodlustKill1 //SOUND EFFECT OF KILL// endfunction constant function BloodlustSND_FX4 takes nothing returns sound return gg_snd_AbilityBloodlustKill2 //SOUND EFFECT OF KILL// endfunction //CONSTANTS END// function Trig_Bloodlust_Conditions takes nothing returns boolean return (GetLearnedSkill() == BloodlustINT_AbilityIdCast()) and (GetUnitAbilityLevel(GetTriggerUnit(),BloodlustINT_AbilityIdCast()) == 1) endfunction function TRIG_BloodlustPursue_Conditions takes nothing returns boolean return (OrderId2String(GetIssuedOrderId()) == "attack") and IsUnitEnemy(GetOrderTargetUnit(),GetOwningPlayer(GetTriggerUnit())) and (GetUnitState(GetOrderTargetUnit(),UNIT_STATE_LIFE) > 0) endfunction function TRIG_BloodlustRemove_Conditions takes nothing returns boolean return ((OrderId2String(GetIssuedOrderId()) == "attack") and IsUnitEnemy(GetOrderTargetUnit(),GetOwningPlayer(GetTriggerUnit())) and (GetUnitState(GetOrderTargetUnit(),UNIT_STATE_LIFE) > 0)) == FALSE endfunction function TRIG_BloodlustRemove_Actions takes nothing returns nothing local unit U_Caster = GetTriggerUnit() call UnitRemoveAbility(U_Caster,BloodlustINT_AbilityIdEffectMove()) set U_Caster = null call DestroyTrigger(GetTriggeringTrigger()) endfunction function TRIG_BloodlustPursue_Actions takes nothing returns nothing local unit U_Caster = GetTriggerUnit() local integer INT_LevelAbilityCast = GetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdCast()) local trigger TRIG_BloodlustRemove = CreateTrigger() if (GetRandomInt(1,2) == 1) then call PlaySoundOnUnitBJ(BloodlustSND_FX1(),100.00,U_Caster) else call PlaySoundOnUnitBJ(BloodlustSND_FX2(),100.00,U_Caster) endif call UnitAddAbility(U_Caster,BloodlustINT_AbilityIdEffectMove()) call SetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdEffectMove(),INT_LevelAbilityCast) call TriggerRegisterUnitEvent(TRIG_BloodlustRemove,U_Caster,EVENT_UNIT_ISSUED_ORDER) call TriggerRegisterUnitEvent(TRIG_BloodlustRemove,U_Caster,EVENT_UNIT_ISSUED_POINT_ORDER) call TriggerRegisterUnitEvent(TRIG_BloodlustRemove,U_Caster,EVENT_UNIT_ISSUED_TARGET_ORDER) call TriggerAddCondition(TRIG_BloodlustRemove,Condition(function TRIG_BloodlustRemove_Conditions)) call TriggerAddAction(TRIG_BloodlustRemove,function TRIG_BloodlustRemove_Actions) set U_Caster = null endfunction function TRIG_BloodlustAttack_Conditions takes nothing returns boolean return (IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))) and (GetUnitAbilityLevel(GetAttacker(),BloodlustINT_AbilityIdCast()) > 0) endfunction function TRIG_BloodlustAttack_Actions takes nothing returns nothing local unit U_Caster = GetAttacker() local unit U_Target = GetTriggerUnit() local integer INT_LevelNew = 11 - R2I((GetUnitState(U_Target,UNIT_STATE_LIFE) / GetUnitState(U_Target,UNIT_STATE_MAX_LIFE)) * 10) call SetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdEffectAttack(),INT_LevelNew) call SetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdMarkerAttack(),(GetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdMarkerAttack()) + 1)) call TriggerSleepAction(1.00) call SetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdMarkerAttack(),(GetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdMarkerAttack()) - 1)) if (GetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdMarkerAttack()) == 1) then call SetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdEffectAttack(),1) endif set U_Caster = null set U_Target = null endfunction function TRIG_BloodlustKill_Conditions takes nothing returns boolean return IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetKillingUnit())) and (GetUnitAbilityLevel(GetKillingUnit(),BloodlustINT_AbilityIdCast()) > 0) endfunction function TRIG_BloodlustKill_Actions takes nothing returns nothing local unit U_Target = GetTriggerUnit() local unit U_Caster = GetKillingUnit() local real R_AmountHeal = GetUnitState(U_Target,UNIT_STATE_MAX_LIFE) * (GetUnitAbilityLevel(U_Caster,BloodlustINT_AbilityIdCast()) * BloodlustR_HealPercentMultiplier()) local texttag TT_Heal = CreateTextTag() local effect FX_Attachment = AddSpecialEffectTarget(BloodlustSTR_ModelNameFX1(),U_Caster,"chest") call PauseUnit(U_Caster,TRUE) call SetUnitAnimation(U_Caster,"victory") if (GetRandomInt(1,2) == 1) then call PlaySoundOnUnitBJ(BloodlustSND_FX3(),100.00,U_Caster) else call PlaySoundOnUnitBJ(BloodlustSND_FX4(),100.00,U_Caster) endif call SetUnitState(U_Caster,UNIT_STATE_LIFE,(GetUnitState(U_Caster,UNIT_STATE_LIFE) + R_AmountHeal)) call SetTextTagPosUnit(TT_Heal,U_Caster,90.00) call SetTextTagVisibility(TT_Heal,TRUE) call SetTextTagColor(TT_Heal,150,50,50,0) call SetTextTagText(TT_Heal,I2S(R2I(R_AmountHeal)),(75 * 0.023 / 10)) call SetTextTagPermanent(TT_Heal,FALSE) call SetTextTagLifespan(TT_Heal,1.00) call SetTextTagVelocity(TT_Heal,0.00,90.00) call TriggerSleepAction(1.00) call PauseUnit(U_Caster,FALSE) call SetUnitAnimation(U_Caster,"stand") call DestroyEffect(FX_Attachment) call DestroyTextTag(TT_Heal) set U_Target = null set U_Caster = null endfunction function Trig_Bloodlust_Actions takes nothing returns nothing local unit U_Caster = GetTriggerUnit() local trigger TRIG_BloodlustPursue = CreateTrigger() local trigger TRIG_BloodlustAttack = CreateTrigger() local trigger TRIG_BloodlustKill = CreateTrigger() call TriggerRegisterUnitEvent(TRIG_BloodlustPursue,U_Caster,EVENT_UNIT_ISSUED_TARGET_ORDER) call TriggerAddCondition(TRIG_BloodlustPursue,Condition(function TRIG_BloodlustPursue_Conditions)) call TriggerAddAction(TRIG_BloodlustPursue,function TRIG_BloodlustPursue_Actions) call UnitAddAbility(U_Caster,BloodlustINT_AbilityIdEffectAttack()) call UnitAddAbility(U_Caster,BloodlustINT_AbilityIdMarkerAttack()) call TriggerRegisterAnyUnitEventBJ(TRIG_BloodlustAttack,EVENT_PLAYER_UNIT_ATTACKED) call TriggerAddCondition(TRIG_BloodlustAttack,Condition(function TRIG_BloodlustAttack_Conditions)) call TriggerAddAction(TRIG_BloodlustAttack,function TRIG_BloodlustAttack_Actions) call TriggerRegisterAnyUnitEventBJ(TRIG_BloodlustKill,EVENT_PLAYER_UNIT_DEATH) call TriggerAddCondition(TRIG_BloodlustKill,Condition(function TRIG_BloodlustKill_Conditions)) call TriggerAddAction(TRIG_BloodlustKill,function TRIG_BloodlustKill_Actions) set U_Caster = null endfunction //==== Init Trigger Bloodlust ==== function InitTrig_Bloodlust takes nothing returns nothing set gg_trg_Bloodlust = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_Bloodlust,EVENT_PLAYER_HERO_SKILL) call TriggerAddCondition(gg_trg_Bloodlust,Condition(function Trig_Bloodlust_Conditions)) call TriggerAddAction(gg_trg_Bloodlust,function Trig_Bloodlust_Actions) endfunction |
| 08-03-2008, 08:40 AM | #2 |
A right click is actually the "smart" order. Not "attack". You have to check for the "smart" order, and if the target is an enemy. |
| 08-03-2008, 08:46 AM | #3 |
What's the OrderId of smart order? |
| 08-03-2008, 08:56 AM | #4 |
OrderId("smart") |
| 08-04-2008, 04:03 AM | #5 |
Will the "attack" order by attributed to the grunt still so that I can check if he is indeed attacking (as able to) the target unit (GetUnitCurrentOrder())? I'm considering the scenario when the "smart" order target is invulnerable. |
| 08-04-2008, 10:06 AM | #6 |
Check if the target is vunerable, ground, and a unit, as a unit can be smarted at the ground. (check for all targets he can, or the inverse if thats faster) that will tell you if hes able to attack it |
| 08-04-2008, 04:04 PM | #7 |
That's not enough, because an etheral unit can't be damaged if the attack type is not magic, and so one ... You could use the return boolean of the functions Issue...Order... First you need to check if the can unit can "setrally", then check the alliance between the attacking and attacked unit. ally = move, enemy == attack, dunno if the units are neutral. And so one ... |
| 08-04-2008, 04:11 PM | #8 |
When smart order is given, try issuing an attack order if the unit is an enemy unit. It will return a boolean value whether it is attackable or not. I think you could create a dummy unit with a dummy ability. There are many ways of doing this. |
| 08-04-2008, 04:14 PM | #9 | |
Quote:
EDIT : He only need to know if it's an attack or not, pretty easy |
| 08-05-2008, 02:53 PM | #10 | |
Quote:
If there is a chance that the attack is deactivated, the most practical way is to rely on the IssueTargetOrder native. AFAIK it will return the exact state whether the unit is able to attack. In this case, you only have to check that the target unit is an enemy unit. Edit: Actually if you just order attack, it would work without fuss because once its ordered via IssueTargetOrder, the event would fire and the condition will be fulfilled- meaning proper activation of the spell. |
| 08-05-2008, 03:05 PM | #11 |
I was just talking about the dummy unit idea. Bad quote ... |
