Spire's Question Thread!(Generous with rep ^^)

Joker(Div)

Always Here..
Reaction score
86
First Trigger seems fine.

Second Trigger, where did you set your "Damage taken" variable? Also, turning on the "Retribution Damage" trigger is unnecesary. Just keep the Third trigger on.

Third Trigger, use this
Code:
Actions
    Floating Text - Change (Last created floating text): Disable permanence
    Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds

instead of this
Code:
        Wait 3.00 game-time seconds
        Floating Text - Destroy (Last created floating text)

Your problem is most likely in your variables
 
S

spiremk

Guest
Tom Jones: The problem is if you want to set it to 'damage taken', you will have to set it to Specific Unit. And Specific Unit doesn't allow you to specify any sort of variables; it only allows you to choose units currently off the map...

My variables are correct.... I believe the problem lies with the event: 'a unit is attacked'... How do I change this to 'damage taken'?
 

Tom Jones

N/A
Reaction score
437
Anyways, what your trying to do is hopeless in GUI. The first time the trigger runs, it'll work fine, however the next time it'll double fire. Jass is the only working solution for this.
*Edit*
>Tom Jones: The problem is if you want to set it to 'damage taken', you will have to set it the Specific Unit. And Specific Unit doesn't allow you to specific any sort of variables; it only allows you to choose units currently off the map...

It allows you to use a trigger unit... Unit - A unit is attacked returns a trigger unit... I fail to see the problem here :)
 
S

spiremk

Guest
Sorry Tom, I still don't understand you... can you give me a trigger as an example?

'A unit attacked returns a trigger unit' --- What does this mean?
 

Tom Jones

N/A
Reaction score
437
No, I didn't say that because that's not correct. The event does exits, however it requires a unit.
 
S

spiremk

Guest
-.- Tom, I need some further and clearer explanation....

You are just talking in circles now...

So how exactly do you do this 'triggering unit'?
 

Tom Jones

N/A
Reaction score
437
Code:
Test
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
       Trigger - Add to Test Copy <gen> the event (Unit - (Triggering unit) Takes damage)
Code:
Test Copy
    Events
    Conditions
    Actions
        Unit - Kill (Triggering unit)
This will kill the unit who started the effect if it takes damage.
*Edit*
If your interrested this is the jass script for Retribution. You'll need a game cache variable named gc and copy paste this to your map header:
Code:
constant function LocalVars takes nothing returns gamecache
    return udg_gc
endfunction
//Local Handle Vars by Kattana//////////////////////////////////////////////////
//Modified by Tom Jones///////////////////////////////////////////////////////
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function SetHandleHandle takes integer i, handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes integer i, handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes integer i, handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes integer i, handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes integer i, handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name, value)
    endif
endfunction


function GetHandleHandle takes integer i, handle subject, string name returns handle
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes integer i, handle subject, string name returns integer
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes integer i, handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes integer i, handle subject, string name returns real
    return GetStoredReal(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction
function GetHandleString takes integer i, handle subject, string name returns string
    return GetStoredString(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes integer i, handle subject, string name returns unit
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes integer i, handle subject, string name returns timer
    return GetStoredInteger(LocalVars(),GetObjectName(i)+ I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes integer i, handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes integer i, handle subject, string name returns effect
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes integer i, handle subject, string name returns group
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes integer i, handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes integer i, handle subject, string name returns widget
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrackable takes integer i, handle subject, string name returns trackable
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTextTag takes integer i, handle subject, string name returns texttag
    return GetStoredInteger(LocalVars(),GetObjectName(i)+I2S(H2I(subject)), name)
    return null
endfunction


function FlushHandleLocals takes integer i, handle subject returns nothing
    call FlushStoredMission(LocalVars(),GetObjectName(i)+I2S(H2I(subject)) )
endfunction
Create a trigger, format it to custom text, delete everything inside the trigger and copy paste this to the trigger. Change the things where I added comments (constant functions and trigger name, the red colored text):
Code:
constant function Retribution takes nothing returns integer
    return[COLOR="Red"] 'A000'[/COLOR] //The rawcode of the retribution. Press ctrl+d in the ability editor to see the rawcode. Remember that rawcodes need ' around them, 'A000' is correct, however A000 is not. 
endfunction
constant function Retribution_Buff takes nothing returns integer
    return [COLOR="red"]'B000'[/COLOR] //The rawcode of the retribution buff.
endfunction

function Retribution_Conditions takes nothing returns boolean
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        return GetSpellAbilityId() == Retribution()
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_ATTACKED then
        return GetUnitAbilityLevel(GetAttacker(),Retribution_Buff()) > 0
    elseif GetTriggerEventId() == EVENT_UNIT_DAMAGED then
        return GetHandleUnit(Retribution(),GetTriggeringTrigger(),"v") == GetEventDamageSource()
    endif
    return false
endfunction

function Retribution_Damaged takes nothing returns nothing
    local unit u = GetEventDamageSource()
    local real dam = GetHandleReal(Retribution(),u,"dam")
    
    call DisableTrigger(GetTriggeringTrigger())
    call SetHandleReal(Retribution(),u,"dam",dam+GetEventDamage())
    set u = null
endfunction

function Retribution_Actions takes nothing returns nothing
    local unit u 
    local unit v
    local real dam
    local trigger trig 
    
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        set u = GetTriggerUnit()
        set v = GetSpellTargetUnit()
        loop
            exitwhen GetUnitAbilityLevel(v,Retribution_Buff()) == 0
            call TriggerSleepAction(0.5)
        endloop
        set dam = GetHandleReal(Retribution(),v,"dam")
        call UnitDamageTarget(u,v,dam,true,false,ATTACK_TYPE_MELEE,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        call FlushHandleLocals(Retribution(),u)
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_ATTACKED then
        set trig = CreateTrigger()
        set v = GetAttacker()
        call SetHandleHandle(Retribution(),trig,"v",v)
        call TriggerRegisterUnitEvent(trig,u,EVENT_UNIT_DAMAGED)
        call TriggerAddCondition(trig,Condition(function Retribution_Conditions))
        call TriggerAddAction(trig,function Retribution_Damaged)
        call TriggerSleepAction(5.)
        call DisableTrigger(trig)
        call FlushHandleLocals(Retribution(),trig)
        call DestroyTrigger(trig)
        set trig = null
    endif
    set u = null
    set v = null
endfunction

function Init_Trig_[COLOR="red"]Retribution[/COLOR] takes nothing returns nothing //Enter the name of your trigger after the "Init_Trig_", and remember it's case sensetive.
    local trigger trig = CreateTrigger()
    local integer i = 0
    
    loop
        exitwhen i > GetPlayers()
        call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_ATTACKED,null)
        set i = i+1
    endloop
    call TriggerAddCondition(trig,Condition(function Retribution_Conditions))
    call TriggerAddAction(trig,function Retribution_Actions)
endfunction
Remember to create a gamecache and assign the gc variable to it. I haven't checked the script, but it should work.
 
S

spiremk

Guest
Thanks Tom, the event adding works... (+rep)

However, there's a new problem. I can see that the damage is now being dealt. But, the damage seems to be increasing exponentially everytime this skill is cast on the same boss/enemy. For eg, 55, 895, 2855, 4955...

I've have already checked to ensure that the trigger values are reset to 0 everytime the spell duration is up...

What is wrong here? Below are all my triggers in running order...

Code:
Retribution Initialization
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Retribution (Spirit)
    Actions
        Set RetributionCaster = (Triggering unit)
        Set RetributionTarget = (Target unit of ability being cast)
        Countdown Timer - Start RetributionTimer as a One-shot timer that will expire in 15.00 seconds
        Trigger - Turn on Target Attack <gen>

Code:
Target Attack
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacking unit) Equal to RetributionTarget
    Actions
        Set DamageTarget = (Attacked unit)
        Trigger - Run Add Event <gen> (ignoring conditions)

Code:
Add Event
    Events
    Conditions
    Actions
        Trigger - Add to Retribution Charge <gen> the event (Unit - DamageTarget Takes damage)
        Trigger - Turn on Retribution Charge <gen>

Code:
Retribution Charge
    Events
    Conditions
    Actions
        Set IndividualDamage = (Integer((Damage taken)))
        Set DamageInteger = (DamageInteger + IndividualDamage)
        Trigger - Turn on Retribution Damage <gen>

Code:
Retribution Damage
    Events
        Time - RetributionTimer expires
    Conditions
    Actions
        Trigger - Turn off Retribution Charge <gen>
        Unit - Cause RetributionCaster to damage RetributionTarget, dealing ((Real(DamageInteger)) x 1.00) damage of attack type Spells and damage type Normal
        Floating Text - Create floating text that reads ((String(((Real(DamageInteger)) x 1.00))) + !) above RetributionTarget with Z offset 0.00, using font size 8.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
        Floating Text - Show (Last created floating text) for (All players)
        Floating Text - Change (Last created floating text): Disable permanence
        Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
        Wait 3.00 game-time seconds
        Floating Text - Destroy (Last created floating text)
        Set DamageInteger = 0
        Set IndividualDamage = 0
        Trigger - Turn off (This trigger)

I would truly appreciate any help...
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Make sure to add the same unit only once.

Every time you use "Trigger - Add to ... event ... <this particular unit>", well... there's one more event for that particular unit.

If it has been added, for example, three times, it will also fire three times if the event happens.

A simple workaround would be to add the unit to a unit group once you added its damage event and only add it to the trigger if it is not yet in that group.
 
S

spiremk

Guest
So how do I modify my trigger to ensure it only adds the event only once?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Create some unit group variable. Called "AlreadyAdded" or so.

Event:
- A unit is attacked
Conditions:
- ((Attacked unit) is in AlreadyAdded) equal to false
- (Attacking unit) Equal to RetributionTarget
Actions:
- Unit group - Add (Attacked unit) to AlreadyAdded
- Set DamageTarget = (Attacked unit)
- Trigger - Add to Retribution Charge <gen> the event (Unit - DamageTarget Takes damage)
- Trigger - Turn on Retribution Charge <gen>


However, events are never removed from triggers, unless the entire trigger is destroyed.
 
S

spiremk

Guest
It still doesnt work... but I can see that the damage has begun to less increase per cast...

I believe that since we cannot destroy the added event, it just keeps adding on and on... So every consecutive cast will do higher and higher damage...

This seems so impossible... is there any way to solve this?

PS: By the way, this base for this spell is the Storm Bolt. So I used the 'Response - Target of Ability being cast'. This is just for ur info...
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Set DamageInteger = (DamageInteger + IndividualDamage)

This will run too often...

Sooner or later, the trigger will look something like this:

Event:
- Unit 1 takes damage
- Unit 2 takes damage
- Unit 3 takes damage
- Unit 4 takes damage
- ...
Actions:
- Set DamageInteger = (DamageInteger + (Integer((Damage taken))))

And, well, for any unit in the events that takes damage, DamageInteger will increase...


Some condition maybe:
(Triggering unit) equal to RetributionTarget
 
S

spiremk

Guest
How is that supposed to help...

As far as I know... it still doesnt change anything...

Maybe the addition of events to another trigger just doesnt hit it... It causes the spawn of too many events without the chance of ever controlling or deleting the last added event... Unless... it could be done by JASS...

Can anyone help me on this? Or is there a way of detecting and deleting the events right after they are added?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> How is that supposed to help?

The condition?
It would prevent the trigger from running for a unit that is not the one you're currently waiting for, regardless of how many events the trigger has...


Quite frankly though, that entire thing is best done in one single trigger.
In JASS.
It would simply dynamically create a new trigger, just for that unit.
And destroy itself after some waiting...
 
S

spiremk

Guest
Ok, so here's my desperate plea...

I need some one proficient enough in JASS to formulate the above Retribution spell... Here's the spell scenario:

"Caster casts Retribution on Enemy A. After 15 seconds, all the damage DONE to other units BY Enemy A will be inflicted back to him in 3/6/9 multiplier."

After much jostling with normal WE triggers we all doubt this can be done without the help of JASS...

So anyone willing to help...?
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well from what i understand this trigger will be increased with event's so i need to know if its making the game lag if it has a lot of events (e.g - 1000)
and if is u would need to make some condition like trigger contains event (not possible im almost sure....) but it might be possible with Jass Ace might know it....

Edit: i checked it out a bit so i think i got a solution for u i think u should try this:
in the spell where u add the event do if\then\else, here look at this:
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        (Number of triggers in the trigger queue) Equal to 1
    Then - Actions
        Do nothing
    Else - Actions
        Trigger - Add Add Event <gen> to the trigger queue (Checking conditions)
        Trigger - Add to Add Event <gen> the event (Unit - DamageTarget Takes damage)
\\Now u put the run trigger action out of the if\then\else
   Trigger - Run Add Event <gen> (ignoring conditions)
hope it might work :p
 
S

spiremk

Guest
The problem isnt the lag...

It's the calculation of the actual damage dealt at the end of the spell duration of 15 seconds...

Doens't anyone know? I need the trigger in JASS as it's the fastest and most efficient way... +rep for anyone that does a workable version...
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
i think i know whats the problem....
u didnt turn off the Target Attack trigger so it keeps going on collecting more damage......
and u also need to set at the end of spell set DamageTakenVariable=0
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top