Jump to content

Attack script help needed for BGII custom creature


ericp07

Recommended Posts

Posted

Hello,

 

The Beast of Malar prefers to target spellcasters in a party, if any are present, using the following script:

 

// Prioritize targets to prefer spellcasters

IF
!See([GOODCUTOFF.0.0.SORCERER]) // Highest priority
!See([GOODCUTOFF.0.0.MAGE_ALL])
!See([GOODCUTOFF.0.0.CLERIC_ALL])
!See([GOODCUTOFF.0.0.DRUID_ALL])
!See([GOODCUTOFF.0.0.PALADIN_ALL])
!See([GOODCUTOFF.0.0.RANGER_ALL])	
!See([GOODCUTOFF.0.0.BARD_ALL]) // Default target
!See([GOODCUTOFF])
THEN
RESPONSE #100
	Attack(LastSeenBy())
END

 

I'd like to add, in whatever passes for the most elegant and efficient coding manner, the ability to detect if the target has protections up that would render the beast's attacks ineffective. Should I add StateCheck lines to the above block to account for various arcane/divine protections, or is it better to do it in a separate block? Also, which specific protections should be checked for in the script?

 

Thanks!

Eric

Posted

You'll probably need separate blocks. Check SCS(2)'s or BP's generic combat scripts for examples of what to include - obviously you'll want some sort of trimmed-down version.

Posted
You'll probably need separate blocks. Check SCS(2)'s or BP's generic combat scripts for examples of what to include - obviously you'll want some sort of trimmed-down version.

 

Good deal. Making it modular might facilitate troubleshooting, too. I was looking at one of the script files in RR, and saw a couple StateChecks to use; I'll look at SCSII as well, as I have that mod (and may be installing it shortly).

 

Thanks!

Eric

Posted

Well, I've cobbled something together, but am not set up to test it. Does this look like it would work?

 

// Prioritize targets to prefer spellcasters, avoid unharmable targets

IF
!See([GOODCUTOFF.0.0.SORCERER]) // Highest priority
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)

!See([GOODCUTOFF.0.0.MAGE_ALL])
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

!See([GOODCUTOFF.0.0.CLERIC_ALL])
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)

!See([GOODCUTOFF.0.0.DRUID_ALL])
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

!See([GOODCUTOFF.0.0.PALADIN_ALL])
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

!See([GOODCUTOFF.0.0.RANGER_ALL])	
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

!See([GOODCUTOFF.0.0.BARD_ALL]) // Default target
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

!See([GOODCUTOFF])
OR(3)
CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
CheckStatLT([GOODCUTOFF],1,STONESKINS)	

THEN
RESPONSE #100
	Attack(LastSeenBy())
END

 

It may be ambitious of me to put all this in one complex block (and I'm sure the formatting could be done better), but at least now I have something to start with. I want the beast to try to avoid attacking a target that won't be harmed by non-magical teeth and claws. Nowhere in the creature's description does it say that the natural weapons are considered magical for combat purposes, so I'm leaving them as-is.

 

How can we shape this up, and are there any other protections I should include?

 

Thanks,

Eric

Posted

change all the OR(3) to OR(4)

insert a ! in front of all the CheckStatLT

include NearestEnemyOfType after all the !CheckStatLT and !See

 

move all the !See() lines down to the next one, deleting the first line.

include an !See([GOODCUTOFF.0.0.FIGHTER_ALL]) and associated checks

 

end with an extra !See(NearestEnemyOf(Myself))

 

in other words, follow the example in SimDing0's Scripting Guide closely, dropping the random-number selection and replacing the Helpless check with the (NOT) check for the 3 spells.

 

While at it, its good to try to understand the meaning of the code. Not easy, I know... ^^;;;

Posted

Getting closer. Here's what I have now, after reading Zyraen's as-usual expert advice:

 

// Prioritize targets to prefer spellcasters, avoid unharmable targets

IF
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.SORCERER])) // Highest priority
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.MAGE_ALL]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL])) // Default target
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
OR(4)
  !See(NearestEnemyOfType([GOODCUTOFF]))
  !CheckStatLT([GOODCUTOFF],1,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
  !CheckStatLT([GOODCUTOFF],1,CLERIC_IRONSKIN)
  !CheckStatLT([GOODCUTOFF],1,STONESKINS)
!See(NearestEnemyOf(Myself))
THEN
RESPONSE #100
	Attack(LastSeenBy())
END

 

I'm not trying not to understand coding and how it works (after all, learning is a large part of why I'm doing this!). The learning curve is very steep, though, every step of the way.

 

Will this script do what I want it to do now, or is more refining needed?

 

Thanks!

Eric

Posted

Moved the action down to its own block, so the creature will still attack a target, even if it's not a spellcaster.

 

Before the priority script, the first thing I had in this attack script file was the following:

 

// IF
// 	Heard([ANYONE],111)
// THEN
// 	RESPONSE #100
// 		MoveToObject(NearestEnemyOf(Myself))
// END

// IF
// 	AttackedBy([GOODCUTOFF],DEFAULT)
// 	!Allegiance(Myself,ENEMY)
// THEN
// 	RESPONSE #100
// 		Enemy()
// END

 

Should I still use this, or do I not need it? I'll delete or uncomment as appropriate.

 

Thanks,

Eric

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...