HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Changing summon with triggers

03-09-2003, 05:42 PM#1
Aiursrage2k
Code:
//*****************************
//*  Trigger: Chaos Summon    *
//*  Author: Aiursrage2k      *
//*****************************
function summonLvlUp takes nothing returns nothing
   local integer skill = GetUnitTypeId(GetLearningUnit()) 
   local integer learn = GetLearnedSkillBJ()

   if(learn == udg_CasterType  and skill == udg_SpellType) then
      if(IsUnitInGroup(GetTriggerUnit(), udg_ChaosElementLvl[2])) then
        call GroupAddUnitSimple( GetLearningUnit(), udg_ChaosElementLvl[3] )
      elseif(IsUnitInGroup(GetTriggerUnit(), udg_ChaosElementLvl[1])) then
        call GroupAddUnitSimple( GetLearningUnit(), udg_ChaosElementLvl[2] )
      else 
        call GroupAddUnitSimple( GetLearningUnit(), udg_ChaosElementLvl[1] )
      endif
   endif
endfunction

function summonChaos takes nothing returns nothing
   local unit tmp 
   local integer lvl 
   local integer i = 3
   loop 
     exitwhen i < 1 
      if(IsUnitInGroup(GetSummoningUnit(), udg_ChaosElementLvl[i])) then
        set lvl = i
        set i = 0
      endif
     set i = i - 1
   endloop

   call ReplaceUnitBJ( GetSummonedUnit(), udg_ChaosW[lvl], bj_UNIT_STATE_METHOD_RELATIVE )
   set tmp = GetLastReplacedUnitBJ()
   call TriggerSleepAction( 61 )
   call ExplodeUnitBJ( tmp )
endfunction

function Init takes nothing returns nothing
   local integer i = 1
   set udg_ChaosW[1] = 'uC01'
   set udg_ChaosW[2] = 'uC02'
   set udg_ChaosW[3] = 'uC03'
   set udg_CasterType = 'AHwe'
   set udg_SpellType = 'UC00'
   loop
     exitwhen i > 3
     set udg_ChaosElementLvl[i] = CreateGroup()
     set i = i + 1
   endloop
endfunction

function InitTrig_SummonChaosWarrior takes nothing returns nothing
    local trigger SummonUp = CreateTrigger(  )
    local trigger SummonChaos = CreateTrigger(  )
    local integer i = 0
    set gg_trg_SummonChaosWarrior = CreateTrigger(  )
    loop
     exitwhen i > 11
     call TriggerRegisterPlayerUnitEventSimple( SummonChaos , Player(i), EVENT_PLAYER_UNIT_SUMMON )
     call TriggerRegisterPlayerUnitEventSimple( SummonUp, Player(i), EVENT_PLAYER_HERO_SKILL )
     set i = i + 1
    endloop

    call TriggerAddAction( SummonChaos, function summonChaos )
    call TriggerAddAction( SummonUp, function summonLvlUp )
    call TriggerAddAction( gg_trg_SummonChaosWarrior , function Init )
endfunction
03-09-2003, 06:45 PM#2
rwxr-xr-x
Very nice. I like it.
04-02-2003, 12:55 AM#3
Guest
Why do all that when you can just go:

E: A unit enters [Playable Map Area]
A: If [[entering unit] is [equal to] [summoned unit]] do [Replace [entering unit] with a [new summon] else [do nothing]]
04-02-2003, 03:49 AM#4
DaKaN
well you would still need part of that code to determin the spells level, or you could just edit the summoned spell in the SLK... either way
04-02-2003, 01:04 PM#5
Aiursrage2k
Currently there is no way getting the spell level a hero has. Say you wanted a spell something Charge Shot where: level one does 10 damage, level 2 20 damage, and level 3 30 damage. If you want to have multiple instances a unit with this ability, you need to somehow determine which spell level it has, and logically the unit groups are the easiest method.

You could slks, but two reasons I chose not to are: you have to re-import the files after every save, it balloons the size of a map.
04-05-2003, 07:15 AM#6
PitzerMike
Anyway I would still use the UnitApplyTimedLife command to determine when the unit dies because then it really looks like a summoned unit. For buffid use 'BFig'