This script is not what i want.Can anyone fix my problem?

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

mariogamer1995
Topic author, Nice citizen
Nice citizen
mariogamer1995
Topic author, Nice citizen
Nice citizen
Reputation: 0
Posts: 10
Joined: 28 Jul 2018

Post #1by mariogamer1995 » 3 Aug 2018, 20:13

I want that hammer bro throw more than 1 hammer at one shoot and i decided to make a new script for this but when i write this script

With npc(sysval(Param1))
If .ID=335 and .curframe=1 and .facing=1 then
Call NCreate(336,.X,.Y,-2,-4,0,0)
Call NCreate(336,.X-30,.Y+30,-3,2,0,0)
Call AudioSet(2,2,0,"Hammer Toss")
End if
End With

It throws hammers like a waterfall but this is not what i want.What i want is that this smb3 style hammer bro throws 2 hammers or more hammers at one shoot.
How can i fix this problem?
(By the way my hammer bro has parallel execution)

NajekK M
Nice citizen
Nice citizen
Avatar
NajekK M
Nice citizen
Nice citizen
Reputation: 21
Posts: 12
Joined: 5 Jan 2017
Location: Poland

Post #2by NajekK » 4 Aug 2018, 0:23

Hi, maybe this would help:

Code: Select all

With npc(sysval(Param1))
If .ivalc = 2 Then
   .ivalc = 3
   If Char(1).X+Char(1).PWidth/2 < .X + 16 Then '+16 is half the width of npc
      Call NCreate(336,.X,.Y,-2,-4,0,0) 'throw left
      Call NCreate(336,.X-30,.Y+30,-3,2,0,0)
   Else
      Call NCreate(336,.X,.Y,2,-4,0,0) 'throw right
      Call NCreate(336,.X+30,.Y+30,3,2,0,0)
   End if
   Call AudioSet(2,25,0,"")
End if
End with

This script is for 1-player mode. If you want, I can make the script for 2 players. :)
PS. I think you must calibrate throwing hammers position.
Image

mariogamer1995
Topic author, Nice citizen
Nice citizen
mariogamer1995
Topic author, Nice citizen
Nice citizen
Reputation: 0
Posts: 10
Joined: 28 Jul 2018

Post #3by mariogamer1995 » 4 Aug 2018, 2:04

Yes i will apply this script i am on phone now.
Yes you are right. I calibrated the values randomly :D
Thank you so much :) :)

Added after 17 hours 29 minutes:
I tested it.It is awesome thank you so much :) :)
There is minor bug this bug is hammer bro throws one hammer at one single shoot rarely.This is not problem. Thank you again :)

NajekK M
Nice citizen
Nice citizen
Avatar
NajekK M
Nice citizen
Nice citizen
Reputation: 21
Posts: 12
Joined: 5 Jan 2017
Location: Poland

Post #4by NajekK » 4 Aug 2018, 21:35

A bug is probably because hammer bro has parallel execution and the original code is in conflict with the new one.
The best option is to make hammer bro code again. I can do it ;)
Image

mariogamer1995
Topic author, Nice citizen
Nice citizen
mariogamer1995
Topic author, Nice citizen
Nice citizen
Reputation: 0
Posts: 10
Joined: 28 Jul 2018

Post #5by mariogamer1995 » 4 Aug 2018, 22:00

Yes you are right if you can i will be happy even if you can't i will be happy :)

by the way, what is function of .ivalc? i wonder

NajekK M
Nice citizen
Nice citizen
Avatar
NajekK M
Nice citizen
Nice citizen
Reputation: 21
Posts: 12
Joined: 5 Jan 2017
Location: Poland

Post #6by NajekK » 4 Aug 2018, 22:36

.ivalc is only an individual variable. I noticed that when hammer bro throws hammer - ivalc is equal to 2. I will make a hammer bro script.

Added after 1 hour 52 minutes:
Try this (don't turn parallel execution on):

Code: Select all

With npc(sysval(Param1))
   If .advset = 0 Then
      .advset = 336
   End if
   If .name <> "1" Then
      If .Xsp = 0 Then
         If .facing = 0 Then
            .Xsp = 0.5
         Elseif .facing = 1 Then
            .Xsp = -0.5
         End if
      End if   
      If .X < .prX-256 or .X > .prX+256 Then
         Select case rnd
            case 0 to 0.5
            case else
               If .Xsp > 0 Then
               .Xsp = -0.5
            Elseif .Xsp < 0 Then
               .Xsp = 0.5
            End if
         End Select
      Elseif .X < .prX-32 or .X > .prX+32 Then
         Select case rnd
            case 0 to 0.99
            case else
               If .Xsp > 0 Then
               .Xsp = -0.5
            Elseif .Xsp < 0 Then
               .Xsp = 0.5
            End if
         End Select
      End if
   End if
   If .ivalb = 0 Then
      .ivalb = -1
   End if
   If .Ysp = 0 and .ivalc = 4 Then
      .ivalc = -1
   End if
   If .ivala < .ivalb and .Ysp = 0 and .ivalc = 0 Then
      .ivalc = 1
   End if
   .Ysp = .Ysp + 0.26
   If .Ysp > 8 Then
      .Ysp = 8
   End if
   If .ivala < 0 Then
      .ivala = fix(160*rnd)
      .ivalb = fix(.ivala*rnd)
      If .ivalc = -1 Then
         .ivalc = 0
      End if
   End if
   .ivala = .ivala - 1
   If .ivalc = 1 Then
      Select case rnd
         case 0 to 0.5
            .Ysp = -7
         case else
            .Ysp = -3
      End Select
      .ivalc = 2
   Elseif .ivalc = 2 Then
      If .Ysp > 0 Then
         .ivalc = 3
      End if
   Elseif .ivalc = 3 Then
      .ivalc = 4
      Call AudioSet(2,25,0,"")
'------------------------------------------------------------------------------------------------------------------------------------------------
      If Char(1).X+Char(1).PWidth/2 < .X + 16 Then '+16 is half the width of npc
         Call NCreate(.advset,.X,.Y-16,-3,-6.5,0,0) 'throw left
         Call NCreate(.advset,.X,.Y-16,-4,-6,0,0)
      Else
         Call NCreate(.advset,.X,.Y-16,3,-6.5,0,0) 'throw right
         Call NCreate(.advset,.X,.Y-16,4,-6,0,0)
      End if
'------------------------------------------------------------------------------------------------------------------------------------------------
   End if
End with

If you want him not to move, name him 1.

Image
Image

mariogamer1995
Topic author, Nice citizen
Nice citizen
mariogamer1995
Topic author, Nice citizen
Nice citizen
Reputation: 0
Posts: 10
Joined: 28 Jul 2018

Post #7by mariogamer1995 » 5 Aug 2018, 19:31

Thank you so much i will try this as soon as my laptop is fixed :)

Lx Xzit M
Moderator
Moderator
Avatar
Lx Xzit M
Moderator
Moderator
Reputation: 216
Posts: 498
Joined: 9 Nov 2015
Website

Post #8by Lx Xzit » 5 Aug 2018, 19:41

NajekK wrote:If you want him not to move, name him 1.

Instead of changing the name of the object, you could use "NoMove" variable
[size=100][b]VISIT MY YOUTUBE CHANNEL![/b] [url=https://www.youtube.com/channel/UC_AcXEExdYtaydxcCVPSGoQ]LX XZIT[/url][/size]
[size=100]Join our 38A Discord server! [url= https://discord.gg/7hCmNBE]CLICK HERE[/url][/size]


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest