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

how do i count hits or damge

Status
Not open for further replies.
Level 3
Joined
Jul 23, 2004
Messages
58
Hi there again,

i am not sure cause its been a long time since mapping for me but try out the following:

I found an old testmap of mine where i implemented something like this.

Its quite difficult cause u have to calculate and do the damage by yourself.

This is my Trigger-Code
Code:
Trigger Unit Attack
    Events
        Unit - A unit Is attacked
    Conditions
        (Attacking unit) Equal to AD&D Hero 0000 <gen>
    Actions
        Trigger - Turn off (This trigger)
        Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + 1.00)
        Set DamageP[1] = (Random integer number between WeaponMinDamageP[1] and WeaponMaxDamageP[1])
        Floating Text - Create floating text that reads (String(DamageP[1])) above (Attacked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
        Set DamageInfoP[1] = (Last created floating text)
        Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) - (Real(DamageP[1])))
        Wait (10.00 / (Real((Agility of AD&D Hero 0000 <gen> (Include bonuses))))) seconds
        Floating Text - Destroy DamageInfoP[1]
        Trigger - Turn on (This trigger)

Hope this helps u.
 
Level 9
Joined
Jun 26, 2005
Messages
511
hmm i dont really get it am not good with variables, too lazy to learn them and all... i think i can do things without variables so i dont wanna learn them, i think the count hits can be found or made in the condition->intger condition.
 
Level 6
Joined
Apr 4, 2005
Messages
299
Heh, and how do you want to put value in condition withouth variable? Variables are your friends and it is really easy - imo easiest than write your last post:)
 
Level 9
Joined
Jun 26, 2005
Messages
511
ok i found this way but i dont know if its gonna work or not, it doesnt need variable, ok first i make a small lil unit and put it anywhere in the make, then i make a item with 100charge and give it to the unit, then do trigger if a unit attacks use 1 charge, then if then item reachs 0 charge remove item and and give it another 100charge, and add 1 damage to attacking unit, btw this might work with no variable but how do i add 1 damage. :\

EDIT:
Heh, and how do you want to put value in condition withouth variable? Variables are your friends and it is really easy - imo easiest than write your last post:)

this sounds easy to u, does that mean u can make it happen?
 
Level 3
Joined
Jul 23, 2004
Messages
58
Lol
i make a small lil unit and put it anywhere in the make, then i make a item with 100charge
This is not a good way. Takes more performance then working with variables. Its not hard to learn it, trust me.
 
Level 3
Joined
Jul 23, 2004
Messages
58
Some explaination:

A variable is an object which can be everything. There r different datatypes of variables i. e. Integer (Only round numbers) String (Text) Float (Numbers)

You have to set a Variable i. e.

Set Integer1 = 5

Later then u can use this Variable

Set Hitpoints of X Unit to Integer1

Why is it useful?

One advantage is that it helps you with modifiing ur map i. e.
instead of changing one value in all your triggers (like add X hp) u have only to change the variable if u r using it.
 
Level 5
Joined
Feb 16, 2006
Messages
151
As for counting hits
Code:
Unit - Set the custom value of UNIT to ((Custom value of UNIT)) + 1)
Like, you would increase that value each time you hit, and once it becomes 99... etc...
This should not be of any problems.
(Unless you already used custom value for another purpose...)
2.)
Now if you are already using custom values for a unit for another purpose after all, you would have to use gamecache, which requires some knowledge with JASS.
JASS:
function game_cache takes nothing returns gamecache   
    if (udg_gamecache==null) then
        call FlushGameCache(InitGameCache("hax.w3v"))
        set udg_gamecache=InitGameCache("hax.w3v")
    endif
    return udg_gamecache
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(game_cache(),I2S(H2I(subject)),name)
    else
        call StoreInteger(game_cache(), I2S(H2I(subject)), name, value)
    endif
endfunction
This "stores" an integer into a unit, meaning, you will be able to retrieve the stored integer from that unit anytime,using
JASS:
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(game_cache(), I2S(H2I(subject)), name)
endfunction
This basicly does the same as Custom Values.

K', that's it for counting hits, now counting damage is a totally different story, but unfortunately I didn't get what you wanted...
or if a unit do his own damage
???...
You can get damage with
Code:
Damage Taken
using
Code:
 Event - Unit takes Damage
Do you want to save the total damage dealt?
Then use the same procedure as before, only that this time:
JASS:
function GetHandleReal...
Store Reals instead of Integers
Oh and, your sense of "not using global variables as much as possible" is a right way to think.
You should learn JASS, I feel you can do it.
 
Level 9
Joined
Jun 26, 2005
Messages
511
thx, i always wanted to know some JASS, but i try to learn it its too hard, i was only up to the converting triggers into text, and the rest i dont really get, so i was thinking ill learn them the normal way, like the normal way i learn how do use WE, i didnt take no tutorial and stuff just comes by.

btw thx for posting the JASS but i dont get it, so am not gonna use it, i dont use the stuff i dont know sry.
 
Status
Not open for further replies.
Top