Skip to content

fix harass groups #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions common.eai
Original file line number Diff line number Diff line change
Expand Up @@ -10031,7 +10031,7 @@ endfunction
// (AMAI) Harrass Functions
//============================================================================
function InitHarass takes nothing returns nothing
local integer i = 1
local integer i = 0
loop
exitwhen i > max_harass_groups
set harass_size[i] = 0
Expand All @@ -10044,6 +10044,7 @@ function InitHarass takes nothing returns nothing
else
call FlushParentHashtable(harass_groups)
set harass_groups = InitHashtable()
call GroupRecycleHarrassPositionInstant(unit_harassing)
endif
//call Trace("InitHarassEnd")
set distraction_group = 0
Expand Down Expand Up @@ -10086,8 +10087,8 @@ 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 group harasser = CreateGroup()
local group g = CreateGroup()
local group harasser = null
local group g = null
local integer key = groupnum
local real strength = 0
local integer qty = 0
Expand All @@ -10097,7 +10098,8 @@ function StartHarass takes integer groupnum, integer harass_target, boolean avoi
// This harass is still running
return
endif

set harasser = CreateGroup()
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, ai_player, null)
set g = SelectByHidden(g, false)
set g = SelectByAlive(g, true)
Expand Down Expand Up @@ -10154,8 +10156,8 @@ function GetHarassGroupStrength takes integer groupnum returns real
local integer t = 0
loop
exitwhen i >= harass_size[groupnum] or t >= 12
set id = LoadInteger(harass_groups, groupnum, i)
set qty = LoadInteger(harass_groups, groupnum, i + 1)
set id = LoadInteger(harass_groups, groupnum, i + 1)
set qty = LoadInteger(harass_groups, groupnum, i)
set t = t + qty
if t + qty > 12 then
set qty = 12 - t
Expand Down