• 🏆 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!

Mountain giant

Status
Not open for further replies.
Level 7
Joined
Nov 19, 2007
Messages
253
Hey everyone,

Is there any way to add tree to mountain giant without using "war club" ability. I want to make ability when mountain giant uses roar he gets tree in his hand, is that possible?
 
The tree he holds doesn't have a texture of its own, so you really need some sort of a trick here. I made it for you, it's in Jass though, because it would require a timer and I wouldn't want to muddle with countdown timers of GUI. Anyway, since the effect you need will result a disable of a certain ability (War Club), this very ability can only be MPI, not MUI. So, here:
JASS:
function Trig_Roar_Copy_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001' and GetUnitTypeId(GetTriggerUnit()) != 'emtg'
endfunction

function SpellDuration takes nothing returns real //This function
    return 20.                                    //gives the duration of the Roar ability,
endfunction                                       //so as to make the replacement afterwards.

function TimedReplace takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId (t)
    local unit u = LoadUnitHandle (udg_RHash, id, StringHash("mainunit"))
    local unit u1 = LoadUnitHandle (udg_RHash, id, StringHash("secunit"))
    local real x = GetUnitX (u1)
    local real y = GetUnitY (u1)
    call SetUnitFacing (u, GetUnitFacing (u1))
    call KillUnit (u1)
    call RemoveUnit (u1)
    call SetUnitX (u, x)
    call SetUnitY (u, y)
    call ShowUnit (u, true)
    call SetPlayerAbilityAvailable (GetOwningPlayer(u), 'Agra', true)
    call SelectUnitForPlayerSingle (u, GetOwningPlayer(u))
    call FlushChildHashtable (udg_RHash, id)
    call DestroyTimer (t)
    set t = null
    set u = null
    set u1 = null
endfunction

function Trig_Roar_Copy_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX (u)
    local real y = GetUnitY (u)
    local real x1 = GetRectCenterX (udg_region)
    local real y1 = GetRectCenterY (udg_region)
    local unit a = CreateUnit (GetOwningPlayer(u), 'emtg', x1, y1, GetUnitFacing(u))
    local timer t = CreateTimer()
    local integer id = GetHandleId (t)
    local real duration = SpellDuration()
    local destructable d = CreateDestructable ('B000', x, y, 0, 0.001, 1)
    call IssueTargetDestructableOrder (a, "grabtree", d)
    call ShowUnit (u, false)
    call SetUnitX (a, x)
    call SetUnitY (a, y)
    call SetUnitFacing (a, GetUnitFacing(u))
    call SelectUnitForPlayerSingle (a, GetOwningPlayer(u))
    call SetPlayerAbilityAvailable (GetOwningPlayer(u), 'Agra', false)
    call SaveUnitHandle (udg_RHash, id, StringHash("mainunit"), u)
    call SaveUnitHandle (udg_RHash, id, StringHash("secunit"), a)
    call PolledWait (0.3)
    call IssueImmediateOrder (a, "roar")
    call TimerStart (t, duration, false, function TimedReplace)
    set u = null
    set a = null
    set d = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Roar_Jass_With_Timer takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Roar_Copy_Conditions ) )
    call TriggerAddAction( t, function Trig_Roar_Copy_Actions )
endfunction
  • Map Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set region = Region 000 <gen>
      • Hashtable - Create a hashtable
      • Set RHash = (Last created hashtable)
Test Map:

View attachment Roar with Grab Tree animation (MPI).w3x

Note: It's not flawless (it uses PolledWait and it can't be MPI with this method, but I couldn't come up with another way), but it does the job pretty good.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
can be done easier

  • RoarEatTree
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Roar
    • Actions
      • Custom script: local destructable d = CreateDestructable('B000',GetUnitX(GetTriggerUnit())+100*CosBJ(GetUnitFacing(GetTriggerUnit())),GetUnitY(GetTriggerUnit())+100*SinBJ(GetUnitFacing(GetTriggerUnit())),0,1,0)
      • Player - Enable War Club Custom for (Owner of (Triggering unit))
      • Unit - Add War Club Custom to (Triggering unit)
      • Custom script: call IssueTargetDestructableOrder (GetTriggerUnit(), "grabtree", d)
      • Player - Disable War Club Custom for (Owner of (Triggering unit))
      • Wait 2.00 game-time seconds
      • Custom script: call RemoveDestructable(d)
      • Custom script: set d = null
the tree is created in front of the caster so he won't turn around while casting
and I have to use the BJs else the line will be too long

edit: congratulations to your 4000th post pharao :)
 

Attachments

  • RoarTreeEat.w3x
    18 KB · Views: 67
Level 7
Joined
Nov 19, 2007
Messages
253
Well D4rk G4nd4lf this works fine but how do i remove that tree animation when roar buff ends?

Pharoah i copied everything in my map but it doesnt work for me. And what does Roar and Roar (fake roar) do? why there are two skills ?

BTW i dont like jass because i dont understand a shit about it.. so anykind of editing in it is just too hard for me.
JASS:
function Trig_War_Club_Copy_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A06W' and GetUnitTypeId(GetTriggerUnit()) != 'U005'
endfunction

function SpellDuration takes nothing returns real //This function
    return 20.                                    //gives the duration of the Roar ability,
endfunction                                       //so as to make the replacement afterwards.

function TimedReplace takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId (t)
    local unit u = LoadUnitHandle (udg_RHash, id, StringHash("mainunit"))
    local unit u1 = LoadUnitHandle (udg_RHash, id, StringHash("secunit"))
    local real x = GetUnitX (u1)
    local real y = GetUnitY (u1)
    call SetUnitFacing (u, GetUnitFacing (u1))
    call KillUnit (u1)
    call RemoveUnit (u1)
    call SetUnitX (u, x)
    call SetUnitY (u, y)
    call ShowUnit (u, true)
    call SetPlayerAbilityAvailable (GetOwningPlayer(u), 'Agra', true)
    call SelectUnitForPlayerSingle (u, GetOwningPlayer(u))
    call FlushChildHashtable (udg_RHash, id)
    call DestroyTimer (t)
    set t = null
    set u = null
    set u1 = null
endfunction

function Trig_War_Club_Copy_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX (u)
    local real y = GetUnitY (u)
    local real x1 = GetRectCenterX (udg_region)
    local real y1 = GetRectCenterY (udg_region)
    local unit a = CreateUnit (GetOwningPlayer(u), 'U005', x1, y1, GetUnitFacing(u))
    local timer t = CreateTimer()
    local integer id = GetHandleId (t)
    local real duration = SpellDuration()
    local destructable d = CreateDestructable ('B000', x, y, 0, 0.001, 1)
    call IssueTargetDestructableOrder (a, "grabtree", d)
    call ShowUnit (u, false)
    call SetUnitX (a, x)
    call SetUnitY (a, y)
    call SetUnitFacing (a, GetUnitFacing(u))
    call SelectUnitForPlayerSingle (a, GetOwningPlayer(u))
    call SetPlayerAbilityAvailable (GetOwningPlayer(u), 'Agra', false)
    call SaveUnitHandle (udg_RHash, id, StringHash("mainunit"), u)
    call SaveUnitHandle (udg_RHash, id, StringHash("secunit"), a)
    call PolledWait (0.3)
    call IssueImmediateOrder (a, "roar")
    call TimerStart (t, duration, false, function TimedReplace)
    set u = null
    set a = null
    set d = null
    set t = null
endfunction

//===========================================================================
function InitTrig_War_Club takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_War_Club_Copy_Conditions ) )
    call TriggerAddAction( t, function Trig_War_Club_Copy_Actions )
endfunction
 
Last edited:
Level 19
Joined
Feb 4, 2009
Messages
1,313
Well D4rk G4nd4lf this works fine but how do i remove that tree animation when roar buff ends?

easy
change the "Art - Animation Names" from "spell,eattree" to "spell" or "spell,slam" or anything else you want
just like with any other ability
keep in mind that you have to copy all abilities, the tree and to change the raw data ids for the tree, the abilities etc. (press "ctrl + d" to convert from normal objectnames to raw data)
the attached image shows how the editor will look like if you press "ctrl + d"
 

Attachments

  • raw data.png
    raw data.png
    52.4 KB · Views: 127
And that is why I used two units, because I knew such a problem would come up. I made it working with a normal unit, not a hero. For your hero case, it needs many calculations, such as Unspent Skill Points, Hero XP, Hero Level, Hero Agility, Hero Strength, Hero Intelligence, which will be reapplied, once the original unit that casted the ability returns, after the spell's duration.

It didn't work for you, because your rawcodes were wrong.
 
Status
Not open for further replies.
Top