- Joined
- Jul 27, 2017
- Messages
- 73
Hello everyone,
i hope someone can help me with this little problem.
In a map i want to add the ability to fuse units to a custom race. (The idea is that you can take for example 2 Footmen and get 1 Knight)
The problem i have is that the trigger doesn´t even come to the point of checking the conditions which fusion is wanted.
Here´s the "interesting" code:
//variables
local unit uTarget = GetSpellTargetUnit()
local player pTrigg = GetOwningPlayer(uTrigg)
local integer iAbility = GetSpellAbilityId()
local integer ic = 0
local integer ic2 = 0
local group groupUnits
local group groupUnits2
//Fusion
elseif(iAbility == 'ACtc') then
set groupUnits = GetUnitsInRectOfPlayer(gg_rct_FusionRect, pTrigg)
call DisplayTextToPlayer(pTrigg, 0, 0, "Get the Group, check"))
if(CountUnitsInGroup(groupUnits) < 2) then
call DisplayTextToPlayer(pTrigg,0,0, "Not enough units to start a fusion")
return
endif
set uTarget = FirstOfGroup(groupUnits)
set ic = GetUnitTypeId(uTarget)
//it works until this point
call GroupRemoveUnit(groupUnits, uTarget) //still works
call DisplayTextToPlayer(pTrigg, 0, 0, "Unit removed from group 1" )
call GroupAddUnit(groupUnits2, uTarget) //here it breaks!!!!!!!!!!!!!
call DisplayTextToPlayer(pTrigg, 0, 0, "Unit added to group 2" ) //i don´t know if it would work now
call DisplayTextToPlayer(pTrigg, 0, 0, "Number of Units to fuse: " + I2S(CountUnitsInGroup(groupUnits)))
call DisplayTextToPlayer(pTrigg, 0, 0, "First unit: " + GetUnitName(uTarget) + I2S(ic) + " number of units: " + I2S(CountUnitsInGroup(groupUnits)))
//Checking conditions 1 example (not the full code)
if(CountUnitsInGroup(groupUnits) == 1) then
call DisplayTextToForce(GetPlayersAll(), "Techlevel: " + I2S(GetPlayerTechCount(pTrigg, 'Rura', true)))
if(ic == 'n025' and GetPlayerTechCount(pTrigg, 'Rura', true) >= 1) then
set uTarget = FirstOfGroup(groupUnits)
set ic = GetUnitTypeId(uTarget)
if(ic == 'n01T') then
set ic2 = 'n02U'
elseif(ic== 'n025' ) then
set ic2 = 'n02T'
endif
Ok this was all that seemed necessary to me.
It breaks when i want to add the unit "uTarget" to the group2 (i want to add the unit to kill all units in the group groupUnits2 later)
ic2 is used to create the wanted unit.
Also if you have a better idea to make this spell and still checking tech-conditions feel free to give me ideas.
Thanks for every help.
i hope someone can help me with this little problem.
In a map i want to add the ability to fuse units to a custom race. (The idea is that you can take for example 2 Footmen and get 1 Knight)
The problem i have is that the trigger doesn´t even come to the point of checking the conditions which fusion is wanted.
Here´s the "interesting" code:
//variables
local unit uTarget = GetSpellTargetUnit()
local player pTrigg = GetOwningPlayer(uTrigg)
local integer iAbility = GetSpellAbilityId()
local integer ic = 0
local integer ic2 = 0
local group groupUnits
local group groupUnits2
//Fusion
elseif(iAbility == 'ACtc') then
set groupUnits = GetUnitsInRectOfPlayer(gg_rct_FusionRect, pTrigg)
call DisplayTextToPlayer(pTrigg, 0, 0, "Get the Group, check"))
if(CountUnitsInGroup(groupUnits) < 2) then
call DisplayTextToPlayer(pTrigg,0,0, "Not enough units to start a fusion")
return
endif
set uTarget = FirstOfGroup(groupUnits)
set ic = GetUnitTypeId(uTarget)
//it works until this point
call GroupRemoveUnit(groupUnits, uTarget) //still works
call DisplayTextToPlayer(pTrigg, 0, 0, "Unit removed from group 1" )
call GroupAddUnit(groupUnits2, uTarget) //here it breaks!!!!!!!!!!!!!
call DisplayTextToPlayer(pTrigg, 0, 0, "Unit added to group 2" ) //i don´t know if it would work now
call DisplayTextToPlayer(pTrigg, 0, 0, "Number of Units to fuse: " + I2S(CountUnitsInGroup(groupUnits)))
call DisplayTextToPlayer(pTrigg, 0, 0, "First unit: " + GetUnitName(uTarget) + I2S(ic) + " number of units: " + I2S(CountUnitsInGroup(groupUnits)))
//Checking conditions 1 example (not the full code)
if(CountUnitsInGroup(groupUnits) == 1) then
call DisplayTextToForce(GetPlayersAll(), "Techlevel: " + I2S(GetPlayerTechCount(pTrigg, 'Rura', true)))
if(ic == 'n025' and GetPlayerTechCount(pTrigg, 'Rura', true) >= 1) then
set uTarget = FirstOfGroup(groupUnits)
set ic = GetUnitTypeId(uTarget)
if(ic == 'n01T') then
set ic2 = 'n02U'
elseif(ic== 'n025' ) then
set ic2 = 'n02T'
endif
Ok this was all that seemed necessary to me.
It breaks when i want to add the unit "uTarget" to the group2 (i want to add the unit to kill all units in the group groupUnits2 later)
ic2 is used to create the wanted unit.
Also if you have a better idea to make this spell and still checking tech-conditions feel free to give me ideas.
Thanks for every help.