PDA

View Full Version : Proper Use of Plurals With $race and $class?


So_1337
06-06-2007, 03:08 AM
Hey folks. I recently got a big batch of log files and have been sifting through all the aggro speak and such for NPCs. Here's a quick example:

Roror says 'Dark Elves like you are better left dead than alive.'
Roror says 'It's Dark Elves like you who have ruined your own lands, You'll not ruin mine!'
Roror says 'You ssssshall know the horror of Cazic-Thule!'

a lizardman watcher says 'Errrrrr. Die soft skin!'

Basher Sklama says 'I shall pluck you limb from limb!!'
Basher Sklama says 'Shadow Knights like you always bring out the worst in me.'
Basher Sklama says 'Those who play with da Basher always gets bashed good!!'

a spectre says 'Areeeeewwwww'
a spectre says 'I really hate Necromancers like you.'

What I'm curious of is how to make the phrases come out correctly. I can get the singular race or class just fine (Necromancer, Dark Elf, etc.), but is there a special variable that can be used for plurals? "Dark Elves", etc. If not, I guess I'll just write some long work-around using variables. $npc->CastToClient()->GetBaseRace() and then a list of all the races and what they should come out to be plural. Then store those in variables and plug it into the quest::say... But that seems like such a long way to go to make something that should be simple work :P

That's why I'm asking for ideas :) Thanks for any help, guys and gals.

Darkonig
06-06-2007, 03:45 AM
Instead of using $race, use ${race}s
The {} is not normally needed around the variable name in a string if it is immediately followed by something that is obviously not part of the name, like a space.
so if $race = "Ogre" then
quest::say("$race"); prints Ogre
quest::say("${race}s"); print Ogres
quest::say("$races"); gives an error because there is no variable $races


quest::say("${race}s like you are better left dead than alive.");
quest::say("It's ${race}s like you who have ruined your own lands, You'll not ruin mine!");
quest::say("${class}s like you always bring out the worst in me.");

So_1337
06-06-2007, 04:10 AM
Fantastic! Thank you!

Any way to account for Dark Elves becoming Dark Elfs, or should we just accept it?

Darkonig
06-06-2007, 04:38 AM
Easiest to just accept it unless you feel like adding a some extra code to build the plurals yourself. Best would be a lookup table for plurals rather than trying to implement some sort of rule based determination since there aren't that many you would want plurals for anyway.