Jump to content
Sign in to follow this  
HerrSvensson

BG2: How to react when attacked by Melee, Ranged, Magic?

Recommended Posts

My question is if there is a good way to react to being attacked and cast the appropriate buffs like protection from magical weapon in script?

 

There are several limitations that I have discovered.

 

AttackedBy does not work properly.

AttackedBy([ANYONE],RANGED) does not work
AttackedBy([ANYONE],MELEE) does not work
AttackedBy([ANYONE],DEFAULT) works

 

What I want to do is to cast WIZARD_MANTLE, WIZARD_IMPROVED_MANTLE, WIZARD_ABSOLUTE_IMMUNITY, WIZARD_PROTECTION_FROM_MAGIC_WEAPONS or WIZARD_PROTECTION_FROM_NORMAL_WEAPONS when it is appropriate. It could work most of the times to just use

 

AttackedBy([ANYONE],DEFAULT)
Range(LastAttackerOf(),10)

 

when attacked by Melee for example (not guaranteed), but to know exactly what type of shield to cast, I need to know more about the attacker, so I use

 

HasItemEquiped("MISTVA01",LastAttackerOf())

 

for example to check if the enemy is using the weapon with code MISTVA01 (vampiric mist use this). According to NearInfinity it is a +3 weapon, but when I try the code against a Vampiric Mist, it will detect the +3 weapon, but the mist attacks with a normal weapon apparently and level drain you, so the spell WIZARD_PROTECTION_FROM_MAGIC_WEAPONS does not work. What does work is WIZARD_PROTECTION_FROM_NORMAL_WEAPONS. Is there a better way to determine what spell to cast? I also tried HasItemEquipedReal, but it seems to do the same.

 

The HitBy function works okay, except against for the CRUSHING constant which is always active for any type of damage for some reason. The problem with this function is that you need to get hit first, and even then you don't know exactly what the appropriate response is (protection vs magic or physical?).

Share this post


Link to post

I think I solved the MISTVA01 mystery. Its flag was not "Magical", and therefore only WIZARD_PROTECTION_FROM_NORMAL_WEAPONS works. The following melee weapons have Enchantments > 0 but can actually be protected with Protection from Normal Weapons:

 

LIONSPIR SNAKSPIR WOLFSPIR BEARSPIR BONEFD MISTCD MISTVA MISTPO ABISRED1 MISTVA2 MISTICE DEMABI01 MISTWA MISTHO PLYSALA STALKESU WIGHT SPECTR ETTIN DAX1H01 PLYFIST WOLFM PLYSPID PLYWYVRN PLYMSTAR SW1H47

 

I tested this with Wakizashi +1 (SW1H47) and then only Protection from Normal Weapons or mantle spells work. Protection from Magical Weapons does not work against these weapons it seems.

Edited by HerrSvensson

Share this post


Link to post

Here are some item codes that I believe the following spells will protect against.

 

Protection from Normal Weapons + all mantle spells:

 

ABISRED1 ACIDOOZ4 AX1H01 AX1H04 B1-10 B1-12 B1-2 B1-20 B1-3 B1-4 B1-6 B1-8 B2-16 B2-8 B3-12 B3-24 B3-30 B4-32 B4-40 BEARBR BEARCA BEARSPIR BLUN01 BLUN02 BLUN04 BLUN06 BLUN08 CARRIO1 CATTAC1 CHILLT DAGG01 DAGG06 DAGG07 DAGG08 DAGG10 DAGG18 DAGG19 DAGGSHIT DAX1H01 DEMABI01 DOGWAWP ETTERC ETTIN FAMPSDAT FIGSPID FIST FLIND1 GBASIL GHOUL1 GHOULC GHOULT GIANTS01 GIBBERIL GISPID HALB01 HALBRD01 HAMM01 HAUNT1 HELLHOUN HUSPID IAX1H01 IBLUN04 IHAMM01 ILLUSION IMP IMPCLAW IMPQUA IOTYUGH ISW1H07 JELLGR1 KIEL1 KUOSPER LACEDO LACEDO02 LIONSPIR MAGICONF MAGIDEAD MAGISPWR MAUREZHI MEPFIR MEPICE MEPLIG MEPMAG MEPSAL MEPSTE MFIST1 MFIST2 MFIST3 MISC4Q MISC5T MISC9O MISC9Q MISTCD MISTHO MISTICE MISTPO MISTVA MISTWA MISTVA2 MUMGREW MUMMYW NEIRED NISHRUU P1-10 P1-12 P1-2 P1-20 P1-3 P1-4 P1-6 P1-8 P2-16 P2-8 PARACARR PARAGHAS PARAGHOU PHSPID PLYFIST PLYMSTAR PLYSALA PLYSPID PLYWYVRN POISA POISF POISK POISSPID PSDCLAW QUASCLAW S1-10 S1-2 S1-20 S1-3 S1-4 S1-6 S1-8 S2-16 S3-8 SAHSPEAR SAHSTAFF SALACOLD SALASPER SAREVO SHADOWWP SIRINE SNAKSPIR SPECTR SPER01 SPIDGI1 SPIDWR SPSPID SQUIRP STAF01 STAF03 STAF04 STALKESU SW1H01 SW1H04 SW1H07 SW1H11 SW1H12 SW1H17 SW1H20 SW1H21 SW1H43 SW1H46 SW1H47 SW1H48 SW1H56 SW1H99 SW2H01 SW2H01B SWSPID SWUDROP TASLOIIL TTSWORD2 VAMPIRE WIGHT WOLFM WOLFSPIR WYVERN XVARTIL

 

 

Only Protection from Normal Missiles:

 

PLYBASS ACIDMIST ACIDOOZ1 ACIDOOZ2 ACIDOOZ3 ANKACID ANKHEG1 AROW01 AROW13 AX1H04 BASIGAZE BASILG1 BOLT01 BULL01 DAGG05 DAGG16 DART01 DART06 DART07 EYEGOR01 IAROW01 IDART01 JELLMU2 KALDW1 MAGICOLD MDK2MTOV MISC7J OOZEGR1 PARABASI POLYOCHR PUDDEN01 QUIV01 SCHLUM1 SPER04 SPER04 SW1H57 ACIDBL WOLFWI1

 

 

 

PFMW + all Mantle spells (Magical weapons):

 

AEGIS AEGIS2 AX1H07 BLUN11 BRUENAXE DWWHIP DWWHIP01 FBLADE HGWRA01 HSWORD MISC4U MISC75 SAHZOM01 SBLADE SHILLE STAF10 SW1H98 SW2H99 ZOMSEA AEGIS ANGAROW AROW03 AROW04 AROW05 AROW06 AROW07 AROW08 AROW09 AROW12 AROW14 AROW16 AROWKC ARROPHE2 ARROPHEO BOLT03 BOLT04 BOLT05 BOLT07 BOW98 BOW99 DART03 DART04 DART05 FLAM01 FRAG01 FRAGSAP FROSTY LASER LIGHT MDK2BUL2 MDK2BULL PULS01 PULS02 SECRET03 SECRET04

 

 

PFMW + all Mantle spells (Enchantment +1):

 

 

AROW02 AROW10 AX1H02 B1-8M1 BLUN03 BLUN05 BLUN07 BLUN14G BLUN14H BLUN14I BLUN20 BOLT02 BOLT08 BRBLP BULL02 CATJAG CATLIO CATTIG DAGG02 DAGG09 DART02 DOPPLE DWBOLT01 DWBOLT02 DWBOLT03 ETTERC1 ETTERC2 GHAST1 HALB02 HAMM02 KORAX01 KUOBOLT MFIST4 NPSW02 OGRE OGRE1 P1-8M1 P3-12M4 PLYBEAR1 PLYWOLF1 QUIVER01 QUIVER02 QUIVER05 RODSWORD S1-12 SAHBOLT SENSPI01 SHAMMR SKELCLUB SPER02 SPER09 SPIDPH1 SPIDSW1 SPIDVO01 SPIDWR1 STAF02 SW1H02 SW1H03 SW1H05 SW1H08 SW1H14 SW1H19 SW1H22 SW1H26 SW1H34 SW1H37 SW1H44 SW1H49 SW1H50 SW1H53 SW2H02 TTSWORD1 WOLFDI WOLFDR WOLFGR

 

 

PFMW + all Mantle spells (Enchantment +2):

 

AROW11 AROW1A AX1H03 AX1H05 AX1H05 AX1H06 AX1H06 AX1H08 AX1H08 AX1H11 B1-10M2 B1-8M2 BASILL1 BASILL2 BLUN13 BLUN14D BLUN14E BLUN14F BLUN15 BLUN16 BLUN17 BLUN19 BLUN21 BLUN24 BOLT06 BONEDAG BRBRP BULL03 CATLIS CHEVIL10 DAGG03 DAGG04 DAGG11 DAGG11 DAGG15 DAGG17 DAGG23 DEMSUC01 DRAGGRE1 DRAGRED1 DRAGSHA1 GENDJI GHOULLOR GOLTOME4 GORWOM1 HALB03 HALB07 HALB08 HALBSHA HAMM03 HAMM05 HAMM08 HELLHO HGNYMPH HGSALF HGSALF HGTRL01 HLOLTH ICETRL JELLMU1 JELLOC1 MFIST5 MINDFLAY NEBDAG NPSTAF NPSW01 NPSW03 NPSW04 NPSW05 NPSW06 PLYTROLL QUIVER03 QUIVER04 QUIVER06 RODMACE S1-12M2 S2-16M2 SALGRFIR SALGRICE SHAMMR2 SIRINE1 SLAYSH01 SPELLH01 SPER05 SPER07 SPSPID3 STAF06 STAF07 STAF09 STAF12 STAF13 STAF15 STAF16 STAF17 STAF18 STAF23 SW1H06 SW1H09 SW1H18 SW1H23 SW1H25 SW1H27 SW1H29 SW1H30 SW1H31 SW1H32 SW1H33 SW1H33A SW1H33C SW1H35 SW1H36 SW1H38 SW1H41 SW1H42 SW1H45 SW1H55 SW2H06 SW2H11 SW2H12 SW2H13 SW2H16 TROLL01 TROLLALL VAMP WA2DAK WA2S1H WAMACE WASTAR WEREWYV WOLFVA1 WOLFWI2 WYVERN1 WYVERN2

 

 

 

PFMW, Improved Mantle, Absolute Immunity(Enchantment +3):

 

ANKHEG2 AROW15 AURSTAF AX1H09 AX1H09 AX1H10 AX1H10 AX1H12 AX1H13 AX1H14 AX1H17 B1-12M3 B1-20M3 B2-16M3 B2-24M3 B3-18M3 B4-32M3 BARLFL BEARPO BEHHIV01 BEHOLD BLUN09 BLUN10 BLUN12 BLUN14 BLUN18 BLUN22 BLUN23 BLUN26 BLUN28 BLUN31 BLUN32 BLUN33 BLUN34 BOLT09 BONEGOLE BOW15 BULL05 CATTIBOW CORNUGON DAGG12 DAGG12 DAGG13 DAGG24 DART08 DEMMAU01 DEVA DEVAEVIL DEVMON01 DOPPLEG DWBLUN01 DWHALB01 DWSPER01 DWSW1H01 DWSW1H02 ELAIRL ELEARL ELEMCHAN ELEMCRYO ELEMHYDR ELEMIMIX ELEMOGRE ELEMSUNN ELEMYANC ELEMZAAM ENMACE ENMORN ENSTAFF ENSW1H01 ENSW1H02 ENSW2H FIREELEL FLOLTH GENDAO GIAFIR GIAFIR2 GIAFIR3 GITH GOLBUR01 GOLFLE GOLMAG01 GORDEM2 GORSNAKE HALB04 HALB12 HAMM06 HAMM06 HAMM07 HAMM12 HSPECTRE KUOBOLT2 KUOBOLT3 MFIST6 MFIST7 MINDFL02 MISCBC MOUND OTYUGH P1-2P PHANBLAD PLANETAR PLYFLIND PLYJELLY POLYCARR POLYRAT REVENT1 REVENT2 RODS04 RODS05 RODSPEAR S3-8M3 SECRET02 SHAMMR3 SKELWASU SPER03 SPER06 SPER08 SPIDHU1 STAF05 STAF08 STAF19 STAF24 STDEATH SW1H10 SW1H13 SW1H15 SW1H39 SW1H40 SW1H51 SW1H52 SW1H54 SW1H62 SW1H68A SW1H70 SW1H72 SW1H73 SW1H74 SW1H75 SW1H76 SW2H03 SW2H07 SW2H14 SW2H15 SW2H20 TELSWD TROLLSP TROLLSPI TROLLTOR UMBER01 UMBER02 WA2HALB WAAXE WAFLAIL WANINJA WAS2H WASPEAR WASTAFF WAWAK WEREGRDR WOLFGRW

 

 

 

PFMW, Absolute Immunity(Enchantment +4):

 

 

AX1H16 AX1H16 B1-12M4 B1-20M4 B4-32M4 BALOR BASILG2 BASILG3 BL3-12M4 BLUN30C BLUN30D BLUN35 BODHI BOW19 BULL04 BULL06 DAGG14 DAGG20 DAGG21 DARTMEL DEMCOR01 DRAGBLUE DRAGBROW DRUEAR DRUFIR EARTHRN ELAIR ELEAR FIREELEM FIRERN GENDJN GENEFR GENSCIM GOLBRA GOLCLA GOLIRO GOLSTO GORWOM4 HALB05 HALB06 HALB09 HALB10 HAMM04 HAMM10 INNOC2 LICH02 LICHEL01 MARILI MFIST8 RAVAG02 S1-10M4 SHAKTI1 SHARSWD SPER10 SPER11 STAF14 STAF20 STAF21 SW1H24 SW1H28 SW1H58 SW1H60 SW1H64 SW1H66 SW1H67 SW1H68 SW1H68C SW1H71 SW1H77 SW1HSEEK SW2H08 SW2H09 SW2HDEAT TELSLAV TELWRAI VAMP1 VAMP2 VAMP3 WATERELE WRAITH1 XBOW15

 

 

 

PFMW, Absolute Immunity(Enchantment +5):

 

AX1H15 BLUN25 BLUN27 BLUN29 BLUN30 CARSOMYR CHALCY1 CHALCY2 DAGG22 DECK622 DEMLORD DEMOGORG DEMOSUM4 DR1-6S DRAGBLAW DRAGSIL1 DRIZZTS ENEBLADE FINSOL01 FINSOL02 GORCAMB HAMM09 HAMM11 HGBER01 HGNYA01 HSLAYWPN MORSWORD RAVAG01 REAVER SENDAI SLAYERWP SPERMEL STAF11 STARDART SW1H16 SW1H59 SW1H61 SW1H63 SW1H65 SW1H69 SW1H69C SW2H05 SW2H10 SW2H17 SW2H18 SW2H21 VORSQUI2 WASLING XBOW16

 

 

PFMW only (Enchantment > +5):

 

KILLSW01 VAMT01 VAMT06 VAMT08 VAMT10 VAMT12 SERIOUS SGRASP SGRASP01 SGRASP02 SGRASP03 SGRASP04 SGRASP05 SGRASP06 SGRASP07 SGRASP08 SGRASP09 SGRASP10 SGRASP11 SGRASP12 SGRASP13 SGRASP14 SGRASP15 SGRASP16 SGRASP17 SGRASP18 SGRASP19 SGRASP20 SGRASP21 SGRASP22 SGRASP23 SGRASP24 SGRASP25 SGRASP26 SGRASP27 SGRASP28 SGRASP29 SGRASP30 SGRASP31 SGRASP32 SLAYLIVE SORB SPER12 BLAKBLAD SW2H19 STAF22 CRITICAL FIRESEED HALB11 HARM MELFMET

 

Most weapons here are just shocking grasp, vampire touch etc.

Edited by HerrSvensson

Share this post


Link to post

crushing damagetype has the silly value of 0 and that's why it's the default and sometimes indistinguishable.

Share this post


Link to post

crushing damagetype has the silly value of 0 and that's why it's the default and sometimes indistinguishable.

That explains it, and makes it a bit more tedious to detect Crushing damage.

Edited by HerrSvensson

Share this post


Link to post

After some testing, to detect some items, you need to use HasItem instead of HasItemEquiped. Example: MELFMET (Melf's MInute meteors). I think it's safer to use HasItem against weapons that are created by magic than static items.

Share this post


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.

Sign in to follow this  

×
×
  • Create New...