1. SPS Accounts:
    Do you find yourself coming back time after time? Do you appreciate the ongoing hard work to keep this community focused and successful in its mission? Please consider supporting us by upgrading to an SPS Account. Besides the warm and fuzzy feeling that comes from supporting a good cause, you'll also get a significant number of ever-expanding perks and benefits on the site and the forums. Click here to find out more.
    Dismiss Notice
Dismiss Notice
You are currently viewing Boards o' Magick as a guest, but you can register an account here. Registration is fast, easy and free. Once registered you will have access to search the forums, create and respond to threads, PM other members, upload screenshots and access many other features unavailable to guests.

BoM cultivates a friendly and welcoming atmosphere. We have been aiming for quality over quantity with our forums from their inception, and believe that this distinction is truly tangible and valued by our members. We'd love to have you join us today!

(If you have any problems with the registration process or your account login, please contact us. If you've forgotten your username or password, click here.)

Scripting question

Discussion in 'BG2: Throne of Bhaal (Classic)' started by OTG, Oct 15, 2006.

  1. OTG Gems: 3/31
    Latest gem: Lynx Eye


    Joined:
    Oct 6, 2006
    Messages:
    64
    Likes Received:
    0
    [​IMG] I've spent some adapting and adding to some of the default scripts to customise them to work better with my playing style, and I've encountered a problem which is really bugging me.
    Jaheira's script is based on the Spellcaster Attack script (fighter3), with spellcasting I've added in, and a small component at the end to check the range to the party leader and move towards them if too far away (useful for when she runs off chasing enemies). My problem is this... While there's still enemies around, Jaheira gets all caught up in the fray and ends up battering Aerie. I can't see anywhere in fighter3 where this should happen. It only seems to be Jaheira and Aerie who are affected, and it's only with weapons that Jaheira lashes out. None of my other party members hate one another so much. Any clues as to where I should look?
     
  2. Gastong Gems: 5/31
    Latest gem: Andar


    Joined:
    Oct 23, 2005
    Messages:
    123
    Likes Received:
    0
    Maybe you could show us the script.
     
  3. OTG Gems: 3/31
    Latest gem: Lynx Eye


    Joined:
    Oct 6, 2006
    Messages:
    64
    Likes Received:
    0
    Doh!

    Code:
    // * For Jaheira and other Fighter / Druids
    // * Heal the party, heal yourself
    // * Attack enemies with spells
    // * Attack enemy spellcasters with ranged weapons
    // * Attack enemy spellcasters with melee weapons
    // * Attack other enemies
    // * Return to the party leader if idle
    // * Based on (and borrowing heavily from) Brent Knowles' scripts - fighter3.baf, cleric3.baf
    
    //*Assistance*
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_SLOW_POISON)
    	See([PC])
    	StateCheck(LastSeenBy(Myself),STATE_POISONED)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_SLOW_POISON)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_NEUTRALIZE_POISON)
    	See([PC])
    	StateCheck(LastSeenBy(Myself),STATE_POISONED)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_NEUTRALIZE_POISON)
    END
    
    // *Heal Others*
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_MASS_CURE)
    	See([PC])
    	OR(2)
    	HPPercentLT(Player1,80)
    	HPPercentLT(Player3,80)
    	OR(2)
    	HPPercentLT(Player2,80)
    	HPPercentLT(Player5,80)
    	OR(2)
    	HPPercentLT(Player4,80)
    	HPPercentLT(Player6,80)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_MASS_CURE)
    END
    
    IF
    	ActionListEmpty()
    	HPPercentLT(LastSeenBy(Myself),10)
    	HaveSpell(CLERIC_HEAL)
    	!StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_HEAL)
    END
    
    IF
    	ActionListEmpty()
    	HPPercentLT(MostDamagedOf(),60)
    	!StateCheck(MostDamagedOf(),STATE_INVISIBLE)
    	HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
    THEN
    	RESPONSE #100
    		Spell(MostDamagedOf(),CLERIC_CURE_SERIOUS_WOUNDS)
    END
    
    IF
    	ActionListEmpty()
    	HPPercentLT(MostDamagedOf(),50)
    	!StateCheck(MostDamagedOf(),STATE_INVISIBLE)
    	HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
    THEN
    	RESPONSE #100
    		Spell(MostDamagedOf(),CLERIC_CURE_LIGHT_WOUNDS)
    END
    
    IF
    	ActionListEmpty()
    	HPPercentLT(MostDamagedOf(),50)
    	!StateCheck(MostDamagedOf(),STATE_INVISIBLE)
    	HaveSpell(CLERIC_AID)
    THEN
    	RESPONSE #100
    		Spell(MostDamagedOf(),CLERIC_AID)
    END
    
    // *Defensive*
    
    // * if see Vampires...
    // * ...protect companions
    IF
    	ActionListEmpty()
    	See([0.0.VAMPIRE])
    	!CombatCounter(0)
    	HaveSpell(CLERIC_NEGATIVE_PLANE_PROTECTION)
    	See([PC])
    	!StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    	CheckStat(LastSeenBy(Myself),0,SCRIPTINGSTATE3)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_NEGATIVE_PLANE_PROTECTION)
    END
    // * ...protect self
    IF
    	ActionListEmpty()
    	See([0.0.VAMPIRE])
    	!CombatCounter(0)
    	HaveSpell(CLERIC_NEGATIVE_PLANE_PROTECTION)
    	CheckStat(Myself,0,SCRIPTINGSTATE3)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_NEGATIVE_PLANE_PROTECTION)
    END
    
    //* Keep protective spells active
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_IRONSKIN)
    	HPGT(LastSeenBy(Myself),20)
    	CheckStatLT(Myself,1,STONESKINS)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_IRONSKIN)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_PHYSICAL_MIRROR)
    	HPGT(LastSeenBy(Myself),20)
    	!HasBounceEffects(Myself)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_PHYSICAL_MIRROR)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_REGENERATE)
    	HPGT(LastSeenBy(Myself),20)
    	HPPercentLT(Myself,60)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_REGENERATE)
    END
    
    //* Offensive druid spells
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_CREEPING_DOOM)
    	HPGT(LastSeenBy(Myself),20)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_CREEPING_DOOM)
    END
     
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_CONFUSION)
    	HPGT(LastSeenBy(Myself),20)
    	!StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_CONFUSION)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_ENTANGLE)
    	HPGT(LastSeenBy(Myself),20)
    	NumCreatureVsPartyGT([ENEMY],4)
    	AreaCheck(OUTDOOR)
    THEN
    	RESPONSE #100
    		Spell(LastSeenBy(Myself),CLERIC_ENTANGLE)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_INSECT_PLAGUE)
    	HPGT(LastSeenBy(Myself),20)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_INSECT_PLAGUE)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_CALL_LIGHTNING)
    	HPGT(LastSeenBy(Myself),20)
    	AreaCheck(OUTDOOR)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_CALL_LIGHTNING)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_SUMMON_INSECTS)
    	HPGT(LastSeenBy(Myself),20)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_SUMMON_INSECTS)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_NATURE_BEAUTY)
    	HPGT(LastSeenBy(Myself),20)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_NATURE_BEAUTY)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))		
    	HaveSpell(CLERIC_FINGER_OF_DEATH)
    	HPGT(LastSeenBy(Myself),20)
    	HPLT(LastSeenBy(Myself),50)
    THEN
    	RESPONSE #100
    		Spell(NearestEnemyOf(Myself),CLERIC_FINGER_OF_DEATH)
    END
    
    
    //*Heal Myself (lower-priority)*
    IF
    	ActionListEmpty()
    	HPPercentLT(Myself,10)
    	HaveSpell(CLERIC_HEAL)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_HEAL)
    END
    
    IF
    	ActionListEmpty()
    	HPPercentLT(Myself,60)
    	HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
    THEN
    	RESPONSE #100
    		Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
    END
    
    //*Combat*
    
    //*target spell-casters first, first with ranged weapons (if at range)
    // * and then with melee weapons
    IF
    	ActionListEmpty()
    	OR(4)
    	See(NearestEnemyOfType([0.0.0.MAGE_ALL]))
    	See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    	See(NearestEnemyOfType([0.0.0.DRUID_ALL]))
    	See(NearestEnemyOfType([0.0.0.BARD_ALL]))
    	!Range(LastSeenBy(Myself),10)
    THEN
    	RESPONSE #100
    		EquipRanged()
    		AttackReevaluate(LastSeenBy(Myself),30)
    END
    
    IF
    	ActionListEmpty()
    	OR(4)
    	See(NearestEnemyOfType([0.0.0.MAGE_ALL]))
    	See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
    	See(NearestEnemyOfType([0.0.0.DRUID_ALL]))
    	See(NearestEnemyOfType([0.0.0.BARD_ALL]))
    THEN
    	RESPONSE #100
    		EquipMostDamagingMelee()
    		AttackReevaluate(LastSeenBy(Myself),30)
    END
    
    // * standard combat
    // * Combat*
    
    IF
    	ActionListEmpty()
    	Help([PC])
    THEN
    	RESPONSE #100
    		AttackReevaluate(LastAttackerOf(LastHelp(Myself)),60)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))
    	!Range(NearestEnemyOf(Myself),10)
    THEN
    	RESPONSE #100
    		EquipRanged()
    		AttackReevaluate(NearestEnemyOf(Myself),30)
    END
    
    IF
    	ActionListEmpty()
    	See(NearestEnemyOf(Myself))
    THEN
    	RESPONSE #100
    		EquipMostDamagingMelee()
    		AttackReevaluate(NearestEnemyOf(Myself),30)
    END
    
    // * don't stray too far from the party leader if not fighting
    IF
    	ActionListEmpty()
    	!Range(LeaderOf(), 20)
    	!See(NearestEnemyOf(Myself))
    THEN
    	RESPONSE #100
    		MoveToObject(LeaderOf(Myself))
    END
    As you can see, it's mostly just bits copied from other scripts, but until I clear this bug, I'm reticent to try to be too clever.
     
Sorcerer's Place is a project run entirely by fans and for fans. Maintaining Sorcerer's Place and a stable environment for all our hosted sites requires a substantial amount of our time and funds on a regular basis, so please consider supporting us to keep the site up & running smoothly. Thank you!

Sorcerers.net is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to products on amazon.com, amazon.ca and amazon.co.uk. Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.