Question on script-triggering NPCs

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Question on script-triggering NPCs

Post by Meatballsub »

This was asked about right around the time CP went down, and I can't seem to remember what was concluded.

Basically, I have several one-time use npcs that trigger different scripts. If possible, I would like to make it so that the npc goes away after the script is run rather than before.

I'm pretty sure of a way to do this with multiple tags, but i'm sure there might be a better way than this.
User avatar
Mogri
Super Slime
Posts: 4668
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

Why don't you just use normal tags for them? The script can set the tag when it's done. If you want, you can pass the tag number as the argument to the script.
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Post by Meatballsub »

I guess it would work fine, but i'm not so sure how to set up my script so that it can read the tag that is being used on that NPC. Here is a sample code for the npc:

Code: Select all

script,Eee,begin
suspend player
suspend random enemies
set hero speed (0)
set caterpillar mode (off)
swap by position (0,find hero(0))
walk hero (0,right,1)
wait for hero (0)
set hero picture (0,29,outside battle)
wait for hero (0)
wait (10)
play sound (15,false,false)
set hero direction (0,left)
wait for hero (0)
wait (10)
set hero direction (0,right)
wait for hero (0)
wait (10)
play sound (15,false,false)
set hero direction (0,left)
wait for hero (0)
wait (10)
set hero direction (0,right)
wait for hero (0)
wait (10)
play sound (15,false,false)
set hero direction (0,left)
wait for hero (0)
wait (10)
set hero direction (0,right)
wait for hero (0)
wait (10)
play sound (15,false,false)
set hero direction (0,left)
wait for hero (0)
wait (10)
set hero direction (0,right)
wait for hero (0)
wait (10)
set hero picture (0,11,outside battle)
walk hero (0,left,1)
wait for hero (0)
set hero direction (0,south)
wait for hero (0)


variable (r) 
r := random(0, 3) 
if (r == 0) then ( 
show textbox (42) 
wait for textbox 
) 
if (r == 1) then ( 
show textbox (43) 
wait for textbox 
) 
if (r == 2) then ( 
show textbox (44) 
wait for textbox 
get item (13,2) 
) 
if (r == 3) then ( 
show textbox (45) 
wait for textbox 
get item (13,3) 
) 

resume player
resume npcs
set caterpillar mode (on)
resume random enemies
wait for all
end 
User avatar
Mogri
Super Slime
Posts: 4668
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

Change it to say:

Code: Select all

script,Eee,whichtag,begin
.
.
.
set tag(whichtag, on)
end
You'll also have to change the script declaration unless you're using the new declaration-free syntax.
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Post by Meatballsub »

Thanks for the help. I could never figure out how to call the tag that was being used for each npc though. Maybe one day my scripting skills won't suck as bad.

I fixed my problem by setting up a textbox to display until the script is finished.

Easy fix. Don't know why I didn't think about that before.
User avatar
JSH357
Liquid Metal Slime
Posts: 1341
Joined: Mon Oct 15, 2007 7:38 pm
Location: Columbia, SC
Contact:

Post by JSH357 »

LIFE2~!

Nowadays you should always add trigger warnings in case an NPC gets activated by something you say or do in a work of fiction.
My website, the home of Motrya:
http://www.jshgaming.com
Post Reply