• Welcome to Freedom Reborn Archive.
 

EZ Script Questions

Started by graver, October 11, 2007, 10:40:32 AM

Previous topic - Next topic

graver

Hey guys,

I have another potentially stupid question and situation here.  Is there a maximum number of "Open Door" encounters that ezscript can run simultaneously?

The reason i ask is I'm having a bit of a problem getting any more then one to run at that same time, though I could have sworn I had 2 running simultaneously in the same script not too long ago.  Now, when ever I set up a script to call on two or more encounters of Open Door, it will randomly select one of the encounters and start that one.  However, it seems like it might be wanting to launch the others, but something is preventing it from doing so.

While the one Open Door event is active, there is a noticeable stutter or hesitation in the game and once the first randomly chosen Open Door mission is completed, another from the list suddenly starts.

I tested this out on a stripped down map with only the doors, a hero, and a script to start two simple open door encounters at once, but I still get the same problem.

Here's the script if you want to see it:

[spoiler]Story: Test

Starting Encounters: Door Test c


Encounter: Door Test c
Type: Cutscene
Next: Door Unlock 01, Door Unlock 02

Alert Cutscene:
Set lighting to sewer



Encounter: Door Unlock 01
Type: Open Door
Objects: nazihq_wide_door_closed named sc_nazihq_wide_door_close1
Next: none

Examine Cutscene:
Hero1 says, "I wish it would open"



Encounter: Door Unlock 02
Type: Open Door
Objects: nazihq_door_closed named sc_nazihq_door_closed6
Next: none

Examine Cutscene:
Hero1 says, "I wish it would open"[/spoiler]

I can post the whole ff.log if someone wants me to, but most all of the lines seemed to be normal run of the mill kinds of things.  There were 4 lines which seemed like they might be related, but I have no idea how to fix it: 

00:00:27.76: FF: ERROR: Couldn't get keyframe file for nif tag library\area_specific\Nazi_HQ\interior_objects\supports\wide_door_closed\wide_door_closed.nif
00:00:27.76: FF: ERROR: CPrecacheMgr::loadCharPowerFX, unable to find nazihq_wide_door_closed character def
00:00:27.76: FF: ERROR: Couldn't get keyframe file for nif tag library\area_specific\Nazi_HQ\interior_objects\supports\door_closed\door_closed.nif
00:00:27.76: FF: ERROR: CPrecacheMgr::loadCharPowerFX, unable to find nazihq_door_closed character def

I've extracted the doors a couple of times from art.ff to see if that would fix the problem but no dice.  However, the doors open just fine when clicked upon, so i don't know if that's an issue or not as the problem doesn't seem to be related to the animations of the doors.

Any insight into this would be greatly appreciated :)

M25

There's no limit on the number of any type of encounter that can be run at once (beyond the speed of the computer).  In the sample campaign I believe I had 11 Open Door encounters running at the same time. 

ff.log generally isn't very useful - the keyframe error can be ignored.  Are there any errors in script.log?


A possible problem I see... you aren't specifying any markers for the encounter to start at.  In that case, EZ script will look for markers called encounter1, encounter2, etc. in case it needs to spawn characters.  To run two encounters at the same time, you need at least two of these encounter markers.  If not, then it will keep trying to spawn the encounter at regular intervals (which may be the stutter you are seeing) and will grab any encounter marker that gets freed up.

With door encounters, its probably better to just place a marker near the door and have the encounter use that marker

Encounter: Door Unlock 01
Type: Open Door
...
Marker: door01


And use Open Door Cutscene:   instead of Examine Cutscene:




graver

 :doh:

It's always something stupid with me.  It was the markers!  I had just renamed the generic encounter markers I had placed earlier to a specific encounter markers (sinc ethe encounters I've been working on lose a lot of punch if they wander too far from home) and was going to put some generics back in at different locations once I got the bugs worked out of what i had   :rolleyes:  It just never occurred to me that was a problem since nothing was being spawned in the open door encounters.  Thank you for pointing that one out.  It (and other things I've been wondering about) no makes perfect sense.

Oh, and thanks for pointing out my miss labeling of the cutscene.  That will save me some, "but WTF?!" latter on ;)

graver

Hey guys, I have another small ez script question.  Has anyone found a way to have an event in ez script start/not start based off of whether a certain hero is present or on the team?

I have been trying to think of a way to have certain maps in a freeroam campaign accessible only if a certain hero is on the players team.  I thought that possibly the easiest way to do this would be to have the to_<map> marker placed behind a door (or object that functioned as a door for all intents and purposes) but have the open door event for that door called only if a certain character is on the players team.  The problem is I couldn't figure out a way to recognize which characters are on the team or in the mission.  I know cut scenes can tell, but I can't figure out a way to branch based on which cut scene of the same name played.

Also, while I'm on character recognition, does anyone know if it's possible to have a character switch between templates for said character based on which map they are on in a freeroam campaign?  I know, this one is probably stretching it, but I figured it couldn't hurt to ask.

GogglesPizanno

QuoteI have been trying to think of a way to have certain maps in a freeroam campaign accessible only if a certain hero is on the players team.

I have a theoretical idea that MIGHT work (don't have any time to test it right now) -- this would require some python scripting on the mission.py of the maps, but it might be worth a try.

Basically the idea is to write a function that loops through the current team, and if it finds a certain character "destroy" the markers on the map that lead to the offlimits map. That way the maps still exist, but all doorways to them are disabled hence you cant get there.

Now you may have to get a bit more complicated to handle instances of recruiting allies at certain points. I'm not sure of the mechanics for when an ally is recruited in freeroam games, but you'd need to fire off that function whenever a character joins or leaves the team. But if you could nail that down, it could make for some cool dynamically appearing/disappearing doors to other levels.

Quote
Also, while I'm on character recognition, does anyone know if it's possible to have a character switch between templates for said character based on which map they are on in a freeroam campaign?  I know, this one is probably stretching it, but I figured it couldn't hurt to ask.

You might be able to do something similar, by again looping through the current team when the map loads, and for a certain character, destroying the "old" version, spawning the "new" version and then adding them to the team. You could ideally have both functions merged so if you ally with a certain character, not only could you process which doors are available, you could have both characters change outfits etc...

As i said, its a theoretical idea that could work. The hardest part I think would be figuring out on each map what characters are blocked from what doors etc... that could get a bit complicated depending on how crazy you wanted to get.

lmalonsof

The following is just an idea and it isn't much versatile...

1.- Put the marker as you said, behind a door. This door only can be opened from inside: the switch can only be activated if you have teleported through the door.

2.- Just before you want to activate the hidden entrance, make a new cutscene encounter wich teleports one hero (or all of them) inside the space where is the marker and put a switch to open the door. This makes the marker only reachable when you want to.

3.- Your character will open the door and they can reach the marker.

The problems of this method are... too many. This won't care the hero you are using, but is the best I can do...

graver

Thanks guys for the responses... definitely gives me some things to try!

GogglesPizanno, I was thinking about adding a python event to the misssion.py as being one of the few and only things that would work nice and smooth and wouldn't be to hackery.  However, I ran into 2 problems with that approach.  The first is from what i can tell it doesn't look like freeroam campaigns use the mission.py's of the individual maps.  All of the code seems to be centralized in the various freeroam.py files in scripts.  The second problem is I can barely get EZ Script to work properly most of the time... I have no idea the damage I will do with python.  I might have to put this on the back burner for a bit until I can at least get ez script right half the time ;)  Definitely an avenue for me to look into down the road... at least I know what I'm looking to do is possible :D

lmalonsof, your a freaking genius!  Actually, the idea you had should care which hero is being used as cut scenes should only fire off if all conditions in them are true.  If I use the actual hero template name to teleport said hero over, then that cut scene should only fire off if that hero template is present!  Else, it will try to fire off another cut scene of the same name in which all conditions are true.  Hell, on this trend, I should be able to use cut scenes to move objects if a certain template is present in the team.  I would only need to have that template say something stupid, move an inch, or what ever, just as long as i reference it, the cut scene to move said object would should only occur if said template present.  I got too caught up in thinking about event branching and the setting of end conditions that I forgot cut scenes can have permanent lasting environmental effects... and if a barrier is all that stands between the heroes and a marker, then all that needs changing is the environment!  Thank you!

And after a bit of messing around with cut scenes, I believe I can use them to switch hero templates that need switching based on the map they are on.  I would just need to set up a chain of events, one event for each switchable hero with their alternate template spawned as an ally hidden off screen, use 2 alert cut scenes to do <template name> is destroyed on the switchable hero if they exist and another to destroy the ally if they don't, and have an Allies Become Controllable action as a part of the event.  As I only have 8 of these heroes planed to be in the campaign, it should be an easy event string to write up.  The biggest pain that i foresee is making sure it always goes off upon entering a map where I need the templates switched...

Thanks for the ideas on cut scenes!

And on the note of reliably using ez script, I have a small question on syntax for the SimpleChoice encounter.  What is the syntax for calling the next event in a simple choice event based on the choice made?  I have tried everything I can think of but I just can't figure out how to get the script to move to the next event based on what choice was made.  I have tried

Next: If <name of choice>: <next event>
Next: If <name of choice> at End: <next event>
Next: If Choice1: <next event>
Next: If Choice1 at End: <next event>
Next: If Choice1:<name of choice>: <next event>
Next: If Choice1 <name of choice>: <next event>
Next: If Choice1 <name of choice> at End: <next event>
Next: If Choice1:<name of choice> at End: <next event>

I honestly can't think of any other way to say "If this choice is chosen, then the next event should be that event over there."  How should I be saying that?

Thanks guys on all the help you have been so far!  You have helped me out considerably! :D

Boalt92

graver,

I hope I understood your question correctly:  You an encounter that can spin off in different directions depending on the outcome of the encounter?

If so, you're probably best off tying the next event to the outcome of the first.  For example, if you're saving civilians, you'll want:

Encounter: SaveEncounter
Type: Save Civilian
....
Next: If Allies Lost: AllyLostEncounter
Next: If Allies Saved: AllySavedEncounter


You are limited to the number and types of outcomes, but, with custom encounters, you can probably get a little more creative.  HOpe that answers your question.

B92

GogglesPizanno

QuoteI was thinking about adding a python event to the misssion.py as being one of the few and only things that would work nice and smooth and wouldn't be to hackery.  However, I ran into 2 problems with that approach.  The first is from what i can tell it doesn't look like freeroam campaigns use the mission.py's of the individual maps.  All of the code seems to be centralized in the various freeroam.py files in scripts.  The second problem is I can barely get EZ Script to work properly most of the time... I have no idea the damage I will do with python.

I haven't delved too much into the freeroam code so I never even thought about mission.py not being read. I suppose you could find the freeroam function itself that generates the "exits" on each map and throw in an additional check for characters at that point. Now I'm getting intrigued at the possibilities  ;)

Of course while we spend days upon days hacking and breaking the script in 10 different ways, M25 could probably hammer out a plug-in in like 30 seconds making us look silly.

graver

QuoteOf course while we spend days upon days hacking and breaking the script in 10 different ways, M25 could probably hammer out a plug-in in like 30 seconds making us look silly.

Too true, too true!  I have been going over the piles and piles of py's that make the ez script and freeroam work and, in the end, I think the only thing I figured out was that i had a splitting headache :rolleyes:  Besides, with lmalonsof's help, i got a workaround for the map and template thing all figured out... and it works nice and smooth like using the power of the cut scene!  :thumbup:

QuoteI hope I understood your question correctly:  You an encounter that can spin off in different directions depending on the outcome of the encounter?

Sorry about not being as specific as I should have been.  Close, yes, but it's a specific kind of encounter that was written as a plug-in by M25 called a Simple Choice encounter.  I'm just hopping someone else has messed around with it and knows how it works... i don't want to be eternally bugging M25 with question after question ;)

What Simple Choice does is it starts a chat/examine encounter with an ally or object specified in the ally or object Parameters and once the examination is complete, it adds several (up to five I think) choices that can be chosen by the player from the object interaction menu (the right click one).  These choices are defined in the Parameters Choice1 through Choice5 (I haven't tested to see if 5 is the max number, but from looking at the py, it looks like it can only take up to 5).  When the choice is made, the appropriate cut scene for the choice plays and an ending is set, from what i gather, to match the choice made.

This is the encounter code I'm using:

Encounter: Chose
Type: Simplechoice
Allies: maude
Choice1: Play God
Choice2: Let her Rest
Next: If Play God: Dead Maude
Next: If Let her Rest: Dead Maude2

Alert Cutscene:
Hero1 says, "Simple Choice activated!"

Play God Cutscene:
Hero1 says, "I shall play god!"

Let her Rest Cutscene:
Hero1 says, "It's better that she remain little girl and never become monster."


The above code plays the alert cut scene and then places the exclamation point on the ally, maude.  When the player clicks on maude, the exclamation point is removed.  I think I could make an examination cut scene for the initial click, but haven't bothered... got obsessed with making the choice work.  When the player right clicks on maude, there will be three actions beyond the norm presented in the menu: "Talk" (which does nothing at this point... or if there was an examination cut scene, it might play it again and again each time it's selected...) "Chose: Play God", and "Chose: Let her Rest".  When "Chose: Play God" is selected, the Play God cut scene is played and all options then removed from the right click menu (except for "talk").  When "Chose: Let her Rest" is selected, Let her rest cut scene is played and all options removed from the right click menu.

However, i can't figure out what the end conditions for each choice are called so i can't figure out how to write the Next parameter of the encounter so it would work.  I tried most everything I could think of but nothing worked.  I, of course, may be entirely wrong in my thinking that different end conditions are set depending on the choice made, but in the write up on the plug-in, it sounded like such was possible.  I don't know enough about python or the rest of the ez script code to figure out from reading the py for the simple choice encounter if there are separate end conditions for the choices and, if so, what they would be called.

However, given all of this, you may be right in thinking that I'd be better off sticking with a more traditional encounter branching for this. 

With the simple choice encounter, my goal was to initially set up an event that, if an ally that the heroes were to rescue should fall, they would have the option of trying a risky reserection type of event which would have the potential of kicking the story off in a different direction from it's current trajectory.  I suppose I could just have said allies death trigger an examine encounter with an explanation as to what it's for in the alert cut scene, and if the player choses to examine said object, then they kick off the whole reserection thing.  However, I don't really want an encounter hanging around indefinitely and would need a way for it to be ended without said object being examined.  I guess I could have the whole reserection thing done and completed in the cut scene for that option alone (since I can at least get that to work) and that would insure encounter tidiness... but then i wouldn't get as much branching as I was hoping for... I guess you can't win them all.

I still have to know about those end conditions for the simple choice else it will drive me batty! ^_^

M25

With regards to Simple Choice, make the choices lower case and it will work.  It looks like there's a bug somewhere in the EZ script engine.
[spoiler]
Encounter: Chose
Type: Simplechoice
Allies: maude
Choice1: play god
Choice2: let her rest
Next: If play god: Dead Maude
Next: If let her rest: Dead Maude2

Alert Cutscene:
Hero1 says, "Simple Choice activated!"

play god Cutscene:
Hero1 says, "I shall play god!"

let her rest Cutscene:
Hero1 says, "It's better that she remain little girl and never become monster."

[/spoiler]

lmalonsof

I wasn't aware of that plugin. M25, would you please upload it in the ezscript wiki? Is there any other 'official' plugins for ezscript that are not in the wiki? Thanks in advance once again M25.

By the way graver, it's a pleasure giving some help back to the forum.

M25

Simple Choice comes with ffx 3.2 more as a 'this is how to create a plug-in' than a part of EZ script.


lmalonsof

ok... that explains why this was the first time I hear about it... thanks M25!

graver

Quote from: M25 on October 15, 2007, 12:40:37 PM
With regards to Simple Choice, make the choices lower case and it will work.  It looks like there's a bug somewhere in the EZ script engine.


Thanks!  Looks like that did it  :thumbup:

Boalt92

Thanks for the heads up on this plug-in....


....it gives me some ideas  :o

B92

lmalonsof

This thing about the plugins reminds me...

Is there any way in EZscript to remove an object from the map?

Imagine you want to use some force fields in an ezscript mission for making the heroes deactivating them. If they were doors there would be no problem: one could use the open door enconter as usual and that's it. But with a force field?

A force field (let's say, blitz_shield_beams) must be correctly placed in the map because it must obviously block your way. I mean if you put the force field via ezscript object it possibly won't block your way, even using properly map markers. It would be wonderful if you could setup your force fields previously in the map editor and then use switches to remove them via ezscript. It would be like 'switch it off' but what you are really doing is removing the object...

I'm simulating the force field effect now using items (usually the hypno sphere) with high knockback powers and switches, but when the hero is very fast it doesn't work. Is there another way of doing this? How could I remove objects from the map via ezscript?

Thanks in advance!

P.S.
I forgot, is there any way of using Simple Choice as a cutscene conversation? Imagine you're talking you're simple plain dialogue with no options with some character and at some point, you can choose to ask him one question or the other, which would lead you to different answers and more different questions... Is this possible? Is it possible to nest more choices in every one of the first 5 ones? If it would... wow! Interactive dialogues in ffvstr!

:EDIT:
Is there any way of changing one object for another? e.g: You use a switch and the cuban_missile becomes the cuban_missile_platform, simulating the missile has been launched.

M25

Quote from: lmalonsof on October 16, 2007, 12:57:10 AM
This thing about the plugins reminds me...

Is there any way in EZscript to remove an object from the map?


In a cutscene you can use the line

<name> is destroyed. 

Where name can be the usual, Villain, Object, Hero, or the name of an actual thing on the map.

Quote

Imagine you want to use some force fields in an ezscript mission for making the heroes deactivating them. If they were doors there would be no problem: one could use the open door enconter as usual and that's it. But with a force field?

A force field (let's say, blitz_shield_beams) must be correctly placed in the map because it must obviously block your way. I mean if you put the force field via ezscript object it possibly won't block your way, even using properly map markers. It would be wonderful if you could setup your force fields previously in the map editor and then use switches to remove them via ezscript. It would be like 'switch it off' but what you are really doing is removing the object...


To place an object on the map, you can either use the game editor that comes with FFEdit, or you can position a marker where you want the object to appear.

If you put the object on the map manually, just give it a name and use the name of the object to reference it in EZ script.  In this example, I called it forcefield.

Encounter: Sample
Type: Fight
Objects: blitz_shield_beams named forcefield

End Cutscene:
forcefield is destroyed


To get more exact placement using a marker, put the object on the map with the editor, and then change it to a marker in FFEdit.  The marker should have the same position and facing as the object you placed.  When the object is spawned during the encounter, the game will use the position and facing of the marker you placed, so it should (in theory) be exactly where you want it.





Quote
I'm simulating the force field effect now using items (usually the hypno sphere) with high knockback powers and switches, but when the hero is very fast it doesn't work. Is there another way of doing this? How could I remove objects from the map via ezscript?

I think you need to use an object that physically blocks their path. 


Quote

P.S.
I forgot, is there any way of using Simple Choice as a cutscene conversation? Imagine you're talking you're simple plain dialogue with no options with some character and at some point, you can choose to ask him one question or the other, which would lead you to different answers and more different questions... Is this possible? Is it possible to nest more choices in every one of the first 5 ones? If it would... wow! Interactive dialogues in ffvstr!


Sort of.  You can branch to a new Simple Choice or to a Cutscene encounter to continue the conversation.  Give the character you are talking to a name to ensure that they stick around between encounters.

Encounter: Talk1
Type: Simple Choice
Allies: civilian_male named bob
Choice1: yes
Choice2: no
Choice3: maybe
Next: if yes: Talk2
Next: if no: Reconsider
Next: if maybe: Reconsider


Chat Cutscene:
Ally says, "Thugs are ruining my business."
Hero says, "That's terrible."
Ally says, "Will you help me?"

yes cutscene:
Hero says, "Of course.  I am a hero after all."

no cutscene:
Hero says, "Sorry, I have other plans."

maybe cutscene:
Hero says, "I'll think about it."

Encounter: Talk2
Type: Cutscene
#this is the character from Talk1
Allies: civilian_male named bob

Start Cutscene:
Ally says, "Thank you so much... here's the details..."


Encounter: Reconsider
Type: Simple Choice
Allies: civilian_male named bob
Choice1: yes
Choice2: definitely not
Next: if yes: Talk2
Next: if definitely not: Kidnap

Chat Cutscene:
Ally says, "Won't you reconsider?"

yes cutscene:
Hero says, "OK, I'll help.  But this better be good."

definitely not cutscene:
Hero says, "Sorry buddy.  I'm busy."
Ally says, "I'm sorry to hear that.  I'll see if I can find a true hero."
Ally moves to encounter2
Fade for 2 seconds
Ally is destroyed
Unfade for 2 seconds

Encounter: Kidnap
...







Quote
:EDIT:
Is there any way of changing one object for another? e.g: You use a switch and the cuban_missile becomes the cuban_missile_platform, simulating the missile has been launched.

Not as such.  Again, you'd have to set it up as two encounters.

Encounter: Missile
Type: Custom
Actions: switches exist
Objects: cuban_missile
Marker: missile1
Next: if all switches off: Missile Launch

End Cutscene:
Object is destroyed

Encounter: Missile Launch
Type: Cutscene
Objects: cuban_missile_platform
Marker: missile1
...


lmalonsof

I have no words. :eek2: What a masterclass!  Thanks M25.

graver

Wow, I'm glad my crazy little questions are helping more people then just me  ^_^

And of these questions, i have another which just cropped up.

In a custom encounter in which Switches Exist, is there a way to get rid of the yellow arrows, the exclamation point above the switch, or the switch its self once the encounter has ended?

Thanks all, and thanks M25 for us ez script and very diligent support of it  :D

lmalonsof

Yeah, I know what you mean... sometimes even after the encounter the green arrow is still there. Maybe we could try this in the end cutscene:

End Cutscene:
remove yellow arrow from switch

graver

Quote from: lmalonsof on October 19, 2007, 09:13:06 AM
Yeah, I know what you mean... sometimes even after the encounter the green arrow is still there. Maybe we could try this in the end cutscene:

End Cutscene:
remove yellow arrow from switch


Thanks, but it didn't seem to work.  The primary difficulty with removing the arrows is the fact that the switches are created dynamically and I haven't figured out how to set an easily retrievable name for the switches in ez script.  The standard <template> named <some_name> breaks the encounter when written in the switches parameter.  I just ended up commenting out the line of code that adds the arrows to the switch and just have the arrows added to the switches marker in the start cutscene and remove the arrows in switches off cutscene.

On a completely different note, I do have a question regarding ez script campaign performance vs freeroam performance.

When taking the mission I've been working on as a regular campaign styled mission (for easer testing) and converting it over into a freeroam mission, there seems to be a drastic decrease in preformance centered around launching new events that spawn enimies.

While testing the misison in campaign mode, an event that spawns 2 villains and 3 minions would maybe cause a very slight stammer (maybe) when the eevnt was innitialized but the same event in freeroam mode would cause the game to stutter three times, each stutter lasting about half a second.  It's a bit annoying but gets considerably worse if more then one event is called at once or if there are already enemies spawned.  At three event calls of the same type at once the game was pretty much locked up (I gave up waiting for it at the 2 min marker).  Having the same events run at the same time in campaign mode just caused a slight stutter (maybe a fourth to half a second in length) when all three were initialized but then proceeded normally.

I've been trying to figure out ways of cuting down on the overhead that the freeroam scripts cause but havent gotten very far at all.  I eleminated any calls to the daylight calculations but that did nothing and I couldn't identify anything else that wasn't essental to the functionality and integrity of the freeroam system.  Does anyone know of anything else I can safely dissable?  All I need the freeroam for is to enable the player to go to any map they wish and have encounters happen on said maps... anything beyond that is something I would be willing to sacrifice for performance sake.

I also noticed that the spawn call for enemies is considerably different in the freeroam script then in the regular enc so possibly there may not be anything I could do to help with spawn rate performance

M25

Freeroam is slower as it has more data to shuffle around, but I hadn't found such a huge difference from the campaigns (and I did time them).  Are you using the same map for both?  The number of objects on a map has a huge impact on performance.

Also, not have enough encounter markers on the map will cause problems for EZ script as it tries to find places to spawn encounters.


Spawning characters is the same across all versions of EZ script.  The spawn code in the freeroam python file isn't used by EZ script.