![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
#1 |
Symbol of Cyric
![]() |
![]()
So, I know we have a few people who are more script savvy than me, and I was wondering what I was doing wrong with this script:
$VAR Count; Count = 0; $WHILE (Count < ($MINUS($PARTYSIZE(), 1))) { $SET_CHAR_STATUS(Count, "2"); Count = (Count + 1); }; $RETURN; Theoretically, it should run thru a loop making each character status "2" (dead) in the party and end when reaching the partysize. But it does not, and I get a GPDL error saying 11 members in party is illegal. This means that the script is failing to exit the loop (as in stop loop when count is no longer lesser than partysize -1). Any ideas? ST ps, does this also mean we may someday have 10 people in the party???
__________________
http://www.wilhelmscream.net/ |
![]() |
![]() |
![]() |
#2 |
Jack Burton
![]() Join Date: July 13, 2001
Location: Stumptown
Age: 53
Posts: 5,444
|
![]()
Well, first off, DC doesn't support $WHILE - maybe you can use it in a conversation (talk.bin) which uses GPDL in a slightly different way (more can be done).
Second thing I notice is that you don't need to use $MINUS, and in fact shouldn't. I'll let Paul explain why. ![]() Third, $SET_CHAR_STATUS is used wrong - it needs an actor $SET_CHAR_STATUS($Target(),"2") Lastly, it's not an error, but you don't need $RETURN, it's implied. I just don't know how to make this loop. ![]() But, if the idea is to kill the whole party, by setting their status to "2" and not giving damage, you should try using a party ASL - since it effects the whole party. ![]() |
![]() |
![]() |
![]() |
#3 |
Drow Warrior
![]() Join Date: July 8, 2003
Location: Madison, Wisconsin
Age: 85
Posts: 296
|
![]()
$VAR Count;
Count = 0; //Nice. Declare a variabel named 'Count' and set it to "0". // Remember!!!!!! Everthing in GPDL is a string. (White //lie alert!). At any rate.....GPDL kindly converted the //zero to a string, saving you two keystrokes and the //associated shifts. $WHILE (Count < ($MINUS($PARTYSIZE(), 1))) //Not too bad.....Let us say the party size is // three. That is "3". Remember everthing is a //string. But $MINUS converts strings to numbers //and back again....So the result is "2". //This works pretty well....even though you //meant to compare numbers, you were actually //comparing strings. Nevertheless, "0" is less //than "2". "1" is less than "2". In dictionary //order. So all is well. If the numbers had gotten //as high as ten, however, we would find that // "10" is less than "2". // Perhaps you should have used a numeric //comparison rather than a string comparison. // Count <# ($MINUS($PARTYSIZE(), 1)) // And Manikus is right. $MINUS is designed to // operate on very large numbers. It would be // a rather slow and inefficient way to subtract // small numbers ( less than about 2 billion ). { $SET_CHAR_STATUS(Count, "2"); //Now it gets complicated. What is count? It //can mean one of two things!!!!! Neither of which //is what you want! // // In combat it is the combatant number. It probably //will be equal to 0, 1, 2, 3, etc for the party //and then continuing with higher numbers for the //monsters. But you should not count on it. // // In adventure it is the unique id of the party //member and could be anything. 12, 22, 97, 103. // Count = (Count + 1); //Here, my friend, is the big mistake. Remember that //everything is a string. "0" + "1" is "01"; //"01" + "1" is "011". // // You should probably use an arithmetic plus... // Count = (Count +# 1); }; $RETURN; Last edited by Paul Stevens; 05-22-2010 at 10:47 PM. |
![]() |
![]() |
![]() |
#4 | |
Symbol of Cyric
![]() |
![]() Quote:
So, I'm to assume a properly set up $WHILE statement won't work fine? are there other loop processes? FOR/NEXT? or GOTO/GOSUB? I know there were functions that GPDL can use that were not listed in the old help file (wherever that may be ![]() ![]() Thanx for the help! Chances are, I'll have a few more posts to this in the near future ![]() ST
__________________
http://www.wilhelmscream.net/ Last edited by SilentThief; 05-23-2010 at 07:46 AM. Reason: major rehash, added a few things ;) |
|
![]() |
![]() |
![]() |
#5 | |
Drow Warrior
![]() Join Date: July 8, 2003
Location: Madison, Wisconsin
Age: 85
Posts: 296
|
![]() Quote:
we'll fix it. $WHILE is documented and has worked for me. Your problem is that the party members are not necessarily numbered 0,1,2,3. Except in combat. You did not say whether youir script was designed for a combat setting. We very definitely need to do something about this because the documentation is wrong and it is most confusing for you , me, and anyone attempting to create scripts. In combat, there is a function to get the next combatant and you can put it into a $WHILE loop until there are no more. $WHILE (next) {}; Perhaps we should do the same for the adventuring party. and attempt to change the documentaion. And add lots of warnings to the documentation!!!! Because the simple 0,1,2,3....method will appear to work well most of the time!!! Perhaps I should change the code to make 0,1,2,3 NEVER work. The problem is that the current code allows a party member to retain his identity as other party members come and go. If, for example, there are members 0, 1, 2, and 3 and party member (1) leaves the party, then party members (2) and (3) retain their identity and party member (2) is missing. So the party size will become three and the members become 0,2,3. Is this valuable? Perhaps we should change the code so that it is much simpler. After party member (1) leaves then the identity of (2) and (3) will become (1) and (2). Oh, dear......difficult choices. |
|
![]() |
![]() |
![]() |
#6 | |
Symbol of Cyric
![]() |
![]()
The $WHILE script example I gave was not used for combat, it was only used for just walking around.
Quote:
$GIVE_CHAR_ITEM(0, "Wimpy Axe"); would give the first partymember (slot zero) the axe and also reading that it would give the active partymember the axe. But you are saying that if a member of the party were removed from the game then the designer could give a call to give an item to that member of the party? Wouldn't that throw an error message? referring to a non-existant partymember? Using your example, in my opinion the references should reset to 0,1,2 instead of having partymembers 0,2,3. But again, thats my opinion. ST
__________________
http://www.wilhelmscream.net/ |
|
![]() |
![]() |
![]() |
#7 |
Drow Warrior
![]() Join Date: July 8, 2003
Location: Madison, Wisconsin
Age: 85
Posts: 296
|
![]()
Well, sir, I have been pondering
this for the last 24 hours or so. I have come to agree with you. I very much doubt that anyone has taken advantage of the unique identity provided by the code. If some existing script depends on it, I will provide conversion functions. Here is a little 'gotcha'. We will change this to be party index rather than PC id. Let us say you do the following: size = $PARTYSIZE $WHILE(index <# size) { ------ $IF (index == 1) delete party member 1 ------- index = index +# 1; }; Do you see what happens? Your code never examines party member(2). Do you see why? And you will get an error when the index exceeds the partysize. Do you see why? But I suppose scripts are unlikely to get caught in such traps. Until you get a version that uses index rather than id, you can probably proceed as if it were indexes because things only get screwed up if a party member leaves the party and no other is added. Last edited by Paul Stevens; 05-24-2010 at 10:02 AM. |
![]() |
![]() |
![]() |
#8 |
Jack Burton
![]() Join Date: July 13, 2001
Location: Stumptown
Age: 53
Posts: 5,444
|
![]()
So, Ive never gotten $WHILE to work in the editor or engine, but I have gotten it to work in the conversation feature (talk.bin).
As it's been a while, I should try again. ![]() I'll let you know...I'm gessing that I just wrote a bad script before, with lots of variations that were also bad. ![]() ![]() |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
RE: Paladin AI Script | Dundee Slaytern | Icewind Dale | Heart of Winter | Icewind Dale II Forum | 15 | 12-08-2003 01:08 AM |
Script help | Lord Splynncryth | Dungeon Craft - RPG Game Maker | 2 | 09-15-2002 11:35 PM |
Script | Wedin | Icewind Dale | Heart of Winter | Icewind Dale II Forum | 3 | 04-06-2002 02:14 PM |
Script Questions | kopema | Icewind Dale | Heart of Winter | Icewind Dale II Forum | 11 | 06-10-2001 05:42 AM |
script writing | slackerboy | Baldurs Gate II Archives | 8 | 03-11-2001 10:52 AM |