ID:1368564
 
(See the best response by MisterPerson.)
Question:
So I want to make a move where a user is able to copy and turn into an opponent that is surrounding them. I just need to know how I would be able to start that cause honestly I'm pretty stuck.

Oh and also, they shouldn't be allowed to copy the opponent's stats, only their moves. So in retrospect, it would kinda be like Zorua in Pokemon and what move he uses.

Many thanks
~ Excalibur
Best response
That depends on how the moves are defined. If they're like
/mob/moveuser/verb/example_move()


Then let's assume the target is target and we're giving the verbs to src:
var/list/verblist = list()

for(v in typesof(/mob/moveuser/verb))
if(v in target.verbs)
verblist += v

verbs += verblist
spawn(n)
verblist -= verblist


Another way to do this that you may not be a good idea:
var/list/bannedverbs = list() //Put admin verbs or anything else you don't want to copy in here. You can do this with the above as well.

var/list/verblist = list()
for(v in target.verbs)
if(v in bannedverbs)
continue
verblist += v

verbs += verblist
spawn(n)
verbs -+ verblist
Thanks for the quick reply bro!
Awesome, now I can get started on this. Thanks for the info :P

~ Excalibur
Also, what if the user has some of the same moves as the target, is there any way that we can avoid having duplicates?
+= with lists will only add things that aren't already in the list.
Verbs do not add twice.

You'll want to keep track of the verbs you added if you want to remove them, to ensure you don't remove any that were not added.

I think you can do the following to do that:

for(v in typesof(/mob/moveuser/verb))
if(v in target.verbs && !(v in src.verbs))
verblist += v
In response to MisterPerson
MisterPerson wrote:
+= with lists will only add things that aren't already in the list.

This is not true; it's only true with a special list like verbs.
K thanks guys :P

~ Excalibur
In response to MisterPerson
MisterPerson wrote:
+= with lists will only add things that aren't already in the list.

Don't you mean |= ?
Oh, so actually, sorry if im annoying you, but is there any way you can just select the verbs from a certain category?
In response to Gogeta9000
Gogeta9000 wrote:
Oh, so actually, sorry if im annoying you, but is there any way you can just select the verbs from a certain category?

I don't believe so, only by the specified path.
verbs+=typesof(/mob/PATH/verb)
Oh, k thanks :P
You actually can get verbs in specific categories. Most people don't know it, but the verbs inside of the verb list have variables, but the compiler isn't really exposed to them, so you have to use the : operator to access them.

mob
verb
TestOne()
set category = "One"
TestTwo()
set category = "One"
TestThree()
set category = "Two"

TestOutput()
for(var/V in verbs)
usr << "The verb [V:name] is in the [V:category] category."


TestOutput() will output all of the names and categories of all the verbs you have in your verbs list.
In response to Nadrew
Nadrew wrote:
You actually can get verbs in specific categories. Most people don't know it, but the verbs inside of the verb list have variables, but the compiler isn't really exposed to them, so you have to use the : operator to access them.

> mob
> verb
> TestOne()
> set category = "One"
> TestTwo()
> set category = "One"
> TestThree()
> set category = "Two"
>
> TestOutput()
> for(var/V in verbs)
> usr << "The verb [V:name] is in the [V:category] category."
>

TestOutput() will output all of the names and categories of all the verbs you have in your verbs list.

Interesting o:
In response to Kozuma3
Kozuma3 wrote:
Nadrew wrote:
You actually can get verbs in specific categories. Most people don't know it, but the verbs inside of the verb list have variables, but the compiler isn't really exposed to them, so you have to use the : operator to access them.

> > mob
> > verb
> > TestOne()
> > set category = "One"
> > TestTwo()
> > set category = "One"
> > TestThree()
> > set category = "Two"
> >
> > TestOutput()
> > for(var/V in verbs)
> > usr << "The verb [V:name] is in the [V:category] category."
> >

TestOutput() will output all of the names and categories of all the verbs you have in your verbs list.

Interesting o:

an example of this - with both explicit and implicit typing - has been in the Red Book forever.

There is a few things I should expand in there, though...