• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] enteringunit, help needed.

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2008
Messages
353
I really don't know what am doing trying to jass. But i just gotta do this if anyone can help...

Code:
function main takes nothing returns nothing
    set rect028=Rect(-5125,-1800,-4095,-2575)
    set triggerSM=CreateTrigger()
    call TriggerRegisterEnterRectSimple(triggerSM,rect028)
    call TriggerAddCondition(triggerSM,Condition(function notsapper))
    call TriggerAddAction(triggerSM,function stopm)

Code:
function notsapper takes nothing returns boolean
return ((IsUnitType(GetEnteringUnit(),UNIT_TYPE_SAPPER))==false)
endfunction

Code:
function stopm takes nothing returns nothing
call IssueImmediateOrderById(GetEnteringUnit(),$D0004)
Endfunction

All the above codes are completely useless. I would greatly appreciate any help on the matter, cause am just bad at this.

I want any unit, except units typed sapper, when they enter the rect028 area, to get a stop order issued. How do i do that? >.<
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
I just typed it somewhere else before and i copied paste it. But is meant to go into an existing map am working on.

would it be better if i did like this(?) :
Code:
function main takes nothing returns nothing
        local region locSM
        set rect028=Rect(-5125,-1800,-4095,-2575)
        set rect029=Rect(4095,-1800,5125,-2575)
        set locSM=CreateRegion()	
        set triggerSM=CreateTrigger()
        call RegionAddRect(locSM,rect028)
        call RegionAddRect(locSM,rect029)
	call TriggerRegisterEnterRegion(triggerSM,locSM,null)
        call TriggerAddCondition(triggerSM,Condition(function notsapper))
        call TriggerAddAction(triggerSM,function stopm)
        set locSM=null
I wanna make that work on 2 areas on the map actually.
 
Last edited:
Level 7
Joined
Oct 19, 2015
Messages
286
Well, the reason I asked was because you had Endfunction in there, which doesn't compile due tot he capital E. However, since you said the codes were useless it sounded like you already tested them ,which didn't make sense since you can't test code if it doesn't even compile.

Anyway, judging by your last post I guess it works now?
 
Level 8
Joined
Jul 10, 2008
Messages
353
well i tested the 2nd version now, kinda works, but units maintain aggro for some reason. (guard is 9999), but i thought stop would make them not keep aggro.
 
Level 8
Joined
Jul 10, 2008
Messages
353
thats the thing, there is nothing in their acquisition range, i think they just go back attacking cause they have vision, and guard its still on from the last "aggro proc"
 
Level 8
Joined
Jul 10, 2008
Messages
353
$D0004=851972 in hex, its same.

No they are suppose to stay there and wait incoming attackers. Other units are coming there. If they dont get any aggro, they stay put. As soon as they get aggro keep going even if i set their location back to that as soon as they leave the rectangle.

Also units that have more than 1 type (not sapper and something else) seems to say fu to stop order >.<

i think i know whats needed...
set their ms to 0 as soon as they enter that rect, then when they get acquire target, i restore their default ms and if they leave that rect i have them moved back and set again ms to 0 till they acquire new target. Now if only i knew how on earth i can do that :p

EDIT:
JASS:
function main takes nothing returns nothing
local region loc_region01
set rect028=Rect(-5125,-1800,-4095,-2575)
set rect029=Rect(4095,-1800,5125,-2575)
set rect095=Rect(-5600,-800,-3500,-4000)
set rect096=Rect(3500,-800,5600,-4000)

set loc_region01=CreateRegion()
set triggerSM=CreateTrigger()
call RegionAddRect(loc_region01,rect028)
call TriggerRegisterEnterRegion(triggerSM,loc_region01,null)
call TriggerAddCondition(triggerSM,Condition(function notsapper))
call TriggerAddAction(triggerSM,function zeroms)
set loc_region01=null

set loc_region01=CreateRegion()
set triggerLR=CreateTrigger()
call RegionAddRect(loc_region01,rect095)
call TriggerRegisterLeaveRegion(triggerLR,loc_region01,null)
call TriggerAddCondition(triggerLR,Condition(function notsapper))
call TriggerAddAction(triggerLR,function goback)
set loc_region01=null

set loc_region01=CreateRegion()
set triggerSM2=CreateTrigger()
call RegionAddRect(loc_region01,rect029)
call TriggerRegisterEnterRegion(triggerSM2,loc_region01,null)
call TriggerAddCondition(triggerSM2,Condition(function notsapper))
call TriggerAddAction(triggerSM2,function zeroms)
set loc_region01=null

set loc_region01=CreateRegion()
set triggerLR2=CreateTrigger()
call RegionAddRect(loc_region01,rect096)
call TriggerRegisterLeaveRegion(triggerLR2,loc_region01,null)
call TriggerAddCondition(triggerLR2,Condition(function notsapper))
call TriggerAddAction(triggerLR2,function goback2)
set loc_region01=null

function notsapper takes nothing returns boolean
return ((IsUnitType(GetEnteringUnit(),UNIT_TYPE_SAPPER))==false)
endfunction     
        
function zeroms takes nothing returns nothing
local trigger loc_trigger01
call SetUnitMoveSpeed(GetEnumUnit(),.0)
call TriggerRegisterUnitEvent(loc_trigger01,GetEnumUnit(),EVENT_UNIT_ACQUIRED_TARGET)
call TriggerAddAction(loc_trigger01,function defms)
endfunction

function defms takes nothing returns nothing
call SetUnitMoveSpeed(GetEnumUnit(),GetUnitDefaultMoveSpeed(GetEnumUnit()))
endfunction

function goback takes nothing returns nothing
set locrect028=GetRectCenter(rect028)
set location001=GetUnitLoc(GetEnumUnit())
call SetUnitPositionLoc(GetEnumUnit(),locrect028)
call IssueImmediateOrderById(GetEnteringUnit(),$D0004)
call SetUnitMoveSpeed(GetEnumUnit(),.0)
call AddSpecialEffectLocBJ(location001,"Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl")
call DestroyEffect(bj_lastCreatedEffect)
call RemoveLocation(location001)
call RemoveLocation(locrect028)
endfunction

function goback2 takes nothing returns nothing
set locrect029=GetRectCenter(rect029)
set location001=GetUnitLoc(GetEnumUnit())
call SetUnitPositionLoc(GetEnumUnit(),locrect029)
call IssueImmediateOrderById(GetEnteringUnit(),$D0004)
call SetUnitMoveSpeed(GetEnumUnit(),.0)
call AddSpecialEffectLocBJ(location001,"Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl")
call DestroyEffect(bj_lastCreatedEffect)
call RemoveLocation(location001)
call RemoveLocation(locrect029)
endfunction

Is this even remotely correct???
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
Nothing I like more than 100 lines of code, that does absolutely nothing in game. LOL

JASS:
function zeroms takes nothing returns nothing
local trigger loc_trigger01=CreateTrigger()
local unit loc_unit01=GetTriggerUnit()
call SetUnitMoveSpeed(loc_unit01,.0)
call IssueImmediateOrderById(loc_unit01,851972)
call TriggerRegisterUnitEvent(loc_trigger01,loc_unit01,EVENT_UNIT_ACQUIRED_TARGET)
call TriggerAddAction(loc_trigger01,function defms)
call DestroyTrigger(loc_trigger01)
endfunction

Anyone knows why this doesnt work?
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
You're adding the RegisterEvent after your actions. The only thing that happens when your event fires is anything in your AddAction and the DestroyTrigger().
I just want the addaction to happen, it restores their ms.

You destroy the trigger loc_trigger01 immediately after creating it, so it won't do anything.
It doesnt do the Addaction first and then get destroyed?
 
Status
Not open for further replies.
Top