HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Attaching and detaching item triggers

02-20-2004, 12:12 AM#1
Whitehorn
I'm setting up something that you would think simple.

Unit picks up sword item, attach sword model to right hand.
Unit loses (drops) sword item, destroy special effect attachment.

Here's the attach (which works fine):

Code:
Frozen Demon Sword Add
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item carried by (Triggering unit) of type Frozen Demon Sword)) Equal to Frozen Demon Sword
    Actions
        Special Effect - Create a special effect attached to the hand right of (Triggering unit) using DemonSword.mdx

And my start of the detach trigger:

Code:
Frozen Demon Sword Lose
    Events
        Unit - A unit Loses an item
    Conditions
        (Item-type of (Last dropped item)) Equal to Frozen Demon Sword
    Actions
        [b][i]Special Effect - Destroy ...[/i][/b][i][/i]

Now, how do I actually remove the attachment. The options using that action are either 'destroy last effect' (won't work when I have lots of effects going on) or using a variable.

So, anyone care to explain how I can set-up a special effect class variable?
02-20-2004, 12:17 AM#2
DoCa-Cola
ok, make an array, a special effect array specifically, and when you add the effect, do - Set EFFECT[#] = Last created effect

then, when you want to destroy it, just do destroy EFFECT[#]
02-20-2004, 12:31 AM#3
Whitehorn
Translating word for word...

Code:
Frozen Demon Sword Add
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item carried by (Triggering unit) of type Frozen Demon Sword)) Equal to Frozen Demon Sword
    Actions
        Special Effect - Create a special effect attached to the hand right of (Triggering unit) using DemonSword.mdx
        Set fds_attach[1] = (Last created special effect)


Code:
Frozen Demon Sword Lose
    Events
        Unit - A unit Loses an item
    Conditions
        (Item-type of (Last dropped item)) Equal to Frozen Demon Sword
    Actions
        Special Effect - Destroy fds_attach[1]
02-20-2004, 12:35 AM#4
DoCa-Cola
Yes, that should do the trick.

-DoCa
02-20-2004, 12:41 AM#5
Whitehorn
But it doesn't :(
02-20-2004, 01:00 AM#6
Shimrra
Quote:
(Item-type of (Item carried by (Triggering unit) of type Frozen Demon Sword)) Equal to Frozen Demon Sword
Why does it say equal to Demon Sword? Shouldn't it say equal to true?
02-20-2004, 01:08 AM#7
Whitehorn
Well, that works either way.

Anyway, hold on, the model I used has no death animation, so it loops the stand anim when 'destroyed'... I hope. finding out now.
02-20-2004, 01:08 AM#8
weaaddar
Not what you want to hear but Dt4a handles all this mess fairly easily. (define the item and the model it uses and it'll make sure when removed it gets destroyed etc.)
02-20-2004, 01:35 AM#9
Whitehorn
Sorted... needed to set condition to 'item being manipulated' and the sword now has a death anim!
02-20-2004, 02:23 AM#10
ObsidianTitan
Since you having it attach when picked up, and detached when removed, triggers is the difficult way to do it.

The easiest way to do it would make an ability for the item based off an ability that creates a model on the unit, examples are orbs/war banner/maybe sphere. Change the model to the one that you want, and change the attachment points. Then simply give the ability to the item.

there is a tutorial for it here
02-20-2004, 02:39 AM#11
Whitehorn
Yeah someone shouted "Orb", and I looked at item abilities, attachment locations... and well, what a waste of time.