ID:1279208
 
Code:
mob/Cantina/npc     
Entertainer
icon = 'NPCS.dmi'
icon_state = "g_twilek"
verb
Interact()
set src in oview(10)
Entertain(src)
mob
var
entertaining = 0

proc
Entertain(mob/entertained)
set src in oview(10)
for(var/mob/Players/M in oview(10))
if(entertained.entertaining == 0)
view() << output("<font color = Yellow>NPC Entertainer:</font><font color =white >Hello everyone, im here today to entertain you all, for todays show, im gonna play an old song on my guitar, i hope you all like it, and remember, tips are always appreciated.","system")
view(6) << 'cantina1.mid'
A
if(entertained.hpwound <= 1)
entertained.entertaining = 1
// if(entertained.entertaining == 0)
if(entertained.hpwound >= 0)
entertained.entertaining = 1
entertained.hpwound -= 1
entertained.actionwound -= 1
entertained.mindwound -= 1
sleep(5)
// entertained.entertaining = 0
goto A
else
entertained << output("<font color = Yellow>NPC Entertainer:</font> You dont need to be entertained today!","system")
else
view() << output("<font color = Yellow>NPC Entertainer:</font> Are you not intertained?","system")
sleep(100)
entertained.entertaining = 0
return


Problem description:
What i want the NPC to do:
When you interact with the NPC, it should start playing music, and then give all players in the view entertaining, and then make their wounds go away.

Right now, when you interact with the NPC it starts playing the music, but the interacting player are not getting the entertaining status, and therefore are not healing wounds. It dont gives any errors or runtime errors or anything, it just dont do anything else the play the music and shows what the npc is saying.

Anyone got an idea how to fix this?

Thanks in advance.
You're passing src as the argument - src is the mob that the verb belongs to. Usr is the person who initiated the verb.

You'd probably want to pass usr as the argument.

However, you have a few other issues - why are you using goto?
And...is the stuff under the for loop supposed to be indented one extra tab...?
im using goto because i want it to be healing in small portions, and not a "full heal", i know if the verb is successfull it will continue forever, but i havent figured out how to make it stop yet.
What extra tab are you talking about?
You have this:
            for(var/mob/Players/M in oview(10))
if(entertained.entertaining == 0)

Is the if() and everything under it supposed to be indented under the for?


You could also just as easy use a while loop for your proc.

while(x > 0) //while x is greater than 0
x--
Well yea, i want it to effect everyone on the screen + the user, so i thought i could make it work with that.

so i would do

while(entertained.hpwound < 0)
entertained.entertaining = 1
entertained.hpwound -= 1
entertained.actionwound -= 1
entertained.mindwound -= 1
sleep(5)
x--
?
i have no idea how that while works.
It was just an example with the x stuff; but while() will do whatever is indented under it as long as the statement in the parenthesis is true. You can pretty much make it do whatever you want.
mob
var
entertaining = 0

proc
Entertain(mob/entertained)
set src in oview(10)
for(var/mob/Players/M in oview(10))
if(entertained.entertaining == 0)
view() << output("<font color = Yellow>NPC Entertainer:</font><font color =white >Hello everyone, im here today to entertain you all, for todays show, im gonna play an old song on my guitar, i hope you all like it, and remember, tips are always appreciated.","system")
view(6) << 'cantina1.mid'
//A
while(entertained.hpwound >= 1)
entertained.entertaining = 1
// if(entertained.entertaining == 0)
if(entertained.hpwound <= 0)
entertained.entertaining = 1
entertained.hpwound -= 1
entertained.actionwound -= 1
entertained.mindwound -= 1
sleep(5)
// entertained.entertaining = 0
entertained.hpwound --
// else
// entertained << output("<font color = Yellow>NPC Entertainer:</font> You dont need to be entertained today!","system")
// entertained.entertaining = 0
else
view() << output("<font color = Yellow>NPC Entertainer:</font> Are you not intertained?","system")
sleep(100)
entertained.entertaining = 0
return


Like this?
Indent everything under the for that is supposed to be under it,

and...maybe? It's your code, test it out.
Okay, i made the changes, and it compiles fine, but when i go ingame and test it, it crashes the server, do i need to but break or somthing in there? I checked the Reference in DM but i cant figure out if i have to put break, and if so, where?
You don't need a break; you just need to make sure the while loop can stop at one point.

Your while loop will continue to run as long as hpwound is greater than or equal to 1.

Your if-statement in the loop though says:
if hpwound is less than or equal to 0, then decrease hpwound.

Just think about the logic of what's happening in the loop.
Ha ! lol. That fixed it :P Thanks mate. But the hpwound is still not decreasing on the player. I removed the first if(entertained.entertaining == 1)
so the loop shouldent stop there anymore, but its not passing on the expressions under the while()
Did you fix your earlier issue, where you passed the wrong mob to the proc?
yea the Entertain(usr) one.. I fixed that.
My codes looks like this now
        Entertainer
icon = 'NPCS.dmi'
icon_state = "g_twilek"
verb
Interact()
set src in oview(10)
Entertain(usr)
view() << output("<font color = Yellow>NPC Entertainer:</font><font color =white >Hello everyone, im here today to entertain you all, for todays show, im gonna play an old song on my guitar, i hope you all like it, and remember, tips are always appreciated.","system")
view(6) << 'cantina1.mid'


mob
var
entertaining = 0

proc
Entertain(mob/entertained)
set src in oview(10)
if(entertained.entertaining == 0)
//A
while(entertained.hpwound <= 1)
for(var/mob/Players/M in oview(10))
// if(entertained.entertaining == 0)
if(entertained.hpwound <= 1)
entertained.entertaining = 1
entertained.hpwound -= 1
entertained.actionwound -= 1
entertained.mindwound -= 1
// entertained.entertaining = 0
sleep(50)
entertained.hpwound --
// else
// entertained << output("<font color = Yellow>NPC Entertainer:</font> You dont need to be entertained today!","system")
// entertained.entertaining = 0
else
view() << output("<font color = Yellow>NPC Entertainer:</font> Are you not entertained?","system")
sleep(100)
entertained.entertaining = 0
return


When i click interact on the mob, it starts playing the music, it does the view() output
but its not passing on the entertaining var.
You don't need that other if statement inside, since it's already checked in the while loop.


I still don't see what you're trying to do with the for loop?
Are you trying to make it so the 'entertained healing' portion is ran for everybody in the view?
Yeah, i want to make one player able to start the entertaining, while it will effect all in the screen. Because imagine if your at a bar, and someone told the dude on the stage to play, if he started playing everyone else can hear the music, not just the one asking him to play. Thats what i want to do. But i dont know if its the right way its done or not.
I'd think you want something like this:
    proc
Entertain(mob/entertained)
set src in oview(10)
if(!entertained.entertaining)
for(var/mob/Players/M in view(10))
spawn(1) while(M.hpwound > 0)
M.entertaining = 1
M.hpwound--
M.actionwound--
M.mindwound--
sleep(50) //This is a 5 second wait time, you're subtracting hpwound twice here?
M.hpwound--
M.entertaining = 0

else
view() << output("<font color = Yellow>NPC Entertainer:</font> Are you not entertained?","system")
sleep(100)
entertained.entertaining = 0
How does the game know how much hp wound i want to subtract? because i want it to be random between 1 and 3.
M.hpwound -= rand(1,3)


both hpwound -- and hpwound -= 1 subtract 1.
You have it twice - it subtracts 2 every time (though it subtracts the second time 5 seconds after the first time...?)
Yeah i changed it to

mob
var
entertaining = 0

proc
Entertain(mob/entertained)
set src in oview(10)
if(!entertained.entertaining)
for(var/mob/Players/M in view(10))
spawn(1) while(M.hpwound > 0)
M.entertaining = 1
M.hpwound--
sleep(10)
spawn(1) while(M.actionwound > 0)
M.entertaining = 1
M.actionwound--
sleep(10)
spawn(1) while(M.mindwound > 0)
M.entertaining = 1
M.mindwound--
sleep(10)
M.entertaining = 0

else
view() << output("<font color = Yellow>NPC Entertainer:</font> Are you not entertained?","system")
sleep(100)
entertained.entertaining = 0


Inorder for it not to subtract twice. Now it works like i wanted it to. Thanks alot mate!