• 🏆 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!

[vJASS] Help with Damage System

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
So I have a damage system I want to work properly with the code I have for it in the playerDamage trigger in the test map I have provided below. I am not sure how to alter it to work with the new damage system I have in my map.

Can anyone help me make the nescessary changes to that trigger in order for the code in it to properly work with the damage system in the map? Thanks, would really appreciate it. :)
 

Attachments

  • DamageTestMap.w3m
    63.4 KB · Views: 42
Level 20
Joined
Jul 14, 2011
Messages
3,213
So many crazy systems there xD

What do you want to achieve, Damage Detection? Use Weep's or Bribe's systems (Weep's is quite simpler, but does the Job, Bribe's requires Unit Indexer System)

Both gives you a variable with the Damage Dealt (wich is a real) Then just use Real to String conversion and use the variable of the damage dealt.
 
Level 8
Joined
Feb 17, 2007
Messages
368
Yeah Damage Detection, but I already have a vJass snippet written in the playerDamage trigger that does exactly what I want. I just need someone to help me alter it to work with the Damage System in this map, provided by the Damage trigger. :p would really appreciate help on this.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Just use the module. It should be pretty straight forward.

It's all in the docs.

JASS:
struct Demo extends array
    private static method onDamage takes nothing returns nothing
        //UnitIndex targetId
        //UnitIndex sourceId
        //unit target
        //unit source
        //real amount (damage amount)

        call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,GetUnitName(source) + " damaged " + GetUnitName(target) + " for " R2S(amount))
    endmethod

    implement DamageEvent 
endstruct

It really is extremely simple if you read the docs :\.
 
Level 8
Joined
Feb 17, 2007
Messages
368
Thanks gorillabull, I appreciate you linking me to that, but I really want to use this code I have written for me. Nestharus I don't know vJass that well though and the way you use it without functions and write it makes it harder for me. :p This is the part I need altered Nestharus, and the whole code in the playerDamage is specific to my needs so I can't use the demo code you provided:

JASS:
    //##################################################################################
    public function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i
        
        //This is where knowing what damage-detection system you use comes into play
        call RegisterDamageEvent(t) //This is not a specific example
        
        //The rest is pretty standard, though not guaranteed (again, depending on damage-
        //detection protocol)
        call TriggerAddAction(t, function onDamage)
        
        //Ensure that the values in the playerDamage array are initialized to 0 so that
        //there are no problems with addition
        set i = 0
        loop
            exitwhen(i == PLAYER_COUNT)
            set playerDamage[i] = 0
            set playerDamageTotal[i] = 0
            set i = i + 1
        endloop
    endfunction
endlibrary
 
Status
Not open for further replies.
Top