Script begginer

Started by egm, January 07, 2005, 06:10:40 PM

Previous topic - Next topic

egm

:banghead:

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:

QuoteIF
  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

#1
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:

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


in trap script:

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...  ^_^

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...
Baldur's Gate II add-on CZ - TC from Dalelands
http://addoncz.gamestar.cz

English forums are opened!

egm

okay, I understand,

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

Thanks!!!

egm

Champagne for everybody!!! :smoke2:

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.

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name:
Email:
Shortcuts: ALT+S post or ALT+P preview