Hey there.
First of all I'd like to say that I'm not good with JASS, but kinda looking through the codes RaiN. made for my map and trying to copycat a littlebit what he did to make other triggers.
Here I wanted to make one long script that has every computer AI thingy in it. From making NPC's invisible/visible to creating units and ordering to move somewere if they enter a certain rect.
Now when I last saved the map it worked. But that was when I only had the invisible/visible part in the code with making a unit visible if someone comes within 400 of it ..etc not so interesting.
The problem is that when I worked on it today and made it summon some units that will get ordered to attack walk to various area's, it kinda went wrong. For some reason the map gives me a fatal error the moment it finishes the loading screen so I suppose there's something wrong on init. But what?!
Is there any kind dude here that would like to check through the code. I may have done something that's not possible while I didn't know it.
Here's the code:
First of all I'd like to say that I'm not good with JASS, but kinda looking through the codes RaiN. made for my map and trying to copycat a littlebit what he did to make other triggers.
Here I wanted to make one long script that has every computer AI thingy in it. From making NPC's invisible/visible to creating units and ordering to move somewere if they enter a certain rect.
Now when I last saved the map it worked. But that was when I only had the invisible/visible part in the code with making a unit visible if someone comes within 400 of it ..etc not so interesting.
The problem is that when I worked on it today and made it summon some units that will get ordered to attack walk to various area's, it kinda went wrong. For some reason the map gives me a fatal error the moment it finishes the loading screen so I suppose there's something wrong on init. But what?!
Is there any kind dude here that would like to check through the code. I may have done something that's not possible while I didn't know it.
Here's the code:
JASS:
scope BloodbaneAI initializer init
globals
private unit GiddyStabfingers ///Level 24 Goblin Thief///
private timer GiddyStabfingersT
private trigger GiddyStabfingersTrigger = CreateTrigger()
private trigger OrcAttackers1T = CreateTrigger()
private group OrcAttackers1g
private group DwarfAttackers1g
private region KorgromReg1
private region KorgromReg2
private region MovementReg1
private trigger KorgromAreaET = CreateTrigger()
private trigger KorgromAreaLT = CreateTrigger()
private boolexpr BoolAlly
private boolexpr BoolPlayer
private group tempg = CreateGroup()
private trigger EnterFirstRegT = CreateTrigger()
private trigger EnterSecondRegT = CreateTrigger()
private region FirstMovementRegion = CreateRegion()
private region SecondMovementRegion = CreateRegion()
endglobals
//==============================================================================================
// Showing/Hiding Heroes
//==============================================================================================
private function GiddyStabfingersHide takes nothing returns nothing
local unit tempu = null
call GroupEnumUnitsInRange(tempg, GetUnitX(GiddyStabfingers), GetUnitY(GiddyStabfingers), 400., BoolAlly)
set tempu = FirstOfGroup(tempg)
if tempu == null then
call ShowUnit(GiddyStabfingers,false)
call PauseUnit(GiddyStabfingers,true)
else
call TimerStart(GiddyStabfingersT, 10., false, function GiddyStabfingersHide)
endif
loop
exitwhen tempu == null
set tempu = FirstOfGroup(tempg)
call GroupRemoveUnit(tempg, tempu)
endloop
endfunction
private function GiddyStabfingersShow takes nothing returns nothing
local unit tempu = null
call GroupEnumUnitsInRange(tempg, GetUnitX(GiddyStabfingers), GetUnitY(GiddyStabfingers), 400., BoolAlly)
set tempu = FirstOfGroup(tempg)
if tempu != null then
call ShowUnit(GiddyStabfingers,true)
call PauseUnit(GiddyStabfingers,false)
loop
exitwhen tempu == null
set tempu = FirstOfGroup(tempg)
call GroupRemoveUnit(tempg, tempu)
endloop
endif
call TimerStart(GiddyStabfingersT, 10., false, function GiddyStabfingersHide)
endfunction
//===============================================================================================
// Unit Orders
//===============================================================================================
private function OrcAttackGroup1 takes nothing returns nothing
local real chance = GetRandomReal(0., 100.)
local unit tempu = null
///Making Orc/Trolls ///
set tempu = CreateUnit(Player(11),'o007', 10700., -10700., 293.)
call GroupAddUnit(OrcAttackers1g, tempu)
set tempu = CreateUnit(Player(11),'o008', 10785., -10342., 274.)
call GroupAddUnit(OrcAttackers1g, tempu)
if chance > 50. then
set tempu = CreateUnit(Player(11),'o007', 10479., -10842., 324.)
call GroupAddUnit(OrcAttackers1g, tempu)
endif
set chance = GetRandomReal(0., 100.)
if chance > 50. then
call GroupPointOrder(OrcAttackers1g, "attack", GetRectCenterX(gg_rct_MovementRect1),GetRectCenterY(gg_rct_MovementRect1))
else
call GroupPointOrder(OrcAttackers1g, "attack", GetRectCenterX(gg_rct_MovementRect2),GetRectCenterY(gg_rct_MovementRect2))
endif
///Making Dwarves///
set tempu = CreateUnit(Player(9),'h00H', 7108., -15762., 108.)
call GroupAddUnit(DwarfAttackers1g, tempu)
set tempu = CreateUnit(Player(9),'h00I', 7396., -15366., 104.)
call GroupAddUnit(DwarfAttackers1g, tempu)
if chance > 50. then
set tempu = CreateUnit(Player(9),'h00I', 6768., -13343., 224.)
call GroupAddUnit(DwarfAttackers1g, tempu)
endif
set chance = GetRandomReal(0., 100.)
if chance > 50. then
call GroupPointOrder(DwarfAttackers1g, "attack", GetRectCenterX(gg_rct_MovementRect1),GetRectCenterY(gg_rct_MovementRect1))
else
call GroupPointOrder(DwarfAttackers1g, "attack", GetRectCenterX(gg_rct_MovementRect2),GetRectCenterY(gg_rct_MovementRect2))
endif
set tempu = null
endfunction
private function GrouppedUnitDied takes nothing returns nothing
local unit tempu = GetDyingUnit()
if IsUnitInGroup(tempu, DwarfAttackers1g) == true then
call GroupRemoveUnit(DwarfAttackers1g, tempu)
elseif IsUnitInGroup(tempu, OrcAttackers1g) == true then
call GroupRemoveUnit(OrcAttackers1g, tempu)
endif
set tempu = null
endfunction
/// Basic Enter/Leave Region Trigger ///
private function EnterFirstReg takes nothing returns nothing
local unit tempu = GetEnteringUnit()
if IsUnitInGroup(tempu, OrcAttackers1g) == true then
call IssuePointOrder(tempu, "attack", GetRectCenterX(gg_rct_MovementRect3),GetRectCenterY(gg_rct_MovementRect3))
endif
if IsUnitInGroup(tempu, DwarfAttackers1g) == true then
call IssuePointOrder(tempu, "attack", GetRectCenterX(gg_rct_MovementRect4),GetRectCenterY(gg_rct_MovementRect4))
endif
endfunction
private function EnterSecondReg takes nothing returns nothing
local unit tempu = GetEnteringUnit()
if IsUnitInGroup(tempu, OrcAttackers1g) == true then
call IssuePointOrder(tempu, "attack", 3930.,-15250.)
endif
endfunction
//===============================================================================================
// Area (de)activation
//===============================================================================================
private function KorgromAreaEnter takes nothing returns nothing
local group tempg = CreateGroup()
call GroupEnumUnitsInRect(tempg, gg_rct_OrcFog1, BoolPlayer)
if FirstOfGroup(tempg) != null then
///Enabling the Area's Triggers///
call EnableTrigger(OrcAttackers1T)
call EnableTrigger(KorgromAreaLT)
call DisableTrigger(KorgromAreaET)
else
call GroupEnumUnitsInRect(tempg, gg_rct_OrcFog2, BoolPlayer)
if FirstOfGroup(tempg) != null then
///Enabling the Area's Triggers///
call EnableTrigger(OrcAttackers1T)
call EnableTrigger(KorgromAreaLT)
call DisableTrigger(KorgromAreaET)
endif
endif
endfunction
private function KorgromAreaLeave takes nothing returns nothing
local group tempg = CreateGroup()
call GroupEnumUnitsInRect(tempg, gg_rct_OrcFog1, BoolPlayer)
if FirstOfGroup(tempg) == null then
///Disabling the ARea's Triggers///
call DisableTrigger(OrcAttackers1T)
call EnableTrigger(KorgromAreaET)
call DisableTrigger(KorgromAreaLT)
else
call GroupEnumUnitsInRect(tempg, gg_rct_OrcFog2, BoolPlayer)
if FirstOfGroup(tempg) == null then
///Disabling the ARea's Triggers///
call DisableTrigger(OrcAttackers1T)
call EnableTrigger(KorgromAreaET)
call DisableTrigger(KorgromAreaLT)
endif
endif
endfunction
//===============================================================================================
// Init
//===============================================================================================
private function IsAlliedHero takes nothing returns boolean
return IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), Player(11)) and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(GetFilterUnit())) == MAP_CONTROL_USER
endfunction
private function IsHero takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) and GetPlayerController(GetOwningPlayer(GetFilterUnit())) == MAP_CONTROL_USER
endfunction
private function init takes nothing returns nothing
local trigger trig = CreateTrigger()
///hiding units///
set GiddyStabfingers = gg_unit_N013_0678
call ShowUnit(GiddyStabfingers,false)
call PauseUnit(GiddyStabfingers,true)
///regions///
set KorgromReg1 = CreateRegion()
call RegionAddRect(KorgromReg1,gg_rct_OrcFog1)
set KorgromReg2 = CreateRegion()
call RegionAddRect(KorgromReg1,gg_rct_OrcFog2)
set BoolAlly = Condition(function IsAlliedHero)
set BoolPlayer = Condition(function IsHero)
///Enter/Leave Regions///
call TriggerRegisterEnterRegion(KorgromAreaET,KorgromReg1,null)
call TriggerRegisterEnterRegion(KorgromAreaET,KorgromReg2,null)
call TriggerAddAction(KorgromAreaET,function KorgromAreaEnter)
call TriggerRegisterLeaveRegion(KorgromAreaLT,KorgromReg1,null)
call TriggerRegisterLeaveRegion(KorgromAreaLT,KorgromReg2,null)
call TriggerAddAction(KorgromAreaLT,function KorgromAreaLeave)
call DisableTrigger(KorgromAreaLT)
///Hero Visibility///
call TriggerRegisterUnitInRange(GiddyStabfingersTrigger,GiddyStabfingers,400.,null)
call TriggerAddAction(GiddyStabfingersTrigger,function GiddyStabfingersShow)
///Movement/Spawns///
call TriggerRegisterTimerEvent(OrcAttackers1T,GetRandomReal(45.,55.),true)
call TriggerAddAction(OrcAttackers1T,function OrcAttackGroup1)
call DisableTrigger(OrcAttackers1T)
call RegionAddRect(FirstMovementRegion,gg_rct_MovementRect1)
call RegionAddRect(FirstMovementRegion,gg_rct_MovementRect2)
call TriggerRegisterEnterRegion(EnterFirstRegT,FirstMovementRegion,null)
call TriggerAddAction(EnterFirstRegT,function EnterFirstReg)
call RegionAddRect(SecondMovementRegion,gg_rct_MovementRect3)
call TriggerRegisterEnterRegion(EnterSecondRegT,SecondMovementRegion,null)
call TriggerAddAction(EnterSecondRegT,function EnterSecondReg)
///Others///
call TriggerRegisterPlayerUnitEvent(trig,Player(9),EVENT_PLAYER_UNIT_DEATH,BOOLEXPR_TRUE)
call TriggerRegisterPlayerUnitEvent(trig,Player(10),EVENT_PLAYER_UNIT_DEATH,BOOLEXPR_TRUE)
call TriggerRegisterPlayerUnitEvent(trig,Player(11),EVENT_PLAYER_UNIT_DEATH,BOOLEXPR_TRUE)
call TriggerAddAction(trig,function GrouppedUnitDied)
set trig = null
endfunction
endscope