Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Phoenix
Newbie


Joined: 03 May 2002
Posts: 9

PostPosted: Tue May 28, 2002 10:03 pm   

Semi-complex problem
 
Hi, I've got a bit of a problem trying to code in a script that adds numerical damage descriptors to vague verbal descriptors ... let me explain.

I am trying to make a script that will append the numerical equivalent of a damage noun on the end of a line during combat.

Let me give you an example:

Your attack strikes mobname with desolating fury!

Now, "desolating" is the damage descriptor which correlates with, lets say, 100 points of damage. However, the "fury" is unrelated to the amount of damage. I could hit with "desolating fury", or "desolating savagery."

What I want to do is make the above line into something like this:

Your attack strikes mobname with desolating fury! (100 Dmg)

Another example:
Groupie's attacks strike mob2name with ravaging savagery.

should become:
Groupie's attacks strike mob2name with ravaging savagery. (150 Dmg)
if ravaging corresponds with 150 pts of damage.

The current way I've been trying to do it is by using the trigger:
(*) {attack|attacks} {strike|strikes} * with (%x) (%x)
In the body of the trigger, I'd have a list of #IF statements, each corresponding to one of the 50 or so damage levels.
e.g. #IF {%2 = "disemboweling"} {#VAR dmg 400}
Then at the end I have:
#SUBSTITUTE %3 {%concat( %3, " (", @dmg, " Dmg)")}

Now, there are two or three problems in this method of doing things ... for one, if there are "*" in the damage descriptors (e.g. ***DECIMATING***) the thing won't work, even if I use ~ before the * in my if statement. Secondly, sometimes the #SUBSTITUTE command just doesn't work all the time... it ignores my output window and makes wierd new triggers often containing that last damage word (savagery, fury, etc.) ... an example: #TR {fury!} {#sub %concat( fury!, " (", @dmg, " Dmg)")}.

Finally, the last problem is that the list of #IF statements is far too long for any sort of efficiency... its at least 60 members long. I was thinking of doing it using an array or database or list, but wasn't sure how to start. Maybe using a for loop incrementing an integer counter to go through the different values in the array?

In any case, there seem to be several problems in my script. If there is any way that you can help me, or even just point me in the right direction, I would be ecstatic!

I'll be trolling the boards all day to answer any questions / comments you may make.

Thanks so much for taking the time to read this!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue May 28, 2002 10:17 pm   
 
#VAR DamWordList {desolating|ravaging|***DECIMATING***}
#VAR DamAmountList {100|150|1.3 million}
#TR {^%*({@DamWordList})%*$} {#SUB {%concat(%trigger," ~(",%item(@DamAmountList,%ismember("%1",@DamWordList))," Dmg~)")}}

There you go, should just have to match entries between the 2 lists.
Reply with quote
Phoenix
Newbie


Joined: 03 May 2002
Posts: 9

PostPosted: Tue May 28, 2002 10:18 pm   
 
I solved some of the problems by using:
#IF {"%2"="*VAPORIZING*"} {#VAR dmg 13000}
as my format for the #IF statements ...

However I still have the problem of efficiency and of making the #SUBSTITUTE command work. I tried using #ECHO, #ECHOPROMPT, #SAY and #SHOW, and none of them seemed to work.

Perhaps something using %replace? I really have no clue where to go from here.
Reply with quote
Phoenix
Newbie


Joined: 03 May 2002
Posts: 9

PostPosted: Tue May 28, 2002 10:20 pm   
 
ooh thanks I'll try that out!
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed May 29, 2002 3:20 am   
 
Don't make this more complicated than it needs to be. Instead of putting the number at the end of the line, stick it right after the adjective. That is, just replace "desolating" with "desolating (100 Dmg)".
#SUB {desolating} {desolating ~(100 Dmg~)}
You'll now have: Your attack strikes mobname with desolating (100 Dmg) fury!

Make similar triggers for the other adjectives. You'll probably want to assign these all to a class (perhaps Combat) which can be enabled while fighting and disabled at other times.

LightBulb
Vague questions get vague answers
Reply with quote
Phoenix
Newbie


Joined: 03 May 2002
Posts: 9

PostPosted: Wed May 29, 2002 4:39 am   
 
OK Guys, I managed to get the entire thing working :)
Thanks a ton.
A combination of Vijilante's and LightBulb's help allowed me to substitute the damage desciptors :)

Now for phase 2!
I'm trying to make it so that when a certain player hits a mob, it will record their damage to their personal counter.

Was thinking of making something like a 2 dimensional array so that when anyone's name from @groupmembers hits a mob, the corresponding damage counter is incremented by the amount.

I don't want you guys to sit down and do the thing for me, but maybe you can point me to the right helpfiles? I found the ones on arrays/lists not detailed enough, whereas the one on databases was confusing and didn't seem to apply properly.

Any help would be greatly appreciated :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed May 29, 2002 11:23 am   
 
For ease of operation I would reccomend you go the nastiest looking form possible, the indirect reference.

You have a groupmembers variable I will assume that is a list, and I will guess you still have the damage words in a list.

#TR {^({@groupmembers}) * ({@DamWordList})} {#ADD {%1} {%item(@DamAmountList,%ismember("%2",@DamWordList))}}

It isn't pretty but should work. You will want to have the same trigger that fills groupmembers create the variables, and you will want to remove them when the person leaves the group.

For display it get even messier the code snippet is something like this...
#FORALL @groupmembers {#SHOW %i:@{%i}}
Reply with quote
Phoenix
Newbie


Joined: 03 May 2002
Posts: 9

PostPosted: Wed May 29, 2002 2:42 pm   
 
Yeah, thats pretty ugly, but I figured that this was the easiest way of doing it. Again, thanks for your help :) Its great having a board where experienced coders are willing to help out less experienced ones.

Maybe one day I'll be able to help a Z-newbie :P
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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

© 2009 Zugg Software. Hosted by Wolfpaw.net