I know very little about AI programming but I have reviewed the AIs of other stage artists and I have tried to modify them and adapt them to my scenario, I explain:
I have the enemy AI that is in the center of the map and the human player and three allies in each cardinal point. The enemy AI through the probability triggers activates the artificial intelligence to randomly attack either the north, south, west or east (human player) use this code to attack:
(defconst gl-punto-inicio1 100)
(defconst gl-punto-destino1 102)
(defconst gl-punto-inicio2 103)
(defconst gl-punto-destino2 104)
(defconst gl-punto-inicio3 105)
(defconst gl-punto-destino3 106)
(defconst gl-punto-inicio4 107)
(defconst gl-punto-destino4 108)
(defconst gl-punto-inicio5 109)
(defconst gl-punto-destino5 110)
(defconst gl-punto-naval1 300)
(defconst gl-punto-navald1 301)
(defconst object-data-language-id 72)
(defconst action-attack-move 19)
(defconst group1 1)
(defconst group2 2)
(defconst group3 3)
(defconst object-data-group-flag 73) ;group id from 0 to 9 or -2 for none
(defconst hint-object 2238)
;destinos
(defrule
(event-detected trigger 10)
=>
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4011) ; destino1
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-destino1)
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4012) ; destino2
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-destino2)
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4013) ; destino1
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-destino3)
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4014) ; destino1
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-destino4)
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4015) ; destino1
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-destino5)
)
; inicio 1
(defrule
(event-detected trigger 21) ;
=>
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4001) ; origen
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-inicio1)
)
(defrule
(event-detected trigger 21)
=>
(up-full-reset-search)
(up-set-target-point gl-punto-inicio1)
(up-filter-distance c: -1 c: 4)
(up-find-local c: infantry-class c: 240)
(up-find-local c: huskarl-line c: 240)
(up-find-local c: cavalry-class c: 240)
(up-find-local c: scout-cavalry-line c: 240)
(up-find-local c: archery-class c: 240)
(up-find-local c: cavalry-archer-class c: 240)
(up-find-local c: scorpion-class c: 240)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-status != 2)
(up-remove-objects search-local object-data-group-flag != -2)
(up-create-group 0 0 c: group1)
(up-modify-group-flag 1 c: group1)
(up-target-point gl-punto-destino1 action-attack-move -1 -1)
)
(defrule
(event-detected trigger 21)
=>
(up-full-reset-search)
(up-find-local c: infantry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: huskarl-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: cavalry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: scout-cavalry-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: archery-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-remove-objects search-local object-data-action == actionid-attack)
(up-target-point gl-punto-destino1 action-attack-move -1 -1)
(acknowledge-event trigger 21)
)
; inicio 2
(defrule
(event-detected trigger 22) ;
=>
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4002) ; origen
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-inicio2)
)
(defrule
(event-detected trigger 22)
=>
(up-full-reset-search)
(up-set-target-point gl-punto-inicio2)
(up-filter-distance c: -1 c: 4)
(up-find-local c: infantry-class c: 240)
(up-find-local c: huskarl-line c: 240)
(up-find-local c: cavalry-class c: 240)
(up-find-local c: scout-cavalry-line c: 240)
(up-find-local c: archery-class c: 240)
(up-find-local c: cavalry-archer-class c: 240)
(up-find-local c: scorpion-class c: 240)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-status != 2)
(up-remove-objects search-local object-data-group-flag != -2)
(up-create-group 0 0 c: group1)
(up-modify-group-flag 1 c: group1)
(up-target-point gl-punto-destino2 action-attack-move -1 -1)
)
(defrule
(event-detected trigger 22)
=>
(up-full-reset-search)
(up-find-local c: infantry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: huskarl-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: cavalry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: scout-cavalry-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: archery-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-remove-objects search-local object-data-action == actionid-attack)
(up-target-point gl-punto-destino2 action-attack-move -1 -1)
(acknowledge-event trigger 22)
)
; inicio 3
(defrule
(event-detected trigger 23) ;
=>
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4003) ; origen
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-inicio3)
)
(defrule
(event-detected trigger 23)
=>
(up-full-reset-search)
(up-set-target-point gl-punto-inicio3)
(up-filter-distance c: -1 c: 4)
(up-find-local c: infantry-class c: 240)
(up-find-local c: huskarl-line c: 240)
(up-find-local c: cavalry-class c: 240)
(up-find-local c: scout-cavalry-line c: 240)
(up-find-local c: archery-class c: 240)
(up-find-local c: cavalry-archer-class c: 240)
(up-find-local c: scorpion-class c: 240)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-status != 2)
(up-remove-objects search-local object-data-group-flag != -2)
(up-create-group 0 0 c: group1)
(up-modify-group-flag 1 c: group1)
(up-target-point gl-punto-destino3 action-attack-move -1 -1)
)
(defrule
(event-detected trigger 23)
=>
(up-full-reset-search)
(up-find-local c: infantry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: huskarl-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: cavalry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: scout-cavalry-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: archery-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-remove-objects search-local object-data-action == actionid-attack)
(up-target-point gl-punto-destino2 action-attack-move -1 -1)
(acknowledge-event trigger 23)
)
; inicio 4
(defrule
(event-detected trigger 24)
=>
(up-full-reset-search)
(up-find-local c: hint-object c: 240)
(up-remove-objects search-local object-data-language-id != 4004) ; origen
(up-set-target-object search-local c: 0)
(up-get-point position-object gl-punto-inicio4)
)
(defrule
(event-detected trigger 24)
=>
(up-full-reset-search)
(up-set-target-point gl-punto-inicio4)
(up-filter-distance c: -1 c: 4)
(up-find-local c: infantry-class c: 240)
(up-find-local c: huskarl-line c: 240)
(up-find-local c: cavalry-class c: 240)
(up-find-local c: scout-cavalry-line c: 240)
(up-find-local c: archery-class c: 240)
(up-find-local c: cavalry-archer-class c: 240)
(up-find-local c: scorpion-class c: 240)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-status != 2)
(up-remove-objects search-local object-data-group-flag != -2)
(up-create-group 0 0 c: group1)
(up-modify-group-flag 1 c: group1)
(up-target-point gl-punto-destino4 action-attack-move -1 -1)
)
(defrule
(event-detected trigger 24)
=>
(up-full-reset-search)
(up-find-local c: infantry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: huskarl-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: cavalry-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: scout-cavalry-line c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: archery-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-find-local c: siege-weapon-class c: 240)
(up-remove-objects search-local object-data-group-flag != group1)
(up-remove-objects search-local object-data-action == actionid-attack)
(up-target-point gl-punto-destino3 action-attack-move -1 -1)
(acknowledge-event trigger 24)
)
To go from one point to another he used the object “Hint object” with which he changed the name for example: 4001 (start) 4011 (destination) and by spawning military units they made the army that attacks each point randomly.
The problem is that it continues to attack the eastern point, it does it without problems but when it is instructed to attack the other points the army goes to another place on the map that is not any of the destination points, I already checked the code also the triggers but I don’t see that it is failing. Help please

