Is there a way to let a NPC run a script when it dies?

Description: Internal scripting system of SMBX-38A Engine based on the simple VB-like language
Moderators: Lx Xzit, Yoshi021, 5438A38A, Semi-moderatos, Moderators

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 399
Posts: 753
Joined: 9 Nov 2015
Website

Post #1by Lx Xzit » 21 Feb 2017, 22:49

I need make a script that when a fireball dies causes something like an explosion, but I don't know how to check if the NPC is alive or not because with the NPC script system, because when it dies the script will stop to executing. Is there a way to do this?
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

Zwertll
Close friend
Close friend
Zwertll
Close friend
Close friend
Reputation: 51
Posts: 82
Joined: 6 Dec 2016

Post #2by Zwertll » 21 Feb 2017, 23:38

Here an example:

Code: Select all

do
   'set "n" as the "send ID to a variable" option of specific NPC first
   with npc(getId(val(n)))
      if .health = 0 then
         call showmsg("NPC was killed")
         exit do
      end if
   end with
   call sleep(1)   
loop

All credits to KFCMario. Remember of create a variable n.
If you want, however, the player fireball...

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 399
Posts: 753
Joined: 9 Nov 2015
Website

Post #3by Lx Xzit » 22 Feb 2017, 5:05

Thanks for the help! I tried everything and it's just too difficult do this with a fireball, I mean, if I'd have to work with only one fireball it wouldn't be a problem, but I have to work with multiple fireballs, which is really hard. So I give up, I'm gonna make the fireball from scratch so that I can execute the script I want before the NPCt dies. Thanks a lot anyway!
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

KFCMARIO
Good citizen
Good citizen
Avatar
KFCMARIO
Good citizen
Good citizen
Reputation: 21
Posts: 33
Joined: 25 Jan 2016

Post #4by KFCMARIO » 22 Feb 2017, 7:55

Executing a script with the Auto-Run event "NPC - Death", sysval(param1) stands for the id of the triggering(dead) NPC

Yoshi021 M
Moderator
Moderator
Avatar
Yoshi021 M
Moderator
Moderator
Age: 20
Reputation: 156
Posts: 689
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #5by Yoshi021 » 22 Feb 2017, 15:20

And do you poo only have acess to the id? Can you also use the .x or .y etc.
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest