- Joined
- May 20, 2009
- Messages
- 822
Okay, so basically I'm trying to make a proof of concept that an AI can make effective use of point-target spells. So, I made a simple version of StarCraft's Psionic Storm, and now I'm building an AI to effectively use it. I have the concept, but it's becoming difficult to script. But basically, the idea is:
A unit comes in range of the caster at any time.
The system will find all units nearby the unit coming in range, within the caster's own sight range. (Important, otherwise it could potentially stream down the whole map because it found a group of units bigger than the group that initially approached the caster)
The system will then bubble sort all the values, to get the top 3 units with the highest number of other nearby units.
Finally, it will cast my Psionic Storm.
Really finally, it will see if any other Psionic Storms are in effect within it's range, and space it out accordingly. (This part hasn't been done yet, but I got ideas)
So, my issue right now is there's an error somewhere I can't quite point out. This is VERY unfinished, so there's a lot of point leaks and other misc leaks that I haven't gotten to yet and I don't think it's MUI yet either, but that doesn't really matter it just needs to function.
Here are the triggers:
A unit comes in range of the caster at any time.
The system will find all units nearby the unit coming in range, within the caster's own sight range. (Important, otherwise it could potentially stream down the whole map because it found a group of units bigger than the group that initially approached the caster)
The system will then bubble sort all the values, to get the top 3 units with the highest number of other nearby units.
Finally, it will cast my Psionic Storm.
Really finally, it will see if any other Psionic Storms are in effect within it's range, and space it out accordingly. (This part hasn't been done yet, but I got ideas)
So, my issue right now is there's an error somewhere I can't quite point out. This is VERY unfinished, so there's a lot of point leaks and other misc leaks that I haven't gotten to yet and I don't think it's MUI yet either, but that doesn't really matter it just needs to function.
Here are the triggers:
-
Add to AI Group
-
Events
-
Map initialization
-
Unit - A unit enters (Playable map area)
-
Unit - A unit leaves (Playable map area)
-
-
Conditions
-
Actions
-
Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to High Templar)) and do (Actions)
-
Loop - Actions
-
Unit Group - Add (Picked unit) to AI_Group
-
Set AI_MaxIndex = (AI_MaxIndex + 1)
-
Set HT_Unit[AI_MaxIndex] = (Picked unit)
-
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Unit-type of (Triggering unit)) Equal to High Templar
-
-
Then - Actions
-
Unit Group - Add (Triggering unit) to AI_Group
-
Set AI_MaxIndex = (AI_MaxIndex + 1)
-
Set HT_Unit[AI_MaxIndex] = (Triggering unit)
-
For each (Integer AI_Index[2]) from 1 to AI_MaxIndex, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Leaving unit) Equal to AI_TargetingGroup[AI_Index[2]]
-
-
Then - Actions
-
Set AI_TargetingGroup[AI_Index[2]] = AI_TargetingGroup[AI_MaxIndex]
-
Set AI_TargetingGroup[AI_MaxIndex] = No unit
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Leaving unit) Equal to HT_Unit[AI_Index[2]]
-
-
Then - Actions
-
Unit Group - Add HT_Unit[AI_Index[2]] to AI_Group
-
Set HT_Unit[AI_Index[2]] = HT_Unit[AI_MaxIndex]
-
Set HT_Unit[AI_MaxIndex] = No unit
-
-
Else - Actions
-
-
-
-
-
-
-
Else - Actions
-
-
-
-
AI
-
Events
-
Time - Every 0.33 seconds of game time
-
-
Conditions
-
Actions
-
For each (Integer AI_Index[1]) from 1 to AI_MaxIndex, do (Actions)
-
Loop - Actions
-
Set IndexSave[AI_Index[1]] = AI_Index[1]
-
Set AI_Index[1] = 1
-
Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units within 900.00 of (Position of HT_Unit[AI_Index[1]])) and do (Actions)
-
Loop - Actions
-
Set AI_TargetingGroup[AI_Index[1]] = (Picked unit)
-
Set AI_Index[1] = (AI_Index[1] + 1)
-
Set TargetingCount[AI_Index[1]] = (TargetingCount[AI_Index[1]] + 1)
-
-
-
Set AI_Index[1] = IndexSave[1]
-
Unit Group - Pick every unit in (Units within 300.00 of (Position of AI_TargetingGroup[AI_Index[1]])) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between (Position of HT_Unit[AI_Index[1]]) and (Position of (Picked unit))) Less than or equal to 1400.00
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
AI_TargetingGroup[AI_Index[1]] Not equal to No unit
-
-
Then - Actions
-
Set AI_Index[1] = (AI_Index[1] + 1)
-
-
Else - Actions
-
Set AI_TargetingGroup[AI_Index[1]] = (Picked unit)
-
Set TargetingCount[AI_Index[1]] = (TargetingCount[AI_Index[1]] + 1)
-
-
-
-
Else - Actions
-
-
-
-
For each (Integer AI_Index[3]) from 1 to TargetingCount[AI_Index[1]], do (Actions)
-
Loop - Actions
-
Set bubblesort[AI_Index[3]] = (Number of units in (Units within 300.00 of (Position of AI_TargetingGroup[AI_Index[3]])))
-
Set bubblepoint[AI_Index[3]] = (Position of AI_TargetingGroup[AI_Index[3]])
-
Set bubblecount[AI_Index[1]] = (bubblecount[AI_Index[1]] + 1)
-
-
-
For each (Integer AI_Index[4]) from 1 to bubblecount[AI_Index[1]], do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
bubblesort[(AI_Index[4] + tempvar[1])] Greater than bubblesort[(AI_Index[4] + tempvar[2])]
-
-
Then - Actions
-
Set tempvar[10] = bubblesort[(AI_Index[4] + tempvar[2])]
-
Set bubblesort[(AI_Index[4] + tempvar[2])] = bubblesort[(AI_Index[4] + tempvar[1])]
-
Set bubblesort[(AI_Index[4] + tempvar[1])] = tempvar[10]
-
Set tempoint[10] = bubblepoint[(AI_Index[4] + tempvar[2])]
-
Set bubblepoint[(AI_Index[4] + tempvar[2])] = bubblepoint[(AI_Index[4] + tempvar[1])]
-
Set bubblepoint[(AI_Index[4] + tempvar[1])] = tempoint[10]
-
Set tempvar[1] = (tempvar[1] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempvar[1] Equal to bubblecount[AI_Index[1]]
-
-
Then - Actions
-
Set tempvar[2] = (tempvar[2] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
tempvar[2] Equal to 3
-
-
Then - Actions
-
Set AI_Index[4] = tempvar[1]
-
Set tempvar[1] = 0
-
Set tempvar[2] = 0
-
-
Else - Actions
-
Set AI_Index[4] = tempvar[2]
-
Set tempvar[1] = 0
-
-
-
-
Else - Actions
-
Set tempvar[1] = 0
-
Set AI_Index[4] = tempvar[2]
-
-
-
-
Else - Actions
-
Set AI_Index[4] = 1
-
Set tempvar[2] = (tempvar[2] + 1)
-
-
-
-
-
Unit - Order HT_Unit[AI_Index[1]] to Neutral Dark Ranger - Silence tempoint[10]
-
-
-
-