• 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.

[JASS] attaching models with jass

Status
Not open for further replies.
Level 11
Joined
Feb 18, 2004
Messages
394
Using special effects. Attatch a special effect with the modle of a gun to a unit's hand attatchemnt point. i think its "hand left" and "hand right" (maybe the reverse order of words)

JASS:
native AddSpecialEffectTarget takes string modelName, widget targetWidget, string attachPointName returns effect
Widgets are items, units, and destructables. Remember, effects will leak unless destroyed
JASS:
native DestroyEffect takes effect whichEffect returns nothing
 
Level 11
Joined
Feb 18, 2004
Messages
394
Widgets are items, units, and destructables.

type widget extends handle
type unit extends widget
type item extends widget
type destructable extends widget

So, a unit-type value, item-type value, or destructable-type value. eg:
JASS:
call AddSpecialEffectTarget("bleh/bleh.mdx", GetTriggerUnit(), "hand left")

much like a function that takes "handle" can be passed any child type of handle.
 
Level 4
Joined
Mar 21, 2007
Messages
88
[/QUOTE]
JASS:
call AddSpecialEffectTarget("bleh/bleh.mdx", GetTriggerUnit(), "hand left")
[/QUOTE]

so in bleh/bleh is the model or the unit getting it attached to? (kinda new to JASS)
 
Level 11
Joined
Feb 18, 2004
Messages
394
The first paramiter is the path to the model. so if you imported an axe model at "weapons/axe.mdx", pass "weapons/axe.mdx" as the first paramiter. The second param is the widget to attatch the model to. the final paramiter is the attatchment point.
 
Level 4
Joined
Mar 21, 2007
Messages
88
ok now i have a leak with my code whats wrong with it?
JASS:
native AddSpecialEffectTarget takes string modelMWP_Minigunattachment, widget targetdDevastatorMarine, string attachRightHand returns effect
call AddSpecialEffectTarget(MWP_MinigunAttachment.mdx, GetTriggerUnit(), left hand)
native DestroyEffect takes effect whichEffect returns nothing
 
Last edited:
Level 4
Joined
Mar 21, 2007
Messages
88
attaching models leak

i got a leak in this code but i can't figure out what it is.. can someone help me?
JASS:
native AddSpecialEffectTarget takes string modelMWP_Minigunattachment, widget targetdDevastatorMarine, string attachRightHand returns effect
call AddSpecialEffectTarget(MWP_MinigunAttachment.mdx, GetTriggerUnit(), left hand)
native DestroyEffect takes effect whichEffect returns nothing
:confused:
 
Level 4
Joined
Mar 21, 2007
Messages
88
thanks a lot i think i've got it. are the color brackets needed?:confused:

this is it right?

JASS:
native AddSpecialEffectTarget takes string modelName, widget targetWidget, string attachPointName returns effect
call AddSpecialEffectTarget("MWP_Minigun.mdx", GetTriggerUnit(), "hand right")
native DestroyEffect takes effect whichEffect returns nothing
call DestroyEffect( GetLastCreatedEffect ) 
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand left"
DestroyEffect(udg_SomeEffect)
 
Level 3
Joined
May 28, 2007
Messages
57
The bracket at the end of
JASS:
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand left"
Where as it should be
JASS:
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand left")
because you should be getting a compile error.
 
Level 11
Joined
Feb 18, 2004
Messages
394
You seem to think having the native declirations in your code is nessisary...
.... they define functions that are implimented in the engine itself, as opposed to directly in JASS. they go in common.j, and those 2 functions are alredy in there. its like trying to define the same function twice... why?
 
Level 4
Joined
Mar 21, 2007
Messages
88
ok i'm reeeaaally confused... how is all this supposed to be ordered?:eekani::confused:

JASS:
native AddSpecialEffectTarget takes string modelDevastation Marine, widget targetWidget, string attachPointName returns effect
call AddSpecialEffectTarget("MWP_Minigun.mdx", GetTriggerUnit(), "hand right")
native DestroyEffect takes effect whichEffect returns nothing
call DestroyEffect( GetLastCreatedEffect ) 
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand right")
DestroyEffect(udg_SomeEffect)
this is starting to look like a waste since i could just do
  • Special Effect - Create a special effect attached to the right hand of (Triggering unit) using MWP_MinigunAttachment.mdx
lol woops o_O
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
No, it's just as easy in JASS, you just don't get how.

Let's say you have a global Special Effect called SomeEffect.

You would write

JASS:
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand right" )
//later, when you want to destroy it
call DestroyEffect( udg_SomeEffect )

Or, preferrably, use locals. (note that locals must be defined at the start of a function)

JASS:
local effect e = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand right" )
//later, when you want to destroy it
call DestroyEffect( e )

And the DoNothingEx function is a joke in my signature... no idea why you put that in your code :p

(edited my signature so that this kind of mistake doesn't happen again... it's happened a few times already, people don't see the little seperation bar apparently)
 
Level 4
Joined
Mar 21, 2007
Messages
88
PLEASE TELL ME THIS IS IT....
JASS:
set udg_SomeEffect = AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "hand left")
call DestroyEffect(udg_SomeEffect)

now i need to know what to change to make it attach to a certain unit >.>
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
But AddSpecialEffectTarget already attaches to a unit, you put Triggering Unit as an argument. You attached that effect to the left hand of Triggering Unit, but I'm not sure about this "hand left", I think it should be "left hand". It seems like you don't understand this at all. Btw, you destroyed the effect right after you created it, don't you won't it to be destroyed a little after that?
 
Level 3
Joined
May 28, 2007
Messages
57
now i need to know what to change to make it attach to a certain unit >.>
1. Yes you have it correct, but don't destroy the effect straight away ;)
2. Just change GetTriggerUnit() to what ever unit you want Ex: gg_unit_Hmkg_0032 this is the mountain king. always use gg_unit than the name of the unit "Hmkg" is the basic 4 string code for the mountain king and the number is the unit's number in the map.

Edit Sorry Silvenon posted the same time i did.
 
Level 4
Joined
Mar 21, 2007
Messages
88
thats just it Silvenon i don't understand it cause i just started using JASS when i was asked to help in a map so i'm just trying to learn it as fast as i can but no one makes it simple and gives me the exact code in everyway it's needed to be. i need to attach my minigun model to devastation marine's left hand but no one understands what i asked for. i just wanted the code not a lecture about it i know what it does just not how to set it up...

but still why would i want to destroy the effect i want it to stay on the unit the whole game
 
Level 3
Joined
May 28, 2007
Messages
57
The reason everyone adds that destroy effect code is because in your first post you said
i got a leak in this code but i can't figure out what it is.. can someone help me?
JASS:
native AddSpecialEffectTarget takes string modelMWP_Minigunattachment, widget targetdDevastatorMarine, string attachRightHand returns effect
call AddSpecialEffectTarget(MWP_MinigunAttachment.mdx, GetTriggerUnit(), left hand)
native DestroyEffect takes effect whichEffect returns nothing
so people thought you where asking why you got a leak in those two codes and so forth.
 
Level 4
Joined
Mar 21, 2007
Messages
88
i know but now i'm asking for the code and still no one understands that if they just give me the flippin code this could be done with!!! O.O
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Calm down, Jamaka. Everything is ok, we're just trying to help you. I think this is what you need:

JASS:
call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", DevastatorMarine, "left hand")


DevastatorMarine is a variable that holds that marine, you can put anything you want here, but note that units already on the map have the prefix 'gg_unit_' and global variables have prefix 'udg_'. If this still isn't clear, just post your code and we'll tell you what you should do, or just use GUI.
 
Level 4
Joined
Mar 21, 2007
Messages
88
so which one would i use for mulitiple devastator marines? this is the code i have so far.
JASS:
native AddSpecialEffectTarget takes string modelMWP_Minigunattachment, widget targetdDevastatorMarine, string attachRightHand returns effect
call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", GetTriggerUnit(), "left hand")
native DestroyEffect takes effect whichEffect returns nothing
 
Level 12
Joined
Aug 3, 2005
Messages
745
this
Code:
call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx",GetTriggerUnit(), "left hand")

Is fine on its own.
If you want to Destroy the added effect in one go, (dont do this is you want a permenant effect attached.

Can just do
JASS:
call DestroyEffect(AddSpecialEffectTarget(effect,unit, attachment))
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Your 'actions' function looks something like this, right?

JASS:
function Trig_AttachModel_Actions
    call AddSpecialEffectTarget....blabla
endfunction

So, if you want to attach the gun to multiple marines, you just add more lines, like in GUI:

JASS:
function Trig_AttachModel_Actions
    call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", Marine1, "left hand")
    call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", Marine2, "left hand")
    call AddSpecialEffectTarget("MWP_MinigunAttachment.mdx", Marine3, "left hand")
    //......and so on
endfunction

So, if the marine(s) is already on the map, make a GUI action(s) that includes that marine(s), example, Unit - Kill Unit. Then convert it to JASS, copy the gg_unit_blabla part and put it instead of that Marine1/2/3 (I was just giving an example with those). And please stop adding those natives, they already exist in WE. So what you are doing is using those natives. Is everything clear now? If not, read some more JASS tutorials damnit! And btw, Daelin's/Vexorian's JASS tutorial is the best
 
Level 4
Joined
Mar 21, 2007
Messages
88
thanks Fulla thats all i needed. also i wanted to use jass not gui cause GUI screws some other stuff i have on my map for sum reason... i dunno why but oh well i just needed that one code that attaches the model for the whole game.. is it so hard to ask for? o_O
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Umm GUI can do the same thing witout all of the hassle

1) if you stick with GUI forever, how will you learn? ;)

2) GUI is slower to write, once you get used to using JASS

3) in general, GUI is less efficient. Thus, restricting yourself to GUI due to the fact that you haven't learned some of the most handy JASS functions isn't a very good idea x.x
 
Level 4
Joined
Mar 21, 2007
Messages
88
thats wat i'm saying GUI was annoying to me and i found it easier to do things with JASS (reviving spawning ect.) but i'm still learning how to use it
 
Level 4
Joined
Mar 21, 2007
Messages
88
everyone has a different answer and code i just wanna know which one works how i want it. the double thread was an axident:bored:
 
Status
Not open for further replies.
Top