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

[General] Attaching certain model to units

Status
Not open for further replies.
Level 4
Joined
Feb 9, 2010
Messages
48
Greetings,

I'm trying to create certain mechanics for a unit:

Flying machine is supposed to pick up explosive barrel, getting a new ability to throw the explosive barrel and the graphics of explosive barrel attached to origin point of unit. Upon casting the ability, he loses the ability, explosion happens and attachment model of explosive barrel is removed.

Everything except for the underlined part works. For the attachment, I'm using 'Item armor bonus' with:
Art - Target: Barrel of Explosives
Art - Target attachment point: origin
...
Art - Target attachments: 1

So the problem is following:

I can't seem to attach 'Barrel of Explosives' model to a unit. If I pick a missle or unit as the model of attachment everything seems to work perfectly. However I need the explosive barrel to be attached to the unit.

I do know that I could go around it and create a trigger of "Create speciall effect at the origin point with explosive barrel model" which works exactly as I want the above spell to work, however attachments can't be easily removed after the flying machine drops the explosive barrel. Which excludes triggers, unless I'm missing something here.

Any help is appreciated.
 
Level 12
Joined
Jan 2, 2016
Messages
973
Well, it will work pretty easily with triggers. You can easily remove the barrel by doing something like this (you need a hashtable on your map):
JASS:
local effect barrel = AddSpecialEffectTarget( /*the barrel path*/, GetTriggerUnit(), "origin")
call SaveEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl', barrel)
set barrel = null

//The above actions should happen in the trigger, responsible for adding the barrel, while the next actions should be in a trigger, which runs when activating the other spell:

local effect barrel = LoadEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl')
call DestroyEffect(barrel)
set barrel = null

//Do have in mind that you could do these in just 1 row as well:
call SaveEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl', AddSpecialEffectTarget( /*the barrel path*/, GetTriggerUnit(), "origin"))
call DestroyEffect(LoadEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl'))
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
Do note that destroying special effect models plays both death and then decay animation if available. If those animations are not available then it waits until end of current animation before removal.

This is where SC2 is a lot more powerful as you have full control over attachments.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
@WereElf you are not removing the effect from the hashtable.

@Dr Super Good I know other games that handle their user API better as well... but that doesnt really help much.

@Ilusioner
Try to use a different model than the explosive barrels.
I think there shouldnt be any difference so if you wont see the barrels, then you wont see the other model either, but it is worth a try.
If it doesnt work, then try to base your ability of Sphere (Human) and change the attachment points/model.

If neither work, then you might indeed want to trigger it. (It can equally as easy be done in GUI.)
 
Level 11
Joined
Jun 2, 2004
Messages
849
Double check that the unit you're giving the attachment to actually has an origin point.

IIRC I had a similar problem with the explosive barrels, but I was able to get it to show up on units' chest attachment point when applied with triggers.
 
Level 12
Joined
Jan 2, 2016
Messages
973
@WereElf you are not removing the effect from the hashtable.
Yeah, kind a forgot to add the FlushChildHashtable, but if it's a hero skill, then it pretty much becomes like a global variable. Sooner or later it will be used again (by the same unit), thus refilling the same slot. In which case it wouldn't matter much if it's flushed or not.
However, if it's a unit skill, then indeed Flushing the hashtable is needed :p
 
Level 4
Joined
Feb 9, 2010
Messages
48
Well, it will work pretty easily with triggers. You can easily remove the barrel by doing something like this (you need a hashtable on your map):
JASS:
local effect barrel = AddSpecialEffectTarget( /*the barrel path*/, GetTriggerUnit(), "origin")
call SaveEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl', barrel)
set barrel = null

//The above actions should happen in the trigger, responsible for adding the barrel, while the next actions should be in a trigger, which runs when activating the other spell:

local effect barrel = LoadEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl')
call DestroyEffect(barrel)
set barrel = null

//Do have in mind that you could do these in just 1 row as well:
call SaveEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl', AddSpecialEffectTarget( /*the barrel path*/, GetTriggerUnit(), "origin"))
call DestroyEffect(LoadEffectHandle(udg_Table, GetHandleId(GetTriggerUnit()), 'barl'))

My knowledge of JASS is simply non-existant, that's why if you could be so nice and create an empty map with just that mechanic it would be great. I'd be able to simply copy the trigger and then change the abilities/units.

To clarify, the flying machine is not a hero, just a regular unit that player would be able to create up to ~15 or something like that. So multiply units picking up the explosive barrel and throwing it has to be implemented into it.

However, won't this trigger cause any leaks or other unwanted lags? 'Cause the map I'm trying to do is something in size of LTA/AW:LR, so quite big. Triggers which leak or cause lag problems are definetely out of question.


@WereElf you are not removing the effect from the hashtable.

@Dr Super Good I know other games that handle their user API better as well... but that doesnt really help much.

@Ilusioner
Try to use a different model than the explosive barrels.
I think there shouldnt be any difference so if you wont see the barrels, then you wont see the other model either, but it is worth a try.
If it doesnt work, then try to base your ability of Sphere (Human) and change the attachment points/model.

If neither work, then you might indeed want to trigger it. (It can equally as easy be done in GUI.)

The problem is that I need those explosive barrels to be the model. I've tried searching for a custom model that would resemble the needed model, but the closest I found was explosive oil cask, which doesn't fit into the map.

I've tried with sphere ability and got the same result, attaching missle works, but attaching explosive barrel gives no effect.



Double check that the unit you're giving the attachment to actually has an origin point.

IIRC I had a similar problem with the explosive barrels, but I was able to get it to show up on units' chest attachment point when applied with triggers.

Yep, it has the origin point, as stated in the first post when I try attaching for example unit or missle it works perfectly.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
What barrel model do you use? TNT barrels works fine to attach in a unit's attachment points. Also destroying the attached TNT barrel plays death animation which creates explosion together with the TNT barrel removed.
 
Last edited:
Level 4
Joined
Feb 9, 2010
Messages
48
What barrel model do you use? TNT barrels works fine to attach in a unit's attachment points. Also destroying the attached TNT barrel plays death animation which creates explosion together with the TNT barrel removed.

I've clearly stated what model I need to use. Not sure if by TNT barrels you mean the regular WC3's Explosive Barrel or some custom imported one, in case you have something like it would be great to get the link to it. However if you are refering to explosive barrel, you can't attach that model to any model. Not with spells atleast.

Greetings,

I'm trying to create certain mechanics for a unit:

Flying machine is supposed to pick up explosive barrel, getting a new ability to throw the explosive barrel and the graphics of explosive barrel attached to origin point of unit. Upon casting the ability, he loses the ability, explosion happens and attachment model of explosive barrel is removed.

Everything except for the underlined part works. For the attachment, I'm using 'Item armor bonus' with:
Art - Target: Barrel of Explosives
Art - Target attachment point: origin
...
Art - Target attachments: 1

So the problem is following:

I can't seem to attach 'Barrel of Explosives' model to a unit. If I pick a missle or unit as the model of attachment everything seems to work perfectly. However I need the explosive barrel to be attached to the unit.

I do know that I could go around it and create a trigger of "Create speciall effect at the origin point with explosive barrel model" which works exactly as I want the above spell to work, however attachments can't be easily removed after the flying machine drops the explosive barrel. Which excludes triggers, unless I'm missing something here.

Any help is appreciated.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Barrel of Explosives <Base> translated into path: "Units\Other\TNTBarrel\TNTBarrel.mdl"
And attaching it to a unit works fine.
~Tested

Only one barrel of explosives model given in default so obviously I'm not referring to any custom imported models maybe you've just misunderstood the name.
 
Level 4
Joined
Feb 9, 2010
Messages
48
Barrel of Explosives <Base> translated into path: "Units\Other\TNTBarrel\TNTBarrel.mdl"
And attaching it to a unit works fine.
~Tested

Only one barrel of explosives model given in default so obviously I'm not referring to any custom imported models maybe you've just misunderstood the name.

It indeed works, just had to use the custom path instead of picking unit from model list. Splendid. Thanks a lot to everyone involved!
 
Status
Not open for further replies.
Top