| 02-23-2007, 11:17 AM | #1 |
Ok when linking events I can do this> JASS:
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT and Trig_Wormhole_Spell_Conditions() then
call Trig_Wormhole_Spell_Actions()
I need to do the same, except if elseif - entered region = gg_rct_Portal_1? elseif - entered region = gg_rct_Portal_2? For these 2 events. JASS:
call TriggerRegisterEnterRectSimple(gg_trg_Wormhole, gg_rct_Portal_1)
call TriggerRegisterEnterRectSimple(gg_trg_Wormhole, gg_rct_Portal_2)
thx for any help |
| 02-23-2007, 11:31 AM | #2 |
You can use JASS:GetTriggeringRegion() |
| 02-23-2007, 12:38 PM | #3 |
OK, I tried that, but it seems the Entering Unit, Action is not triggering. I assume I need to write it differently? Just incase here what spell does: Wormhole Creates a portal next to your hero and target location, allowing 1 friendly hero to teleport between them which causes both portals to instantly collapse and dissapear. Just need Entering Unit part to get working, the 'wormholes' are created fine. lastly, im open to all suggestion sif theres a better way than using globals JASS:
//####################################################################################\\
// Spell Name: Wormhole \\
// Spell Auth: Fulla \\
//####################################################################################\\
//################################################################\\
// \\
// Configuration Section \\
// \\
//################################################################\\
globals
player WormholePlayer
unit Wormhole1
unit Wormhole2
boolean WormholeBoolean
endglobals
constant function Wormhole_AbilId takes nothing returns integer
return 'A001'
endfunction
constant function Wormhole_Dummy_PortalUnitId takes nothing returns integer
return 'h001'
endfunction
constant function Wormhole_SFX takes nothing returns string
return "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
endfunction
//constant function Wormhole_Duration takes integer lvl returns real
//if (lvl != 5) then
//return (lvl * 200.) + 250.
//endif
//return 1100.
//endfunction
//################################################################\\
// \\
// Spell Section \\
// \\
//################################################################\\
function Trig_Wormhole_Spell_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Wormhole_AbilId()
endfunction
function Trig_Wormhole_Spell_Actions takes nothing returns nothing
local unit c = GetSpellAbilityUnit()
local player p = GetOwningPlayer(c)
local location l = GetSpellTargetLoc()
local real f = GetUnitFacing(c)
local real x1 = GetUnitX(c)
local real y1 = GetUnitY(c)
local real x2 = GetLocationX(l)
local real y2 = GetLocationY(l)
local location r = PolarProjectionBJ(Location(x1, y1), 200., f)
set x1 = GetLocationX(r)
set y1 = GetLocationY(r)
set WormholePlayer = p
set Wormhole1 = CreateUnit(p, Wormhole_Dummy_PortalUnitId(), x1, y1, f)
call MoveRectTo(gg_rct_Portal_1, x1 , y1)
set Wormhole2 = CreateUnit(p, Wormhole_Dummy_PortalUnitId(), x2, y2, f)
call MoveRectTo(gg_rct_Portal_2, x2 , y2)
set WormholeBoolean = true
call RemoveLocation(l)
call RemoveLocation(r)
set l = null
set r = null
set c = null
endfunction
function Trig_Wormhole_Enter_Actions takes nothing returns nothing
local unit e = GetEnteringUnit()
local rect r1
local rect r2
local real x
local real y
call BJDebugMsg("Works")
if WormholeBoolean == true and (IsUnitType(e, UNIT_TYPE_HERO) == true) and (IsUnitAlly(e, WormholePlayer)) then
if GetTriggeringRegion() == gg_rct_Portal_1 then
set r1 = gg_rct_Portal_1
set r2 = gg_rct_Portal_2
elseif GetTriggeringRegion() == gg_rct_Portal_2 then
set r1 = gg_rct_Portal_2
set r2 = gg_rct_Portal_1
endif
set x = GetRectCenterX(r2)
set y = GetRectCenterY(r2)
call SetUnitX(e, x)
call SetUnitY(e, y)
call DestroyEffect(AddSpecialEffectTarget(Wormhole_SFX(), e, "origin"))
call RemoveUnit(Wormhole1)
call RemoveUnit(Wormhole2)
endif
set WormholeBoolean = false
set e = null
endfunction
function Wormhole_Events takes nothing returns nothing
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT and Trig_Wormhole_Spell_Conditions() then
call Trig_Wormhole_Spell_Actions()
elseif GetTriggeringRegion() == gg_rct_Portal_1 or GetTriggeringRegion() == gg_rct_Portal_2 then
call Trig_Wormhole_Enter_Actions()
endif
endfunction
//===========================================================================
function InitTrig_Wormhole takes nothing returns nothing
set gg_trg_Wormhole = CreateTrigger()
call TriggerRegisterEnterRectSimple(gg_trg_Wormhole, gg_rct_Portal_1)
call TriggerRegisterEnterRectSimple(gg_trg_Wormhole, gg_rct_Portal_2)
call TriggerRegisterAnyUnitEventBJ(gg_trg_Wormhole, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(gg_trg_Wormhole, function Wormhole_Events)
endfunction
|
| 02-24-2007, 07:15 AM | #4 |
Ah, you didn't say the event that fire is a unit, and not a region. You are using a rect, and not a Region, remember. I wonder how you could save if you are using different parameters, between gg_trg_Portal_X and GetTriggeringRegion(). Try this : JASS://####################################################################################\\ // Spell Name: Wormhole \\ // Spell Auth: Fulla \\ //####################################################################################\\ //################################################################\\ // \\ // Configuration Section \\ // \\ //################################################################\\ globals player WormholePlayer unit Wormhole1 unit Wormhole2 boolean WormholeBoolean rect gg_rct_Portal_1 rect gg_rct_Portal_2 endglobals constant function Wormhole_AbilId takes nothing returns integer return 'A001' endfunction constant function Wormhole_Dummy_PortalUnitId takes nothing returns integer return 'h001' endfunction constant function Wormhole_SFX takes nothing returns string return "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl" endfunction //constant function Wormhole_Duration takes integer lvl returns real //if (lvl != 5) then //return (lvl * 200.) + 250. //endif //return 1100. //endfunction //################################################################\\ // \\ // Spell Section \\ // \\ //################################################################\\ function Trig_Wormhole_Spell_Conditions takes nothing returns boolean return GetSpellAbilityId() == Wormhole_AbilId() endfunction function Trig_Wormhole_Spell_Actions takes nothing returns nothing local unit c=GetSpellAbilityUnit() local player p=GetOwningPlayer(c) local location l=GetSpellTargetLoc() local real f=GetUnitFacing(c) local real x1=GetUnitX(c)+200*Cos(f*3.14159/180.0) local real y1=GetUnitY(c)+200*Sin(f*3.14159/180.0) local real x2=GetLocationX(l) local real y2=GetLocationY(l) set WormholePlayer=p set Wormhole1=CreateUnit(p, Wormhole_Dummy_PortalUnitId(),x1,y1,f) call MoveRectTo(gg_rct_Portal_1,x1,y1) set Wormhole2=CreateUnit(p, Wormhole_Dummy_PortalUnitId(),x2,y2,f) call MoveRectTo(gg_rct_Portal_2,x2,y2) set WormholeBoolean=true call RemoveLocation(l) set l=null set c=null endfunction function Trig_Wormhole_Enter_Actions takes nothing returns nothing local unit e=GetTriggerUnit() local rect r1 local rect r2 local real x local real y local region r=CreateRegion() call RegionAddRect(r,gg_rct_Portal_1) call BJDebugMsg("Works") if WormholeBoolean and IsUnitType(e,UNIT_TYPE_HERO) and IsUnitAlly(e,WormholePlayer) then if GetTriggeringRegion()==gg_rct_Portal_1 then set r1=gg_rct_Portal_1 set r2=gg_rct_Portal_2 else call RegionAddRect(r,gg_rct_Portal_2) call RegionClearRect(r,gg_trg_Portal_1) if GetTriggeringRegion() == gg_rct_Portal_2 then set r1=gg_rct_Portal_2 set r2=gg_rct_Portal_1 endif endif set x=GetRectCenterX(r2) set y=GetRectCenterY(r2) call SetUnitX(e,x) call SetUnitY(e,y) call DestroyEffect(AddSpecialEffectTarget(Wormhole_SFX(),e,"origin")) call RemoveUnit(Wormhole1) call RemoveUnit(Wormhole2) endif set WormholeBoolean=false set e=null call RemoveRegion(r) set r=null endfunction function Wormhole_Events1 takes nothing returns nothing if Trig_Wormhole_Spell_Conditions() then call Trig_Wormhole_Spell_Actions() endif endfunction function Wormhole_Events2 takes nothing returns nothing call Trig_Wormhole_Enter_Actions() endfunction //=========================================================================== function InitTrig_Wormhole takes nothing returns nothing local trigger t=CreateTrigger() call TriggerRegisterEnterRectSimple(t, gg_rct_Portal_1) call TriggerRegisterEnterRectSimple(t, gg_rct_Portal_2) call TriggerAddAction(t,function Wormhole_Events1) set t=CreateTrigger() call TriggerAddAction(t,function Wormhole_Events2) call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT) set t=null endfunction |
| 02-24-2007, 09:15 AM | #5 |
thx alot, I fiddeled with the code a bit, managed to get it semi working now. - The first rect doesnt seem to move, when the wormholes are created. It still remains at its default psotion. When I walk through it thou, I get teleported to the 2nd rects 'new' position. (Semi working) Heres current code, with a few fixes I made. JASS:
//####################################################################################\\
// Spell Name: Wormhole \\
// Spell Auth: Fulla \\
//####################################################################################\\
//################################################################\\
// \\
// Configuration Section \\
// \\
//################################################################\\
globals
player WormholePlayer
unit Wormhole1
unit Wormhole2
boolean WormholeBoolean = false
rect rect1 = gg_rct_Portal_1
rect rect2 = gg_rct_Portal_2
endglobals
constant function Wormhole_AbilId takes nothing returns integer
return 'A001'
endfunction
constant function Wormhole_Dummy_PortalUnitId takes nothing returns integer
return 'h001'
endfunction
constant function Wormhole_SFX takes nothing returns string
return "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
endfunction
//constant function Wormhole_Duration takes integer lvl returns real
//if (lvl != 5) then
//return (lvl * 200.) + 250.
//endif
//return 1100.
//endfunction
//################################################################\\
// \\
// Spell Section \\
// \\
//################################################################\\
function Trig_Wormhole_Spell_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Wormhole_AbilId()
endfunction
function Trig_Wormhole_Spell_Actions takes nothing returns nothing
local unit c=GetSpellAbilityUnit()
local player p=GetOwningPlayer(c)
local location l=GetSpellTargetLoc()
local real f=GetUnitFacing(c)
local real x1=GetUnitX(c)+200*Cos(f*3.14159/180.0)
local real y1=GetUnitY(c)+200*Sin(f*3.14159/180.0)
local real x2=GetLocationX(l)
local real y2=GetLocationY(l)
set WormholePlayer=p
set Wormhole1=CreateUnit(p, Wormhole_Dummy_PortalUnitId(),x1,y1,f)
call MoveRectTo(gg_rct_Portal_1,x1,y1)
set Wormhole2=CreateUnit(p, Wormhole_Dummy_PortalUnitId(),x2,y2,f)
call MoveRectTo(gg_rct_Portal_2,x2,y2)
set WormholeBoolean=true
call RemoveLocation(l)
set l=null
set c=null
endfunction
function Trig_Wormhole_Enter_Actions takes nothing returns nothing
local unit e=GetTriggerUnit()
local rect r1 =gg_rct_Portal_1
local rect r2 =gg_rct_Portal_2
local real x
local real y
local region r=CreateRegion()
call RegionAddRect(r,rect1)
call BJDebugMsg("Works")
if WormholeBoolean and IsUnitType(e,UNIT_TYPE_HERO) and IsUnitAlly(e,WormholePlayer) then
if GetTriggeringRegion()==gg_rct_Portal_2 then
call RegionAddRect(r,rect2)
call RegionClearRect(r,rect1)
set r1=gg_rct_Portal_2
set r2=gg_rct_Portal_1
endif
set x=GetRectCenterX(r2)
set y=GetRectCenterY(r2)
call SetUnitX(e,x)
call SetUnitY(e,y)
call DestroyEffect(AddSpecialEffectTarget(Wormhole_SFX(),e,"origin"))
call RemoveUnit(Wormhole1)
call RemoveUnit(Wormhole2)
endif
set WormholeBoolean=false
set e=null
call RemoveRegion(r)
set r=null
endfunction
function Wormhole_Events1 takes nothing returns nothing
if Trig_Wormhole_Spell_Conditions() then
call Trig_Wormhole_Spell_Actions()
endif
endfunction
function Wormhole_Events2 takes nothing returns nothing
call Trig_Wormhole_Enter_Actions()
endfunction
//===========================================================================
function InitTrig_Wormhole takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterEnterRectSimple(t, gg_rct_Portal_1)
call TriggerRegisterEnterRectSimple(t, gg_rct_Portal_2)
call TriggerAddAction(t,function Wormhole_Events2)
set t=CreateTrigger()
call TriggerAddAction(t,function Wormhole_Events1)
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
set t=null
endfunction
|
