Jump to content


Photo

Why Doesn't This Script Block Work in BGEE?


  • Please log in to reply
9 replies to this topic

#1 Morkfel

Morkfel
  • Member
  • 11 posts

Posted 07 July 2013 - 05:04 PM

// AVOID CHARMED PCs
IF
	AttackedBy([PC],DEFAULT)
THEN
	RESPONSE #100
		RunAwayFrom(LastAttackerOf(Myself),45)
END

 

Just got BGEE on Steam (pretty stoked! Installed the Archaic interface.

 

The thing I always loved about IE games is making scripts. I was cannibalizing some BG2 scripts and included this, but my party members just kill each other when they get charmed. Anyone?

 

The attack style (DEFAULT) never did anything in any of the games, so far as I know.



#2 Yovaneth

Yovaneth

    The newly-appointed Master Builder of Baldur's Gate

  • Modder
  • 3058 posts

Posted 08 July 2013 - 01:20 AM

Instead of using DEFAULT, list all the attack styles in an OR block. DEFAULT sometimes works but most times doesn't.

 

-Y-



#3 Morkfel

Morkfel
  • Member
  • 11 posts

Posted 13 July 2013 - 10:57 PM

Thanks Yovaneth. I've changed it for BGEE to:

 



//AVOID CHARMED PCs
IF
	OR(14)
	  AttackedBy([PC],DEFAULT)
	  HitBy([PC],ACID)
	  HitBy([PC],COLD)
	  HitBy([PC],CRUSHING)
	  HitBy([PC],ELECTRICITY)
	  HitBy([PC],FIRE)
	  HitBy([PC],MAGIC)
	  HitBy([PC],MAGICCOLD)
	  HitBy([PC],MAGICFIRE)
	  HitBy([PC],MISSILE)
	  HitBy([PC],PIERCING)
	  HitBy([PC],POISON)
	  HitBy([PC],SLASHING)
	  HitBy([PC],STUNNING)
THEN
	RESPONSE #100
		RunAwayFrom(LastAttackerOf(Myself),45)
END

 

But poison has a duration that can outlast charm and running from missiles is stupid. Also, area effect spells can damage allies. There is probably a more elegant way, maybe when I'm less tired I'll look at it again.


Edited by Morkfel, 13 July 2013 - 10:59 PM.


#4 Yovaneth

Yovaneth

    The newly-appointed Master Builder of Baldur's Gate

  • Modder
  • 3058 posts

Posted 14 July 2013 - 03:23 PM

There's no easy way to check for a charmed attacker - trust me; there's a group of us fought with this one when ToB was new.

 

-Y-



#5 Morkfel

Morkfel
  • Member
  • 11 posts

Posted 14 July 2013 - 09:34 PM

I believe you. Thanks for the help. Did you ever discover a way to use AREATYPE.IDS to control whether Call LIghtning would be cast or not?



#6 Yovaneth

Yovaneth

    The newly-appointed Master Builder of Baldur's Gate

  • Modder
  • 3058 posts

Posted 15 July 2013 - 12:16 AM

In theory AreaType(areatype.ids) should do it but I've never tried it. I wouldn't be surprised if it doesn't work though; if you're that desperate to use the spell you can always create an OR() list using AreaCheck(resref) where resref is a list of all the outdoors areas (63, I think).

 

-Y-



#7 Morkfel

Morkfel
  • Member
  • 11 posts

Posted 15 July 2013 - 10:49 PM

Hmmm. I don't think I like listing all the areas where it is acceptable to use a spell, since it disables it in any added content/modules.

 

Since I'm asking you about things on my wishlist for scripting, how about favored enemies? It would be nice to be able to script to get Rangers to target their favored enemies first.

 

It's available to scripts through the STATS.IDS as 'HATEDRACE', but I assume it's a string and even if it were an integer which appears in the RACE.IDS, I'm not even sure how I would use that in a script. I would have to retrieve the integer value for HATEDRACE and use it in [EA.GENERAL.RACE] format; something like (pseudocode):

 

IF

GetStat(HATEDRACE > Var1)

See([ENEMY.0.$Var1])

THEN

 

But I don't think we can create variables on the fly like that...



#8 Yovaneth

Yovaneth

    The newly-appointed Master Builder of Baldur's Gate

  • Modder
  • 3058 posts

Posted 16 July 2013 - 03:48 AM

You're right; it won't work. I don't have access to the ids files where I am ATM but what about NearestEnemyOfType()?

 

-Y-



#9 Morkfel

Morkfel
  • Member
  • 11 posts

Posted 16 July 2013 - 10:44 AM

I think you could do either 

 

IF
	See(NearestEnemyOfType(OGRE))
THEN

 

Or

IF
	See([ENEMY.0.OGRE])
	Range(LastSeenBy(Myself),#)
THEN

 

With the range being optional if you need it. But in either case I can't make it universal for whatever favored enemy the player has chosen by accessing the HATEDRACE stat.

 

 

 

 

I've moved over to using STATS from STATE to improve scripting efficiency. For example, some spells:

// 2120 WIZARD_REFLECTED_IMAGE
// 2212 WIZARD_MIRROR_IMAGE
// 2607 WIZARD_MISLEAD
// 2703 WIZARD_PROJECT_IMAGE
// 2804 WIZARD_SIMULACRUM

 

Have a similar function. You can tell if one is already active:

	!StateCheck(Myself,STATE_MIRRORIMAGE)
	!StateCheck(Myself,STATE_INVISIBLE)
	!StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
	!CheckStat(Myself,1,PUPPETMASTERTYPE)
	!CheckStat(Myself,2,PUPPETMASTERTYPE)
	!CheckStat(Myself,3,PUPPETMASTERTYPE)
// 1 = Mislead, 2 = Project Image, 3 = Simulacrum

So if the player chooses to memorize multiple variations they won't overlap and will get used in sequence instead.

 

I wish I could do this for Protection from Evil and Petrification. There don't seem to be states or stats for them.



#10 Wisp

Wisp
  • Modder
  • 1353 posts

Posted 16 July 2013 - 11:09 AM

Use Detectable Spells for PfE. Petrification is STATE_STONE_DEATH.