hi,
this library doesn't compile...
the syntax check doesn't help a lot... if anything come to your mind about what might be wrong...i'd like to be enlightned.
[Jass=]
library Animal
globals
private group g=CreateGroup()
private group g2=CreateGroup()
constant integer MANASTONE_ID = 'I036'
endglobals
private function countplayer takes nothing returns integer
local integer np=0
local integer i=0
loop
exitwhen i > 11
if udg_Defeat == false then
set np = np + 1
endif
set i = i + 1
endloop
return np
endfunction
private function removeUnit takes unit u returns nothing
call UnitRemoveItemFromSlot( u, 0 )
call UnitRemoveItemFromSlot( u, 1 )
call UnitRemoveItemFromSlot( u, 2 )
call UnitRemoveItemFromSlot( u, 3 )
call UnitRemoveItemFromSlot( u, 4 )
call UnitRemoveItemFromSlot( u, 5 )
call RemoveUnit(u)
endfunction
private function babies takes player owner, real x, real y, integer id, integer spawn returns nothing
local integer j
local integer k
local real x1
local real y1
local real n
set k = GetRandomInt(1, 10)
if k < 7 then
set k = 1
elseif k < spawn then
set k = 2
else
set k = 3
endif
set j = 1
loop
exitwhen j > k
set n = GetRandomReal(0, 360)
set x1 = x + 200. * Cos(n * bj_DEGTORAD)
set y1 = y + 200. * Sin(n * bj_DEGTORAD)
call CreateUnit( owner, id, x1, y1, bj_UNIT_FACING )
set j = j + 1
endloop
endfunction
private function sprout takes player owner, real x, real y, integer id returns nothing
local real x1
local real y1
local real n
local unit beast
set n = GetRandomReal(0, 360)
set x1 = x + 400. * Cos(n * bj_DEGTORAD)
set y1 = y + 400. * Sin(n * bj_DEGTORAD)
set beast = CreateUnit( owner, id, x1, y1, bj_UNIT_FACING )
call UnitRemoveAbility( beast,'Afir' )
call UnitRemoveAbility( beast,'Afio' )
call UnitRemoveAbility( beast,'Afih' )
call UnitRemoveAbility( beast,'Afin' )
call UnitRemoveAbility( beast,'Afiu' )
endfunction
public function Reproduction takes nothing returns nothing
local real x
local real y
local unit u
local unit beast
local integer i
local integer t
local integer p
local player owner
set p = countplayer()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
set i = GetUnitTypeId(u)
set x = GetUnitX(u)
set y = GetUnitY(u)
set owner = GetOwningPlayer(u)
exitwhen u == null
if IsUnitType(u, UNIT_TYPE_DEAD) == false then
// beast behaviour when full mana (evolve, spawn babies)
if GetUnitState(u, UNIT_STATE_MANA) == GetUnitState(u, UNIT_STATE_MAX_MANA) then
if i == CARNIVORBUSH_ID then
call removeUnit(u)
set udg_Eat_count = ( udg_Eat_count + 1 )
set udg_Bush[udg_Eat_count] = CreateDestructable( 'B003', x, y, 0., 1.60, 0 )
set udg_MonsterBush[udg_Eat_count] = true
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, udg_Bush[udg_Eat_count] )
call SetUnitUserData( CreateUnit( Player(PLAYER_NEUTRAL_AGGRESSIVE), CARNIVORPLANT_ID, x, y, bj_UNIT_FACING ), udg_Eat_count )
set udg_Eat_Current = ( udg_Eat_Current + 1 )
set udg_Eat_DataStore[udg_Eat_Current] = udg_Eat_count
elseif i == MONSTER_2_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, MONSTER_3_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_AQUA )
elseif i == MONSTER_1_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, MONSTER_2_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_AQUA )
elseif i == BOAR_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, FATHOG_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,PIGLET_ID,9)
endif
elseif i == PIGLET_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, BOAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == RABBIT_ID then
call removeUnit(u)
call CreateUnit( owner, FATRABBIT_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,BUNNY_ID,9)
endif
elseif i == BUNNY_ID then
call removeUnit(u)
call CreateUnit( owner, RABBIT_ID, x, y, bj_UNIT_FACING )
elseif i == ALLIGATOR_ID then
call removeUnit(u)
call CreateUnit( owner, GIANTALLIGATOR_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,ALLIGATOR_EGG_ID,10)
endif
elseif i == ALLIGATORHATCHLING_ID then
call removeUnit(u)
call CreateUnit( owner, ALLIGATOR_ID, x, y, bj_UNIT_FACING )
elseif i == ALLIGATOR_EGG_ID then
call removeUnit(u)
call CreateUnit( owner, ALLIGATORHATCHLING_ID, x, y, bj_UNIT_FACING )
elseif i == RACOON_ID then
call removeUnit(u)
call CreateUnit( owner, FATRACOON_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,RACOONCUB_ID,9)
endif
elseif i == RACOONCUB_ID then
call removeUnit(u)
call CreateUnit( owner, RACOON_ID, x, y, bj_UNIT_FACING )
elseif i == SABERCAT_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, OLDSABERCAT_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,SABERKITTEN_ID,9)
endif
elseif i == SABERKITTEN_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, SABERCAT_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
elseif i == SNAKE_EGG_ID then
call removeUnit(u)
call babies(owner,x,y,JUNGLEASPIC_ID,10)
elseif i == JUNGLEASPIC_ID then
call removeUnit(u)
call CreateUnit( owner, JUNGLEVIPER_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, SNAKE_EGG_ID, x, y, bj_UNIT_FACING )
call CreateItem('I00A', x, y)
endif
elseif i == SPIDER_EGGBAG_ID then
call removeUnit(u)
call babies(owner,x,y,BLACKWIDOW_ID,11)
elseif i == BLACKWIDOW_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, TARENTULA_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
elseif i == TARENTULA_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, TARENTULAQUEEN_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, SPIDER_EGGBAG_ID, x, y, bj_UNIT_FACING )
call CreateUnit( owner, WEBLAIR_ID, x, y, bj_UNIT_FACING )
endif
elseif i == TORTOISE_EGG_ID then
call removeUnit(u)
call babies(owner,x,y,TORTOISE_ID,11)
elseif i == TORTOISE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, GIANTTORTOISE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == GIANTTORTOISE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, ANCIENTTORTOISE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, TORTOISE_EGG_ID, x, y, bj_UNIT_FACING )
endif
elseif i == RIVERCRAB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, IMPERCRAB_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_ORANGE )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,HERMITCRAB_ID,9)
endif
elseif i == HERMITCRAB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, RIVERCRAB_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == FROG_ID then
call removeUnit(u)
call CreateUnit( owner, BULLFROG_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,FROG_ID,10)
endif
elseif i == UGLYFROG_EGG_ID then
call removeUnit(u)
call CreateUnit( owner, FROLL_ID, x, y, bj_UNIT_FACING )
elseif i == BIRDNEST_A_ID or i == BIRDNEST_G_ID then
call removeUnit(u)
call babies(owner,x,y,JUNGLEBIRD_ID,11)
elseif i == JUNGLEBIRD_ID then
call removeUnit(u)
call CreateUnit( owner, BIGJUNGLEBIRD_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
set t = GetRandomInt(1,udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0.5 then
set udg_NestNumber = udg_NestNumber + 1
set udg_NestTree[udg_NestNumber] = udg_Tree[t]
set x = GetDestructableX(udg_NestTree[udg_NestNumber])
set y = GetDestructableY(udg_NestTree[udg_NestNumber])
set udg_BirdNest[udg_NestNumber] = CreateUnit( owner, BIRDNEST_A_ID, x, y, bj_UNIT_FACING )
call TriggerRegisterDeathEvent( gg_trg_NestingBirds, udg_NestTree[udg_NestNumber] )
endif
endif
elseif i == VULTURENEST_A_ID or i == VULTURENEST_G_ID then
call removeUnit(u)
call babies(owner,x,y,VULTURE_ID,11)
elseif i == VULTURE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, GRIFFONVULTURE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_LIGHT_GRAY )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
set t = GetRandomInt(1,udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0.5 then
set udg_NestNumber = udg_NestNumber + 1
set udg_NestTree[udg_NestNumber] = udg_Tree[t]
set x = GetDestructableX(udg_NestTree[udg_NestNumber])
set y = GetDestructableY(udg_NestTree[udg_NestNumber])
set udg_BirdNest[udg_NestNumber] = CreateUnit( owner, VULTURENEST_A_ID, x, y, bj_UNIT_FACING )
call TriggerRegisterDeathEvent( gg_trg_NestingBirds, udg_NestTree[udg_NestNumber] )
endif
endif
elseif i == ANTELOPE_ID then
call removeUnit(u)
set beast = CreateUnit( owner, ANTELOPESTAG_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) then
call UnitAddAbility( beast ,'A007' )
endif
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,ANTELOPEFAWN_ID,9)
endif
elseif i == ANTELOPEFAWN_ID then
call removeUnit(u)
set beast = CreateUnit( owner, ANTELOPE_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) then
call UnitAddAbility( beast ,'A007' )
endif
elseif i == BEAR_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, OLDBEAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,BEARCUB_ID,9)
endif
elseif i == BEARCUB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, BEAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == RAT_ID then
call removeUnit(u)
call SetUnitAbilityLevel( CreateUnit( owner, MANGYRAT_ID, x, y, bj_UNIT_FACING ),'A0E0', 2 )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,RAT_ID,9)
endif
elseif i == BERRYSAPPLING_ID then
call removeUnit(u)
call CreateUnit( owner, BERRYBUSH_ID, x, y, bj_UNIT_FACING )
call UnitRemoveAbility( beast,'Afir' )
call UnitRemoveAbility( beast,'Afio' )
call UnitRemoveAbility( beast,'Afih' )
call UnitRemoveAbility( beast,'Afin' )
call UnitRemoveAbility( beast,'Afiu' )
elseif i == BERRYBUSH_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call UnitAddItemById( u, BERRY_ID )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,BERRYBUSH_ID)
endif
elseif i == ARIA_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, ARIA_BLOSSOM_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,ARIA_ID)
endif
elseif i == BARDANE_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, BARDANE_PETAL_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,BARDANE_ID)
endif
elseif i == CORIAN_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, CORIAN_LEAVE_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,CORIAN_ID)
endif
elseif i == DRAXIMOR_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, DRAXIMOR_BELL_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,DRAXIMOR_ID)
endif
elseif i == BEEHIVE_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call UnitAddItemById( u, HONEY_ID )
elseif i == DOG1_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG2_ID, x, y, bj_UNIT_FACING )
elseif i == DOG2_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG3_ID, x, y, bj_UNIT_FACING )
elseif i == DOG3_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG4_ID, x, y, bj_UNIT_FACING )
elseif i == DOG4_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG5_ID, x, y, bj_UNIT_FACING )
elseif i == DOG5_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG6_ID, x, y, bj_UNIT_FACING )
elseif i == HAWK1_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG2_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == HAWK2_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG3_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == HAWK3_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG4_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == FROLLHUTT_ID or i == FROLLVILLAGE_ID then
elseif i == FROLL_ID then
endif
// beast behaviour when 0 mana (evolve, die)
elseif GetUnitState(u, UNIT_STATE_MANA) == 0. then
if i == WARFROLL_ID then
call UnitAddAbility( u, 'S00Y' )
// some old beast instead of dying have 10% chance to evolve into a rare beast type
elseif GetRandomInt(1, 10) == 1 then
if i == ANTELOPESTAG_ID then
call removeUnit(u)
call CreateUnit( owner, ROYALSTAG_ID, x, y, bj_UNIT_FACING )
elseif i == GIANTALLIGATOR_ID then
call removeUnit(u)
call CreateUnit( owner, CROCODILE_ID, x, y, bj_UNIT_FACING )
elseif i == FATHOG_ID then
call removeUnit(u)
call CreateUnit( owner, RAZORBACK_ID, x, y, bj_UNIT_FACING )
elseif i == OLDSABERCAT_ID then
call removeUnit(u)
call CreateUnit( owner, SABERLION_ID, x, y, bj_UNIT_FACING )
elseif i == OLDBEAR_ID then
call removeUnit(u)
call CreateUnit( owner, CAVEBEAR_ID, x, y, bj_UNIT_FACING )
elseif i == BULLFROG_ID then
call removeUnit(u)
call CreateUnit( owner, POISONFROG_ID, x, y, bj_UNIT_FACING )
endif
// old beast die (everybeast here has failed the 10% chance)
elseif i == BULLFROG_ID or i == FATRABBIT_ID or i == TARENTULAQUEEN_ID or i == ANCIENTTORTOISE_ID or i == IMPERCRAB_ID or i == PIRANHA_ID or i == MANGYRAT_ID or i == FATRACOON_ID or i == JUNGLEVIPER_ID or i == BIGJUNGLEBIRD_ID or i == GRIFFONVULTURE_ID or i == FATUGLYFROG_ID or i == ANTELOPESTAG_ID or i == GIANTALLIGATOR_ID or i == FATHOG_ID or i == OLDSABERCAT_ID or i == OLDBEAR_ID then
call removeUnit(u)
endif
// beast ordinary behaviour when mana is between 0 and full
else
elseif i == CROCODILE_ID or i == GIANTALLIGATOR_ID or i == ALLIGATOR_ID or i == ALLIGATORHATCHLING_ID or i == ANCIENTTORTOISE_ID or i == GIANTTORTOISE_ID or i == TORTOISE_ID or i == JUNGLEASPIC_ID or i == ANACONDA_ID or i == JUNGLEVIPER_ID or i == COMODODRAGON_ID or i == GIANTTORTOISE_Z_ID_ID or i == TORTOISE_Z_ID_ID or i == SNAKE_Z_ID or i == ALLIGATOR_Z_ID then
if GetRandomInt(1, 4) == 1 then
call UnitRemoveAbility( u, 'SCae' )
elseif GetUnitAbilityLevel(u, 'SCae') == 0 then
call UnitAddAbility( u, 'SCae' )
endif
elseif i == BULLFROG_ID or i == FROG_ID or i == POISONFROG_ID or i == UGLYFROG_ID or i == FATUGLYFROG_ID then
if GetRandomInt(1, 2) == 1 then
call UnitRemoveAbility( u, 'SCae' )
elseif GetUnitAbilityLevel(u, 'SCae') == 0 then
call UnitAddAbility( u, 'SCae' )
endif
elseif i == SABERLION_ID or i == OLDSABERCAT_ID or i == SABERCAT_ID or i == SABERKITTEN_ID or SABERCAT_Z_ID then
if GetRandomInt(1, 3) < 3 then
call UnitRemoveAbility( u, 'A0DY' )
call UnitRemoveAbility( u, 'S00W' )
elseif GetUnitAbilityLevel(u, 'A0DY') == 0 then
call UnitAddAbility( u, 'A0DY' )
call UnitAddAbility( u, 'S00W' )
endif
endif
endif
endif
call GroupRemoveUnit(g, u)
endloop
endfunction
endlibrary
[/code]
this library doesn't compile...
the syntax check doesn't help a lot... if anything come to your mind about what might be wrong...i'd like to be enlightned.
[Jass=]
library Animal
globals
private group g=CreateGroup()
private group g2=CreateGroup()
constant integer MANASTONE_ID = 'I036'
endglobals
private function countplayer takes nothing returns integer
local integer np=0
local integer i=0
loop
exitwhen i > 11
if udg_Defeat == false then
set np = np + 1
endif
set i = i + 1
endloop
return np
endfunction
private function removeUnit takes unit u returns nothing
call UnitRemoveItemFromSlot( u, 0 )
call UnitRemoveItemFromSlot( u, 1 )
call UnitRemoveItemFromSlot( u, 2 )
call UnitRemoveItemFromSlot( u, 3 )
call UnitRemoveItemFromSlot( u, 4 )
call UnitRemoveItemFromSlot( u, 5 )
call RemoveUnit(u)
endfunction
private function babies takes player owner, real x, real y, integer id, integer spawn returns nothing
local integer j
local integer k
local real x1
local real y1
local real n
set k = GetRandomInt(1, 10)
if k < 7 then
set k = 1
elseif k < spawn then
set k = 2
else
set k = 3
endif
set j = 1
loop
exitwhen j > k
set n = GetRandomReal(0, 360)
set x1 = x + 200. * Cos(n * bj_DEGTORAD)
set y1 = y + 200. * Sin(n * bj_DEGTORAD)
call CreateUnit( owner, id, x1, y1, bj_UNIT_FACING )
set j = j + 1
endloop
endfunction
private function sprout takes player owner, real x, real y, integer id returns nothing
local real x1
local real y1
local real n
local unit beast
set n = GetRandomReal(0, 360)
set x1 = x + 400. * Cos(n * bj_DEGTORAD)
set y1 = y + 400. * Sin(n * bj_DEGTORAD)
set beast = CreateUnit( owner, id, x1, y1, bj_UNIT_FACING )
call UnitRemoveAbility( beast,'Afir' )
call UnitRemoveAbility( beast,'Afio' )
call UnitRemoveAbility( beast,'Afih' )
call UnitRemoveAbility( beast,'Afin' )
call UnitRemoveAbility( beast,'Afiu' )
endfunction
public function Reproduction takes nothing returns nothing
local real x
local real y
local unit u
local unit beast
local integer i
local integer t
local integer p
local player owner
set p = countplayer()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
set i = GetUnitTypeId(u)
set x = GetUnitX(u)
set y = GetUnitY(u)
set owner = GetOwningPlayer(u)
exitwhen u == null
if IsUnitType(u, UNIT_TYPE_DEAD) == false then
// beast behaviour when full mana (evolve, spawn babies)
if GetUnitState(u, UNIT_STATE_MANA) == GetUnitState(u, UNIT_STATE_MAX_MANA) then
if i == CARNIVORBUSH_ID then
call removeUnit(u)
set udg_Eat_count = ( udg_Eat_count + 1 )
set udg_Bush[udg_Eat_count] = CreateDestructable( 'B003', x, y, 0., 1.60, 0 )
set udg_MonsterBush[udg_Eat_count] = true
call TriggerRegisterDeathEvent( gg_trg_DropItemDestructible__JASS, udg_Bush[udg_Eat_count] )
call SetUnitUserData( CreateUnit( Player(PLAYER_NEUTRAL_AGGRESSIVE), CARNIVORPLANT_ID, x, y, bj_UNIT_FACING ), udg_Eat_count )
set udg_Eat_Current = ( udg_Eat_Current + 1 )
set udg_Eat_DataStore[udg_Eat_Current] = udg_Eat_count
elseif i == MONSTER_2_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, MONSTER_3_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_AQUA )
elseif i == MONSTER_1_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, MONSTER_2_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_AQUA )
elseif i == BOAR_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, FATHOG_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,PIGLET_ID,9)
endif
elseif i == PIGLET_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, BOAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == RABBIT_ID then
call removeUnit(u)
call CreateUnit( owner, FATRABBIT_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,BUNNY_ID,9)
endif
elseif i == BUNNY_ID then
call removeUnit(u)
call CreateUnit( owner, RABBIT_ID, x, y, bj_UNIT_FACING )
elseif i == ALLIGATOR_ID then
call removeUnit(u)
call CreateUnit( owner, GIANTALLIGATOR_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,ALLIGATOR_EGG_ID,10)
endif
elseif i == ALLIGATORHATCHLING_ID then
call removeUnit(u)
call CreateUnit( owner, ALLIGATOR_ID, x, y, bj_UNIT_FACING )
elseif i == ALLIGATOR_EGG_ID then
call removeUnit(u)
call CreateUnit( owner, ALLIGATORHATCHLING_ID, x, y, bj_UNIT_FACING )
elseif i == RACOON_ID then
call removeUnit(u)
call CreateUnit( owner, FATRACOON_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,RACOONCUB_ID,9)
endif
elseif i == RACOONCUB_ID then
call removeUnit(u)
call CreateUnit( owner, RACOON_ID, x, y, bj_UNIT_FACING )
elseif i == SABERCAT_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, OLDSABERCAT_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,SABERKITTEN_ID,9)
endif
elseif i == SABERKITTEN_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, SABERCAT_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
elseif i == SNAKE_EGG_ID then
call removeUnit(u)
call babies(owner,x,y,JUNGLEASPIC_ID,10)
elseif i == JUNGLEASPIC_ID then
call removeUnit(u)
call CreateUnit( owner, JUNGLEVIPER_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, SNAKE_EGG_ID, x, y, bj_UNIT_FACING )
call CreateItem('I00A', x, y)
endif
elseif i == SPIDER_EGGBAG_ID then
call removeUnit(u)
call babies(owner,x,y,BLACKWIDOW_ID,11)
elseif i == BLACKWIDOW_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, TARENTULA_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
elseif i == TARENTULA_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, TARENTULAQUEEN_ID, x, y, bj_UNIT_FACING ), ConvertPlayerColor(12) )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, SPIDER_EGGBAG_ID, x, y, bj_UNIT_FACING )
call CreateUnit( owner, WEBLAIR_ID, x, y, bj_UNIT_FACING )
endif
elseif i == TORTOISE_EGG_ID then
call removeUnit(u)
call babies(owner,x,y,TORTOISE_ID,11)
elseif i == TORTOISE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, GIANTTORTOISE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == GIANTTORTOISE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, ANCIENTTORTOISE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call CreateUnit( owner, TORTOISE_EGG_ID, x, y, bj_UNIT_FACING )
endif
elseif i == RIVERCRAB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, IMPERCRAB_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_ORANGE )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,HERMITCRAB_ID,9)
endif
elseif i == HERMITCRAB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, RIVERCRAB_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == FROG_ID then
call removeUnit(u)
call CreateUnit( owner, BULLFROG_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,FROG_ID,10)
endif
elseif i == UGLYFROG_EGG_ID then
call removeUnit(u)
call CreateUnit( owner, FROLL_ID, x, y, bj_UNIT_FACING )
elseif i == BIRDNEST_A_ID or i == BIRDNEST_G_ID then
call removeUnit(u)
call babies(owner,x,y,JUNGLEBIRD_ID,11)
elseif i == JUNGLEBIRD_ID then
call removeUnit(u)
call CreateUnit( owner, BIGJUNGLEBIRD_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
set t = GetRandomInt(1,udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0.5 then
set udg_NestNumber = udg_NestNumber + 1
set udg_NestTree[udg_NestNumber] = udg_Tree[t]
set x = GetDestructableX(udg_NestTree[udg_NestNumber])
set y = GetDestructableY(udg_NestTree[udg_NestNumber])
set udg_BirdNest[udg_NestNumber] = CreateUnit( owner, BIRDNEST_A_ID, x, y, bj_UNIT_FACING )
call TriggerRegisterDeathEvent( gg_trg_NestingBirds, udg_NestTree[udg_NestNumber] )
endif
endif
elseif i == VULTURENEST_A_ID or i == VULTURENEST_G_ID then
call removeUnit(u)
call babies(owner,x,y,VULTURE_ID,11)
elseif i == VULTURE_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, GRIFFONVULTURE_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_LIGHT_GRAY )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
set t = GetRandomInt(1,udg_Tree_count)
if GetDestructableLife(udg_Tree[t]) > 0.5 then
set udg_NestNumber = udg_NestNumber + 1
set udg_NestTree[udg_NestNumber] = udg_Tree[t]
set x = GetDestructableX(udg_NestTree[udg_NestNumber])
set y = GetDestructableY(udg_NestTree[udg_NestNumber])
set udg_BirdNest[udg_NestNumber] = CreateUnit( owner, VULTURENEST_A_ID, x, y, bj_UNIT_FACING )
call TriggerRegisterDeathEvent( gg_trg_NestingBirds, udg_NestTree[udg_NestNumber] )
endif
endif
elseif i == ANTELOPE_ID then
call removeUnit(u)
set beast = CreateUnit( owner, ANTELOPESTAG_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) then
call UnitAddAbility( beast ,'A007' )
endif
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,ANTELOPEFAWN_ID,9)
endif
elseif i == ANTELOPEFAWN_ID then
call removeUnit(u)
set beast = CreateUnit( owner, ANTELOPE_ID, x, y, bj_UNIT_FACING )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) then
call UnitAddAbility( beast ,'A007' )
endif
elseif i == BEAR_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, OLDBEAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,BEARCUB_ID,9)
endif
elseif i == BEARCUB_ID then
call removeUnit(u)
call SetUnitColor( CreateUnit( owner, BEAR_ID, x, y, bj_UNIT_FACING ), PLAYER_COLOR_BROWN )
elseif i == RAT_ID then
call removeUnit(u)
call SetUnitAbilityLevel( CreateUnit( owner, MANGYRAT_ID, x, y, bj_UNIT_FACING ),'A0E0', 2 )
if owner != Player(PLAYER_NEUTRAL_AGGRESSIVE) or GetRandomInt(1, 12) + p >= 12 - udg_Day then
call babies(owner,x,y,RAT_ID,9)
endif
elseif i == BERRYSAPPLING_ID then
call removeUnit(u)
call CreateUnit( owner, BERRYBUSH_ID, x, y, bj_UNIT_FACING )
call UnitRemoveAbility( beast,'Afir' )
call UnitRemoveAbility( beast,'Afio' )
call UnitRemoveAbility( beast,'Afih' )
call UnitRemoveAbility( beast,'Afin' )
call UnitRemoveAbility( beast,'Afiu' )
elseif i == BERRYBUSH_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call UnitAddItemById( u, BERRY_ID )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,BERRYBUSH_ID)
endif
elseif i == ARIA_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, ARIA_BLOSSOM_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,ARIA_ID)
endif
elseif i == BARDANE_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, BARDANE_PETAL_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,BARDANE_ID)
endif
elseif i == CORIAN_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, CORIAN_LEAVE_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,CORIAN_ID)
endif
elseif i == DRAXIMOR_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call SetItemCharges( UnitAddItemById( u, DRAXIMOR_BELL_ID ), GetRandomInt(1, 3) )
if GetRandomInt(1, 100) == 100 then
call sprout(owner,x,y,DRAXIMOR_ID)
endif
elseif i == BEEHIVE_ID then
call SetUnitState(u, UNIT_STATE_MANA, 0.)
call UnitAddItemById( u, HONEY_ID )
elseif i == DOG1_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG2_ID, x, y, bj_UNIT_FACING )
elseif i == DOG2_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG3_ID, x, y, bj_UNIT_FACING )
elseif i == DOG3_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG4_ID, x, y, bj_UNIT_FACING )
elseif i == DOG4_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG5_ID, x, y, bj_UNIT_FACING )
elseif i == DOG5_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG6_ID, x, y, bj_UNIT_FACING )
elseif i == HAWK1_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG2_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == HAWK2_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG3_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == HAWK3_ID then
call removeUnit(u)
set udg_Pet[GetPlayerId(owner)+1] = CreateUnit( owner, DOG4_ID, x, y, bj_UNIT_FACING )
call SetUnitColor( udg_Pet[GetPlayerId(owner)+1], PLAYER_COLOR_BROWN )
elseif i == FROLLHUTT_ID or i == FROLLVILLAGE_ID then
elseif i == FROLL_ID then
endif
// beast behaviour when 0 mana (evolve, die)
elseif GetUnitState(u, UNIT_STATE_MANA) == 0. then
if i == WARFROLL_ID then
call UnitAddAbility( u, 'S00Y' )
// some old beast instead of dying have 10% chance to evolve into a rare beast type
elseif GetRandomInt(1, 10) == 1 then
if i == ANTELOPESTAG_ID then
call removeUnit(u)
call CreateUnit( owner, ROYALSTAG_ID, x, y, bj_UNIT_FACING )
elseif i == GIANTALLIGATOR_ID then
call removeUnit(u)
call CreateUnit( owner, CROCODILE_ID, x, y, bj_UNIT_FACING )
elseif i == FATHOG_ID then
call removeUnit(u)
call CreateUnit( owner, RAZORBACK_ID, x, y, bj_UNIT_FACING )
elseif i == OLDSABERCAT_ID then
call removeUnit(u)
call CreateUnit( owner, SABERLION_ID, x, y, bj_UNIT_FACING )
elseif i == OLDBEAR_ID then
call removeUnit(u)
call CreateUnit( owner, CAVEBEAR_ID, x, y, bj_UNIT_FACING )
elseif i == BULLFROG_ID then
call removeUnit(u)
call CreateUnit( owner, POISONFROG_ID, x, y, bj_UNIT_FACING )
endif
// old beast die (everybeast here has failed the 10% chance)
elseif i == BULLFROG_ID or i == FATRABBIT_ID or i == TARENTULAQUEEN_ID or i == ANCIENTTORTOISE_ID or i == IMPERCRAB_ID or i == PIRANHA_ID or i == MANGYRAT_ID or i == FATRACOON_ID or i == JUNGLEVIPER_ID or i == BIGJUNGLEBIRD_ID or i == GRIFFONVULTURE_ID or i == FATUGLYFROG_ID or i == ANTELOPESTAG_ID or i == GIANTALLIGATOR_ID or i == FATHOG_ID or i == OLDSABERCAT_ID or i == OLDBEAR_ID then
call removeUnit(u)
endif
// beast ordinary behaviour when mana is between 0 and full
else
elseif i == CROCODILE_ID or i == GIANTALLIGATOR_ID or i == ALLIGATOR_ID or i == ALLIGATORHATCHLING_ID or i == ANCIENTTORTOISE_ID or i == GIANTTORTOISE_ID or i == TORTOISE_ID or i == JUNGLEASPIC_ID or i == ANACONDA_ID or i == JUNGLEVIPER_ID or i == COMODODRAGON_ID or i == GIANTTORTOISE_Z_ID_ID or i == TORTOISE_Z_ID_ID or i == SNAKE_Z_ID or i == ALLIGATOR_Z_ID then
if GetRandomInt(1, 4) == 1 then
call UnitRemoveAbility( u, 'SCae' )
elseif GetUnitAbilityLevel(u, 'SCae') == 0 then
call UnitAddAbility( u, 'SCae' )
endif
elseif i == BULLFROG_ID or i == FROG_ID or i == POISONFROG_ID or i == UGLYFROG_ID or i == FATUGLYFROG_ID then
if GetRandomInt(1, 2) == 1 then
call UnitRemoveAbility( u, 'SCae' )
elseif GetUnitAbilityLevel(u, 'SCae') == 0 then
call UnitAddAbility( u, 'SCae' )
endif
elseif i == SABERLION_ID or i == OLDSABERCAT_ID or i == SABERCAT_ID or i == SABERKITTEN_ID or SABERCAT_Z_ID then
if GetRandomInt(1, 3) < 3 then
call UnitRemoveAbility( u, 'A0DY' )
call UnitRemoveAbility( u, 'S00W' )
elseif GetUnitAbilityLevel(u, 'A0DY') == 0 then
call UnitAddAbility( u, 'A0DY' )
call UnitAddAbility( u, 'S00W' )
endif
endif
endif
endif
call GroupRemoveUnit(g, u)
endloop
endfunction
endlibrary
[/code]