mIRC Home    About    Download    Register    News    Help

Print Thread
#6166 11/01/03 09:30 PM
Joined: Jan 2003
Posts: 16
D
DynaMup Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2003
Posts: 16
Continuing from my earlier problems, I have now run into more trouble with my RPG utility.

I am in the process of making a section which will allow people to add skills to their character, based on their chosen Race - but each of these skills needs a level.

This is how each skill is currently added to a Hash Table (named CharSheet):
Code:
 
{ hadd CharSheet Skill Athletics $hget(CharSheet, Skill) .Climbing $hget(CharSheet, Skill) .Running }
 


Quite straightforward, and the skils are written into a listbox (id 47) when the dialog displaying them is initialised:

Code:
 
on *:dialog:sheet:init:0:{

didtok sheet 47 46 $hget(CharSheet, Skill)

}
 


But now, I want to also set the "value" of these "Athletics" skill to 1. I assume I'd need to do something like this:

Code:
hadd CharSheet Skill Athletics 1 $hget(CharSheet,Skill) .Climbing 1 $hget(CharSheet, Skill) .Running 1
  


I may be wrong about that, so any help would be appreciated. Now, I have 2 questions:

1) Is there a way to set the value of these "skills" to 1, but not display the number in the same listbox? Ideally, I would like this number to be seen elsewhere - in a different box.

2) I am also trying to devise a way that by the click of a certain button control, this number could be increased (i.e. make Athletics = 2). How can I increment this value?

I don't even know if what I'm asking is possible (I could be going about this in completely the wrong way), but any help would be greatly appreciated.


A poor life this, if full of care,
We have no time to stand and stare.
#6167 11/01/03 11:54 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
CharSheet
Skills=Climbing:2 Running:5 Stealth:15 Endurance:90

or
Skills=Climbing Running Stealth Endurance
SkillLevels=2 5 15 90

or

CharSheet
Skills=Climbing Running Stealth Endurance
Climbing=2
Running=5
Stealth=15
Endurance=90

The first method lends itself better to scripts that will be storing multiple characters in the same hash table. The second and third methods assume that everything in the hashtable deals with just that one character and the values will not be used in other contexts elsewhere in your script. The second method matches up each value found in Skills with the skill level for that skill in the exact same position. The third method specifies that there will be one item per skill with its data following.

The last method is particularly handy (meaning easy to comprehend) if your skills have more than a single piece of data. Endurance might have a value of 9 but a replenish rate of +3 per round/minute and also have a minumum practical value of 5 to perform basic skills.

Endurance=9 3 5

Running might have several attributes. Top speed might be 15 for an elf but only 7 for a dwarf. Running might have an Endurance modifier for speed. If Endurance is less than 75%, then run speed is cut by 2 for an elf but only 1 for a dwarf; if Endurance is less than 50%, then speed is cut by 4 (2 for dwarf) and if it's less than 25%, it's cut by 6 (3 for dwarf). So for an elf, you might have:

Running=15 2 4 6

If you wanted to do the same thing using the first method, you simply choose a different character to separate the skill from its modifier list, such as ÿ ($chr(255)) or : ($chr(58)).

Skills=Climbing:20 Running:15:2:4:6 Stealth:15 Endurance:9:3:5

In all of the above cases, you would just use $gettok(value,N,C) to get to the value you want, either in a loop to get them all or directly using the position number. Using the above example:

Skills=Climbing:20 Running:15:2:4:6 Stealth:15 Endurance:9:3:5
$gettok($hget(CharSheet,Skills),1,32) returns Climbing:20
$gettok($hget(CharSheet,Skills),2,32) returns Running:15:2:4:6
$gettok($hget(CharSheet,Skills),3,32) returns Stealth:15
$gettok($hget(CharSheet,Skills),4,32) returns Endurance:9:3:5

$gettok($gettok($hget(CharSheet,Skills),2,32),2,58) returns Max Running Speed of 15
$gettok($gettok($hget(CharSheet,Skills),4,32),4,58) returns Minimum Useful Endurance of 5

You would probably alias such cumbersome identifier strings in custom identifiers:

alias MaxRunSpeed return $$gettok($gettok($hget(CharSheet,Skills),2,32),2,58)
alias MinEndurance return $$gettok($gettok($hget(CharSheet,Skills),4,32),4,58)

if ($CurrentEndurance < $MinEndurance) { don't let them carry a heavy load }


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#6168 12/01/03 01:15 AM
Joined: Jan 2003
Posts: 16
D
DynaMup Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2003
Posts: 16
Right - final problem - at least for tonight!

I now have a listbox of skills, all with values that I now know how to call upon when needed.

Now, in this listbox, when a skill is selected, I would like related "specializations" to appear in another listbox below.

I have grouped these specializations together, under headings like HistorySpecs, CultureSpecs, AthleticsSpecs, and so on. I would like it so that when the user clicks on "History" in the Skills Listbox, it brings up the list of "HistorySpecs" in the Specializations Listbox.

The following code is incorrect, but I would like to know where I'm going wrong.

47 is the id of the Skill Listbox, and 48 is the id of the Specializations Listbox.

Code:
on *:dialog:sheet:sclick:47:{

  if ($did(47).seltext == "History" ) { didtok -ra sheet 48 46 $hget(CharSheet, HistorySpecs) }

  if ($did(47).seltext == "Culture") { didtok -ra sheet 48 46 $hget(CharSheet, CultureSpecs) }

  


As usual, I am grateful for any assistance smile


A poor life this, if full of care,
We have no time to stand and stare.
#6169 12/01/03 01:42 AM
Joined: Dec 2002
Posts: 191
N
Vogon poet
Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
didtok doesn't accept switches.

Code:

on *:dialog:sheet:sclick:47:{
  did -r $dname 48
  didtok $dname 48 46 $hget(CharSheet, $+($remove($did(47).seltext,$chr(34)),Specs))
}

Last edited by Nobodi; 12/01/03 01:45 AM.
#6170 12/01/03 10:24 AM
Joined: Jan 2003
Posts: 16
D
DynaMup Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2003
Posts: 16
That doesn't seem to work.

Here is my code for storing a skill:
Code:
 

on *:dialog:new1:sclick:13:{
  
  if ($did(new1,5).state == 1) {
    hadd CharSheet Skills Culture:1$hget(CharSheet, Skills) .History:2 $&amp;
      $hget(CharSheet, Skills) .Primitive Weaponry:2 $&amp;
      $hget(CharSheet, Skills) .World Knowledge:2 
  }
  hadd CharSheet HistorySpecs .Andorian:3
  hadd CharSheet CultureSpecs .Andorian:3
  
}

They are then called in a new dialog.

Code:
on *:dialog:sheet:init:0:{
  
  did -ra sheet 8 $hget(CharSheet, Template)
  didtok sheet 47 46 $hget(CharSheet, Skills)
  
}
on *:dialog:sheet:sclick:47:{
  
  did -r $dname 48
  didtok $dname 48 46 $hget(CharSheet, $+($remove($did(47).seltext, $chr(34)), Specs)) 
  
}

The skills are displayed in Listbox 47 during the on init event, and when, say "History:2" is clicked in this box, I would like the "HistorySpecs" to display in Listbox 48. However, since that "2" could change (as the player develops their character, for example), the code needs to work just as well if they click "History:1" or "History:5".

I'm stuck at this point, but if you know a way to help me out, please let me know smile


[EDIT: Added $& and a little formatting to shorten up the lines for the forum. No other changes. -Hammer]

Last edited by Hammer; 12/01/03 02:42 PM.

A poor life this, if full of care,
We have no time to stand and stare.
#6171 12/01/03 11:13 AM
Joined: Dec 2002
Posts: 191
N
Vogon poet
Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
Code:
on *:dialog:sheet:sclick:47:{
  did -r $dname 48
  didtok $dname 48 46 $hget(mirc,$+($remove($gettok($did(47).seltext,1,58),$chr(34)),Specs))
}

#6172 12/01/03 03:21 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
You will have to show us exactly what you are storing in $hget( CharSheet, Skills) as well as in $hget( CharSheet, HistorySpecs) and $hget( CharSheet, CultureSpecs), etc. It would also be of great help to see exactly what you want in your listbox(es) with no extra formatting (such as quotes or braces) that you do not want shown. If you want History to show up in the listbox, we need to know that. The same holds true for what you actually store in your data. Please present it like this:

[CharSheet]
item=value
Skills=Culture:1.History:2.Primitive Weaponry:2.World Knowledge:2
HistorySpecs=.Andorian:3
CultureSpecs=.Andorian:3

ListBoxID:13
"Culture"
"History"
"Primitive Weaponry"
"World Knowledge"

Without knowing exactly how you've chosen to store/display your data, we'll end up guessing at what you need, so specific examples of "working" code won't work for you.

When you have data that has spaces either in the sub-item name (such as Primitive Weaponry), you can separate each skill using the . as you have done above. As a general rule, though, it's frequently best to use a different character, one that is highly unlikely to ever be used in such a name. A period might conceivably be used inside a name, such as if you happen to store an address or IP inside one of your records. I like to use $chr(149) or $chr(158) for this, since when I echo it out to a window or an editbox (in FixedSys9), I get a rather large black box that quite easily visually separates my data so I can "see" the different records, or subsections, and don't have to worry about not using normal characters, or even abnormal ones. For the following examples, you would use the $gettok() specified to get through each of the items:

[$gettok($hget(CharSheet,Skills),N,133)] Skills=Culture:1History:2Primative Weaponry:2Word Knowledge:2
[$gettok($hget(CharSheet,Skills),N,149)] Skills=Culture:1History:2Primative Weaponry:2Word Knowledge:2
[$gettok($hget(CharSheet,Skills),N,151)] Skills=Culture:1History:2Primative Weaponry:2Word Knowledge:2

What you end up using will ultimately depend on which font you use in your windows and in your mIRC editor. I prefer $chr(158) usually since I frequently use the single character $chr(255) to represent $crlf; and I use FixedSys9 everywhere.

You can copy/paste the following string of printable characters into a window, delete the characters you will EVER use, and then see which one gives you a visually distinct separator. Then copy that one character into and editbox and use $asc(•) on it to see what the character separator number is for use in $gettok(). If you find that all of these characters can possibly be used in either a subitem name or value, then you can venture into the non-printable ASCII characters, such as $chr(2) bold. Just be careful which $chr()'s you choose as separators if they're not visible or you can end up with unusual results.

! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  €  ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ  Ž   ‘ ’ “ ” • – — ˜ ™ š › œ  ž Ÿ   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#6173 12/01/03 11:56 PM
Joined: Jan 2003
Posts: 16
D
DynaMup Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2003
Posts: 16
Okay, I'll try and be as clear as I possibly can. As you've gathered by now, my script is for a Star Trek RPG.

1) When the user chooses a "Race" from a list of radio buttons, this adds certain "Skills" to their Character Sheet (when they click the "Next" button). This is done in a Dialog Box called new1. Certain "Skills" added also have "Specializations" that go with them. A character receiving the "History" skill might also receive "Modern" and "Ancient" as specializations. So, this is how I intend to store this data. Here is an example, if the race chosen is "Andorian".

[CharSheet]

Skills = Culture:1.History:2 .Primitive Weaponry:2 .World Knowledge:2

HistorySpecs = .Andorian:3
CultureSpecs = .Andorian:3
PrimWeapSpecs = .Chaka:3

Now, I would like the Skills (not the Specializations) to display in a ListBox like so.

ListBox ID:47
"Culture:1"
"History:2"
"Primitive Weaponry:2"
"World Knowledge:2"

2) As you can see, this character has received several basic skills by virtue of being an Andorian. They are also specialised in Andorian History, Andorian Culture and the Chaka, a primitive Andorian weapon.

When "History:2" is selected in ListBox 47, I would like a second ListBox (id 48) to display the HistorySpecs like so:

ListBox ID:48
"Andorian:3"

And if "Primitive Weaponry:2" should be selected in ListBox 47, I want ListBox 48 to be cleared and to display the PrimWeapSpecs:

ListBox ID:48
"Chaka:3"

3) My code:

All data is stored in a Hash Table named CharSheet. Each character has one CharSheet, which contains all of their data.

To ensure that the Hash Table allows me to store multiple items under the same heading, "Skills" are stored like so (else each new skill would overwrite the last in the hash table):

Code:
 
on *:dialog:new1:sclick:13: {

if ($did(new1,5).state == 1) { hadd CharSheet Template Andorian }

{ hadd CharSheet Skills $hget(CharSheet, Skills) .History:2 }

{ hadd CharSheet HistorySpecs $hget(CharSheet, HistorySpecs) .Andorian:3 }

}
 


These "Skills" are then displayed on a Character Sheet - which is another Dialog Box (id sheet) in ListBox ID:47.

Code:
 
on *:dialog:sheet:init:0:{
  didtok sheet 47 46 $hget(CharSheet, Skills) }
 


What I cannot seem to do is find the right code that will show the HistorySpecs in Box 48 when "History" is selected in Box 47, or CultureSpecs when "Culture" is selected - and so on.

There are also other skills to be added later on - an Andorian does not, for example receive the skill "Music" or the specialization "Guitar", nor does a Human become an expert in Andorian Culture, so whatever system you can devise needs to be flexible enough to implement this as well. I am willing to completely overhaul whatever parts of my system you deem necessary to make this work smile

Sorry if I sounded patronising - I just wanted to be as clear as possible. If I've left anything out that you need, let me know and I'll answer as soon as I can. If you could return any answers in an equally clear way, I'll be ecstatic! smile I really need hand-holding through this one, but I'm determined to make this project work cool


A poor life this, if full of care,
We have no time to stand and stare.
#6174 13/01/03 08:53 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
This code can be downloaded (briefly) here in text form.
Code:
dialog tdef.Star.Trek.RPG.Character.Editor {
  title "Star Trek RPG - Character Editor"
  size -1 -1 258 114
  option dbu

  button "OK"            ,   1, 183  96  34  14, default ok
  button "Cancel"        ,   2, 221  96  34  14, cancel
  text "Race:"           , 101,   6   6  20   8
  radio "Human"          ,   9,  34   5  30  10, group
  radio "Vulcan"         ,  10,  64   5  30  10
  radio "Klingon"        ,  11,  94   5  30  10
  radio "Romulan"        ,  12, 124   5  32  10
  radio "Andorian"       ,  13, 156   5  34  10
  text "Skills:"         , 102,   4  18  22   8
  list                      47,   4  26 124  66, size hsbar vsbar
  text "Specializations:", 103, 132  18  40   7
  list                      48, 131  26 124  66, size hsbar vsbar
}
alias st dialog -m new1 tdef.Star.Trek.RPG.Character.Editor
on *:DIALOG:new1:init:*:{
  didtok $dname 47 46 $hget(CharSheet,Skills)
  if ($hget(CharSheet,Race) == Human) did -c $dname 9
  elseif ($hget(CharSheet,Race) == Vulcan) did -c $dname 10
  elseif ($hget(CharSheet,Race) == Klingon) did -c $dname 11
  elseif ($hget(CharSheet,Race) == Romulan) did -c $dname 12
  elseif ($hget(CharSheet,Race) == Andorian) did -c $dname 13
}
on *:DIALOG:new1:sclick:*:{
  if (($did &gt; 8) &amp;&amp; ($did &lt; 14)) {
    hdel -w CharSheet *Specs
    did -r $dname 47
    if ($did($did) == Human) {
      hadd CharSheet Race Human
      hadd CharSheet Skills Culture:1.History:1.World Knowledge:1.Logic:-1
      hadd CharSheet CultureSpecs Human:2
      hadd CharSheet HistorySpecs Human:3
      hadd CharSheet WorldKnowledgeSpecs Human:5
      hadd CharSheet LogicSpecs Human:1
    }
    elseif ($did($did) == Vulcan) {
      hadd CharSheet Race Vulcan
      hadd CharSheet Skills Culture:4.History:5.World Knowledge:7.Logic:253
      hadd Charsheet CultureSpecs Vulcan:2
      hadd CharSheet HistorySpecs Vulcan:6.Galactic:6.Human:2.Romulan:1.Klingon:2
      hadd CharSheet WorldKnowledgeSpecs Vulcan:4.Human:1
      hadd CharSheet LogicSpecs 200
    }
    elseif ($did($did) == Klingon) {
      hadd CharSheet Race Klingon
      hadd CharSheet Skills Primitive Weaponry:5.Medium Weaponry:6.Advanced Weaponry:8
      hadd CharSheet PrimitiveWeaponrySpecs Klingon:5.Vulcan:1.Human:3
      hadd CharSheet MediumWeaponrySpecs Klingon:7.Vulcan:2.Human:5
      hadd CharSheet AdvancedWeaponrySpecs Klingon:9.Vulcan:3.Human:7
    }
    elseif ($did($did) == Romulan) {
      hadd CharSheet Race Romulan
      hadd CharSheet Skills Primitive Weaponry:5.Medium Weaponry:6.Advanced Weaponry:8
      hadd CharSheet PrimitiveWeaponrySpecs Romulan:5.Klingon:2
      hadd CharSheet MediumWeaponrySpecs Romulan:6.Klingon:2
      hadd CharSheet AdvancedWeaponrySpecs Romulan:9.Klingon:2
    }
    elseif ($did($did) == Andorian) {
      hadd CharSheet Race Andorian
      hadd Charsheet Skills Culture:1.History:2.Primitive Weaponry:2.World Knowledge:2
      hadd Charsheet CultureSpecs Andorian:2
      hadd Charsheet HistorySpecs Andorian:5.Galactic:1
      hadd Charsheet PrimitiveWeaponrySpecs Chaka:3
    }
    didtok $dname 47 46 $hget(CharSheet,Skills)
    did -c $dname 47 1
    did -r $dname 48
    didtok $dname 48 46 $hget(CharSheet,$+($remove($gettok($did(47).seltext,1,58),$chr(32)),Specs))
  }
  elseif ($did == 47) {
    did -r $dname 48
    didtok $dname 48 46 $hget(CharSheet,$+($remove($gettok($did(47).seltext,1,58),$chr(32)),Specs))
  }
}
on *:LOAD: hmake CharSheet

Make sure you don't have any of your own hash table CharSheet loaded when you load this one or it will alter the values. Once loaded, start it with /st and click on the different races and individual skills to see how Specializations change. Then go in and read the code carefully to see how I made it all work together.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#6175 14/01/03 12:14 AM
Joined: Jan 2003
Posts: 16
D
DynaMup Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Jan 2003
Posts: 16
Okay, Hammer - I've studied your script, tested it and learnt a great deal from it, so thanks for all your work and help.

I now have a script that does exactly what I want it to do. If you'd like a copy of it when I eventually get it finished, you're welcome, if you ever happen to want to play a Star Trek RPG smile


A poor life this, if full of care,
We have no time to stand and stare.

Link Copied to Clipboard