• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Giving stats/hits with a item (Chances percentage)

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
hi there is my knowledge about this trigger :

  • Water element stats triger
    • Evénements
    • Conditions
    • Actions
      • Héros - Modify Force of (Hero manipulating item): Ajouter 1
      • Héros - Modify Agilité of (Hero manipulating item): Ajouter 1
I wanna that if a hero manipulating the item "Water element" has 33% chance to gain 2 str and 2 agi and 66%chances gaining 4 int attributes.

if someone has the solution, help please :)
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
hi there is my knowledge about this trigger :

  • Water element stats triger
    • Evénements
    • Conditions
    • Actions
      • Héros - Modify Force of (Hero manipulating item): Ajouter 1
      • Héros - Modify Agilité of (Hero manipulating item): Ajouter 1
I wanna that if a hero manipulating the item "Water element" has 33% chance to gain 2 str and 2 agi and 66%chances gaining 4 int attributes.

if someone has the solution, help please :)
Can you be more clear? When will that chance happen? When attacked? When it killed an enemy? When it used an item?
 
Level 6
Joined
Sep 24, 2015
Messages
174
Can you be more clear? When will that chance happen? When attacked? When it killed an enemy? When it used an item?

33% chances gaining 2 str and 2 agi and 66% chances gaining 4 int attributes when hero manipulating item hits a building.

sorry, i forgot to finish.
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
Use Damage Detection System like this to detect when a building is damaged via physical damage.
Then check if the damage source has item of type "Water Element" then trigger the effect.
Something like this:
  • Chance to Increase
    • Events
      • Game - PDD_damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PDD_damageType Equal to PDD_PHYSICAL
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (PDD_target)) Equal to SomeBuilding
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) has an item of type Water Element) Equal to True
                • Then - Actions
                  • Set tempInt = (Random integer number between 1 and 3)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • tempInt Equal to 1
                    • Then - Actions
                      • Hero - Modify Strength of (PDD_source): Add 2
                      • Hero - Modify Agility of (PDD_source): Add 2
                    • Else - Actions
                      • Hero - Modify Intelligence of (PDD_source): Add 4
                • Else - Actions
            • Else - Actions
        • Else - Actions
 
Level 6
Joined
Sep 24, 2015
Messages
174
Thanks a friend gave me a, really easy and better way to understand, solution xD

let me show it to you :)

  • Water element stats triger
    • Evénements
      • Unité - A unit Est attaqué
    • Conditions
      • ((Owner of (Attacking unit)) is an ally of (Owner of (Triggering unit))) Egal Ã* FALSE
      • ((Attacking unit) has an item of type Elemental Essence - |c000000ffWater|r) Egal Ã* TRUE
      • ((Unit-type of (Attacking unit)) is Un héros) Egal Ã* TRUE
      • (Mana of (Attacking unit)) Supérieur ou égal Ã* 1045.00
    • Actions
      • Set WaterElementChances = (Integer((Random real number between 0.00 and 101.00)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • WaterElementChances Inférieur ou égal Ã* 33
        • Alors - Actions
          • Héros - Modify Force of (Attacking unit): Ajouter 1
          • Héros - Modify Agilité of (Attacking unit): Ajouter 1
          • Unité - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) - 45.00)
        • Sinon - Actions
          • Do nothing
It's World Editor in french version sorry ;)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
If it uses the unit is attacked evenet be aware that unless you set attack backswing to 0 the player can repeatedly trigger the event by ordering the unit to stop. Since it gives stats this means he could find a building, spam press stop for 1-2 seconds and gain near 30-50 of all stats. If he could spam press for a minute that would be several hundred of all stats.

This is why Flux recommended a Damage Detection System instead since that way it would only ever fire when damage is dealt (hard to fake results) as opposed to when an attack is started (easy to fake results).
 
Level 6
Joined
Sep 24, 2015
Messages
174
but, guys, really, i'm a total noob at JASS scripts...

So the PDD damage detection is a bit hard to make for me i guess...but y ofc i'll try it out

#NoPainNoGain

;)
 
Level 6
Joined
Sep 24, 2015
Messages
174
so if I understood why it's better to make a damage engine , tell me if i'm wrong, is because you can "fake" the order atack by stoping the unit several times and it gives free stats to the stop attacking order unit right?

I'll take a look at your thread Bribe
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Yes, that's correct. This is what Flux's trigger will look like with DamageEngine:

  • Chance to Increase
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to True
      • (Unit-type of DamageEventTarget) Equal to SomeBuilding
      • (DamageEventSource has an item of type Water Element) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • Hero - Modify Strength of (PDD_source): Add 2
          • Hero - Modify Agility of (PDD_source): Add 2
        • Else - Actions
          • Hero - Modify Intelligence of (PDD_source): Add 4
 
Level 6
Joined
Sep 24, 2015
Messages
174
And why it is random integer between 1 and 3? and not between 0 and 101

0 % to 101% if you see what i'm meaning.

it's the stats gain chances.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
And why it is random integer between 1 and 3? and not between 0 and 101

0 % to 101% if you see what i'm meaning.

it's the stats gain chances.
No I have no idea what you mean and I have studied university level probability.

I wanna that if a hero manipulating the item "Water element" has 33% chance to gain 2 str and 2 agi and 66%chances gaining 4 int attributes.
To be technical what he is asking is for a 33% chance of 2 str and agi, a 66% chance for 4 int and a 1% chance for nothing. Although what you provided was about correct it does mean he has a point that it is not what he asked for.

As such it should be between 1 and 100 (100 different possibilities) with the range 1 to 33 giving agi and str, 34 to 99 giving int and 100 giving nothing.

Or one can use reals since those map to probability better than integer. With a random real in the range 0 to less than 0.33 giving agi and str, from greater than or equal to 0.33 and less than 0.99 giving int and from greater than or equal to 0.99 up to 1 giving nothing. Boarder case sare actually quite flexible though.

Actual probability runs from 0 (never, impossibility etc) to 1 (always, certainty etc). The reason 0 to 99 or 1 to 100 is used for integer percentages is because integers have uncertainty associated with them which would mean 0 to 100 is more like -0.5 to 1.005 due to discrete sampling.
 
Level 6
Joined
Sep 24, 2015
Messages
174
I did the trigger but it's not working :(

  • Watter element stats trigger
    • Event
      • game - PDD_damageEventTrigger becomes Equal to* 1.00
    • Conditions
      • IsDamageSpell Equal to* TRUE
      • (Unit-type of DamageEventTarget) Equal to* SomeBuilding
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to* TRUE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to* 1
        • Then - Actions
          • Hero - Modify Strenght of PDD_source: Add 1
          • Hero - Modify Agility of PDD_source: Add 1
        • Else - Actions
          • Hero - Modify Intelligence of PDD_source: Add 2
variables i did :

IsDamageSpell = bolean
Damage event target = unit
SomeBuilding = unit type
DamageEventSource = unit

what is wrong? i don't get it :/
 
Level 6
Joined
Sep 24, 2015
Messages
174
I have to redo all the whole trigger? because the damage engine is not on the downloaded map... or am i missing something?
 
Level 6
Joined
Sep 24, 2015
Messages
174
there is no Damage engine trigger Bribe...

there is only OnDamage and DamageEvent and VariableCreator
 
Level 6
Joined
Sep 24, 2015
Messages
174
the trigger is not working...the damage engine trigger...i don't know why

it says there is an syntax error when i save the map...

here the error : gEvUnit, UNIT_TYPE_STRUCTURE) == false ) ) then
 
Level 6
Joined
Sep 24, 2015
Messages
174
It doesn't have any errors unless you didn't tell WorldEditor to automatically create variables of unkown type. It must be coming from somewhere else.


hmm i can't activate the trigger...it's in the trigger
it says me Argument incorrect(real)

and i really dont know what this means xD
 
Level 6
Joined
Sep 24, 2015
Messages
174
248097-albums8484-picture102568.png



There is the screenshot finally xD
 
Last edited:
Level 6
Joined
Sep 24, 2015
Messages
174
You have the Damage Detection System installed into your map?

Done but it's not working :/

  • Watter element stats trigger
    • Event
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equat to TRUE
      • (Unit-type of DamageEventTarget) Equal to SomeBuilding
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to TRUE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Alors - Actions
          • Hero - Modify Strenght of PDD_source: Add 1
          • Hero - Modify Agility of PDD_source: Add 1
        • Else - Actions
          • Hero - Modify Intelligence of PDD_source: Add 2
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Sounds like one of the variables is the wrong type. Or at least that is what I think it means (it is not English).

I agree. It sounds like he has a real variable named DmgEvUnit in variable manager.

aitz-, can you go into Variable Manager and delete the variable DmgEvUnit? Then go ahead and copy/paste DamageEngine again.
 
Level 6
Joined
Sep 24, 2015
Messages
174
I agree. It sounds like he has a real variable named DmgEvUnit in variable manager.

aitz-, can you go into Variable Manager and delete the variable DmgEvUnit? Then go ahead and copy/paste DamageEngine again.

Done, but it's still not working, the DamageEngine is okay but i guess i did a mistake on the Watter element trigger...

  • Watter element stats trigger
    • Event
      • Game - DamageEvent becomes Equal to* 1.00
    • Conditions
      • ((Unit-type of DamageEventSource) is Un hero) Equal to* TRUE
      • ((Owner of DamageEventSource) is an ally of (Owner of DamageEventTarget)) Equal to FALSE
      • IsDamageSpell Equal to TRUE
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to* TRUE
      • (Mana of DamageEventSource) Greater or Equal to* 1045.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to* 1
        • Then - Actions
          • Hero - Modify Strenght of DamageEventSource: Add 1
          • Hero - Modify Agility of DamageEventSource: Add 1
          • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) - 45.00)
        • Else - Actions
          • Hero - Modify Intelligence of DamageEventSource: Add 2
          • Unit - Set mana of (Attacking unit) to ((Mana of (Attacking unit)) - 45.00)
 
Level 6
Joined
Sep 24, 2015
Messages
174
Nope i want that only if the hero has over 1045 mana points he can gain stats...

I need DamageEngine ,DamageEvent,UnitIndexer, this trigger and the variable creator to make it working right?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
DamageEvent and the variable creator are part of PDD, a different damage system. It sounds like something isn't configured right in the map. I recommend reviewing the install instructions for damage engine (for example make sure you have set the two variables). Also, if you're going to use PDD with DamageEngine, you need the cross-compatibility plugin which is found on the DamageEngine download page.
 
Level 6
Joined
Sep 24, 2015
Messages
174
function UnitDamageTargetEx takes unit source, unit target, boolean b, real amount, boolean attack, boolean ranged, attacktype a, damagetype d, weapontype w returns boolean
local integer ptype = udg_PDD_damageType
//To keep this functioning EXACTLY the same as it does in PDD, you need to move it
//to an AfterDamageEvent Equal to 1.00 trigger. It's up to you.
if ptype != udg_CODE then <-------------------------

it's the error when i copy/paste the friendly fire detection custom script


I guess i won't use that system wich is to complicated for me, at moment, to understand.

In my map the vamp will attack walls and back of that wall will be an offensive tower that wil target the vamp if a player orders the vamp to stop attacking and the attack backswing animation is .6 seconds.
so basically while spamming stop, all you do is cancel trying to move to the target instead of actually canceling attacking.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Hey, I am sorry! There was an error in the PDD script that you found. I have updated the script to this and it should now work:

JASS:
//Physical Damage Detection plugin for Damage Engine 3.
//
//A few important notes:
//- Spell reduction is handled multiplicatively in DamageEngine, instead of additively like in PDD.
//- Just like in PDD, make sure you've modified the Runed Bracers item to remove the Spell Damage Reduction ability
//- Move any UnitDamageTargetEx calls to an "AfterDamageEvent Equal to 1.00" trigger
//- You do not need custom Get/Set-Unit(Max)Life functions, but I included them for ease of import.
//
//I will add more disclaimers, tips or fixes if anyone runs into issues!
function GetUnitLife takes unit u returns real
    return GetWidgetLife(u)
endfunction

function SetUnitLife takes unit u, real r returns nothing
    call SetWidgetLife(u, r)
endfunction

function GetUnitMaxLife takes unit u returns real
    return GetUnitState(u, UNIT_STATE_MAX_LIFE)
endfunction

function UnitDamageTargetEx takes unit source, unit target, boolean b, real amount, boolean attack, boolean ranged, attacktype a, damagetype d, weapontype w returns boolean
    local integer ptype = udg_PDD_damageType
    //To keep this functioning EXACTLY the same as it does in PDD, you need to move it
    //to an AfterDamageEvent Equal to 1.00 trigger. It's up to you.
    if ptype != udg_PDD_CODE then
        set udg_PDD_damageType = udg_PDD_CODE
        call UnitDamageTarget(source, target, amount, attack, ranged, a, d, w)
        call TriggerEvaluate(udg_ClearDamageEvent)
        set udg_PDD_damageType = ptype
        return true
    endif
    return false
endfunction

function PDD_OnDamage takes nothing returns boolean
    //cache previously-stored values in the event of recursion.
    local unit source = udg_PDD_source
    local unit target = udg_PDD_target
    local real amount = udg_PDD_amount
    local integer typ = udg_PDD_damageType

    //set variables to their event values.
    set udg_PDD_source = udg_DamageEventSource
    set udg_PDD_target = udg_DamageEventTarget
    set udg_PDD_amount = udg_DamageEventAmount

    //Extract the damage type from what we already have to work with.
    if udg_IsDamageSpell then
        set udg_PDD_damageType = udg_PDD_SPELL
    elseif udg_PDD_damageType != udg_PDD_CODE then
        set udg_PDD_damageType = udg_PDD_PHYSICAL
    endif

    //You can delete the next few lines if you have already modified your runed bracers
    //ability to 1.67 instead of removing it from the item:
    if udg_IsDamageSpell and IsUnitType(udg_PDD_target, UNIT_TYPE_HERO) and UnitHasItemOfTypeBJ(udg_PDD_target, 'brac') then
        set udg_PDD_amount = udg_PDD_amount * 0.67
    endif

    //Fire PDD event.
    set udg_PDD_damageEventTrigger = 0.00
    set udg_PDD_damageEventTrigger = 1.00

    //Hey, this works and I'm really happy about that!
    set udg_DamageEventAmount = udg_PDD_amount

    //reset things just in case of a recursive event.
    set udg_PDD_damageEventTrigger = 0.00
    set udg_PDD_source = source
    set udg_PDD_target = target
    set udg_PDD_amount = amount
    set udg_PDD_damageType = typ
    set source = null
    set target = null
    return false
endfunction

function InitTrig_DamageEvent takes nothing returns nothing
    set udg_PDD_PHYSICAL = 0
    set udg_PDD_SPELL = 1
    set udg_PDD_CODE = 2
    set udg_PDD_damageEvent = CreateTrigger()
    call TriggerRegisterVariableEvent(udg_PDD_damageEvent, "udg_DamageModifierEvent", EQUAL, 1.00)
    call TriggerAddCondition(udg_PDD_damageEvent, Filter(function PDD_OnDamage))
endfunction
 
Level 6
Joined
Sep 24, 2015
Messages
174
here's the solution guys :)

  • Watter element stats trigger
    • Event
      • Game - DamageEvent becomes Equal to* 1.00
    • Conditions
      • IsDamageSpell Equal to* FALSE
      • (DamageEventTarget is A building) Equal to* TRUE
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to* TRUE
      • (Mana of DamageEventSource) Greater or Equal to* 45.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to* 1
        • Alors - Actions
          • Hero - Modify Force of DamageEventSource: Add 1
          • Hero - Modify Agility of DamageEventSource: Add 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to* 3
            • Then - Actions
              • Hero - Modify Intelligence of DamageEventSource: Add 2
            • Sinon - Actions
      • Unit - Set mana of DamageEventSource to ((Mana of DamageEventSource) - 45.00)
Thanks Bribe :)
 
Last edited:
Status
Not open for further replies.
Top