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

arrays
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 02, 2009 10:24 am    Post subject: arrays Reply with quote

Okay ... okay ...
One more question, then I can stop hassling you guys :-P

Is it possible to define a global array (or list) in a plotscript?

I've scanned over the PS dictionary, and couldn't find anything list or array-like.

I'm going to try and enable the player to split the party into multiple groups (which he/she can switch between at any time).
To do so, I'll need to manage 2 or more lists of heros present in each sub-party.

The lists will never be larger than 4, so it's conceivable to do this without arrays ... it'll just be kinda sucky :-D
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Mon Nov 02, 2009 10:37 am    Post subject: Reply with quote

No array support is available yet. It is planned for a future revision.

For now, you can fake it using the read global and write global commands.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ShakeyAir




Joined: 27 Apr 2004
Posts: 93

PostPosted: Mon Nov 02, 2009 10:52 am    Post subject: Reply with quote

It is possible. Kind of. What all are you looking to store? Just the hero and the position in either party? That should be really easy.

Have all the globals that you want to represent heroes in each party in order (you don't have to give them a name and you can go way up, like start at 4000 to make sure you never interfere with the party system later)

Basically how this works would be that global 4000 is Party1, global 4004 is Party 2, global 4008 is Party3, etc. etc.

This example uses the scripts Define Party and Swap party, which are down below because I thought it would be easier to see how they fit in to actually doing something first.

So as an example, here's a mega simplified script when we pick our teams (the real one would need a custom thing in place to make sure a hero wasn't picked for two teams simultaneously):

Code:
plotscript, deal with teams, begin
  #pick team 1
  team menu
  define party (party1) #global number 4000
  wait (1)
  team menu
  define party (party2) #global number 4004
  wait (1)
end


and here, we change them for a predefined team:

Code:

plotscript, switch to team 2, begin
  swap party for (party2)
end


So define your first party, or 2nd, or whatever (This defines it based on who is in the hero's current team):
Code:

script, define party, which party, begin
 for (a, 0, 3, 1) do (
   write global (which party+a, hero by slot (a))
 )
end


Then do something like this to change party:

Code:
script, swap party for, which party, begin
  for (a, 0, 3, 1) do (
    swap out hero (hero by slot (a))
  )
  for (myhero, which party, (which party+3),1) do (
   swap in hero (myhero)
 )
end


I MAKE NO PROMISES THAT THIS WILL WORK
Back to top
View user's profile Send private message
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Mon Nov 02, 2009 11:30 am    Post subject: Reply with quote

I have a place in my first game, Tales of the New World, that has multiple party selection. The basic idea is similar to Shakey Air's, but there are a couple other things to be careful of:

You will need 8 global var's per party (9 if you want them to have their own separate money) - 4 for people in the party, 1 for the map they are on, 2 for their x,y coordinates, and 1 for the direction they are facing.

When you are constructing the party, don't forget that the player may choose less than four people! -1 is usually what is used for an empty hero slot, but you have to be checking for this throughout your scripts.
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 02, 2009 12:01 pm    Post subject: Reply with quote

Ooh - so instead of using arrays, I tinker with ... memory addresses? Is that what those numbers are?
Yay!
*is going to try it this evening*

Haha.
I was thinking of using a dummy map to store data in a 2D array (with each maptile representing a different number).
That would be both clumsy and funny.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Mon Nov 02, 2009 1:06 pm    Post subject: Reply with quote

Bagne wrote:
Ooh - so instead of using arrays, I tinker with ... memory addresses? Is that what those numbers are?
Yay!
*is going to try it this evening*


Not memory addresses, just global variable ID numbers... actually, I guess that is a little bit similar to memory addresses.

Bagne wrote:
Haha.
I was thinking of using a dummy map to store data in a 2D array (with each maptile representing a different number).
That would be both clumsy and funny.


That sounds like more work, and it wouldn't get stored in your SAV file.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Mon Nov 02, 2009 9:01 pm    Post subject: Reply with quote

Oioi - Problems galore! I haven't even tackled splitting and joining a single group of heros, let alone 2 or more ...

I think I've ironed out most of the problems, except one ...
and I'm beginning to suspect that I've found a reportable bug, but I want to check here first to make sure that I'm not just using the wrong PS command.

Precisely what does "hero by slot" do?

My understanding of the PS dictionary:
hero by slot (position)
The argument corresponds to a position in the caterpillar (or non-caterpillar walkabout party) and it returns the corresponding hero's ID#, yes?

So, if I had a caterpillar of 4 heros, I could walk all four, one by one, like this:

Code:

variable (i)
variable (heroID)

suspend caterpillar
for (i,0,3) do(
  set variable (heroID,hero by rank(i))
  walk hero (heroID,north,2)
  wait for hero (heroID)
  walk hero (heroID, south,2)
  wait for hero (heroID)
)
resume caterpillar


Well, this is not what's happening in my game - I don't know what "hero by rank" is returning, but I can't get it to make the right hero walk.

Can anyone verify this?
Please tell my I haven't lost my mind. I'm going to bed.
:-(
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



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

PostPosted: Mon Nov 02, 2009 10:04 pm    Post subject: Reply with quote

You don't want hero by rank(i). You just want i.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Tue Nov 03, 2009 5:07 am    Post subject: Reply with quote

Aha!

Now my swapping works.
Thanks for your help.

I was confused because I didn't realize that some commands take a hero ID#, and some take a caterpillar position number.

I'm using a combination of the two types of commands, and have them sorted out now.

Now I realize that whenever the PS dictionary says that a hero related command uses constants defined in the HSI file - that means I should be looking at the hero ID#.
In my particular application of the commands, I can't/(don't want to) use the HSI constants because I'm iterating over a loop.

Phew.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Nov 03, 2009 10:46 pm    Post subject: Reply with quote

Yeah, it confused me so badly when I first encountered it that I avoided all hero commands for years! (Well that, and the fact that I never had a use for them in whatever I was or wasn't doing)

I think I'll create a wiki page later categorising all the commands, but in the meantime, some rules of thumb:

Any command which affects a hero's stats, spells, name, etc., eg. teachspell, giveexperience, getherostat, uses position in party (battle party plus reserves), as returned by findhero.

Any command which affects the hero sprites on the map, eg. heroX, walkhero, setherospeed, uses position in catapillar party. Exception is setting a hero's walkabout sprite, that's the above category.

Some commands which operate on the party take a hero ID number, eg swapouthero, lockhero, addhero. This is not too great, you might have multiple heroes with the same ID in the party.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Wed Nov 04, 2009 5:11 am    Post subject: Reply with quote

BaHaha!
Battle party position!
Oioi! I'm glad you told me about that, because this confusion probably would have happened all over again!

Yeah, that's another thing I'm not 100% clear on. Does the battle party include every single hero you own, including the swapped out ones?
What about the locked ones?
Does anyone know if a swapped out and locked hero will have the "have hero" tag set to ON?
What about the "is in party" tag? Is that just for the walkabout party?
(these could be used in my party splitting/joining/swapping scripts)

About documentation:

My feeling is that some of the PS dictionary needs to be clarified.
It's not always crystal clear what kind of hero-specifying number you're supposed to throw in - although you can usually compare the command with others and figure it out.

For example, set hero direction, set hero frame, set hero position probably all take an argument value of between 0-3 for the caterpillar position. But none of them say so.
They just say
"script name (who, blabla) does -blah- to the specified hero"
The reader never learns how "who" specifies the hero.

Lock hero takes a different kind of argument, but is listed in a very similar way. It says:
"lock hero (who, other arguments)", and it never directly says that "who" refers to the hero's ID number. All it says is that you should use the constants defined in the HSI file.

But if I was a total n00b, or if I was as confused as I was a few days ago, I might not realize that HSI constants include hero ID numbers ... in fact, I'm still not completely sure this is true! lol!

I don't know how sacred the PS dictionary is, but I've been tempted to change a few things myself. Is this - ah - kosher? I don't want to step on anyone's toes.
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Nov 04, 2009 9:12 am    Post subject: Reply with quote

Bagne wrote:
Yeah, that's another thing I'm not 100% clear on. Does the battle party include every single hero you own, including the swapped out ones?
What about the locked ones?


Confusingly enough, yes :)

Swapped out hero's start at slot 4

Bagne wrote:
Does anyone know if a swapped out and locked hero will have the "have hero" tag set to ON?


yes it will. Locking only affects the team menu, it has no effect on scripting commands.

Bagne wrote:
What about the "is in party" tag? Is that just for the walkabout party?
(these could be used in my party splitting/joining/swapping scripts)


Yes. The "is in party tag" only applies to battle party slots 0-3

Bagne wrote:

About documentation:

My feeling is that some of the PS dictionary needs to be clarified.
It's not always crystal clear what kind of hero-specifying number you're supposed to throw in - although you can usually compare the command with others and figure it out.

For example, set hero direction, set hero frame, set hero position probably all take an argument value of between 0-3 for the caterpillar position. But none of them say so.
They just say
"script name (who, blabla) does -blah- to the specified hero"
The reader never learns how "who" specifies the hero.

Lock hero takes a different kind of argument, but is listed in a very similar way. It says:
"lock hero (who, other arguments)", and it never directly says that "who" refers to the hero's ID number. All it says is that you should use the constants defined in the HSI file.

But if I was a total n00b, or if I was as confused as I was a few days ago, I might not realize that HSI constants include hero ID numbers ... in fact, I'm still not completely sure this is true! lol!

I don't know how sacred the PS dictionary is, but I've been tempted to change a few things myself. Is this - ah - kosher? I don't want to step on anyone's toes.


I would be delighted to have your help fixing the documentation up. A lot of hero commands really do need this clarification.

Start with the latest copy from http://hamsterrepublic.com/ohrrpgce/docs/plotdict.xml and when you have made changes, send the xml file to me and I can merge your changes into subversion.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Wed Nov 04, 2009 10:06 am    Post subject: Reply with quote

Oh!
That's the old PS dictionary that I remember from years ago, isn't it?

I was talking about the wiki-PS dictionary ... that's what I've been referencing.

But I can do that instead, sure.
I guess this way its easier to check to see if I made a mistake :-S
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Nov 04, 2009 10:09 am    Post subject: Reply with quote

Bagne wrote:
Oh!
That's the old PS dictionary that I remember from years ago, isn't it?

I was talking about the wiki-PS dictionary ... that's what I've been referencing.

But I can do that instead, sure.
I guess this way its easier to check to see if I made a mistake :-S


The wiki docs are generated from the xml file (which sucks, because any updates to the plotscripting parts of the wiki get lost)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bagne
ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA




Joined: 19 Feb 2003
Posts: 518
Location: Halifax

PostPosted: Wed Nov 04, 2009 4:32 pm    Post subject: Reply with quote

Hey, when a hero is swapped in,
are they swapped to the highest empty slot?
_________________
Working on rain and cloud formation
Back to top
View user's profile Send private message
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, 3  Next
Page 1 of 3

 
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