Jump to content

AttackReevaluate() + constantly switching target


Luke

Recommended Posts

As you probably know, creatures currently executing an 'AttackReevaluate()' action won't switch target unless they're forced to move in order to attack their target.

This is particularly relevant for ranged creatures (since unlike melee attackers they usually don't chase their target) => As a result, you need to execute a 'ClearActions(Myself)' command in order to stop 'AttackReevaluate()' and look for another valid target.

The problem is that it doesn't seem to work in my case.... I'd like to summon @DavidW since he uses this technique quite often in SCS.... Sample script below:

Spoiler

BEGIN_ACTION_DEFINITION
	Name(AttackReevaluateRanged)
	TRIGGER
		!StateCheck(scstarget,STATE_REALLY_DEAD)
	ACTION
		RESPONSE #scsprob1
		EquipRanged()
		AttackReevaluate(scstarget,scsargument1)
END

/////////////////////////////////

IF
	Global("validtarget","LOCALS",1)
	!Range(NearestEnemyOf(Myself),5)
THEN
	RESPONSE #100
		SetGlobal("validtarget","LOCALS",0)
		SetGlobalTimer("stayontarget","LOCALS",TWO_ROUNDS)
		ClearActions(Myself)
END

IF
	See(NearestEnemyOf(Myself))
	!Range(NearestEnemyOf(Myself),5)
	GlobalTimerExpired("stayontarget","LOCALS")
THEN
	RESPONSE #100
		SetGlobalTimer("stayontarget","LOCALS",TWO_ROUNDS)
		ClearActions(Myself)
END

IF
	!Global("inafight","LOCALS",1)
	See(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		SetGlobal("inafight","LOCALS",1)
		SetGlobalTimer("stayontarget","LOCALS",TWO_ROUNDS)
		Continue()
END

IF TRIGGER
	TargetBlock(EnemiesInOrder)
THEN DO
	Combine()
	Action(AttackReevaluateRanged,30)
END

 

The problem is that the CRE in question keeps attacking always the same target, even if someone else is closer than the current target ('NearestEnemyOf(Myself)' is the most important target). It will switch target only after the timer "stayontarget" has expired... But SCS ranged creatures constantly switch targets (even if the timer has not expired yet).

How do you manage to achieve that?

Edited by Luke
Link to post

I’m not sure, to be honest: SCS’s combat AI involves a lot of trial-and-error and playtesting, it wasn’t written off the back of a systematic understanding of exactly what does what. I suggest starting with existing SCS code and editing it one step at a time until the behavior changes.

Link to post

Suit youself, but this makes a creature stop when Player1 leaves:

IF
    !See(Player1)
THEN
    RESPONSE #1
        ClearActions(Myself)
END

IF
    True()
THEN
    RESPONSE #1
        AttackReevaluate("imoen",60)  // Imoen
END

 

Link to post

There's another detail that (unfortunately) the IESDP doesn't mention, i.e.: 'ActionListEmpty()' doesn't return true once 'Reevaluation Period' is up (to tell the truth, I'm not sure about this...)

Edited by Luke
Link to post
On 9/26/2019 at 2:32 AM, DavidW said:

I’m not sure, to be honest: SCS’s combat AI involves a lot of trial-and-error and playtesting, it wasn’t written off the back of a systematic understanding of exactly what does what. I suggest starting with existing SCS code and editing it one step at a time until the behavior changes.

OK, I think I found out what's happening here: it's a matter of using object specifiers (e.g., [PC], SecondNearest([PC]), [EVILCUTOFF] and so forth) instead of 'NearestEnemyOf(Myself)', 'SecondNearestEnemyOf(Myself)', and so forth... Now everything seems to work as I originally intended + this explains why your AI cannot be "lured/kited" 🙂...

Edited by Luke
Link to post
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...