• 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.

need help with this jass.

Status
Not open for further replies.
Level 8
Joined
Jan 18, 2007
Messages
331
hello, can you help me translate this jass script(telling me wath it does) and please change it so it wuld fit with a Blood Mage 0002 in it as hero. id apriciate it ALOT cus this makes my map not working properly.

JASS:
function Credit takes nothing returns string
return "
|cffffff10Spell book experiments|r
|cff00cccc*** Map by : |cff0000ffVexorian.|r

"
endfunction
function DemomapColors takes integer i returns integer
return IntegerTertiaryOp(i>0,12,3)
endfunction
function DemoMapObj takes integer i returns integer
return 0
endfunction
function DemoMapFilter_IsHero takes nothing returns boolean
return IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO)
endfunction
function DemoMap_H2I takes handle h returns integer
return h
return 0
endfunction
function DemoMap_Cache takes nothing returns gamecache
return gg_trg_SpellDemoMap
endfunction
function DemoMap_CacheT takes nothing returns trigger
return InitGameCache("demomap.c")
endfunction
function DemoMap_SetItem takes nothing returns nothing
local item e=GetEnumItem()
local string k=I2S(DemoMap_H2I(e))
call StoreReal(bj_lastCreatedGameCache,k,"sx",GetItemX(e))
call StoreReal(bj_lastCreatedGameCache,k,"sy",GetItemY(e))
call StoreBoolean(bj_lastCreatedGameCache,k,"sb",true)
set e=null
endfunction
function RestoreItemAfterUse takes nothing returns nothing
local item it=GetManipulatedItem()
local string k=I2S(DemoMap_H2I(it))
local gamecache g=InitGameCache("demomap.c")
local real x=GetStoredReal(g,k,"sx")
local real y=GetStoredReal(g,k,"sy")
local integer i=GetItemTypeId(it)
call TriggerSleepAction(0)
if not(GetStoredBoolean(g,k,"sb")) then
elseif not IsItemOwned(it) and GetWidgetLife(it)<=0 and (StringLength(GetItemName(it))>0 or GetTriggerEventId()==EVENT_PLAYER_UNIT_USE_ITEM)then
call FlushStoredMission(g,k)
call PolledWait(3)
set k=I2S(DemoMap_H2I(CreateItem(i,x,y)))
call StoreReal(g,k,"sx",x)
call StoreReal(g,k,"sy",y)
call StoreBoolean(g,k,"sb",true)
endif
set it=null
set g=null
endfunction
function SpawnFootmen takes real x,real y,real angle,boolean showeyecandy returns nothing
local integer a=0
loop
exitwhen a>5
if IsUnitDeadBJ(bj_ghoul[a]) or GetOwningPlayer(bj_ghoul[a])!=Player(0) then
set bj_ghoul[a]=CreateUnit(Player(0),DemoMapObj(0),x,y,angle)
else
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl",GetUnitX(bj_ghoul[a]),GetUnitY(bj_ghoul[a])))
call SetUnitPosition(bj_ghoul[a],x,y)
endif
if showeyecandy then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl",bj_ghoul[a],"origin"))
endif
set a=a+1
endloop
endfunction
function DemoMapLevel takes unit u returns nothing
local dialog prompt=DialogCreate()
local trigger array trig
local integer n=0
local integer i=0
local integer result=0
local integer T=6
call DialogSetMessage(prompt,"Choose Level")
set trig[0]=CreateTrigger()
call TriggerRegisterDialogEvent(trig[0],prompt)
loop
exitwhen n>=9
set n=n+1
set trig[n]=CreateTrigger()
call TriggerRegisterDialogButtonEvent(trig[n],DialogAddButton(prompt,I2S(IMaxBJ(1,(n-1)*T)),0))
endloop
call DialogDisplay(Player(0),prompt,true)
loop
exitwhen GetTriggerEvalCount(trig[0])>0
call TriggerSleepAction(0)
endloop
set i=0
call DialogClear(prompt)
call DialogDestroy(prompt)
set prompt=null
loop
exitwhen i>n
if GetTriggerEvalCount(trig[i])>0 then
set result=i
endif
call DestroyTrigger(trig[i])
set trig[i]=null
set i=i+1
endloop
set result=IMaxBJ(1,(result-1)*T)
if result<GetHeroLevel(u) then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",u,"origin"))
call SetHeroLevelBJ(u,result,true)
call ModifyHeroSkillPoints(u,bj_MODIFYMETHOD_SET,result)
else
call SetHeroLevelBJ(u,result,true)
endif
endfunction
function DemoMapSpell takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
if s==DemoMapObj(2) then
call SetUnitLifePercentBJ(u,100)
call SetUnitManaPercentBJ(u,100)
call UnitResetCooldown(u)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIre\\AIreTarget.mdl",u,"origin"))
elseif s==DemoMapObj(3) then
call DemoMapLevel(u)
elseif s==DemoMapObj(4) then
call SpawnFootmen(GetUnitX(u)+300*CosBJ(GetUnitFacing(u)),GetUnitY(u)+300*SinBJ(GetUnitFacing(u)),GetUnitFacing(u),true)
endif
set u=null
endfunction
function AutoRevive takes nothing returns nothing
local group g=GetUnitsSelectedAll(Player(0))
call ReviveHero(GetTriggerUnit(),GetStartLocationX(0),GetStartLocationY(0),true)
call SetUnitColor(GetTriggerUnit(),ConvertPlayerColor(DemomapColors(0)))
if FirstOfGroup(g)==null then
call SetCameraPosition(GetStartLocationX(0),GetStartLocationY(0))
call SelectUnit(GetTriggerUnit(),true)
endif
call DestroyGroup(g)
set g=null
endfunction
function DemoMapAddItem takes nothing returns nothing
call UnitAddItemToSlotById(GetEnumUnit(),DemoMapObj(1),1)
endfunction
function DemoMapGetGroup takes gamecache g,string k returns group
return GetStoredInteger(g,k,"camp")
return null
endfunction
function RespawnCreep takes nothing returns nothing
local unit u=GetTriggerUnit()
local string k=I2S(DemoMap_H2I(u))
local integer typeid=GetUnitTypeId(u)
local gamecache g=InitGameCache("demomap.c")
local group camp=DemoMapGetGroup(g,k)
local real x=GetStoredReal(g,k,"sx")
local real y=GetStoredReal(g,k,"sy")
local real f=GetStoredReal(g,k,"sf")
local rect r=bj_mapInitialPlayableArea
local integer a=0
if not(HaveStoredReal(g,k,"sx")) then
else
if IsUnitType(u,UNIT_TYPE_HERO) then
loop
exitwhen a>5
call RemoveItem(UnitItemInSlot(u,a))
set a=a+1
endloop
endif
call GroupRemoveUnit(camp,u)
loop
exitwhen FirstOfGroup(camp)==null
call TriggerSleepAction(1)
endloop
call TriggerSleepAction((GetRectMaxX(r)-GetRectMinX(r)+GetRectMaxY(r)-GetRectMinY(r))/2/(90+2.0/3))
if IsUnitType(u,UNIT_TYPE_HERO) then
call SetUnitOwner(u,Player(1),false)
call ReviveHero(u,x,y,true)
call SetUnitOwner(u,Player(12),false)
call GroupAddUnit(camp,u)
set a=0
loop
exitwhen a>5
call UnitAddItemToSlotById(u,GetStoredInteger(g,k,"i"+I2S(a)),a)
set a=a+1
endloop
else
call FlushStoredMission(g,k)
set u=CreateUnit(Player(12),typeid,x,y,f)
set k=I2S(DemoMap_H2I(u))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl",u,"origin"))
call StoreReal(g,k,"sx",x)
call StoreReal(g,k,"sy",y)
call StoreReal(g,k,"sf",f)
call StoreInteger(g,k,"camp",DemoMap_H2I(camp))
call GroupAddUnit(camp,u)
endif
endif
set camp=null
set u=null
set g=null
set r=null
endfunction
function DemoMapIsCreep takes nothing returns boolean
return IsUnitOwnedByPlayer(GetFilterUnit(),Player(12)) and IsUnitInGroup(GetFilterUnit(),bj_groupRemoveGroupDest)
endfunction
function DemoMapCreepsInit takes gamecache g returns nothing
local boolexpr B=Condition(function DemoMapIsCreep)
local group r=CreateGroup()
local group aux=CreateGroup()
local group aux2=CreateGroup()
local group c
local unit u
local string k
local integer a=0
call GroupEnumUnitsOfPlayer(r,Player(12),null)
set bj_groupRemoveGroupDest=r
loop
set u=FirstOfGroup(r)
exitwhen u==null
call GroupRemoveUnit(r,u)
set c=CreateGroup()
set bj_groupAddGroupDest=c
call GroupClear(aux)
loop
call GroupClear(aux2)
call GroupEnumUnitsInRange(aux2,GetUnitX(u),GetUnitY(u),500,B)
call GroupAddGroup(aux2,aux)
call GroupRemoveUnit(aux,u)
call GroupRemoveUnit(r,u)
call GroupAddUnit(c,u)
set k=I2S(DemoMap_H2I(u))
call StoreReal(g,k,"sx",GetUnitX(u))
call StoreReal(g,k,"sy",GetUnitY(u))
call StoreReal(g,k,"sf",GetUnitFacing(u))
call StoreInteger(g,k,"camp",DemoMap_H2I(c))
if IsUnitType(u,UNIT_TYPE_HERO) then
set a=0
loop
exitwhen a>5
call StoreInteger(g,k,"i"+I2S(a),GetItemTypeId(UnitItemInSlot(u,a)))
set a=a+1
endloop
endif
set u=FirstOfGroup(aux)
exitwhen u==null
endloop
endloop
call DestroyGroup(r)
call DestroyGroup(aux)
call DestroyGroup(aux2)
call DestroyBoolExpr(B)
set B=null
set r=null
set aux=null
set aux2=null
endfunction
function InitTrig_SpellDemoMap takes nothing returns nothing
local trigger t=CreateTrigger()
set gg_trg_SpellDemoMap=DemoMap_CacheT()
call SetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD,100000)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,100000,Credit())
set bj_wantDestroyGroup=true
call ForGroupBJ(GetUnitsOfPlayerMatching(Player(0),Condition(function DemoMapFilter_IsHero)),function DemoMapAddItem)
call TriggerAddAction(t,function RestoreItemAfterUse)
set bj_lastCreatedGameCache=InitGameCache("demomap.c")
call EnumItemsInRectBJ(GetPlayableMapRect(),function DemoMap_SetItem)
call TriggerRegisterPlayerUnitEvent(t,Player(0),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(t,Player(0),EVENT_PLAYER_UNIT_USE_ITEM,null)
set t=CreateTrigger()
call DemoMapCreepsInit(bj_lastCreatedGameCache)
call TriggerRegisterPlayerUnitEvent(t,Player(12),EVENT_PLAYER_UNIT_DEATH,null)
call TriggerAddAction(t,function RespawnCreep)
set t=CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t,Player(0),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
call TriggerAddAction(t,function DemoMapSpell)
set t=CreateTrigger()
call TriggerRegisterPlayerUnitEventSimple(t,Player(0),EVENT_PLAYER_HERO_REVIVABLE)
call TriggerAddAction(t,function AutoRevive)
set t=CreateTrigger()
call TriggerAddAction(t,function Credit)
set gg_trg_SpellDemoMap=t
call SpawnFootmen(GetStartLocationX(0)+100,GetStartLocationY(0)+100,0,false)
call SetPlayerColorBJ(Player(0),ConvertPlayerColor(DemomapColors(0)),true)
call SetPlayerColorBJ(Player(12),ConvertPlayerColor(DemomapColors(1)),true)
call EnableCreepSleepBJ(false)
call SetTimeOfDay(12)
call SetTimeOfDayScalePercentBJ(0.00)
call FogMaskEnableOff()
call FogEnableOff()
call Preload("Abilities\\Spells\\Items\\AIim\\AIimTarget.mdl")
call Preload("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl")
set t=null
endfunction


:emote_clap: thnx:emote_clap:
 
Status
Not open for further replies.
Top