(Please help) Koopa Troopa / Koopa Paratroopa Custom Behaviors

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

OfficialJC02 M
Topic author, Good citizen
Good citizen
Avatar
OfficialJC02 M
Topic author, Good citizen
Good citizen
Age: 18
Reputation: 13
Posts: 33
Joined: 30 May 2020
Youtube channel URL

Post #1by OfficialJC02 » 21 Nov 2020, 3:27

I am making an NPC pack which exclusively contains custom behaviors for Koopa Troopas and Koopa Paratroopas. I am going to need help with this, so here are a few questions I have:

1. How do you make Koopa Paratroopas fly in circles?

2. How do you make an enemy chase the player BUT turn around 1 second after the player goes in the opposite direction?

3. Is it possible to make a script so that Koopa Paratroopas only jump over Koopa shells (i.e. The yellow Koopa Paratroopa from SMW)

4. So the way this script works is that the Koopa Paratroopas have different behaviors depending on their ExtX. Here is what I got so far:

Code: Select all

with npc(sysval(param1))
 if .extx=1 then 'Jumps
 .ysp=.ysp+0.26
 if .ysp>8 then
  .ysp=8
 end if
 
 .ivala=.ivala+1
 if .ivala=1 then
  .xsp=1.2*(1-2*.facing)
  if .name="" then 
  .ivalb=4
  else
  .ivalb=cdbl(.name)
  end if
 end if
 if .ysp=0.26 and .ivala>1 then
  .ysp=-sqr(0.52*32*.ivalb)
 end if
 end if
 
If .extx=2 then 'Flies forward without stopping or turning around
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.06
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.06
End if
If .Ysp => 1 Then
.ivala = 0
Elseif .Ysp =< -1 Then
.ivala = 1
End if
If .facing = 0 and .ivalc = 0 Then
.Xsp = 1
Elseif .facing = 1 and .ivalc = 0 Then
.Xsp = -1
End if
end if

if .extx=3 then 'Flies in place with little vertical movement
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.06
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.06
End if
If .Ysp => 1 Then
.ivala = 0
Elseif .Ysp =< -1 Then
.ivala = 1
End if
end if

if .extx=4 then 'Flies up and down 7 tiles
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.018
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.018
End if
If .Ysp => 2 Then
.ivala = 0
Elseif .Ysp =< -2 Then
.ivala = 1
End if
If char(1).X > .X then
.facing=0
elseif char(1).X < .X then
.facing=1
end if
end if

end with


Now for .extx=0, I want the Koopa Paratroopas to use their regular default behavior. Is that possible?

Also not all of the script is entirely mine. Of course I will credit the people who helped make a portion of this script. Also I am not very good at scripting, so most of this is greatly modifying other people's scripts.

FyreNova
Nice citizen
Nice citizen
Avatar
FyreNova
Nice citizen
Nice citizen
Reputation: 7
Posts: 15
Joined: 27 Oct 2019

Post #2by FyreNova » 23 Nov 2020, 1:58

OfficialJC02 wrote:I am making an NPC pack which exclusively contains custom behaviors for Koopa Troopas and Koopa Paratroopas. I am going to need help with this, so here are a few questions I have:

1. How do you make Koopa Paratroopas fly in circles?

2. How do you make an enemy chase the player BUT turn around 1 second after the player goes in the opposite direction?

3. Is it possible to make a script so that Koopa Paratroopas only jump over Koopa shells (i.e. The yellow Koopa Paratroopa from SMW)

4. So the way this script works is that the Koopa Paratroopas have different behaviors depending on their ExtX. Here is what I got so far:

Code: Select all

with npc(sysval(param1))
 if .extx=1 then 'Jumps
 .ysp=.ysp+0.26
 if .ysp>8 then
  .ysp=8
 end if
 
 .ivala=.ivala+1
 if .ivala=1 then
  .xsp=1.2*(1-2*.facing)
  if .name="" then 
  .ivalb=4
  else
  .ivalb=cdbl(.name)
  end if
 end if
 if .ysp=0.26 and .ivala>1 then
  .ysp=-sqr(0.52*32*.ivalb)
 end if
 end if
 
If .extx=2 then 'Flies forward without stopping or turning around
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.06
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.06
End if
If .Ysp => 1 Then
.ivala = 0
Elseif .Ysp =< -1 Then
.ivala = 1
End if
If .facing = 0 and .ivalc = 0 Then
.Xsp = 1
Elseif .facing = 1 and .ivalc = 0 Then
.Xsp = -1
End if
end if

if .extx=3 then 'Flies in place with little vertical movement
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.06
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.06
End if
If .Ysp => 1 Then
.ivala = 0
Elseif .Ysp =< -1 Then
.ivala = 1
End if
end if

if .extx=4 then 'Flies up and down 7 tiles
.ivalb = .ivalb + 1
If .ivala = 0 Then
.Ysp = .Ysp - 0.018
Elseif .ivala = 1 Then
.Ysp = .Ysp + 0.018
End if
If .Ysp => 2 Then
.ivala = 0
Elseif .Ysp =< -2 Then
.ivala = 1
End if
If char(1).X > .X then
.facing=0
elseif char(1).X < .X then
.facing=1
end if
end if

end with


Now for .extx=0, I want the Koopa Paratroopas to use their regular default behavior. Is that possible?

Also not all of the script is entirely mine. Of course I will credit the people who helped make a portion of this script. Also I am not very good at scripting, so most of this is greatly modifying other people's scripts.
  • sine/cosine.
  • simple xsp/ysp chase code
  • while looping (use npc(x) to see if there are any moving shells near said npc)
  • no; you're not using parallel execution, and if you were, you wouldn't be able to set xsp/ysp.

OfficialJC02 M
Topic author, Good citizen
Good citizen
Avatar
OfficialJC02 M
Topic author, Good citizen
Good citizen
Age: 18
Reputation: 13
Posts: 33
Joined: 30 May 2020
Youtube channel URL

Post #3by OfficialJC02 » 23 Nov 2020, 2:30

sine/cosine.
I don’t know what this means or how to use this.

simple xsp/ysp chase code
So the script I have for chasing NPCs is this:

Code: Select all

with npc(sysval(param1))
if char(1).X > .X then
.facing=0
elseif char(1).X < .X then
.facing=1
end if
end with

What do I need to add to make the NPC turn around 1 second after the player goes in the opposite direction?

while looping (use npc(x) to see if there are any moving shells near said npc

Can you please be more specific about what you mean? What do I need to loop?

no; you're not using parallel execution, and if you were, you wouldn't be able to set xsp/ysp.

What a shame. I hope this gets added in future versions.

Victor ManuelMR M
Marquis
Marquis
Avatar
Victor ManuelMR M
Marquis
Marquis
Age: 19
Reputation: 99
Posts: 192
Joined: 7 Feb 2018

Post #4by Victor ManuelMR » 23 Nov 2020, 4:01

OfficialJC02 wrote:sine/cosine.
I don’t know what this means or how to use this.

Sine/Cosine are trigonometric functions, you will have to learn to use them. Start with something like this, and then change and discover:

Code: Select all

do
val(a) += 1
char(1).ysp = sin(val(a) * 0.01)
call sleep(1)
loop


So the script I have for chasing NPCs is this:

Code: Select all

.xsp = (char(1).x-.x)*0.01
Image
[1.4.5] - Dream Team at The Challenging Portals:
Image

OfficialJC02 M
Topic author, Good citizen
Good citizen
Avatar
OfficialJC02 M
Topic author, Good citizen
Good citizen
Age: 18
Reputation: 13
Posts: 33
Joined: 30 May 2020
Youtube channel URL

Post #5by OfficialJC02 » 23 Nov 2020, 23:14

Sine/Cosine are trigonometric functions, you will have to learn to use them. Start with something like this, and then change and discover:

Code: Select all

 do
val(a) += 1
char(1).ysp = sin(val(a) * 0.01)
call sleep(1)
loop


This code crashes the game. SMBX will just not respond.

I also figured out how to make enemies chase the player but turn around after a certain amount of time the player is in the opposite direction.

Code: Select all

with npc(sysval(param1))
if char(1).X > .X+32 then
.facing=0
elseif char(1).X < .X-32 then
.facing=1
end if
end with

Victor ManuelMR M
Marquis
Marquis
Avatar
Victor ManuelMR M
Marquis
Marquis
Age: 19
Reputation: 99
Posts: 192
Joined: 7 Feb 2018

Post #6by Victor ManuelMR » 24 Nov 2020, 0:34

OfficialJC02 wrote:
Sine/Cosine are trigonometric functions, you will have to learn to use them. Start with something like this, and then change and discover:

Code: Select all

 do
val(a) += 1
char(1).ysp = sin(val(a) * 0.01)
call sleep(1)
loop


This code crashes the game. SMBX will just not respond.
[/code]

The Code didn't crash when I tested it.
Image
[1.4.5] - Dream Team at The Challenging Portals:
Image

OfficialJC02 M
Topic author, Good citizen
Good citizen
Avatar
OfficialJC02 M
Topic author, Good citizen
Good citizen
Age: 18
Reputation: 13
Posts: 33
Joined: 30 May 2020
Youtube channel URL

Post #7by OfficialJC02 » 24 Nov 2020, 14:36

Is there any alternative way to make winged enemies fly in circles?

FyreNova
Nice citizen
Nice citizen
Avatar
FyreNova
Nice citizen
Nice citizen
Reputation: 7
Posts: 15
Joined: 27 Oct 2019

Post #8by FyreNova » 7 Dec 2020, 6:36

OfficialJC02 wrote:Is there any alternative way to make winged enemies fly in circles?
yes, but it's time consuming and not worth pursuing. just use the code victor posted and run it via event.

OfficialJC02 M
Topic author, Good citizen
Good citizen
Avatar
OfficialJC02 M
Topic author, Good citizen
Good citizen
Age: 18
Reputation: 13
Posts: 33
Joined: 30 May 2020
Youtube channel URL

Post #9by OfficialJC02 » 8 Dec 2020, 16:57

3color bomb dx is helping me with the circling Koopa Paratroopas. I have one more question though. Using this script, how do you change the starting point for the NPC in the circle? I want to have multiple NPCs spinning in the same circle (like in NSMB2).

Code: Select all

with npc(sysval(param1))
if .ivala = .ivala + 1 then
select case .name
   case 1
      .ivala=90
   case 2
      .ivala=180
   case 3
      .ivala=270
   case 4
      .ivala=0
end select
end if
.ivala = .ivala + 1 'Change this value to change the speed
.ivalb = 4375 'Change this value to change the speed
.ivalc = 96 'Change this value to change the radius
'ivalc is the radius ,the centre is the npc's original position
.xsp = (.PrX + cos(.ivalb/250000*.ivala)*.ivalc)-.x
.ysp = (.PrY - sin(.ivalb/250000*.ivala)*.ivalc)-.y
'.ivalb should be 1.75*the 250000 part
end if
end with


Return to “TeaScript”