- Joined
- Dec 15, 2009
- Messages
- 625
I am currently using JNGP and Warcraft 1.24e. I wrote a simple JASS code(im learning), but the map doesn't load in Wc3, can anyone help me out? I don't have access to the code atm (im on a different computer).
globals
integer array minecount //tracks the stone mined by a villager. It should not exceed the allowed number. Default is 10, can be increased.
integer mc_index
endglobals
//researches for faster mining speed will not be implemented. However the amount of stone mined can go up.
function minecountset takes nothing returns nothing
local integer LoopHolder = 0
loop
exitwhen LoopHolder > 5
set minecount[LoopHolder] =10
endloop
endfunction
//The above function sets minecount to 10 for every player. This can be upgraded by researching the stone mining techs in the storage.
function stoneconds takes nothing returns boolean
if ( not ((GetSpellAbilityId()=='Ahar'))) then
return false
endif
return true
endfunction // 'Ahar' is the standard harvest ability of the peasant.
function stoneconds2 takes nothing returns boolean
if ( not ( (GetUnitTypeId(GetSpellTargetUnit())=='h008'))) then
return false
endif
return true // 'h008' is the id for the stone mine
endfunction
function stoneactions takes nothing returns nothing
call IssueTargetOrder(GetSpellAbilityUnit(),"attack",GetSpellTargetUnit()) //supposed to order the casting unit into attacking the target unit.
endfunction
function ocond takes nothing returns boolean
return (GetIssuedOrderId()== String2OrderIdBJ("attack"))//Converts string to an order,in this case,attack
endfunction
function unitcheckcond takes nothing returns boolean
if( not ((IsUnitType(GetTriggerUnit(), ConvertUnitType('h008'))))) then
return false
endif
return true//'h008' is the Id for the Stone Mine
endfunction
function extraction takes nothing returns nothing
local integer amountmined = 0
loop
exitwhen amountmined == minecount[GetPlayerId(GetOwningPlayer(GetAttacker()))]//ends the loop when the worker has the required amount (10 stone)
set amountmined = amountmined + 1
call SetUnitLifePercentBJ(GetAttackedUnitBJ(),100.0) // sets life of this to 100%
call IssueTargetOrder(GetAttacker(),"attack",GetAttackedUnitBJ())//Orders the 'harvesting' unit to attack the mine once more
endloop
endfunction
function theactualharvest takes nothing returns nothing
local trigger stoneharvest=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(stoneharvest,EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(stoneharvest,Condition(function ocond))//function ocond is condition for this trigger/action
call TriggerAddAction(stoneharvest,function extraction)
endfunction
function maintrigger takes nothing returns nothing
local trigger stonetrigharvest = CreateTrigger()
call TriggerAddAction(stonetrigharvest, function stoneactions)
call TriggerAddCondition(stonetrigharvest, Condition(function stoneconds))
call TriggerAddCondition(stonetrigharvest, Condition(function stoneconds2))
call TriggerRegisterAnyUnitEventBJ(stonetrigharvest,EVENT_PLAYER_UNIT_SPELL_CAST)
endfunction
function unitcheckcond takes nothing returns boolean
if( not ((IsUnitType(GetTriggerUnit(), ConvertUnitType('h008'))))) then
return false
endif
return true//'h008' is the Id for the Stone Mine
endfunction
function unitcheckcond takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), ConvertUnitType('h008'))
endfunction
function unitcheckcond takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h008'
endfunction
//researches for faster mining speed will not be implemented. However the amount of stone mined can go up.
function minecountset takes nothing returns nothing
local integer LoopHolder = 0
loop
exitwhen LoopHolder > 5
set minecount[LoopHolder] =10
endloop
endfunction
Also,i think triggers can only have one condition right?
ConvertUnitType('h008')
//===================================================
// Unit Type Constants for use with IsUnitType()
//===================================================
constant unittype UNIT_TYPE_HERO = ConvertUnitType(0)
constant unittype UNIT_TYPE_DEAD = ConvertUnitType(1)
constant unittype UNIT_TYPE_STRUCTURE = ConvertUnitType(2)
constant unittype UNIT_TYPE_FLYING = ConvertUnitType(3)
constant unittype UNIT_TYPE_GROUND = ConvertUnitType(4)
constant unittype UNIT_TYPE_ATTACKS_FLYING = ConvertUnitType(5)
constant unittype UNIT_TYPE_ATTACKS_GROUND = ConvertUnitType(6)
constant unittype UNIT_TYPE_MELEE_ATTACKER = ConvertUnitType(7)
constant unittype UNIT_TYPE_RANGED_ATTACKER = ConvertUnitType(8)
constant unittype UNIT_TYPE_GIANT = ConvertUnitType(9)
constant unittype UNIT_TYPE_SUMMONED = ConvertUnitType(10)
constant unittype UNIT_TYPE_STUNNED = ConvertUnitType(11)
constant unittype UNIT_TYPE_PLAGUED = ConvertUnitType(12)
constant unittype UNIT_TYPE_SNARED = ConvertUnitType(13)
constant unittype UNIT_TYPE_UNDEAD = ConvertUnitType(14)
constant unittype UNIT_TYPE_MECHANICAL = ConvertUnitType(15)
constant unittype UNIT_TYPE_PEON = ConvertUnitType(16)
constant unittype UNIT_TYPE_SAPPER = ConvertUnitType(17)
constant unittype UNIT_TYPE_TOWNHALL = ConvertUnitType(18)
constant unittype UNIT_TYPE_ANCIENT = ConvertUnitType(19)
constant unittype UNIT_TYPE_TAUREN = ConvertUnitType(20)
constant unittype UNIT_TYPE_POISONED = ConvertUnitType(21)
constant unittype UNIT_TYPE_POLYMORPHED = ConvertUnitType(22)
constant unittype UNIT_TYPE_SLEEPING = ConvertUnitType(23)
constant unittype UNIT_TYPE_RESISTANT = ConvertUnitType(24)
constant unittype UNIT_TYPE_ETHEREAL = ConvertUnitType(25)
constant unittype UNIT_TYPE_MAGIC_IMMUNE = ConvertUnitType(26)
JASS:function unitcheckcond takes nothing returns boolean if( not ((IsUnitType(GetTriggerUnit(), ConvertUnitType('h008'))))) then return false endif return true//'h008' is the Id for the Stone Mine endfunction
These kind of functions can be simplified to
JASS:function unitcheckcond takes nothing returns boolean return IsUnitType(GetTriggerUnit(), ConvertUnitType('h008')) endfunction
I'd use
JASS:function unitcheckcond takes nothing returns boolean return GetUnitTypeId(GetTriggerUnit()) == 'h008' endfunction
it might be wise to use a global for the h008.
Almia said:Kay. Fair enough.
Wait i spotted something
ConvertUnitType('h008')
You can't convert that. unit types are structures,heroes,flying,ground,ancient,mechanical,etc