ID:179621
 
Some of you might remember me asking this Q.
I didn't get an answer yet and this problem really bugs me.
I really need an example to get me started...

I've been trying to make a magic shop where you can learn a magic spell only once.
Thx to Nadrews spell system, I made a spell and a small shop.
The only problem i've had is to find a code that allows the magicshop to know if I already have learned the spell or not.


//part of the shop code. After I choose the Charm spell.
if("Charm")
if(...) // I need to find something to put here...
alert("You know this spell!","Sorry")
return 0
else
usr.verbs+=new/mob/proc/Charm

... //rest of the code here.


This is the only spell I have for now (it works):

mob/proc/Charm(mob/M as mob in view(10))
set category = "Magic"
if(usr.mp>=10)
view() <<"[usr] casts Charm!"
M.hp=min(M.hp+100,M.maxhp)
usr.mp-=10
else
usr<<"You don't have enough MP !"



Someone suggested putting a hascall(), like
if(hascall(usr.verbs,"Charm")).
It compiles well, but the magicshop just ignores that part of the code.
Thx for those who tried to help before.
Any new suggestions?

THX.



Try

if(hascall(usr.verbs,/mob/proc/Charm))


and see if that works.
In response to Nadrew
Nadrew wrote:
Try

> if(hascall(usr.verbs,/mob/proc/Charm))
>

and see if that works.

Nope, same thing. It compiles well, but i can still learn the same spell twice.

Thx anyways.
Cravens wrote:
Some of you might remember me asking this Q.
I didn't get an answer yet and this problem really bugs me.
I really need an example to get me started...

I've been trying to make a magic shop where you can learn a magic spell only once.
Thx to Nadrews spell system, I made a spell and a small shop.
The only problem i've had is to find a code that allows the magicshop to know if I already have learned the spell or not.


//part of the shop code. After I choose the Charm spell.
if("Charm")
> if(...) // I need to find something to put here...
> alert("You know this spell!","Sorry")
> return 0
> else
> usr.verbs+=new/mob/proc/Charm

... //rest of the code here.


This is the only spell I have for now (it works):

mob/proc/Charm(mob/M as mob in view(10))
> set category = "Magic"
> if(usr.mp>=10)
> view() <<"[usr] casts Charm!"
> M.hp=min(M.hp+100,M.maxhp)
> usr.mp-=10
> else
> usr<<"You don't have enough MP !"

Someone suggested putting a hascall(), like
if(hascall(usr.verbs,"Charm")).
It compiles well, but the magicshop just ignores that part of the code.
Thx for those who tried to help before.
Any new suggestions?

THX.

Here's a simple way of solving the problem. Mind you, it's not very professional, but what the hey.

mob/var/list/learned_spells

//the shop code after Charm is chosen

if("Charm")
if("Charm" in usr.learned_spells)
usr << "You're kidding, right? You know that spell already!"
return
usr.verbs += new/mob/proc/Charm

Very very simple, but a way nonetheless.
Try giving the mob in your game a var called Charm, or whatever you want. Then, when the person gets the charm spell, have it add one to the charm var, then when they try to get it again, have it check to see if the person's charm var is >= 1, if so, tell them to beat it. Like so....
mob
var
Charm

mob
Guy
verb
Learn()
set src in oview(1)
switch(input("Want to learn charm?","Charm")in list("Yes","No"))
if("Yes")
if(usr.Charm >= 1)
usr << "You know this spell already!"
else
usr.Charm = 1
usr.verbs += new/mob/proc/Char
if("No")
usr << "Thank you come again"

Hope this helped

This is not tested
In response to The Wizard of How
That's a pretty ingenious way to do it.
Isn't there a way to know if you have a certain proc/verb or not ?

Anyways, Thx.

In response to Cravens
Cravens wrote:
That's a pretty ingenious way to do it.
Isn't there a way to know if you have a certain proc/verb or not ?

Anyways, Thx.


Yeah...use the hascall proc like they said earlier. Instead of checking to see if their charm var is >= 1, check to see if they have the charm proc.