• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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,240
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: 58
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