Jump to content

Photo

a script question


  • Please log in to reply
16 replies to this topic

#1 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 14 June 2019 - 04:57 PM

hi everyone i had a question: It's possible for making a barrel script that Links hides on it and if the monster (like a darknut for exemple) saw him moving inside the barrel or if Link is in front of the monster without the barriel that would produice the same thing as the guard alert thing and that would active a auto side warp after the alarm sound and the string when the enemy saw Link. 

I was thinking about that as a alternative guard script file from the detabase with some warp function corrections on it.



#2 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 14 June 2019 - 05:28 PM

Possible, yes, easy, no.

And it would take a lot of different things, so it may be difficult to find someone willing to take a script request for it.

 

Firstly, not doing it in 2.55 immediately makes it a lot more difficult. NPC scripts would be really useful for the being seen thing. But, a normal darknut wouldn't really work, because it's AI would just know where Link is, so you'd want a totally scripted enemy that follows a set path. Basically one of the things it would do is check if Link is within a certain distance of it (a 'sight range'), and also check if Link is in the barrel. If Link is within the range and not in the barrel, or in the barrel and Link->Action != LA_NONE, then play a short cutscene of it walking towards Link, and a sound effect, and then do a warp.

 

The barrel itself would be something to interact with, and would need a button designated to it; likely A. If Link faces a barrel and presses A, remove the barrel object (probably an FFC, running an FFC script to check if Link interacts with it), and give link an item. This item would do 2 things:

 

Firstly, it would have a Link Tile Modifier, which makes Link look like he's under a barrel. That's totally non-script stuff.

 

Secondly, it would have a passive item script (fairly new addition). This script would constantly do `Link->SwordJinx = 2;` and `Link->ItemJinx = 2;` to prevent him from using his items. It would also check for Link pressing A. If Link presses A and is facing something solid, nothing happens; if he is facing an open space, it will first re-create the Barrel FFC in front of him, then it would remove the item from Link's inventory. (which would revert him to normal).

 

....as for actually scripting this, well, not sure if/when I'll have time. But, it's honestly interesting enough that I might....


  • Anthus likes this

#3 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 14 June 2019 - 07:26 PM

ah i see but i was thought that would be a good idea for infiltrations events for exemple. Like Wind Waker for exemple



#4 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 14 June 2019 - 07:45 PM

ah i see but i was thought that would be a good idea for infiltrations events for exemple. Like Wind Waker for exemple

Certainly a good idea. Not the easiest thing to make, but....

Well, I think I have most of it done, except for the enemies that can find you. That will probably take a lot longer than the rest of it.



#5 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 15 June 2019 - 08:49 AM

okey it's not a problem :)



#6 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 19 June 2019 - 11:55 PM

Spoiler

 

Mostly got this done, just waiting on a couple ZC bugs I found to be fixed before it works.

(Mostly, npc scripts can't call WarpEx(), meaning the guard isn't actually able to warp Link into the jail area until that gets fixed)

 

This was far more of a project than I thought it would be, because it required creating a triangular collision function, which... Shall we say "Really awful" and "wanted to rip my hair out several times"?

...but, hey, a working generic triangular collision function is nice to have in general.

 

When this is done, I will also be releasing an update to my VenrobMisc.zh header (of which will be required by the script)

Oh, and I'm also going to include an ffc script for spotlights that can catch link. You can make them move with changers. There will be an example quest showing off some of the different ways to set this stuff up, for reference.


  • Lüt likes this

#7 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 20 June 2019 - 08:36 AM

alright but wow that's a great progress :O i didn't expected that result that's reminds me the Phantom enemies back from Phantom Hourglass and Spirit Tracks. It's a good works to be honest.



#8 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 20 June 2019 - 05:07 PM

alright but wow that's a great progress :O i didn't expected that result that's reminds me the Phantom enemies back from Phantom Hourglass and Spirit Tracks. It's a good works to be honest.

If I do something, I do my best to not do it half-way :)

I'll be able to use this myself in MM2D for the Gerudo area, as well, so making it how I would want it also helps.

 

And triangular collision is totally awesome to have done in general.

 

Oh, and their line of sight is totally configurable. It will always be a trapezoid, but you can tell it how far forward they can see, and at what angle they can see peripherally.



#9 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 20 June 2019 - 06:55 PM

Yeah you're right :) I was planning thoses enemies for the 'Lost Tower' level of my quest and also maybe import thoses enemies in my other quests too i'll maybe make exclusively for 2.55 :)
Just a question: When the darknut enemy will touch the barriel will he push the barriel to let him pass, or will he just changes directions, or worst he'll destroy the barriel with his sword (adding sword attack) and he'll catch Link, or he'll just pass through him ?


Edited by Sans, 20 June 2019 - 06:59 PM.


#10 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 20 June 2019 - 07:01 PM

Yeah you're right :) I was planning thoses enemies for the 'Lost Tower' level of my quest and also maybe import thoses enemies in my other quests too i'll maybe make exclusively for 2.55 :)
Just a question: When the darknut enemy will touch the barriel will he push the barriel to let him pass, or will he just changes directions, or worst he'll destroy the barriel with his sword (adding sword attack) and he'll catch Link, or he'll just pass through him ?

He'll hit Link, which will result in Link being caught.



#11 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 20 June 2019 - 07:19 PM

i think that would be the best ^^' so Link must carefully to not go on his way wich that will be difficult for thoses who don't know wich directions exactly the darknut will takes :P



#12 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 23 June 2019 - 03:36 AM

This script is going to require the next alpha, so it won't be usable until that is finalized and released. But, the script is done, and here's an example video:

 

 

I'll post the script on the database, and post a link to the database entry in this thread, once the alpha is released.



#13 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 23 June 2019 - 08:17 AM

Wow i like it :) there's just the sound and strings that didn't added. 



#14 venrob

venrob

    Scripter / Dev

  • ZC Developers
  • Real Name:Rob
  • Gender:Male

Posted 23 June 2019 - 08:26 AM

Wow i like it :) there's just the sound and strings that didn't added. 

Yeah, there is a sound effect set up though, I just left it blank. So, you just need to set the constant for CAUGHT_SFX and it will play it when you are seen.

The section for being caught is set up to be modifiable, so, you can add a string there however you want it to work. I didn't want to include that for the database, since you could either just play a normal string, or use Tango, or whatever as all different ways of doing it. The main focus was getting the actual barrel and npcs working, and then there's one function that you can modify however you want for getting caught.

 

This is a block of code from the script, which is the "default implementation" for the NPC catching Link (when it walks over to him after having noticed him):

//start Default implementation - freeze Hero, play sound, NPC runs to hero
Audio->PlaySound(CAUGHT_SFX);
Hero->Stun = 500;
//
Waitframes(5); //Pause for a moment, when noticing Hero
int angle = RadtoDeg(TurnTowards(CenterX(this), CenterY(this), Hero->X + 8, Hero->Y + 8, 0, 1));
this->Dir = AngleDir4(angle); //Make the npc face in a way that makes sense
int dX = VectorX(this->Step / 100, angle);
int dY = VectorY(this->Step / 100, angle);
this->CollDetection = false; //Don't hit Hero (if don't do this, will repeatedly knock him back while trying to walk towards him)
until(Distance(Hero->X + 8, Hero->Y + 8, CenterX(this), CenterY(this)) <= 8) //Walk towards Hero to catch him
{
	unless(Hero->Stun) {Hero->Stun += 100; break;} //Make sure it doesn't somehow get stuck in an infinite loop, due to a weird angle or something
	this->X += dX;
	this->Y += dY;
	Waitframe();
}
if(Hero->Item[BARREL_ITEM]) //If Hero had a barrel, spend a few frames to break it. No animation, but you could add one here.
{
	Waitframes(2);
	Hero->Item[BARREL_ITEM] = false;
	Waitframes(2);
}
//
Hero->Stun = 0;
//end Default Implementation

You could probably add showing a string right above the `Waitframes(5)` near the top, without much difficulty; though, you'd want to make the rest of the script wait for the string to be gone through, so if using a normal ZC string, you'd need to make sure `Messages Freeze All Action` is on.

The spotlight uses a different block of code, but it's mostly similar. When the alpha is released and I post the full script files, you'll find them in the `void npcCatchesHero` and `void spotlightCatchHero` functions, which you can add whatever code you want to to change what it does.



#15 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Gender:Male
  • Location:Judgement Hall

Posted 23 June 2019 - 08:29 AM

okey




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users