HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Major trigger error overhaul

06-29-2007, 09:29 PM#1
darkwulfv
Ok, this request is only for people with lots of time. I've done alot of JASS, but some stuff is causing me issues, and I want to see if anyone knows why. These are the triggers that are not working/not working correctly.

Should: Create the unit that died at that location after X seconds
Does: Nothing.

Collapse JASS:
function Prey_Dies_Conditions takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) 
endfunction

function Prey_Dies_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local real randomwait = GetRandomReal(150., 270.)
  local real x = GetUnitX(u)
  local real y = GetUnitY(u)
    call PolledWait(randomwait)
    call CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), x, y, GetRandomReal(0., 360.))
set u = null
endfunction

//===========================================================================
function InitTrig_Prey_Dies takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(t, Condition( function Prey_Dies_Conditions ) )
    call TriggerAddAction(t, function Prey_Dies_Actions )
set t = null
endfunction


Should: Periodically heal every unit in the rects.
Does: Nothing.

Collapse JASS:
function Clearing_Heal takes unit healed returns nothing
  local unit u = healed
  local real life = GetUnitState(u, UNIT_STATE_LIFE)
   if life > 1 and life < GetUnitState(u, UNIT_STATE_MAX_LIFE) then
    call TargetHeal(u, 1.8)
   endif
set u = null
endfunction

function Heal_Actions takes nothing returns nothing
  local group array g
  local integer i = 1
  local unit f 
  
   loop
   exitwhen i > 10
   set g [i] = CreateGroup()
   set g[i] = GetUnitsInRectMatching(udg_Clearing_Rects[i], null)
   set i = i + 1
   endloop
   
set i = 1

   loop
   exitwhen i > 10
   set f = FirstOfGroup(g[i])
      loop
      exitwhen f == null
          call Clearing_Heal(f)
          call GroupRemoveUnit(g[i], f)
      set f = FirstOfGroup(g[i])
      endloop
   set i = i + 1
   endloop
      
set i = 1

   loop
   exitwhen i > 10
       call DestroyGroup(g[i])
   set g[i] = null
   set i = i + 1
   endloop

set f = null   
endfunction

//=============================================
function InitTrig_Clearing_Healing takes nothing returns nothing
    call TimerStart(CreateTimer(), 3., true, function Heal_Actions)
endfunction


Should: Create a Blade Wolf at the start and prevent others from making one
Does: Creates a Blade Wolf, stops allies from making one, but also stops enemies (which shouldnt happen)

Collapse JASS:
function Blade_Select takes nothing returns nothing
  local player p = GetTriggerPlayer()
  local location l = GetPlayerStartLocationLoc(p)
  local real x = GetLocationX(l)
  local real y = GetLocationY(l)
     if udg_WolfCheck[GetPlayerId(p)] != 1 then
      if GetPlayerId(p) < 6 then
         if udg_BladeSelected[1] != true then
         set udg_Wolves[GetPlayerId(p)] = CreateUnit( p, 'H00A', x, y, 270.)
         set udg_WolfCheck[GetPlayerId(p)] = 1
         set udg_BladeSelected[1] = true
         else
             call ErrorMsg(p, "The Blade wolf has already been selected." )
         endif
      elseif GetPlayerId(p) > 5 then
         if udg_BladeSelected[2] != true then
         set udg_Wolves[GetPlayerId(p)] = CreateUnit( p, 'H00A', x, y, 270.)
         set udg_WolfCheck[GetPlayerId(p)] = 1
         set udg_BladeSelected[2] = true
         else
             call ErrorMsg(p, "The Blade wolf has already been selected.")
         endif
      endif
   endif

    call RemoveLocation(l)
   if GetLocalPlayer() == p then
       call MultiboardDisplay(udg_Multiboards[6], true)
   endif
set p = null
set l = null
endfunction

//===========================================================================
function InitTrig_Blade_Select takes nothing returns nothing
  local trigger t = CreateTrigger()
  local integer i = 0
  
   loop
   exitwhen i == 13
       call TriggerRegisterPlayerChatEvent( t, Player(i), "-Blade", true )
   set i = i + 1
   endloop
    
    call TriggerAddAction( t, function Blade_Select)
set i = 0
set t = null
endfunction

Thanks to anyone who helps, Rep to anyone who does, also. Sorry for posting so much. I just thought I'd blend them together since they were all causing issues.
06-30-2007, 12:52 AM#2
Vexorian
Collapse JASS:
function Prey_Dies_Conditions takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) 
endfunction

function Prey_Dies_Actions takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local integer ty = GetUnitTypeId(u)
  local player p=GetOwningPlayer(u)
  local real randomwait = GetRandomReal(150., 270.)
  local real x = GetUnitX(u)
  local real y = GetUnitY(u)
    call PolledWait(randomwait)
    call CreateUnit(p, ty, x, y, GetRandomReal(0., 360.))
set u = null
 // no need to null players
endfunction

//===========================================================================
function InitTrig_Prey_Dies takes nothing returns nothing
  local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(t, Condition( function Prey_Dies_Conditions ) )
    call TriggerAddAction(t, function Prey_Dies_Actions )
set t = null
endfunction

06-30-2007, 01:34 AM#3
Toink
You wait 150 - 270 seconds before creating a unit at the location?
06-30-2007, 01:49 AM#4
darkwulfv
Yeah. The unit dies, then the trigger waits (whatever)seconds and makes a new one in its place.

Vex, I'm confused. Other than a couple variables, what did you change?
EDIT: Oh! I get it! Because the unit died the information lost it's value (like GetUnitId(u)), so you set it before the info could vanish! Ooooh, that makes sense. Thanks! That fixes my other problem too with a trigger like this. +rep for you
06-30-2007, 07:25 AM#5
Pyrogasm
The local unit u = healed line is unneccessary; just reference "healed".

In the Blade Wolf trigger, try changing the elseif to an else. If the player number is not < 6, it's obviously more than 5.