Page 1 of 2

Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 7:21 am
by DrMekar
Would it be possible to stop Mouser from jumping via a Lua Code without
making him from Scratch?

He's problably the Legacy Boss with the best customize potential, so his
Jump is still an annoying thing for Plattform based Battles.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 7:44 am
by Emral
Monitor the values v.ai1 thru v.ai5 to see what they do, and then set them to prevent them from going where they trigger a jump.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 7:51 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 7:44 am
Monitor the values v.ai1 thru v.ai5 to see what they do, and then set them to prevent them from going where they trigger a jump.
How would I do this? There is No Mouser AI included, like it is for some other NPCs.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 7:54 am
by Emral
In onTick or onDraw:
Text.print(v.ai1, 100, 100)
for all 5. (maybe a smart idea to not print all 5 to the same coordinates)
Then just some thinking work to figure out what each one does.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:11 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 7:54 am
In onTick or onDraw:
Text.print(v.ai1, 100, 100)
for all 5. (maybe a smart idea to not print all 5 to the same coordinates)
Then just some thinking work to figure out what each one does.
Okay, Thanks, though what do I miss here?

Image

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:15 am
by Emral
Why do you have two "end"s? You only open one scope.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:17 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 8:15 am
Why do you have two "end"s? You only open one scope.
I already tried removing one. It resulted in a even larger Error Message:
Image

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:20 am
by Emral
That's because v is undefined. You need to actually GET the NPC instance.
There's a small sample on it below the "instance functions" header here:
https://wohlsoft.ru/pgewiki/NPC_(class)
I urge you to actually read the error messages. They're in english, so it's not difficult to understand them.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:28 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 8:20 am
That's because v is undefined. You need to actually GET the NPC instance.
There's a small sample on it below the "instance functions" header here:
https://wohlsoft.ru/pgewiki/NPC_(class)
I urge you to actually read the error messages. They're in english, so it's not difficult to understand them.
So I use NPC.get(), right?
I can easily read them, though it lacks in the understanding what they mean for me. I will finally have the time
to get more into Lua when my last Final Exam is through which is tomorow, so this might have been atleast
my last "Beginner's" Question I hope.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 8:31 am
by Emral
You make a for loop, looping over all the mouser npcs in your level, correct. The page I linked above has more information on how to limit that loop to just mousers, if you're interested.

I brought up reading the error messages becuase length of error message has nothing to do with how relevant it is. it has to be fixed regardless of length by addressing the contents.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:04 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 8:31 am
You make a for loop, looping over all the mouser npcs in your level, correct. The page I linked above has more information on how to limit that loop to just mousers, if you're interested.

I brought up reading the error messages becuase length of error message has nothing to do with how relevant it is. it has to be fixed regardless of length by addressing the contents.
Okay, I'll defenitly keep it open then. I tried out the Example Function given, so
it still throws an Error saying it can't find the 'v'.

Image

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:09 am
by Emral
DrMekar wrote:
Tue May 12, 2020 9:04 am
Enjl wrote:
Tue May 12, 2020 8:31 am
You make a for loop, looping over all the mouser npcs in your level, correct. The page I linked above has more information on how to limit that loop to just mousers, if you're interested.

I brought up reading the error messages becuase length of error message has nothing to do with how relevant it is. it has to be fixed regardless of length by addressing the contents.
Okay, I'll defenitly keep it open then. I tried out the Example Function given, so
it still throws an Error saying it can't find the 'v'.

Image
As you can see in the example you copypasted into your code, the example uses the variable name myNPC instead.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:17 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 9:09 am
DrMekar wrote:
Tue May 12, 2020 9:04 am
Enjl wrote:
Tue May 12, 2020 8:31 am
You make a for loop, looping over all the mouser npcs in your level, correct. The page I linked above has more information on how to limit that loop to just mousers, if you're interested.

I brought up reading the error messages becuase length of error message has nothing to do with how relevant it is. it has to be fixed regardless of length by addressing the contents.
Okay, I'll defenitly keep it open then. I tried out the Example Function given, so
it still throws an Error saying it can't find the 'v'.

Image
As you can see in the example you copypasted into your code, the example uses the variable name myNPC instead.
I saw it thought that led to the same result. I guess I need to write cervenka a second time into the Code.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:18 am
by Emral
I doubt that lead to the same result, but I can't say for certain because I don't know what your code is.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:22 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 9:18 am
I doubt that lead to the same result, but I can't say for certain because I don't know what your code is.
Image

I of course removed the Speed Line given in the Code.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:23 am
by Emral
Yet you still have v.ai1 in the code. Notice anything wrong with that?

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:34 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 9:23 am
Yet you still have v.ai1 in the code. Notice anything wrong with that?
Okay, it works now.

None of the AI's did what I wanted though. I changed the 100's you gave me to the
starting coordinates of the NPC.

Code: Select all

function onTick()
    for index,myNPC in ipairs(NPC.get()) do
        Text.print(myNPC.ai5, -199288, -200190)
	end
end

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 9:51 am
by Emral
Text.print prints text relative to the screen coordinates. You're now printing text where noone will ever see it. The ai values are what redigit uses to code his NPC behaviours, so analyzing a combination of the 5 will help you in determining what ai values you need to manipulate to stop mouser from jumping.

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 10:01 am
by DrMekar
Enjl wrote:
Tue May 12, 2020 9:51 am
Text.print prints text relative to the screen coordinates. You're now printing text where noone will ever see it. The ai values are what redigit uses to code his NPC behaviours, so analyzing a combination of the 5 will help you in determining what ai values you need to manipulate to stop mouser from jumping.
In all honesty. I have no idea how that would help me. Couldn't I just set the Y-Speed of Mouser to 0?

Re: Anti-Jump Code for Mouser?

Posted: Tue May 12, 2020 10:09 am
by Emral
That is a possibility. Permanent speedY of 0 has fairly obvious side-effects, but it's a possibility.

It would help you insofar that if you put your head to understanding mouser ai you would be able to catch the point in the AI loop where a jump occurs and prevent the ai values from ever reaching that point.