ID:179570
 
1.
I am using a random combat system in my game.
I want to know how to change the music once you enter a battle, and once it's over, put's back the original.


2.
Is there a way to make the character face a certain direction. Someone told me to use
src.dir = EAST, but the whole map turned 90 degrees, which is not what I wanted.


3.
Since I started my project, I was using this weird Login()
code. I just need to know if there's anything I should change on it.

world
mob = /mob/create_character

mob
Login()
usr.Move(locate(/area/start1))
..()

create_character
var/mob/character
Login()
usr << sound('start.mid',1)
world << "[src.name] logs in!"
... //character selection here
character.name = charactername
src.client.mob = character
del(src)


It's works, but I have 2 Login(), and I'm not sure that's good.


4.
I'm still trying to make a code that allows an object to call a verb.

obj/stone
icon = 'stone.dmi'
Click()
usr.Charm()

mob/proc/Charm(mob/M as mob in view(5))
set hidden = 1
if(usr.mp>=5)
M.hp=min(M.hp+100,M.maxhp)
usr.mp-=5
else
usr<<"You don't have enough MP !"

Now, when someone gives me that "stone", I use the following codes:
usr.contents += new/obj/stone
usr.verbs+=new/mob/proc/Charm

Since the verb is hidden, no one can cast the spell, but
by clicking on the stone it should call it.
Unfortunately, it doesn't.
The spell works though when I remove the "hidden" and
call it from the verb panel.


THX in advance.
That's a lot of questions in one post. You should really post a separate thread (with a descriptive topic line) so that each one can be handled separately and given full attention by people who understand individual problems you face.

Cravens wrote:
1.
I am using a random combat system in my game.
I want to know how to change the music once you enter a battle, and once it's over, put's back the original.

It depends on how you trigger music in your game. If you trigger it in an area's Entered() proc, it should take care of this for you automatically if you make the battlefield in a special area. You move to the battlefield, the battle music plays. You move back and the other area's music plays.


2.
Is there a way to make the character face a certain direction. Someone told me to use
src.dir = EAST, but the whole map turned 90 degrees, which is not what I wanted.

You changed the client dir var. That will shift the display as you described. If you set the dir of an atom (Area, Turf, Obj, or Mob), that atom will turn in the direction specified.

Since the place you used src.dir is in a client proc, using mob.dir should work to turn the mob in the desired direction.


3.
Since I started my project, I was using this weird Login()
code. I just need to know if there's anything I should change on it.

It's works, but I have 2 Login(), and I'm not sure that's good.

There's nothing wrong with having the separate Login() codes. In this instance, your game wouldn't work right if you did have them both in one Login() code. The top level Login moves any mob that a client logs into to the start1 area. The other Login() proc adds extra steps that happen when a client logs into character creation mob.


4.
I'm still trying to make a code that allows an object to call a verb.

obj/stone
icon = 'stone.dmi'
Click()
usr.Charm()

Since the verb is hidden, no one can cast the spell, but
by clicking on the stone it should call it.
Unfortunately, it doesn't.
The spell works though when I remove the "hidden" and
call it from the verb panel.

When you click the stone, it doesn't know which mob you want to Charm. It calls usr.Charm(null) and seems to do nothing because Charm wasn't made to accept null input.

You can add an input in the Click() proc to find out which mob they wish to charm, then call the Charm() proc.

You should also make sure that the stone is in the usr's inventory, or people will be able to use the charm stone from anywhere on the map that they can see it. (or even further away through some devious trickery I don't care to disclose. :P)

You don't have to add the Charm() proc as a verb for Click() to be able to call it. Adding it as a hidden verb means that the player can't see it, but could type it into the command line manually to execute it.
In response to Shadowdarke
1.
I am using a random combat system in my game.
I want to know how to change the music once you enter a battle, and once it's over, put's back the original.

It depends on how you trigger music in your game. If you trigger it in an area's Entered() proc, it should take care of this for you automatically if you make the battlefield in a special area. You move to the battlefield, the battle music plays. You move back and the other area's music plays.

That's the first thing I tried, but the music is having trouble changing.
Here's my code:

area
battlearea
Entered(mob/M)
if(M.client)
if(usr.music == "battle.mid")
return
else
usr << sound('battle.mid',1)
usr.music = "battle.mid"

Now here's the code once you enter a battle:

mob/proc
randomencounter1(mob/M)
var/area/battlearea/T
for(T in world)
if(!T.occupied)
T.occupied = 1
usr.oldlocx = usr.x
usr.oldlocy = usr.y
usr.oldlocz = usr.z
usr.battlearea = T
spawn(1)M.loc=(M.battlearea)
M.oldbattlefield = M.onbattlefield
M.onbattlefield = null
src.movelock = TRUE
M << "Fight!"
spawn(1)new /mob/monsters/Yo(locate(M.battlearea.x-4,M.battlearea.y,M.battlearea.z))
return 1
else
..()



It's probably having trouble with the Entered(), i'm not sure.



4.
I'm still trying to make a code that allows an object to call a verb.

obj/stone
icon = 'stone.dmi'
Click()
usr.Charm()

Since the verb is hidden, no one can cast the spell, but
by clicking on the stone it should call it.
Unfortunately, it doesn't.
The spell works though when I remove the "hidden" and
call it from the verb panel.

When you click the stone, it doesn't know which mob you want to Charm. It calls usr.Charm(null) and seems to do nothing because Charm wasn't made to accept null input.

You can add an input in the Click() proc to find out which mob they wish to charm, then call the Charm() proc.

hmm.. I'm not sure what to put inside the input.
This is all I have:

obj/stone
icon = 'stone.dmi'
Click()
input("Who do you want to heal ?","Charm") in list ("???")
if("???")
usr.Charm()


I want it to heal a mob around view(5) of the usr.

Any ideas ?

THX for the other 2 Q.
In response to Cravens
Cravens wrote:
1.
That's the first thing I tried, but the music is having trouble changing.

It's probably having trouble with the Entered(), i'm not sure.

Entered() is only called if you use Move() to change the loc. Since you are setting the loc directly, it doesn't automatically call Entered(). Just call it after the loc is changed:

spawn(1)
M.loc=(M.battlearea)
M.battlearea.Entered(M)


4.
hmm.. I'm not sure what to put inside the input.

I want it to heal a mob around view(5) of the usr.

obj/stone
icon = 'stone.dmi'
Click()
if(!(src in usr.contents)) return // make sure the clicker owns the stone
var/list/moblist = list()
var/mob/M

// filter out all the mobs in view(5)
for(M in view(5))
moblist += M

M = input("Who do you want to heal ?","Charm") as null|mob in moblist
if(M)
usr.Charm(M)</DM>



The "as null|mob" part allows them to cancel the selection by hitting esc. You may be able to skip the filtering part and just use "as null|mob in view(5)" so that it filters the mobs for you automatically, but I'm not positive it will work properly like that. Filtering it yourself shouldn't hurt performance and it's a good learning experience ;)


THX for the other 2 Q.

You're welcome. :)
In response to Shadowdarke
1.
That's the first thing I tried, but the music is having trouble changing.

It's probably having trouble with the Entered(), i'm not sure.

Entered() is only called if you use Move() to change the loc. Since you are setting the loc directly, it doesn't automatically call Entered(). Just call it after the loc is changed:

spawn(1)
M.loc=(M.battlearea)
M.battlearea.Entered(M)

Ok, 1 last question. I thought this would work when you exit battles too, but it doesn't.

mob/proc
endbattle(mob/M as mob)
var/area/battlearea/T = M.battlearea
T.occupied = 0
M.battlearea = null
M.loc = locate(M.oldlocx,M.oldlocy,M.oldlocz)
M.onbattlefield = M.oldbattlefield
M.oldbattlefield = null
M.oldlocx = null
M.oldlocy = null
M.oldlocz = null
checklevel(M)

As you can see, the loc isn't a simple area, although it brings you back in one major area called "areamonster1".
This "areamonster1" has the same Entered() like the one
before, but for a different tune.

Any ideas ?

THX.
In response to Cravens
Cravens wrote:
M.loc = locate(M.oldlocx,M.oldlocy,M.oldlocz)

As you can see, the loc isn't a simple area, although it brings you back in one major area called "areamonster1".
This "areamonster1" has the same Entered() like the one
before, but for a different tune.

locate() used this way returns a turf. The turf's loc is it's area, so after the line above, you should use this code to find the turf's area and call the area's Entered() proc.

var/area/A = M.loc.loc
A.Entered(M)