Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

3 Questions
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Fri Apr 15, 2005 3:29 am    Post subject: 3 Questions Reply with quote

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
View user's profile Send private message Visit poster's website
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Fri Apr 15, 2005 3:34 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Uncommon
His legend will never die




Joined: 10 Mar 2003
Posts: 2503

PostPosted: Fri Apr 15, 2005 1:17 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Sephyroth
Renegade Rebel Redmage
Class A Minstrel



Joined: 04 Feb 2003
Posts: 644
Location: Schmocation

PostPosted: Fri Apr 15, 2005 1:25 pm    Post subject: Reply with quote

Quote:
Altering npc pictures


alter npc is just about the slowest fregging function in HS.
_________________
im realy ded Sad...
Back to top
View user's profile Send private message Send e-mail AIM Address
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Fri Apr 15, 2005 2:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Fri Apr 15, 2005 6:45 pm    Post subject: Reply with quote

I *think* the reference number has something to do with the order in which they were placed on the map.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Apr 15, 2005 7:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Mike Caron
Technomancer




Joined: 26 Jul 2003
Posts: 889
Location: Why do you keep asking?

PostPosted: Sat Apr 16, 2005 7:16 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sat Apr 16, 2005 3:45 pm    Post subject: Reply with quote

I told you, try compiling it with QB7.1!!
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Mon Apr 18, 2005 3:28 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Mon Apr 18, 2005 5:04 am    Post subject: Reply with quote

Alter NPC is the slowest command ever. You're better off replacing them all.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Uncommon
His legend will never die




Joined: 10 Mar 2003
Posts: 2503

PostPosted: Mon Apr 18, 2005 9:25 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Tue Apr 19, 2005 6:25 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Uncommon
His legend will never die




Joined: 10 Mar 2003
Posts: 2503

PostPosted: Tue Apr 19, 2005 9:16 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Apr 19, 2005 9:25 am    Post subject: Reply with quote

Yes, the reference should be preserved, but obviously you can no longer refer to the NPC by its old ID.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group