• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

NON PERMANENT CHARM

Status
Not open for further replies.
Level 4
Joined
Apr 13, 2006
Messages
83
I made a variation of "charm" that would allow the hero to target other heroes but would last only for a few seconds, but for some reason it ignores the time I set on the "duration time" space.
Then I made a trigger wich was

Event:
If a unit changes owner
Condition:
Unit target of ability being cast equal to a hero
Action
wait 5 seconds
Change owner of "owner changed unit" to "last owner"


or something like that, but it would obviously switch between owners once and again!!!
What can I do to make my ability work?
HELP ME PLEASE!!!!
 
Level 2
Joined
Dec 18, 2005
Messages
28
I would recomand you to do this in JASS with local vars to make it multiinstanceable. I would do it like this:
JASS:
function Trig_charm_Conditions takes nothing returns boolean
    if ( GetSpellAbilityId() == 'ANch') then
        if(IsUnitType(GetSpellTargetUnit(), UNIT_TYPE_HERO) == true) then
           return TRUE
        endif
    endif
return FALSE
endfunction

function Trig_charm_Actions takes nothing returns nothing
    local unit targetunit = GetSpellTargetUnit()
    local player realplayer = GetOwningPlayer(GetSpellTargetUnit())
    local real duration = ( 3.00 * I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetTriggerUnit())) )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 6
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if( CheckItemStatus(UnitItemInSlotBJ(targetunit, GetForLoopIndexA()), bj_ITEM_STATUS_SELLABLE) == true )then
            call SetItemDroppableBJ( UnitItemInSlotBJ(targetunit, GetForLoopIndexA()), false )
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call PolledWait(duration)
    call SetUnitOwner( targetunit, realplayer, true )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 6
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if( CheckItemStatus(UnitItemInSlotBJ(targetunit, GetForLoopIndexA()), bj_ITEM_STATUS_SELLABLE) == true )then
            call SetItemDroppableBJ( UnitItemInSlotBJ(targetunit, GetForLoopIndexA()), true )
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===================================================
function InitTrig_charm takes nothing returns nothing
    set gg_trg_charm = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_charm, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_charm, Condition( function Trig_charm_Conditions ) )
    call TriggerAddAction( gg_trg_charm, function Trig_charm_Actions )
endfunction

Use the charm ability as basic and change its allowed targets field to Air, Ground, Enemy. Now you if you cast the ability on normal creeps its permanent, else if you cast on heros it will only last for a certain duration.
First thing you'll have to do is to change the raw code of your ability in the conditions trigger (i took the standard charm raw code) and for the duration just change the real value of "duration" in the actions trigger. I also added a loop that makes all sellable items in the inventory of the target hero undropable, so people dont abuse this skill to steal items, just make sure all items that you use in the map and want them to be undropable to set them as unsellable in the editor so this skill doesnt affect them after the duration when it changes all items back to dropable.
 
Level 4
Joined
Apr 13, 2006
Messages
83
I MADE IT!!!!
I KNOW ITS SOMETHING FOOLISH AND EASY BUT IT MAKES ME PROUD OF MYSELF!!!!!!!! :D :D

I MADE IT WITH THIS TRIGGERS:

EVENTS
Unit - A unit Begins channeling an ability

CONDITIONS
ABILITY BEING CAST = DARK SIDE OF THE FORCE

ACTIONS
Set LASTDARKEDUNIT = (Owner of (Target unit of ability being cast))

Set DARKPLAYER = (TARGET UNIT OF SPELL BEING CAST)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of (Ability being cast) for (Casting unit)) Equal to 1
Then - Actions
Wait 7.00 seconds
Unit - Change ownership of darkplayer to LASTDARKEDUNIT and Change color
Item - Make (Item carried by darkplayer in slot 1) Droppable
Item - Make (Item carried by darkplayer in slot 2) Droppable
Item - Make (Item carried by darkplayer in slot 3) Droppable
Item - Make (Item carried by darkplayer in slot 4) Droppable
Item - Make (Item carried by darkplayer in slot 5) Droppable
Item - Make (Item carried by darkplayer in slot 6) Droppable
Else - Actions
Trigger - Run Dark Side 2 <gen> (ignoring conditions)



_____________________________________________________


DARK SIDE 2


If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of (Ability being cast) for (Casting unit)) Equal to 2
Then - Actions
Wait 9.00 seconds
Unit - Change ownership of (Target unit of ability being cast) to LASTDARKEDUNIT and Change color
Item - Make (Item carried by darkplayer in slot 1) Droppable
Item - Make (Item carried by darkplayer in slot 2) Droppable
Item - Make (Item carried by darkplayer in slot 3) Droppable
Item - Make (Item carried by darkplayer in slot 4) Droppable
Item - Make (Item carried by darkplayer in slot 5) Droppable
Item - Make (Item carried by darkplayer in slot 6) Droppable
Else - Actions
Trigger - Run Dark Side 3 <gen> (ignoring conditions)



-----------------------------------------------------

DARK SIDE 3



If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of (Ability being cast) for (Casting unit)) Equal to 1
Then - Actions
Wait 12.00 seconds
Unit - Change ownership of (Target unit of ability being cast) to LASTDARKEDUNIT and Change color
Item - Make (Item carried by darkplayer in slot 1) Droppable
Item - Make (Item carried by darkplayer in slot 2) Droppable
Item - Make (Item carried by darkplayer in slot 3) Droppable
Item - Make (Item carried by darkplayer in slot 4) Droppable
Item - Make (Item carried by darkplayer in slot 5) Droppable
Item - Make (Item carried by darkplayer in slot 6) Droppable
Else - Actions
Do nothing




THANKS TO THE ONES THAT HELPED ME!!!
 
Level 2
Joined
Dec 18, 2005
Messages
28
Well, your spell is not multiinstanceable, as soon as 2 ppl would use the skill in the same time it would screw the game since one of them wouldnt get his hero back. And I also have to mention that your code is senseless long you could have just used:
Code:
Wait x[(Level of (Ability being cast) for (Triggering unit))] seconds
where x is an real array of 3 and stores the duration of your spell at each level
 
Status
Not open for further replies.
Top