ID:180832
 
can it be done? And another question: Is there any way i can add multiple verbs to a person during runtime, instead of putting the code for each and every one?
On 2/5/01 3:59 pm Cinnom wrote:
can it be done? And another question: Is there any way i can add multiple verbs to a person during runtime, instead of putting the code for each and every one?

I'm not quite sure what you mean in either case...could you provide some game situation examples that would help me understand?
On 2/5/01 3:59 pm Cinnom wrote:
can it be done?

Nope. There hasn't been any real conclusions on how to make it work, and none of us BYONDudes (or BYONDudettes) have been helpful enough to make any suggestions...

And another question: Is there any way i can add multiple verbs to a person during runtime, instead of putting the code for each and every one?

If you look at the mob.verbs var in the reference, that might answer that question. Might.

You'd still have to make those verbs for a mob or obj, but then you could add those verbs to any other mob or obj without having to copy and paste, by using

usr.verbs += /mob/verbs_mob/attack()
In response to Spuzzum
can it be done?

Nope. There hasn't been any real conclusions on how to make it work, and none of us BYONDudes (or BYONDudettes) have been helpful enough to make any suggestions...

Well, if by "redefining" you mean changing the source code of the proc without recompiling (and rebooting) the world, then no. It just can't be done.

However, if you want the proc to behave differently under different circumstances but you know what those circumstances will be, then you could check out the "switch" statement. Here's a very simple example.

var/deadliness = "normal"

mob/dm
verb/set_deadliness(T as text)
if(T in list("newbie", "normal", "deadly"))
deadliness = T
usr << "Damage severity is now [T]."

mob/proc/Damage(myAmount)
//Reduce the mob's health by the damage amount. Modify
//the damage amount according to the severity set by the DM.
switch(deadliness)
if("newbie") myAmount *= 0.5
if("deadly") myAmount *= 1.5

health -= myAmount
In response to Deadron
On 2/5/01 4:55 pm Deadron wrote:
I'm not quite sure what you mean in either case...could you provide some game situation examples that would help me understand?

Well, my first question has been answered. As for the second one, heres a little scenario: An admin logs in, and i want to give him all of his admin verbs. Theres obviuosly more than one verb, and i want to add all of them. All of these are in one group (one place in the code).

I know how to add verbs to a person, what i want is a one or two line way of adding all of them at once.
In response to Cinnom
Well, my first question has been answered. As for the second one, heres a little scenario: An admin logs in, and i want to give him all of his admin verbs. Theres obviuosly more than one verb, and i want to add all of them. All of these are in one group (one place in the code).

I know how to add verbs to a person, what i want is a one or two line way of adding all of them at once.

Here's an idea, but I don't know if it would work or not! Maybe Dantom can tell us...

You could create a /mob/admin object with special verbs. Then at runtime, in world.New, you create one instance of the admin mob and assign it to a global var. Then, whenever a player needs the set of admin verbs--this is the part I'm not sure about--I *think* you could just loop through that admin mob's verbs list and copy it to the player. Like so:

var/mob/admin/GlobalAdmin

world
New()
GlobalAdmin = new()

mob/admin
verb
destroy()
resurrect()
teleport()
//etc...

mob/player
verb/gimme_power()
var/V
for(V in GlobalAdmin.verbs)
verbs += V
In response to Guy T.
On 2/7/01 5:23 pm Guy T. wrote:
Well, my first question has been answered. As for the second one, heres a little scenario: An admin logs in, and i want to give him all of his admin verbs. Theres obviuosly more than one verb, and i want to add all of them. All of these are in one group (one place in the code).

I know how to add verbs to a person, what i want is a one or two line way of adding all of them at once.

Here's an idea, but I don't know if it would work or not! Maybe Dantom can tell us...

How quickly we forget! Guy himself provided a nice little solution to this long ago, which I enhanced a bit for my own use. It's called "verb packages", and here is a sample from one of my games:

client
proc
AddVerb(the_verb)
if(!verbs.Find(the_verb))
verbs += the_verb

verb_package
GM_commands
proc
AddClientVerbs(client/the_client)
the_client.AddVerb(/verb_package/GM_commands/proc/create)
the_client.AddVerb(/verb_package/GM_commands/proc/money)


create(O_type in typesof(/obj))
set category = "GM"
set desc = "(an object)"
var/obj/new_object = new O_type()
new_object.Initialize()
if (new_object.isHoldable)
usr.AddToInventory(new_object)
else
new_object.loc = dd_get_step_rand(usr)

money(m as num)
set category = "GM"
usr.money += m


So this is a class called verb_package, which adds all the verbs it has to a client when this function is called:

call(/verb_package/GM_commands/proc/AddClientVerbs)(src)

If I were working on this now, I would probably add something like Guy mentioned, and instead of needing to explicitly list which verbs to add, I would have the AddClientVerbs() function loop through the verb_package's verbs list.

I will leave that addition (which is what you are really asking for I think) as an exercise for the reader. Use F1 in DreamMaker and look up 'verbs' to see how to loop through the verbs of an object.