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

[Trigger] Flashbang Spell

Status
Not open for further replies.
Level 15
Joined
Jun 11, 2007
Messages
969
Hi! I am making an AoS type map, trying to make it as unique as possible. The map is about a virus which infects the game, causing different gaming characters, divided into 2 teams, battle against each other.

Now one of the characters is a Counter-Terrorist, and one of his abilities is Flashbang. I've based the spell on Storm Bolt. What I want it to do, is to create a White Fade Filter for the targeted player for 2x(Current Level of ability) seconds. This will make the player completely blinded, but still able to move, attack etc, but as said unable to see anything.

Now I've gotten to the Event and Conditions in the trigger, but I've no idea how to implent proper Actions.

If anyone could help me on this one, I would be greatly thankful. If it can't be done in GUI, then Jass is ofcoarse an option, but personally I've no experience in Jass, so I would need some help. :thumbs_up:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Use GetLocalPlayer to fade a player locally (so it does not fade on the other player's computers).
Be aware that anything player inhibitave is not to be recommended, as there are local work arounds as well and it messes up other things like being able to read tooltips as well.
 
Level 9
Joined
Apr 25, 2009
Messages
468
Or, you pick every player who has a unit nearby the caster (Player Group) and change the fog for the players, create a large white fog for them?
 
Level 9
Joined
Apr 25, 2009
Messages
468
So, you pick every targeted player...?
That's what I meant with the Player Group, pick every player that are effected by the spell and create the fog?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
GetLocalPlayer() returns the player who's PC executes it. Thus in multiplayer each player runs that with the value of their player in its place. Thus in a condition, you can get it to run an action that affects everyone for only them, thus it affects only them. Poor usage of it though can result in OOS (splits) so do not do anything gameplay changing or random in it.
 
Level 9
Joined
Apr 25, 2009
Messages
468
Haha ye ;)

  • Your Trigger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to <Your Spell>
    • Actions
      • Set PlayerGroup = (All players matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • Environment - Set fog to style Linear, z-start <Value>, z-end <Value>, density <Value> and color (<Value>%, <Value>%, <Value>%)
      • -------- When you are done with all your Actions, do this --------
      • Custom script: call DestroyForce(udg_PlayerGroup)
Also, create a timer for how long you want the flash to be, then when the timer expires, do this:
  • When your timer expires
    • Actions
      • Environment - Reset fog to default values
 
Level 15
Joined
Jun 11, 2007
Messages
969
Hey HaniBon. I tryed that out, couldn't make it work. As timer I created a Timer Variable, One-Shot Timer, then 2xlevel of ability of unit.
I tryed out using Storm Bolt and Shadow Strike as base spell, neither got it working.

To test it, I set'd Set PlayerGroup = (All players matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True)) to (All Players), so that I could see if it worked.
 
Level 15
Joined
Jun 11, 2007
Messages
969
Yeah, I mean I changed it so that I could test the spell =D
It it had worked, then I would've been flashed myself when I casted the spell, which I didn't. I will post my trigger here, see what you can do.

  • FlashbangSpell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to flashbang (1)
    • Actions
      • Set PlayerGroup = (All players)
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • Environment - Set fog to style Exponential 1, z-start 1000.00, z-end 8000.00, density 50.00 and color (100.00%, 0.00%, 0.00%)
          • Countdown Timer - Start Timer as a One-shot timer that will expire in (2.00 x (Real((Level of flashbang (1) for (Casting unit))))) seconds
          • Environment - Reset fog to default values
      • Custom script: call DestroyForce(udg_PlayerGroup)
And the variables are;
Player Group - Player Group - Empty Player Group (Default)
Timer - Timer - New Timer (Default)

Notice any leaks?
 
Level 8
Joined
Aug 4, 2006
Messages
357
  • FlashbangSpell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to flashbang (1)
    • Actions
      • Set PlayerGroup = (All players)
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • Environment - Set fog to style Exponential 1, z-start 1000.00, z-end 8000.00, density 50.00 and color (100.00%, 0.00%, 0.00%)
          • Countdown Timer - Start Timer as a One-shot timer that will expire in (2.00 x (Real((Level of flashbang (1) for (Casting unit))))) seconds
          • Environment - Reset fog to default values
      • Custom script: call DestroyForce(udg_PlayerGroup)
I would like to point out two problems with this.
1. "Environment - Set fog..." changes the fog for all players. you are changing all players' fog, every loop through the group. If PlayerGroup has 5 players, you will change all players' fog 5 times. You need to use JASS to make this effect work.
2. Your countdown timer doesn't do anything. You are resetting the fog immediately after starting the timer. GUI will not wait for the timer to expire to run the next line.

I'll try working on a JASS trigger for this spell. I'll post it when done.
 
Level 9
Joined
Apr 28, 2009
Messages
538
the reason you cannot do such thing is because you cannot create Environment effects for only a specific player.
Same thing with cinematics, sadly.

However, if you find a solution to create a cinematic for a specific player only, you can use this trigger for making a more easy-to-made flashbang effect.
(The "fog" from environment can, and it will cause lag)

  • Cinematic - Fade out and back in over 5.00 seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 0.00% transparency
However, you should make 2 lines, one with "Fade in in 1.5 seconds" and another one, "Fade out in 10 seconds"
 
Level 10
Joined
Jun 1, 2008
Messages
485
try this, it use GetLocalPlayer, and, as mentioned by Dr Super Good, it can disconnect player.
  • Flashbang
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flashbang
    • Actions
      • Player Group - Pick every player in (All enemies of (Owner of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Custom script: if (GetLocalPlayer()==GetEnumPlayer()) then
          • Cinematic - Fade out and back in over (2.00 x (Real((Level of (Ability being cast) for (Triggering unit))))) seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 0.00% transparency
          • Custom script: endif
 
Level 8
Joined
Aug 4, 2006
Messages
357
okay i finished it. i've tested it and it only flashes enemy players in the radius. i am pretty sure the way i used local player won't desync, but i would like a more experienced JASSer to clarify. oh and this is all regular jass, so you don't have to recompile it.

okay so here is the custom text of the trigger:
JASS:
//======SETUP (STUFF YOU CAN CHANGE)========
function Trig_flashbang_Radius takes integer spellLevel returns real
    //this is the flash effect radius, depending on the ability level
    return 300.0 + 200*spellLevel
endfunction

function Trig_flashbang_Duration takes integer spellLevel returns real
    //this calculates the duration
    return 2.0*spellLevel
endfunction

function Trig_flashbang_AbilityId takes nothing returns integer
    //replace AHtb with the raw code of your flashbang spell.
    //to find the raw code value, go to object editor, click the view tab, and click "display values as raw data."
    //you should now see the raw values next to the names of everything
    return 'AHtb'
endfunction

//=======CONDITIONS===========

function Trig_flashbang_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == Trig_flashbang_AbilityId() )
endfunction

//========ACTIONS==============

//put this next function in your map header if you want to use it outside this trigger
function CinematicFadeForPlayer takes player whichPlayer, integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
    if(GetLocalPlayer() == whichPlayer)then
        call CinematicFadeBJ(fadetype, duration, tex, red, green, blue, trans)
    endif
endfunction

function Trig_flashbang_filter takes nothing returns boolean
    return ( IsPlayerEnemy( GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetTriggerUnit()) ) )
endfunction

function Trig_flashbang_ForGroupActions takes nothing returns nothing
    local player owningPlayer = GetOwningPlayer(GetEnumUnit())
    call CinematicFadeForPlayer(owningPlayer, bj_CINEFADETYPE_FADEOUT, .1, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0)
endfunction

function Trig_flashbang_ForGroupActions2 takes nothing returns nothing
    local player owningPlayer = GetOwningPlayer(GetEnumUnit())
    call CinematicFadeForPlayer(owningPlayer, bj_CINEFADETYPE_FADEIN, Trig_flashbang_Duration( GetUnitAbilityLevel(GetTriggerUnit(), Trig_flashbang_AbilityId()) )/2, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100, 100, 100, 0)
endfunction

function Trig_flashbang_Actions takes nothing returns nothing
    local integer skillLevel = GetUnitAbilityLevel(GetTriggerUnit(), Trig_flashbang_AbilityId())
    local unit target = GetSpellTargetUnit()
    local real targetX = GetUnitX(target)
    local real targetY = GetUnitY(target)
    local group affectedUnits = CreateGroup()
    call GroupEnumUnitsInRange(affectedUnits, targetX, targetY, Trig_flashbang_Radius(skillLevel), Condition(function Trig_flashbang_filter))
    call ForGroup(affectedUnits, function Trig_flashbang_ForGroupActions )
    //this next line is a bad function to use, but the alternative method is too much work without using JassNewGenPack (vJass)
    call TriggerSleepAction ( .1+Trig_flashbang_Duration(skillLevel)/2 )
    call ForGroup(affectedUnits, function Trig_flashbang_ForGroupActions2 )

    call DestroyGroup(affectedUnits)
    set affectedUnits = null
    set target = null
endfunction

//========EVENTS==============

function InitTrig_flashbang takes nothing returns nothing
    set gg_trg_flashbang = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_flashbang, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_flashbang, Condition( function Trig_flashbang_Conditions ) )
    call TriggerAddAction( gg_trg_flashbang, function Trig_flashbang_Actions )
endfunction

to use it, create a new trigger called "flashbang" in GUI. click edit --> convert to custom text, and delete everything. copy/paste the above bunch of code in there. find out the raw value of your flashbang ability, and copy it into the AbilityId function (there's more details about that in the setup section). i think that's about all there is to it. let me know if you have any questions

oh and here's a test map to see how it works. the trigger is set to go off when a unit casts storm bolt. look at the difference between when you cast storm bolt, and when an enemy casts it on you.
 

Attachments

  • flashbang.w3x
    18.5 KB · Views: 47
Level 15
Joined
Jun 11, 2007
Messages
969
@maskedpoptart! Thank you very much, worked perfectly =D I had some problems importing it to my map, but I realised that there couldn't be a capital letter on flashbang >.<

@Mage_Goo; Well thank you to for trying, but as maskedpoptarts worked I'll just go with that ^^ Thanks anyway, all of ya =D

You can set it to solved.

Edit; Realised it isn't that thread :3
 
Status
Not open for further replies.
Top