HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Special Effects for one player

11-04-2005, 05:47 PM#1
Soultaker
Hi All!

I was wondering if one could create a special effect that only shows for one player, and that works on B-Net.

It is intented for on a unit and should follow the unit, or I will create the trigger for that later.

-Soultaker
11-04-2005, 07:21 PM#2
Zoxc
Add custom script: if GetLocalPlayer() = Player(0) then
Your SFX code
(Watch out for server splits)

And custom script: endif
11-04-2005, 08:43 PM#3
Soultaker
Quote:
Originally Posted by Zoxc
Add custom script: if GetLocalPlayer() = Player(0) then
Your SFX code
(Watch out for server splits)

And custom script: endif

Hmmm, I'm not very good at Jass/Custom Script, but are you sure that GetLocalPlayers works on B-Net? I have seen some splits with it... But I will test it out anyways.. thanks a lot :)

Btw. I guess that "Player(0)" is where I should put the player number :P Could you give me a "Player(Owner of triggering unit)" with no memory leaks please?

Thank you

Edit: I need it to be on a unit, will that work too?

-Soultaker
11-04-2005, 09:20 PM#4
Tim.
GetLocalPlayer does desync a lot of functions, however as far as I am aware a special effect will be fine.
11-04-2005, 09:27 PM#5
Soultaker
Quote:
Originally Posted by Tim.
GetLocalPlayer does desync a lot of functions, however as far as I am aware a special effect will be fine.

Okay, thanks :)

Could you please show me one code of line that shows me how to do this as I can't make it work?

Should be something like this:

Code:
Custom script: if GetLocalPlayer() = Player(0) then call AddSpecialEffectTargetUnitBJ( "overhead", GetSpellTargetUnit(), "Abilities\\Spells\\Other\\Drain\\ManaDrainTarget.mdl" )

But I can't make it work.. also if you could edit "GetSpellTargetUnit" to a unit variable, that would be nice :P

Thanks...

-Soultaker
11-05-2005, 12:26 AM#6
LegolasArcher
Quote:
Originally Posted by Soultaker
Quote:
Originally Posted by Tim.
GetLocalPlayer does desync a lot of functions, however as far as I am aware a special effect will be fine.

Okay, thanks :)

Could you please show me one code of line that shows me how to do this as I can't make it work?

Should be something like this:

Code:
Custom script: if GetLocalPlayer() = Player(0) then call AddSpecialEffectTargetUnitBJ( "overhead", GetSpellTargetUnit(), "Abilities\Spells\Other\Drain\ManaDrainTarget.mdl" )

But I can't make it work.. also if you could edit "GetSpellTargetUnit" to a unit variable, that would be nice :P

Thanks...

-Soultaker

JASS functions cannot be combined onto one lines like most programming languages. Also, you forgot the "endif", and that backslashes must be escaped in JASS strings.

Collapse JASS:
if GetLocalPlayer() = Player(0) then
    call AddSpecialEffectTargetUnitBJ( "overhead", GetSpellTargetUnit(), "Abilities\Spells\Other\Drain\ManaDrainTarget.mdl" )
endif
11-05-2005, 08:58 AM#7
Anitarf
As far as I remember, special effects are handle objects (like units, locations, groups...), creating one for a single player will desync because of the difference made on the handle stack.

But there's a way around this, you can create a special effect for all players, but with different models, thus making it invisible for all but one player.

Collapse JASS:
    local string s = ""
    if GetLocalPlayer() == GetOwningPlayer( GetTriggerUnit() ) then
        set s = "AbilitiesSpellsOtherDrainManaDrainTarget.mdl"
    endif
    call AddSpecialEffectTarget( s , GetSpellTargetUnit(), "overhead" )
11-05-2005, 12:57 PM#8
LegolasArcher
Antarf's code should work flawlessly, and I believe he is correct about handles on Bnet games. Please note that locals are slightly screwy when you use them in the GUI, since the WE defines tons of new functions when they're (In my opinion) completely useless. Your best bet might be to plop the code Antarf gave you into a function, and call that from the GUI custom script action:

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local s = ""
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    call AddSpecialEffectTarget(s, u, attachpt)
endfunction

Drop that into the map header, then just call it like so when you wish to create a player-specific floating text:

Collapse JASS:
call AddSpecialEffectTargetForPlayer("Abilities\\Spells\\Other\\DrainManaDrainTarget.mdl", GetSpellAbilityUnit(), "overhead", GetOwningPlayer(GetTriggerUnit()))

Also note that every \ in the path must be followed by a second \. Since \ is the escape character, you must place it twice in a row to prevent errors.
11-05-2005, 09:33 PM#9
Soultaker
Quote:
Originally Posted by LegolasArcher
Antarf's code should work flawlessly, and I believe he is correct about handles on Bnet games. Please note that locals are slightly screwy when you use them in the GUI, since the WE defines tons of new functions when they're (In my opinion) completely useless. Your best bet might be to plop the code Antarf gave you into a function, and call that from the GUI custom script action:

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local s = ""
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    call AddSpecialEffectTarget(s, u, attachpt)
endfunction

Drop that into the map header, then just call it like so when you wish to create a player-specific floating text:

Collapse JASS:
call AddSpecialEffectTargetForPlayer("Abilities\Spells\Other\DrainManaDrainTarget.mdl", GetSpellAbilityUnit(), "overhead", GetOwningPlayer(GetTriggerUnit()))

Also note that every in the path must be followed by a second . Since is the escape character, you must place it twice in a row to prevent errors.

Hmm, I can't get this to work in WE or WE Unlimited... When I try to save the map with that in the map code, it just says that everything is an error..

It starts with that
Code:
local s = ""
is an error, then it continues with everything else, including my triggers that has nothing to do with that..

-Soultaker
11-06-2005, 03:15 AM#10
LegolasArcher
Ah yes, sorry, it was a typo:

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local string s = ""
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    call AddSpecialEffectTarget(s, u, attachpt)
endfunction

Sorry, once again, I don't have access to the editor to make sure this works.
11-06-2005, 10:17 AM#11
Soultaker
Quote:
Originally Posted by LegolasArcher
Ah yes, sorry, it was a typo:

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local string s = ""
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    call AddSpecialEffectTarget(s, u, attachpt)
endfunction

Sorry, once again, I don't have access to the editor to make sure this works.

Nop, that doesn't work either, that just makes the WE crash when I try to save the map ^^

Thanks for trying :P

-Soultaker
11-06-2005, 01:01 PM#12
Anitarf
Quote:
Originally Posted by Soultaker
Nop, that doesn't work either, that just makes the WE crash when I try to save the map ^^
That means that actually it does work. :) Because it does, the checker manages to come to another bug, which causes the crash. Let me guess, you forgot to double all the "\\" in the path.

There's a list of known bugs (including bugs that cause the editor to crash while saving) here.
11-06-2005, 02:43 PM#13
LegolasArcher
Quote:
Originally Posted by Anitarf
Quote:
Originally Posted by Soultaker
Nop, that doesn't work either, that just makes the WE crash when I try to save the map ^^
That means that actually it does work. :) Because it does, the checker manages to come to another bug, which causes the crash. Let me guess, you forgot to double all the "\" in the path.

There's a list of known bugs (including bugs that cause the editor to crash while saving) here.

Actually he was correct, I made an error and called the function instead of returning the special effect. This works, I just tested it (Finally on a computer with WE )

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local string s = ""
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    return AddSpecialEffectTarget(s, u, attachpt)
endfunction
11-06-2005, 07:57 PM#14
Soultaker
Quote:
Originally Posted by LegolasArcher
Quote:
Originally Posted by Anitarf
Quote:
Originally Posted by Soultaker
Nop, that doesn\'t work either, that just makes the WE crash when I try to save the map ^^
That means that actually it does work. :) Because it does, the checker manages to come to another bug, which causes the crash. Let me guess, you forgot to double all the \"\" in the path.

There\'s a list of known bugs (including bugs that cause the editor to crash while saving) here.

Actually he was correct, I made an error and called the function instead of returning the special effect. This works, I just tested it (Finally on a computer with WE )

Collapse JASS:
function AddSpecialEffectTargetForPlayer takes string file, unit u, string attachpt, player p returns effect
    local string s = \"\"
    if (GetLocalPlayer() == p) then
        set s = file
    endif
    return AddSpecialEffectTarget(s, u, attachpt)
endfunction

Thanks, it works now, but instead of putting it on the \"Target unit of ability being cast\" it puts it on the casting unit...

Here is the trigger:

Code:
Select Target
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Select Target 
    Actions
        Set CurrentTarget[(Player number of (Owner of (Triggering unit)))] = (Target unit of ability being cast)
        Multiboard - Set the text for (Last created multiboard) item in column 2, row ((Player number of (Owner of (Triggering unit))) + 1) to (((Name of (Owner of CurrentTarget[(Player number of (Owner of (Triggering unit)))])) + \'s ) + (Name of CurrentTarget[(Player number of (Owner of (Triggering unit)))]))
        Custom script:   call AddSpecialEffectTargetForPlayer(\"Abilities\\Spells\\Other\\Aneu\\AneuCaster.mdl\", GetSpellAbilityUnit(), \"overhead\", GetOwningPlayer(GetTriggerUnit()))
        Set CurrentTargetEffect[(Player number of (Owner of (Triggering unit)))] = (Last created special effect)

Should be no problem :P

-Soultaker
11-07-2005, 10:15 AM#15
Anitarf
GetSpellAbilityUnit() gives you the caster. GetSpelltargetUnit() gives you the target.