HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Damaging enemies but healing allies w/ spell

06-16-2006, 03:33 AM#1
darkwulfv
Could somebody give me a general idea on how to incorporate this via triggers? (GUI or JASS)

Tranquility, heals allies and damages enemies at the same time.

I thought of something using an Integer Loop with GUI, I just don't know how to do it. Can't you do something along the lines of this?:

integer A 1-30
Roll random integer 1-100
if integer less than or equal to 40, deal 100 damage to enemy units within spell's AOE.

I'm unfamiliar with more advanced integer loops. Thx for any help ahead of time
06-16-2006, 04:25 AM#2
sheep.spirit
i am not very profecient in GUI so i'll try to do it in JASS.Actually if u want it in the same time, i dont understand why u needed the randomness. I assume u are no very good with timers and stuff, so i made one without timers or triggers

Collapse JASS:
function tran takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local group g
  local integer i = 0
  local unit f
  
 loop
   set i = i + 1
   exitwhen i == 30   // 30 is the duration in seconds
   set g = CreateGroup()
    call GroupEnumUnitsInRange(g, GetUnitX(u), GetUnitY(u), 1000., null)  // 1000. is the detection radius
     loop
        set f = FirstOfGroup(g)
        exitwhen f == null
         if IsUnitAlly(f, GetOwningPlayer(u)) then
         call SetUnitState(f, UNIT_STATE_LIFE, GetUnitState(f, UNIT_STATE_LIFE) + 250.00) // heals for 250
       elseif IsUnitEnemy(f, GetOwningPlayer(u)) then
         call UnitDamageTarget(u, f, 100., false,false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)   // damage = 100
      endif
    call GroupRemoveUnit(g, f)
   endloop
   call DestroyGroup(g)
   call PolledWait(1.)
 endloop
call DestroyGroup(g)
set f = null
set u = null
endfunction

That's all i can help, i wrote this code just like that, if it doesnt really work then... but hope this helps
06-16-2006, 04:43 AM#3
darkwulfv
From what little I know about JASS, it looks ok. I'll test it when i get the chance. thanks a ton : )
O, and the randomness was so that my units would always heal but the enemies would only have like a 40% chance of taking damage. The JASS code you made works just as well for what I'm looking for. Will it heal 250 per run for 30 seconds or just once? Wait nvm I see the loop now.

+REP : )

EDIT: crap need to spread the rep around... :p I'll write myself a note to rep you when I can...
06-16-2006, 06:39 AM#4
BertTheJasser
It easier to read if you always use 4 spaces if you enter/leave a "layer".
GetWidgetLife(widget) and SetWidgetLife(widget,life) make it even easier to read. But in general that' the thing