You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a harassment group can continue to harass, it should be supplemented
I tried to understand this Hashtable function and modified the logic, but I am not sure about this code because AddUnitsToHashtable has intervals and is not the actual unit quantity
You will see that the logic of supplementing the harassment group is still retained here
At the same time, it comes with a fallback recovery freeze logic
function InitHarass takes nothing returns nothing
local integer i = 1
loop
exitwhen i > max_harass_groups
set harass_size[i] = 0
set harass_time[i] = -1000000
if harass_groups[i] == null then
set harass_groups[i] = InitHashtable()
else
set g = CreateGroup()
set g = ReturnLivingUnitsOfHashtable(additional_info, i, HARASS_UNITGROUP, g)
call GroupRecycleGuardPositionInstant(g)
call FlushParentHashtable(harass_groups[i])
set harass_groups[i] = InitHashtable()
endif
set i = i + 1
endloop
set harass_group_length = 0
set distraction_group = 0
set g = null
endfunction
.....................
function StartHarass takes integer groupnum, integer harass_target, boolean avoid_towers, real strength_limit, real flee_percent, integer flee_number, real lx, real ly returns nothing
local integer i = 0
local integer t = 0
local integer c = 0
local group harasser = null
local group g = null
local integer key = groupnum
local real strength = 0
local real getstrength = LoadReal(additional_info, key, START_STRENGTH)
local integer qty = 0
local integer uid = 0
if LoadInteger(additional_info, key, STATE_RETREAT) == 1 then
// This harass is still running
return
elseif getstrength > 0 then
set g = CreateGroup()
set g = ReturnLivingUnitsOfHashtable(additional_info, key, HARASS_UNITGROUP, g)
set c = BlzGroupGetSize(g)
call DestroyGroup(g)
if c >= 12 then
set g = null
return
endif
endif
set harasser = CreateGroup()
set g = CreateGroup()
call Trace("StartHarass : get harass unit" )
call GroupEnumUnitsOfPlayer(g, ai_player, null)
set g = SelectByHidden(g, false)
set g = SelectByAlive(g, true)
loop
exitwhen i >= harass_size[groupnum] or FirstOfGroup(g) == null or t >= 12
set qty = LoadInteger(harass_groups[groupnum], i, HARASS_STORE_QTY)
set uid = LoadInteger(harass_groups[groupnum], i, HARASS_STORE_UNITS)
if t + qty > 12 then // Group Order max control 12 unit
set qty = 12 - t
set t = 12
else
set t = t + qty
endif
if qty > 0 then
set harasser = AddHarassUnittype(groupnum, i, g, harasser, qty, uid, key)
set strength = strength + LoadReal(additional_info, key, START_STRENGTH_TEMP)
endif
set i = i + 1
endloop
call DestroyGroup(g)
set g = null
if FirstOfGroup(harasser) == null or strength <= 0 then
call DestroyGroup(harasser)
set harasser = null
call Trace("StartHarass : get harass unit fail" )
return
endif
if c == 0 then
set harass_time[groupnum] = ai_time
call GroupAddGroup(unit_harassing, harasser)
call FlushChildHashtable(additional_info,key)
call SaveReal(additional_info, key, START_STRENGTH, strength)
call SaveBoolean(additional_info, key, AVOID_TOWERS, avoid_towers)
call SaveReal(additional_info, key, STRENGTH_LIMIT, strength_limit)
call SaveBoolean(additional_info, key, STATE_ATTACKING, true)
call SaveInteger(additional_info, key, STATE_RETREAT, 0)
call SaveReal(additional_info, key, FLEE_PERCENT, flee_percent)
call SaveInteger(additional_info, key, FLEE_NUMBER, flee_number)
call SaveInteger(additional_info, key, INVISIBLE_COUNT, 0)
call SaveReal(additional_info, key, LOCX, lx)
call SaveReal(additional_info, key, LOCY, ly)
call SaveInteger(additional_info, key, HARASS_TARGET, harass_target)
call DisplayToAll("StartHarass : start harass job " + Int2Str(i))
call AddUnitsToHashtable(additional_info, key, HARASS_UNITGROUP, harasser)
call TQAddUnitJob(0, HARASS, key, null)
else
set getstrength = LoadReal(additional_info, key, START_STRENGTH)
call SaveReal(additional_info, key, START_STRENGTH, strength + getstrength)
call GroupAddGroup(unit_harassing, harasser)
call AddUnitsToHashtable(additional_info, key, HARASS_UNITGROUP + BlzGroupGetSize(harasser) + c, harasser)
call Trace("StartHarass : add new unit to harass group" )
endif
call DestroyGroup(harasser)
set harasser = null
endfunction
The text was updated successfully, but these errors were encountered:
During harassment, if the harassment group loses units but does not trigger a stop, new units can be added to the group to continue the harassment. This way, the harassment will not be easily stopped, similar to the logic of replacing wounded soldiers in combat
Will be difficult to do as just because its the same harass group doesn't mean its the exact same harass, any time the strategy changes it could be a different set of units it wants to harass.
I overlooked this point.............
If you are willing to accept the fallacy
if the current harassment team does not retreat, only need to replace the injured and do not need to initiate new harassment -- This actually disperses the troops. It will be dealt with simply and roughly
If a harassment group can continue to harass, it should be supplemented
I tried to understand this
Hashtable function
and modified the logic, but I am not sure about this code becauseAddUnitsToHashtable
has intervals and is not the actual unit quantityYou will see that the logic of supplementing the harassment group is still retained here
At the same time, it comes with a fallback recovery freeze logic
The text was updated successfully, but these errors were encountered: