Jul 16, 2009 at 8:21 PM
Cold Agony of Resolute Vacuum
"Heavy swords for sale. Suitable for most RPG Protagonists. Apply now!"
Join Date: Jan 1, 2008
Location: Elsewhere
Posts: 1973
With the recent influx of new modders making new mods, I figure I'd give them a break and post these few basic TSC scripts for functions common to most mods. They are very, very basic, only expanding a little into flags, but, with a few changes to the numbers provided in the examples, you can use these for many, many things. I may expand to include a teleports script and a few others, such as a pitfall trap or a basic boss fight. I don't intend to make this a script-mart for easy scripts, I intend this to be a dissection of the basic functions, as well as a learning tool. The scripts, while *theorhetically* just usable as a copy-and-paste idea, will probably have to have a few values changed (and thus learn what the values do). I encourage those reading this to a.) view my organized and fully-explained TSC notes found here and b.) experiment with everything.
Basic Door (Inter-map)
On the map you're leaving:
#0100
<KEY<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is a basic room-to-room door script.
Upon interacting with entity 101 (a door), the game locks out player control (<KEY), changes the door to a <nothing> (<CNP), makes a door opening sound (<SOU), hides your character (<HMC), fades out into the center (FAO), and travels to map 2, coordinates X: 6 Y: 9, then runs script 0100 on that map (TRA).
Upon arriving at the destination map, the game changes the music (<CMU), unhides your character (<SMC), fades in from the center (<FAI), displays the name of the area (<MNA) and finally frees the earlier player control lock (<END).
Basic Door (Intre-map)
#0100
<KEY<CNP0100:0000:0000<SOU0011<HMC<WAI0010<CNP0100:0018:0000<MOV0006:0009<WAI0020<CNP0101:0000:0000<SOU0011<SMC<CNP0101:0018:0000<END
#0101
<KEY<CNP0101:0000:0000<SOU0011<HMC<WAI0010<CNP0101:0018:0000<MOV0009:0006<WAI0020<CNP0100:0000:0000<SOU0011<SMC<CNP0100:0018:0000<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
#0101: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is a simple script to move a character via a door within a single room, and back. The doors are: #0100 @ (9,6) and #0101 @ (6,9). The similarities between the inter-map and intra-map script warrent no real explaination, apart from pointing out the major difference: intra-map uses the <MOV command instead of <TRA, and no additional script is called beyond the event that is triggered.
Locking Inter-map Door (Item)
On the map you're leaving:
#0100
<KEY<ITJ0001:0101<MSG
It's locked...
Try getting a key!<NOD<CLO<END
#0101
<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
In this case, when you interact with the door, it called a check to see if you have item 0001 (Arthurs Key). If you have it, it continues (jumps) to event 0101 and runs the standard intra-map door script. If you lack the item, it give a message: "It's locked. Try getting a key!"
Additional: the above can be done using a flag as well by replacing the <ITJ with a <FLJ. In doing so, to unlock the door you need to set the flag.
Locking Intra-map Door (Item)
#0100
<KEY<ITJ0001:0101<MSG
It's locked...
Try getting a key!<NOD<CLO<END
#0101
<KEY<CNP0100:0000:0000<SOU0011<HMC<WAI0010<CNP0100:0018:0000<MOV0006:0009<WAI0020<CNP0101:0000:0000<SOU0011<SMC<CNP0101:0018:0000<END
#0102
<KEY<CNP0101:0000:0000<SOU0011<HMC<WAI0010<CNP0101:0018:0000<MOV0009:0006<WAI0020<CNP0100:0000:0000<SOU0011<SMC<CNP0100:0018:0000<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
#0102: Door sprite with flag 2000 set (run on interact)
Explanation:
This case provides (depending on context) a one-way door (if the first door you encounter is #0102) or a locked door requiring an item to open. Again, the doors are: #0100 @ (9,6) and #0102 @ (6,9).
Lock-if-has (Inter)
On the map you're leaving:
#0100
<KEY<ITJ0001:0101<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
#0101
<FLJ0100:0102<MSG
Oops, you bwoke it!<FL+0100<NOD<CLO<END
#0102
<KEY<MSG
Still bowken... <NOD<CLO<END
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is an interesting variation; the door is unlocked if you DON'T have the item, and locked (broken) if you do. Additionally, by the addition of a <FLJ to #0101 and a <FL+ that sets the appropriate flag, you create a second message that says "Still bwoken..." upon re-examining the door. Upon the removal of the item from the inventory, the door will once again function; you need not clear the flag because it is inside an event that is not triggered if the door is unlocked.
Chest (Basic)
#0100
<KEY<FLJ0100:0101<MSG
Opened the chest...<NOD<CLR<CNP0100:0021:0000<SOU0022
<CMU0010<GIT1001<IT+0001You got =Arthurs Key=!<WAI0160<NOD<GIT0001<CLO<FL+0100<END
#0101
<KEY<MSG
Empty...<NOD<CLO<END
Entities used:
#0100: Chest (closed) sprite with flags 2000 (run on interact) and 4000 (invisible if flag ID is set), and it's flag ID set to 100
#0101: Chest (open) sprite with 2000 (run on interact) and 800 (visible if flag ID is set), and it's flag ID set to 100, positioned one tile above #0100
Explanation:
This is a basic script for a chest. Upon opening the chest (#0100), the closed chest is changed to an open one, and the player recieves an item and a little message with the "Got item" jingle, as well as the little graphic of the item. After that, flag #0100 is set. Upon re-examining the now open chest, the player recieves the "Empty..." message (it can be called as event #0001 from any map, but is provided here as #0101 for clarity). Upon leaving and re-entering the stage, because flag #0100 is set, entity #0100 doesn't appear and entity #0101 does. Upon interacting with the chest again, the player still recieves the "Empty..." message.
Basic Door (Inter-map)
On the map you're leaving:
#0100
<KEY<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is a basic room-to-room door script.
Upon interacting with entity 101 (a door), the game locks out player control (<KEY), changes the door to a <nothing> (<CNP), makes a door opening sound (<SOU), hides your character (<HMC), fades out into the center (FAO), and travels to map 2, coordinates X: 6 Y: 9, then runs script 0100 on that map (TRA).
Upon arriving at the destination map, the game changes the music (<CMU), unhides your character (<SMC), fades in from the center (<FAI), displays the name of the area (<MNA) and finally frees the earlier player control lock (<END).
Basic Door (Intre-map)
#0100
<KEY<CNP0100:0000:0000<SOU0011<HMC<WAI0010<CNP0100:0018:0000<MOV0006:0009<WAI0020<CNP0101:0000:0000<SOU0011<SMC<CNP0101:0018:0000<END
#0101
<KEY<CNP0101:0000:0000<SOU0011<HMC<WAI0010<CNP0101:0018:0000<MOV0009:0006<WAI0020<CNP0100:0000:0000<SOU0011<SMC<CNP0100:0018:0000<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
#0101: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is a simple script to move a character via a door within a single room, and back. The doors are: #0100 @ (9,6) and #0101 @ (6,9). The similarities between the inter-map and intra-map script warrent no real explaination, apart from pointing out the major difference: intra-map uses the <MOV command instead of <TRA, and no additional script is called beyond the event that is triggered.
Locking Inter-map Door (Item)
On the map you're leaving:
#0100
<KEY<ITJ0001:0101<MSG
It's locked...
Try getting a key!<NOD<CLO<END
#0101
<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
In this case, when you interact with the door, it called a check to see if you have item 0001 (Arthurs Key). If you have it, it continues (jumps) to event 0101 and runs the standard intra-map door script. If you lack the item, it give a message: "It's locked. Try getting a key!"
Additional: the above can be done using a flag as well by replacing the <ITJ with a <FLJ. In doing so, to unlock the door you need to set the flag.
Locking Intra-map Door (Item)
#0100
<KEY<ITJ0001:0101<MSG
It's locked...
Try getting a key!<NOD<CLO<END
#0101
<KEY<CNP0100:0000:0000<SOU0011<HMC<WAI0010<CNP0100:0018:0000<MOV0006:0009<WAI0020<CNP0101:0000:0000<SOU0011<SMC<CNP0101:0018:0000<END
#0102
<KEY<CNP0101:0000:0000<SOU0011<HMC<WAI0010<CNP0101:0018:0000<MOV0009:0006<WAI0020<CNP0100:0000:0000<SOU0011<SMC<CNP0100:0018:0000<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
#0102: Door sprite with flag 2000 set (run on interact)
Explanation:
This case provides (depending on context) a one-way door (if the first door you encounter is #0102) or a locked door requiring an item to open. Again, the doors are: #0100 @ (9,6) and #0102 @ (6,9).
Lock-if-has (Inter)
On the map you're leaving:
#0100
<KEY<ITJ0001:0101<CNP0100:0000:0000<SOU0011<HMC<FAO0004<TRA0002:0100:0006:0009
#0101
<FLJ0100:0102<MSG
Oops, you bwoke it!<FL+0100<NOD<CLO<END
#0102
<KEY<MSG
Still bowken... <NOD<CLO<END
On the map you're arriving at:
#0100
<CMU0024<SMC<FAI0004<MNA<END
Entities used:
#0100: Door sprite with flag 2000 set (run on interact)
Explanation:
The above is an interesting variation; the door is unlocked if you DON'T have the item, and locked (broken) if you do. Additionally, by the addition of a <FLJ to #0101 and a <FL+ that sets the appropriate flag, you create a second message that says "Still bwoken..." upon re-examining the door. Upon the removal of the item from the inventory, the door will once again function; you need not clear the flag because it is inside an event that is not triggered if the door is unlocked.
Chest (Basic)
#0100
<KEY<FLJ0100:0101<MSG
Opened the chest...<NOD<CLR<CNP0100:0021:0000<SOU0022
<CMU0010<GIT1001<IT+0001You got =Arthurs Key=!<WAI0160<NOD<GIT0001<CLO<FL+0100<END
#0101
<KEY<MSG
Empty...<NOD<CLO<END
Entities used:
#0100: Chest (closed) sprite with flags 2000 (run on interact) and 4000 (invisible if flag ID is set), and it's flag ID set to 100
#0101: Chest (open) sprite with 2000 (run on interact) and 800 (visible if flag ID is set), and it's flag ID set to 100, positioned one tile above #0100
Explanation:
This is a basic script for a chest. Upon opening the chest (#0100), the closed chest is changed to an open one, and the player recieves an item and a little message with the "Got item" jingle, as well as the little graphic of the item. After that, flag #0100 is set. Upon re-examining the now open chest, the player recieves the "Empty..." message (it can be called as event #0001 from any map, but is provided here as #0101 for clarity). Upon leaving and re-entering the stage, because flag #0100 is set, entity #0100 doesn't appear and entity #0101 does. Upon interacting with the chest again, the player still recieves the "Empty..." message.