Help - Search - Members - Calendar
Full Version: Script begginer
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modder's Workshop
egm
banghead.gif

Here what I want: make a container invisible for everybody unless a thief (or a character with the detect traps skill) detect a special trap. Detecting invisible container should reward XP. I have a container named "Cont01" and a trap "Traps01". i decided to code that in the area script (AREATEST)

Here it is:

QUOTE
IF
  True()
THEN
  RESPONSE #100
ContainerEnable("Cont01",0)
END

IF
  Detected("Traps01")
THEN
  RESPONSE #100
RemoveTraps("Traps01")
ContainerEnable("Cont01",1)
DisplayStringHead("Cont01",XXXXX)//You have detected a secret container!
AddexperienceParty(YYY)
DisplayString((),ZZZZZ)//You win YYY XP
END


Is it correct?
Vlasák
First: In your first block, you have there True() in triggers. That means that this block is always proceeded. When the block is proceeded, the scripts restarts to its beginning -> you have the infinite loop with this first block. Use there some variable to ensure that the container is disabled only once.

Second: Detected...

0x0054 Detected(O:Object*)
Only for trap scripts. Returns true only if the specified object detected this trap in the last script round.



- detected() can be used only in trap script and with correct object. ([ANYONE], [PC],...)

So I suggest something as:

in area script:

CODE
IF
 Global("ContainerStuff","ARxxxx",0)
THEN
 RESPONSE #100
 ContainerEnable("Cont01",0)
 SetGlobal("ContainerStuff","ARxxxx",1)
END


in trap script:

CODE
IF
 Detected([ANYONE])
 Global("ContainerStuff","ARxxxx",1) //ensure that party got the XP only once and all the stuff is proceeded just once
THEN
 RESPONSE #100
   RemoveTraps("Traps01")
   ContainerEnable("Cont01",1)
   DisplayStringHead("Cont01",XXXXX)//You have detected a secret container!
//I'm not sure whether this works with containers... whether they have any "head" (technically;))) if not, you can simulate it via invisible creature stands near this container and ActionOverride("my_invis",DisplayStringHead(myself,XYZ))
   AddexperienceParty(YYY)
   DisplayString((),ZZZZZ)//You win YYY XP
   SetGlobal("ContainerStuff","ARxxxx",2)
END



This may work... happy.gif

BTW just an addition: AddexperienceParty(N) provides the displaying of "Party gains N XPs" - so dispalystring((),'Party gains N XPs') is not needed after it...
egm
okay, I understand,

And for the DisplayStringHead, I think I will display on "LastTrigger" instead

Thanks!!!
egm
Champagne for everybody!!! smoke2.gif

It takes me hours to fully tested and understand how it works, but now its works!!!
egm
By, the way, it seems that the trigger Detected () isn't triggered by the spell effect: find traps. I mean, when its Yoshimo with its class ability, it works, but when it's Jaheira with a spell, it doesn't.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.