• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Change unit model in game

Status
Not open for further replies.
Level 4
Joined
Oct 2, 2011
Messages
89
I am trying to find a way to change the model of a unit in game (when the player picks up a certain item). I have seen where some people do this by basing the morph off of an ability, but the problem for me is there are many different items that the player could get (but only one at a time), and I think if I base the switch off of an ability, it would not work for as many switches as I would need. I know you can replace unit in game, and I think I can use that instead (with also transferring all of the items and such as well), but I think there would be a problem with that. How could I transfer the buffs? Does anybody know either a better way of changing the unit when the player picks up an item or know how to transfer everything (buffs, etc.) to a new unit?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You could use multiple levels on the morph ability. Each level is linked to an item type, with a hashtable for example.

When you use an item, load the correct level from a hashtable and set the ability level accordingly.


  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set trht = (Last created hashtable)
      • -------- ---------------------------------------- --------
      • Set trab = Transform
      • -------- ---------------------------------------- --------
      • -------- Claws of Attack +15 --------
      • Custom script: set udg_i = 'ratf'
      • Hashtable - Save 1 as 0 of i in trht
      • -------- Crown of Kings +5 --------
      • Custom script: set udg_i = 'ckng'
      • Hashtable - Save 2 as 0 of i in trht
      • -------- Kelen's Dagger of Escape --------
      • Custom script: set udg_i = 'desc'
      • Hashtable - Save 3 as 0 of i in trht
      • -------- ---------------------------------------- --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable trab for (Player((Integer A)))
  • Untitled Trigger 002
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_trht, GetItemTypeId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Player - Enable trab for (Triggering player)
          • Unit - Remove trab from (Triggering unit)
          • Unit - Add trab to (Triggering unit)
          • Unit - Set level of trab for (Triggering unit) to i
          • Unit - Order (Triggering unit) to Night Elf Demon Hunter - Metamorphosis
          • Player - Disable trab for (Triggering player)
        • Else - Actions
  • Untitled Trigger 002 Copy
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_trht, GetItemTypeId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Unit - Remove trab from (Triggering unit)
          • Unit - Add trab to (Triggering unit)
        • Else - Actions


The acquires/loses an item are just example events.
 

Attachments

  • TransTest.w3x
    15.8 KB · Views: 59
Last edited:
Level 4
Joined
Oct 2, 2011
Messages
89
You could use multiple levels on the morph ability. Each level is linked to an item type, with a hashtable for example.

When you use an item, load the correct level from a hashtable and set the ability level accordingly.


  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set trht = (Last created hashtable)
      • -------- ---------------------------------------- --------
      • Set trab = Transform
      • -------- ---------------------------------------- --------
      • -------- Claws of Attack +15 --------
      • Custom script: set udg_i = 'ratf'
      • Hashtable - Save 1 as 0 of i in trht
      • -------- Crown of Kings +5 --------
      • Custom script: set udg_i = 'ckng'
      • Hashtable - Save 2 as 0 of i in trht
      • -------- Kelen's Dagger of Escape --------
      • Custom script: set udg_i = 'desc'
      • Hashtable - Save 3 as 0 of i in trht
      • -------- ---------------------------------------- --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable trab for (Player((Integer A)))
  • Untitled Trigger 002
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_trht, GetItemTypeId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Player - Enable trab for (Triggering player)
          • Unit - Remove trab from (Triggering unit)
          • Unit - Add trab to (Triggering unit)
          • Unit - Set level of trab for (Triggering unit) to i
          • Unit - Order (Triggering unit) to Night Elf Demon Hunter - Metamorphosis
          • Player - Disable trab for (Triggering player)
        • Else - Actions
  • Untitled Trigger 002 Copy
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Custom script: set udg_i = LoadInteger(udg_trht, GetItemTypeId(GetManipulatedItem()), 0)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Not equal to 0
        • Then - Actions
          • Unit - Remove trab from (Triggering unit)
          • Unit - Add trab to (Triggering unit)
        • Else - Actions


The acquires/loses an item are just example events.

Wow... Thank you very much for this. :goblin_yeah: The way I was going to do it would have taken a lot longer.

EDIT: One thing though, would it by chance be possible to have multiple abilities like this implemented in the map? (of course on different units)
 
Level 4
Joined
Oct 2, 2011
Messages
89
Thanks for what you have done, as this system is almost exactly what I need. However, in order to tweak this so it is exactly how I need it, I need to understand some things about your code.
You have used the
JASS:
set udg_i = '<someitem>'
where <someitem> has been the different items (crown of kings, etc.), but what is this actually doing? i is an integer, so how are you assigning an item to an integer? :vw_wtf:
 
Status
Not open for further replies.
Top