Rand program question

For builders to discuss and ask building questions.
Post Reply
Amalia
Sword Grand Master
Sword Grand Master
Posts: 331
Joined: Wed Feb 01, 2006 6:51 pm
Location: Ardeep Forest
Contact:

Rand program question

Post by Amalia » Tue May 15, 2007 1:08 am

Is it possible to construct a rand program that functions based on a given value plus the level of a particular character? There's a task in a quest that I'd optimally like to make such that it's more likely to succeed the higher level the PC responsible for doing it is (the giver of the quest tells the leader to bring along a powerful X to get a certain thing done).

My first thought for the least possible mess per iteration of the progarm would be to check the party for the appropriate character and store that character's level as a value, say N. Then the rand prog, assuming this is possible, would be set to 50+N, where N defaults to -50 so if there is no such appropriate character the task is automatically failed-- that would at least avoid the need to check the party every tick, which I imagine would range anywhere from horrific to disastrous.

If this isn't possible or would be too resource-intensive (it would be an area that people could only enter for a specific step of a quest) I can always make the check simply succeed if a character of the appropriate class above a certain level is there.

On a related note, is there any way to temporarily disable a character's ability to use skills or fight in order to reflect the fact that he is "busy" without removing the character's ability to walk?
Dear Enemy: May the Lord hate you and all your kind, may you be turned orange in hue, and may your head fall off at an awkward moment.
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Post by Japcil » Tue May 15, 2007 3:44 am

yes:

Code: Select all

rand_prog 5~
if level <#
  if race goblin
    code for random stuff goes here
  endif
endif
You cannot create a variable in our area code however. Sounds like you have coding background however. :wink:
Image
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Tue May 15, 2007 8:55 am

There's no way to "temporarily disable" a character, as far as I know.

As for a program whose behaviour would depend on the level of a character, you would need to use several if-checks (since you can't use variables as parameters to programs - or anywhere in area code, actually -).

Code: Select all

if level($n) < 10
  Action1-9
else
  if level($n) < 20
    Action10-19
  else
    if level($n) < 30
      Action 20-29
    else
      if level($n) < 40
        Action30-39
      else
        Action40-50
      endif
    endif
  endif
endif
~
would be a good way to do it, by approximating $n's level. If you need a finer analysis, you can add more if-checks and divide the 1-50 level ranger into blocks of 5 levels for example.

If what you really want is an action that happens with a probability that depends on $n's level, you can simply replace all "ActionX-Y" placeholders above with a piece of code of the form

Code: Select all

if rand(N)
  Action
endif
where "N" can be a different value for each group of levels. For example, in Action1-9, it could be rand(55); in Action10-19, it could be rand(65); an and so on. That would be a pretty good approximation of what you described above, that is, rand(50+level).

Hope that helps.
Post Reply