ID:270507
 
Im creating a Harry Potter game and was wondering how i woukd create the Sorting Hat to shout out either Gryffindor, Hufflepuff, ravenclaw or Slytherin and make the icon to that of their new house. How would I do that?
Look up pick(), switch() and the icon var.

Slap it together in a verb, and enjoy.
In response to Detnom
Thank You.

Whilst your here ive made a verb called wandthreaten and i switch the icon state, how can i make the icon state switch back to the normal icon after 5 seconds?
In response to Master Scar
Do something similar to this:
var/I=usr.icon_state  //to hold the icon_state
usr.icon_state="dancing" //Just an example
spawn(50) usr.icon_state=I //Wait 50 ticks (approximately 5 seconds)\
and switch back to the stored state


That should work.
In response to Detnom
Thanks so much!

EDIT: How would i do a spell called "Expeliarmus" that knocks back the person it is used on 2 tiles?
In response to Master Scar
i do believe you would put:
mob/verb/Expeliarmus(mob/M in oview(4))
M.y-=2
In response to Dragon_fire6653
Thank You

What is wrong with this though?

obj
sortinghat
icon = 'Sorting Hat.dmi'
desc = "Sorting Hat"


I get inconsistent indentation
In response to Master Scar
look at your post in code problems ; )
In response to Dragon_fire6653
That would work if it was a tilted side-scroller. You'd do better to use get_step().

mob/proc/Expeliarmus_Hit(direction,N=2)
ASSERT(direction && N && N>0)
for(var/i=1,i<=N,i++)
src.Move(get_step(src,direction),turn(direction,180))

mob/verb/Expeliarmus(mob/M in view())
if(!M) return
M.Expeliarmus_Hit(get_dir(src,M),2)


Let me explain this a bit. It's very simple. When you call the Expeliarmus verb, you are asked to choose a mob, (or not if there is only 1 mob in view, or none at all) and it calls that mob's Expeliarmus_Hit() proc. It sends the direction between the usr and the mob selected so that you may knock the mob in that direction through the proc.

The 2 is how many spaces the mob will be knocked back. You can remove it if you'd like. I just though that some people might have more power with the verb or something, so better to keep it in.

Experliarmus_Hit() accepts the arguments sent through the Expeliarmus() verb. It uses them to alter everything. ASERT() checks to see if that values are true.

I'm going to take it that you don't know how that for() loop works. In which case, you can always look it up. For every number between 1 and N, know the src mob back one in the direction sent to the procedure. I used Move() so that incase there is a dense atom in the way, you don't move ovet them.

And turn() is so that they are still facing the way that they face the mob who shot at them. If you want them to keep facing the same way, you can take it out and place src.dir in it's place.
In response to Master Scar
how about you just flat out ask us to program an entire game for you? cause god forbid you should look at libraries *GASP*
In response to Darkdemonrad
Or read the guide. Most libraries are too complex for him to understand yet and learn anything from. Or they are just ugly to look at. That's what discourages me from looking at them.

They should be written in ASCII art.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
Or read the guide. Most libraries are too complex for him to understand yet and learn anything from. Or they are just ugly to look at. That's what discourages me from looking at them.

They should be written in ASCII art.

Im half way through reading the guide, and that code was fixed a while ago
In response to Master Scar
Still, you got alot of code from people. Probably half of it you don't know and also ripping ideas such as threaten with wand off of other harry potter games isn't just shady. It's wrong.
In response to Darkdemonrad
Darkdemonrad, how good your intentions might be, Detnom only gave him directions and he didn't say something along the lines of;
"That doesn't help me..."
No, he did what detnom said. Thus, I highly doubt he's a copy/paster. There are some good people in this world too, you know.
In response to Mysame
obj/sortinghat
verb/puton()
set category = ("Actions")
usr << pick (
"[usr] puts on the sorting hat.",
prob(25)
"[usr] becomes a Slytherin!"
icon = "slytheringirl.dmi"
icon_state = gender,
prob(25)
"[usr] becomes a Gryffindor!"
icon = "gryffindorgirl.dmi"
icon_state = gender,
prob(25)
"[usr] becomes a Hufflepuff!"
icon = "hufflepuffgirl.dmi"
icon_state = gender,
prob(25)
"[usr] becomes a Ravenclaw!"
icon = "ravenclawgirl.dmi"
icon_state = gender,
)


Whats wrong with it, im a losuy coder and im reading the DM guide so dont scream at me..... much please
In response to Master Scar
Master Scar wrote:
set category = ("Actions")

Since you didn't tell us what errors you're getting, it's tough to tell - but that line is almost certianly wrong. If it's not, it's some wierd syntax that I've just never seen before. Try it without the parens.