wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 06-17-2009, 02:15 PM   #1
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default General Idea for spell algorithm

Hi guys... we all know that cliché spell that depends on the life of a unit. Per example, the weaker a unit is, the faster it attacks, or more damage it causes or some other bonus happens.
I have an ability in my map called Chaotic Rage which gives some Chaos units a chance that their attacks will do a Chaos damage instead of regular damage (Chaos owns all damages).
However it is too simple ... it can even be compared to a cheap version of critical strike ...
I would like it depend on the life of the who has the ability (like, give X% chance to deal chaos damage per each Y% of life missing) but I make no idea on how to make it ...

If someone has a general algorithm for problems like this I would appreciate the help...

Thx in advance.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 06-17-2009, 02:24 PM   #2
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

Collapse JASS:
GetWidgetLife(target)/GetUnitState(target,UNIT_STATE_MAX_LIFE)
= x

x = the percent life the target has

1 - x = percent life the target is missing = y

use x or y and multiply it by your percent based factor for said effects

i.e.

25% chance to deal bonus damage per 20% missing life of target, max of 75%

Collapse JASS:
GetRandomReal(0.,1.)<.25*IMinBJ(3,R2I(((1.-(GetWidgetLife(target)/GetUnitState(target,UNIT_STATE_MAX_LIFE)))/.2))

theory:

we get the percent missing life our target has, divide it by .2 (20%) to give us how many 20% portions the target is missing

since we want a max of 75% chance, in 25% increments, we take the minimum number of bonuses, up to a max of 3, using IMinBJ, mutliply that by our percent chance to fire factor (25%), and check whether a random real between 0 and 1 is less then this number, thus if the critical should fire

say the unit has 75% hp

hes missing 25% (1-percent life)

.25/.2 = 1.25

R2I(1.25) = 1

1<3

1*.25 = .25

GetRandomReal(0.,1.)<.25

will be the chance (25% in this case)

the only problem I forsee in this instance is that I am not sure how R2I() rounds numbers, thus 1.6 could become 2, which we dont want it to, we'd rather it remainded 1 - however, if you'd rather use a constant progression, as opposed to step-wise, this isn't a problem, and you can just forgo the R2I() conversion and use RMinBJ instead
__________________

Last edited by emjlr3 : 06-17-2009 at 02:42 PM.
emjlr3 is offline   Reply With Quote
Old 06-17-2009, 06:45 PM   #3
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Mmm I will try to add some twists to that theory (I like better when my units grow in power to +infinitum xD ) but this is a really nice explanation of the algorithm I was looking for.
Now I believe I need to periodically check the HP of the units with the ability, say every 1 second and then change the level of the ability.

Thx, I think I may find my way on this.
If not, I will just come back for more candy xD

rep++ !
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 11:06 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services