Custom options

envenger

Active Member
Reaction score
3
Hey guys the rpg which i am making is gonna have a lot of custom option in items. which need to be triggered. So to find the value of the option from the attacked unit and attacking unit there are 2 ways.

1. Using fake passive ability as a option


in this method when ever the hero picks or drops items he loses and gain a number through which i increase the level of a fake ability. e.g. if i want my evasion to 25 i have 2 passives

One from 0,1,2,3,4..9
another one 10,20,30..100

when i need to detect this value when the unit is being attacked, so

Trigger:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Set level of Critical-Evasion for Text 0000 <gen> to 3

This trigger i have made to re-create a situation when a unit is wearing any item giving 3 critical evasion and leveled the ability to level 3

Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - Text 0000 <gen> Is attacked
    • Conditions
    • Actions
      • Set attacker = (Attacking unit)
      • Set attacked = (Attacked unit)
      • Custom script: loop
      • Custom script: exitwhen GetUnitAbilityLevelSwapped('A000', udg_attacked) == udg_evasion
      • Set evasion = (evasion + 1)
      • Custom script: endloop
      • -------- Do rest of the damage trigger --------


With this trigger i find out the level of the ability of the attacked unit and store it in a variable named evasion

The second method is using hastables


2. Using Hashtables


Trigger:
  • Untitled Trigger 002
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Set the custom value of Paladin 0001 <gen> to 123
      • Hashtable - Create a hashtable
      • Set hastable = (Last created hashtable)
      • -------- The first part of the hastable is custom vaule of the unit and second part is id of option e.g evasion = 0 --------
      • Unit - Set the custom value of Paladin 0001 <gen> to 2
      • -------- Let the vaule of option = 3 --------
      • Hashtable - Save 3 as qwe of 0 in hastable


By this i use the first part of hashtables to store the custom value of unit then the second part is the id of the option stored.
Then increase the value of that hashtable when the unit picks or drops a item. i have use the current value as 3


Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set attacker = (Attacking unit)
      • Set attacked = (Attacked unit)
      • Set attackedCV = (Custom value of attacked)
      • Set attackedCV = (Load qwe of 0 from hastable)
      • Game - Display to (All players) the text: (String(attackedCV))
      • -------- Do rest of the damage trigger --------


Here when the unit is being attacked i find the custom value of the attacked unit and with the help of it i find the value of critical evasion.


My question:

Which do you think is better

What i am think is using hashtable for pvp combat and abilities for pve combat. And round of all monsters and unit values to a multiple of 5 to make the trigger a bit faster

what do you think is better?


Other notes : I have used another good system for damage detection and it cant be abused. :shades:
 

Executor

I see you
Reaction score
57
So, you basically want to attach variables to units and item types.

E.x. if you pick up an evasion item the evasion value of the unit is increased by a item-type specific amount. Dropping the item will decrease the evasion value of the unit by the item-type specific evasion amount again. Am I right till there?


Well, vJass grants wonderful possibilities for circumstances like this.


example:
JASS:

struct ItemData
    real meleeEvasion
    real rangeEvasion
    real spellEvasion
    private Hashtable ref
    static method operator[] takes item i returns thistype
        return LoadInteger(.ref,GetItemTypeId(i),0)
    endmethod
    private static method onInit takes nothing returns nothing
        set .ref = InitHashtable()
    endmethod
    static method newType takes integer id returns thistype
        local thistype this = thistype.allocate()
        call SaveInteger(.ref,id,0,this)
        return this
    endmethod
endstruct

struct UnitData
    //! runtextmacro AIDS()
    real meleeEvasion
    real rangeEvasion
    real spellEvasion
    static method onItemPickUp takes nothing returns boolean
        local thistype this = thistype[GetTriggerUnit()]
        local ItemData d    = ItemData[GetManipulatedItem()]
        set .meleeEvasion = .meleeEvasion + d.meleeEvasion
        set .rangeEvasion = .rangeEvasion + d.rangeEvasion
        set .spellEvasion = .spellEvasion + d.spellEvasion
        return false
    endmethod
    static method onItemDrop takes nothing returns boolean
        local thistype this = thistype[GetTriggerUnit()]
        local ItemData d    = ItemData[GetManipulatedItem()]
        set .meleeEvasion = .meleeEvasion - d.meleeEvasion
        set .rangeEvasion = .rangeEvasion - d.rangeEvasion
        set .spellEvasion = .spellEvasion - d.spellEvasion
        return false
    endmethod
    static method AIDS_onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
        call TriggerAddCondition(t,Condition(function thistype.onItemPickUp))
        set t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(EVENT_PLAYER_UNIT_DROP_ITEM,null)
        call TriggerAddCondition(t,Condition(function thistype.onItemDrop))
    endmethod
endstruct

// ....

function someFunction takes nothing returns nothing
    local ItemData d = ItemData.newType('kpin')
    set d.meleeEvasion = 0.1
    set d.rangeEvasion = 0.0
    set d.spellEvasion = 0.4
endfunction
 

envenger

Active Member
Reaction score
3
not really understand, besides what is the point for doing all this thing?

I am gonna have a lot of triggered options in game which cant be done by manually like Critical hit % = attackers critical hit rate - opponents critical hit evasion. So when there is a damage condition, I can do the calculation and damage accordingly.

This things were not possible without calculating the amount of critical hit evasion of opponent

And these are the 2 ways which i think it could be done
 

envenger

Active Member
Reaction score
3
So, you basically want to attach variables to units and item types.

E.x. if you pick up an evasion item the evasion value of the unit is increased by a item-type specific amount. Dropping the item will decrease the evasion value of the unit by the item-type specific evasion amount again. Am I right till there?

Well not evasion actually there a lot of triggered attributes in mah RPG responsible for damage. So finding all those attributes by this manner would be easy.

i still think i couldn't explain you correctly :banghead:
 

Executor

I see you
Reaction score
57
Of course. Evasion was only an example. You can insert other attributes easily in the mentioned script. Something like: "spellPower" "spellCrit" "meleeCritical" "chanceToReplenishMana" ...

Well, maybe try again explaining your situation to us. Maybe then I can help you more :thup:
 

envenger

Active Member
Reaction score
3
See I am working on a map called Guardian Angels. and currently working on a damage system. I have already made a system to detect the damage leak-less and cant be exploited.

Now i am doing the Custom-damage trigger

There are many option in game like Critical hit rate, Critical hit Percent. These things cannot be done with normal warcraft-3 damage system.

But when i add these custom values in items they are going to stored in a variable and will be brought back again in damage triggers. And these 2 are the ways which i find it easy to get the values from the
"Event response - attacked unit"
i got these 2 ways from my limited knowledge of GUI(Warning i am still new to world editor :p)

The first one is made when the variable in which the value of the option is present i increase a fake ability of the hero and the ability is hidden is a disabled spell book and is a unit passive ability. With the increase in the value of the option i increase the level of the ability. And the trigger which i gave was a example of the method in which this value could be found.

/
/

And the second one is by naming all unit to custom values say e.g 2. and naming all item option in a order and storing it in the hastable. e.g evasion is 5 so hashtable position for this option is 2 of 3.And increase it with respect to items in hero inventory. So form the "event response attacked unit" we find the custom variable of the unit and store it in a variable and find out the respective option form the hashtable 2 of 3. 2 = custom value of the unit and 3 is the base id for evasion and is common for evasion for all hero's. once i get the value i can do the custom damage with respect to its values.

Hope this is better :banghead:
 

Ayanami

칼리
Reaction score
288
If you have a definite way of detecting Physical attacks, then go for option 2.
 
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