View previous topic :: View next topic |
Author |
Message |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Fri Apr 15, 2005 3:29 am Post subject: 3 Questions |
|
|
Question the first:
Does anyone have any idea about which takes longer for game.exe to perform:
Reading/Writing globals
Altering npc pictures
generating random numbers
Reading/Writing maptiles
checking 'if' conditions *EDITED IN*
Question the second:
How are npc copies (of the same ID) assigned? Are they made by which npc was placed first (by custom map editor or by plotscripting) or where the npc copy is located, or any other reason?
Question the third:
Again, does anyone have any idea about which slows down game.exe more:
Lots of copies of a few different stationary NPC ID's present onscreen
Lots of different stationary NPC ID's present onscreen
Moving NPCs onscreen
Last edited by msw188 on Fri Apr 15, 2005 4:58 am; edited 1 time in total |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Fri Apr 15, 2005 3:34 am Post subject: |
|
|
Answer Sr:
I would imagine that generating the random numbers takes longer, since the other things are just reading/writing arrays. However, this would be a difference of a few milliseconds at best, so for all practical purposes, it's irrelavent.
Answer:
I haven't fully explored the NPC reference system, so I cannot answer this question. But, the answer probably involves "sequentially".
Answer Jr:
Moving NPCs as in wandering or as in scripting? I think they're all about the same, with moving NPCs being slightly longer (see Answer Sr.) _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Fri Apr 15, 2005 1:17 pm Post subject: |
|
|
I'm not totally sure, as it's been a good year since I've messed with it, but I think the NPC ID's are gathered by location on the map, moving down each row and from left to right. |
|
Back to top |
|
 |
Sephyroth Renegade Rebel Redmage Class A Minstrel

Joined: 04 Feb 2003 Posts: 644 Location: Schmocation
|
Posted: Fri Apr 15, 2005 1:25 pm Post subject: |
|
|
Quote: | Altering npc pictures |
alter npc is just about the slowest fregging function in HS. _________________ im realy ded  |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Fri Apr 15, 2005 2:31 pm Post subject: |
|
|
Now that I think about it, you're probably right, since it must hand so many different things. It would be nice to have a bunch of smaller seprate functions... *hint hint to a developer* _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Apr 15, 2005 6:45 pm Post subject: |
|
|
I *think* the reference number has something to do with the order in which they were placed on the map. _________________
|
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Apr 15, 2005 7:35 pm Post subject: |
|
|
To answer the npc reference question:
"npc reference" returns the npc with highest reference number first. Actually, npc references are NEGATIVE (-300 to -1), so it returns the lowest first.
When you place NPCs in custom it assigns them refereences going from -1 down.
When you use "createnpc", it gives them refereences from -300 up.
"npcreference" checks npcs starting from -1 to -300
If you had 2 copies of npc 10, one placed in custom, and two more created, npcreference(10,0) would return the one placed in custom, and npcreference(10,1) the one created last.
According to the code alternpc shouldn't be slow at all unless you change picture or palette, in which case it reloads all npc graphics. And there would be no speedup by splitting it. Mike, you're a developer, if you want something done, do it.
Reading/writing globals, generating random numbers, and map operations are likely to be all roughly as long. However, flow control runs through a whole bunch of extra code, andis likely to be slightly slower.
The most reliable way to tell how quickly something is going to run is to check the amount of args. Each arg, even if only a number, or if you didn't even specify it, uses up several extra interpreter cycles. (Though numbers are of course quicker than commands) Thus write global(id,number) can be assumed to be slower than read global(id)
Question the third:
NPCs onscreen must be drawn, whereas those offscreen are not. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Sat Apr 16, 2005 7:16 am Post subject: |
|
|
The Mad Cacti wrote: | Mike, you're a developer, if you want something done, do it. |
I'm an OHRFB developer. I can't compile the OHR. Hence, any code patches I make are like playing russian roulette. _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sat Apr 16, 2005 3:45 pm Post subject: |
|
|
I told you, try compiling it with QB7.1!! _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Mon Apr 18, 2005 3:28 am Post subject: |
|
|
A very hearty thanks to the Mad Cacti for the wealth of information he provided. I have only one question about your response: you said that
Quote: | Reading/writing globals, generating random numbers, and map operations are likely to be all roughly as long. |
As long as what? Do you mean to say as long as each other, or as long as alter NPC (which was what you had been discussing in the previous paragraph)?
However, I must say that the information is a bit distressing for my present purpose. I want to make sure I understand some things. Can some people verify these ideas?
1. If I want some things to happen with greater probability than others, I am better off trying to perform mathematical operations such as 'mod-ing' and raising numbers to randomly generated powers than performing a series of 'if' checks.
2. If I am using autonumber scripts, the less arguments I send it the better. I am actually better off defining a whole bunch of global variables specifically for the task that these autonumber scripts are used for, and setting them in the master script (that calls the autonumber), rather than sending them to the autonumber script via arguments.
Also, another question that I can't quite make out yet. Suppose I need 18 different npcs on the screen, and then they all must change. Am I better off using alterNPC on all of them to change their picture and palette, or should I destroy all of them and create 18 new ones, with the pictures defined on the map editor in custom? |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Apr 18, 2005 5:04 am Post subject: |
|
|
Alter NPC is the slowest command ever. You're better off replacing them all. _________________
|
|
Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Mon Apr 18, 2005 9:25 am Post subject: |
|
|
If you're writing a script that needs to move faster than it is and are using "alter npc", one plausible solution is to have another npc that has the stats changed to what you need it and use "change npc id". 'Course, that'll use at least two of your thirty-six per map npcs, so you'll have to have extra space in there for it to work. |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Tue Apr 19, 2005 6:25 am Post subject: |
|
|
Ah, I had never used 'change NPC ID' before. It basically sounds like destroy npc and create npc built into one. But in using this approach, I will no longer be able to reference my npcs by their ID. Thus I will be forced to reference them as globals (where I store their current ID) or with 'NPC at spot' commands (for my present purpose they do not move, luckily). Is either way preferable for speed, do you know? Or are there other faster ways that I am not thinking of? I am also still immensely interested in anything people can say about my other statements above.
Thank you so much to everyone for helping me with this. |
|
Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Tue Apr 19, 2005 9:16 am Post subject: |
|
|
I'm not sure, but I think the npc reference is kept. Like, if you have the reference stored in a global variable, let's say "hero", and then change the ID of "hero", you might still be able to refer to that npc with "hero". My memory's a little foggy as it was a good year or so since I tried, but it's worth a test, I think. |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Apr 19, 2005 9:25 am Post subject: |
|
|
Yes, the reference should be preserved, but obviously you can no longer refer to the NPC by its old ID. _________________
|
|
Back to top |
|
 |
|