FredSRichardson Posted August 13, 2007 Share Posted August 13, 2007 Does anyone know what the code below actually does? I'm trying to guess, but I'm not sure. This code is used for "Skeleton Traps" that occur in the Vale of Shadows tombs. I think the idea is that they make skeletons suddenly appear and attack. The converted scripts aren't working quite right in IWD2. It looks like if the AREA_GROUP_VAR:1 (i.e. bit 1) is set, then the creature becomes visible and hostile, but the script doesn't change this variable. Otherwise, if this is the first time through, then the CREATURE_STATE_VAR:1 bit is set and I'm hidden. After that, if AREA_GROUP_VAR:1 is still not set, then I just remain hidden and exit after the next block. Now if I'm no longer hidden (which I guess can only happen if AREA_GROUP_VAR:1 is set), then if I see my enemy and my CREATURE_STATE_VAR:2 isn't set then there's a 50% chance that I'll turn my head or not. In either case CREATURE_STATE_VAR:2 is set and I continue on. (I'll have to look more closely to watch the creatures heads turn). The last 3 blocks are then typical attack sequences. I attack an enemy I see, or one I don't see who attacks me, or I move to the PC if I don't see an enemy. Okay, maybe I do have this figured out. I pasted the trap script below this one. It looks like this is what sets the "AREA_GROUPVAR:1" bit. Then all the skeletons with the first script should appear and attack. I'll have to look more closely and see if I can figure out what's not working. IF !Allegiance(Myself,ENEMY) BitGlobal(":AREA_GROUP_VAR","MYAREA",1,AND) THEN RESPONSE #100 Enemy() Continue() END IF CreatureHidden(Myself) BitGlobal(":AREA_GROUP_VAR","MYAREA",1,AND) THEN RESPONSE #100 HideCreature(Myself,FALSE) Continue() END IF !BitGlobal(":CREATURE_STATE_VAR","LOCALS",1,AND) THEN RESPONSE #100 BitGlobal(":CREATURE_STATE_VAR","LOCALS",1,OR) HideCreature(Myself,TRUE) Continue() END IF CreatureHidden(Myself) THEN RESPONSE #100 NoAction() END IF !BitGlobal(":CREATURE_STATE_VAR","LOCALS",2,AND) See(NearestEnemyOf(Myself)) THEN RESPONSE #50 BitGlobal(":CREATURE_STATE_VAR","LOCALS",2,OR) PlaySequence(Myself,HEAD_TURN) Continue() RESPONSE #50 BitGlobal(":CREATURE_STATE_VAR","LOCALS",2,OR) Continue() END IF See(NearestEnemyOf(Myself)) THEN RESPONSE #100 AttackReevaluate(LastSeenBy(Myself),75) END IF AttackedBy(NearestEnemyOf(Myself),DEFAULT) THEN RESPONSE #100 MoveToObject(LastAttackerOf(Myself)) END IF ActionListEmpty() !See([PC]) THEN RESPONSE #100 MoveToObject([PC]) END Trap triggered script IF Entered([PC]) THEN RESPONSE #100 BitGlobal(":AREA_GROUP_VAR","MYAREA",1,OR) DisplayString(Myself,14381) // ~Trap Sprung~ [AMB_D05C] END IF Opened([PC]) THEN RESPONSE #100 BitGlobal(":AREA_GROUP_VAR","MYAREA",1,OR) DisplayString(Myself,14381) // ~Trap Sprung~ [AMB_D05C] END Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.