ID:142438
 
Problem description:
I have recently made a game called naruto recreated and i am currently adding clans etc i have come across a major problem that i cannot fix i have tried almost everything. I was wondering if anyone could help me out

Code1:
mob/Hidan
verb
bloodbind(mob/M in get_step(usr,usr.dir))
set category = "Jutsus"
set name = "blood bind"
usr.Handseals()
if(usr.firing) // If the mob's firing var is one...
usr << "You must wait before using this."
return
if(usr.AFK)
usr<<"You can't use this jutsu while being AFK."
usr<<"Preventing <B><font color= red>AFKing</B><font color=white>...</FONT>"
return
if(!usr.handseals)
return
if(usr.chakra<=2000)
usr<<"You do not have enough chakra to perform this"
return
if(usr==M)
return
else
usr.targeter = ""
view()<<"<B>[usr] <font color = green>Says: Hidan blood bind!"
view()<<"[usr] takes [M]'s blood."
M.move = 0
usr.move = 0
usr<<"You collected blood from [M]."
usr<<"You have 60 seconds before the blood becomes a waste"
M<<"[usr] collected blood from you."
usr.targeter = M
sleep(600)
if(usr.targeter==M)
usr.targeter = ""
usr<<"The blood is nolonger useful"
M<<"You are no longer in bloodbind"
return


Problem description:
The code above works fine well i think anyway i made the Hidan clan have a selfharm jutsu that like in the anime harms people binded to them

Code2:
mob/Hidan
verb
selfharm()
set category = "Jutsus"
set name = "selfharm"
usr.Handseals()
if(usr.firing) // If the mob's firing var is one...
usr << "You must wait before using this."
return
if(usr.AFK)
usr<<"You can't use this jutsu while being AFK."
usr<<"Preventing <B><font color= red>AFKing</B><font color=white>...</FONT>"
return
if(usr.health <= 2000)
usr<<"You dont have enough health!"
return
if(!usr.handseals)
return
else
for(var/mob/M in world)
if(usr.targeter==M)
usr.health -= 1000
var/damage = rand(1000,10000)
M.health -= damage
M.Death(usr)
usr<<"You gave [damage] damage to [M]."
M<<"You took [damage] froms [usr]'s bloodbind"
return
else
usr<<"You have not taken the blood of any one."
return


Problem description:
Everytime i use self harm it says "You have not taken the blood of anyone"
Is there a way to fix these two codes.

What i want is a system where a player(player1) signs a blood contract with another(player2) and once he does that player1 can then harm himself while harming the other. I have seen this in a few games the best being naruto GOA so i know it is possible


Thanks Rapmaster

Your problem is that you're using a for() loop. You already know which mob you're going to attack: usr.targeter. So, remove the for() loop and replace every instance of M with usr.targeter. Also, change the if() statement to if(usr.targeter), because if it's null then you have no target.
Well I have created naruto games and I must tell you that using that type of coding style for your game is not good.
Anyways At the part in the jutsu where you have the if statement you need to switch that around.

Example
1. make a varable called hidianblood=0 in vars.
2. Next go to blood blind and below the part where it says you have collected his blood put M.hidianblood=1.
3. Then go to self harm and in the statement "if usr.targeter==M" replace "usr.targeter==M" with M.hidianblood=1.
That should make it read the enemy to see if you have his blood. When you do it will let you do it. If not it will say you do not have his blood. If you need any more help email me at [email protected]
In response to Garthor
I tried your method Valoesdette but it didnt work.

I then tried your method Garthar but it gives me two errors.This is what the code looks like at the moment

mob/Hidan
verb
selfharm()
set category = "Jutsus"
set name = "selfharm"
usr.Handseals()
if(usr.firing) // If the mob's firing var is one...
usr << "You must wait before using this."
return
if(usr.AFK)
usr<<"You can't use this jutsu while being AFK."
usr<<"Preventing <B><font color= red>AFKing</B><font color=white>...</FONT>"
return
if(usr.health <= 2000)
usr<<"You dont have enough health!"
return
if(!usr.handseals)
return
else
if(usr.targeter)
usr.health -= 1000
var/damage = rand(1000,10000)
usr.targeter.health -= damage
usr.targeter.Death(usr.targeter)
usr<<"You gave [damage] damage to [usr.targeter]."
usr.targeter<<"You took [damage] froms [usr]'s bloodbind"
return
else
usr<<"You have not taken the blood of any one."
return


<dm/>
mob/Hidan
verb
selfharm()
set category = "Jutsus"
set name = "selfharm"
usr.Handseals()
if(usr.firing) // If the mob's firing var is one...
usr << "You must wait before using this."
return
if(usr.AFK)
usr<<"You can't use this jutsu while being AFK."
usr<<"Preventing <B><font color= red>AFKing</B><font color=white>...</FONT>"
return
if(usr.health <= 2000)
usr<<"You dont have enough health!"
return
if(!usr.handseals)
return
else
var/mob/M=usr.targeter
if(M)
usr.health -= 1000
var/damage = rand(1000,10000)
M.health -= damage
M.Death(usr)
usr<<"You gave [damage] damage to [M]."
M<<"You took [damage] froms [usr]'s bloodbind"
return
else
usr<<"You have not taken the blood of any one."
return



I dont understand your handseals variable. If your code doesnt work see if it works by removing the if(!usr.handseals) code.
In response to Masterdan
the handseals variable checks whether the user is still doin handseals.

By the way thanks alot for your help

Rapmaster
In response to Rapmaster
You errors are likely because you didn't define the targeter variable as a mob.

Also, your Death() proc is being called with the wrong argument. It should be usr.targeter.Death(usr).
In response to Garthor
umm I used masterdan's code and it worked but i still appreciate the time you took to help me. Thanks a lot for your help anyway
In response to Rapmaster
What he posted is a workaround that isn't needed if you simply declare the variable's type correctly.
In response to Garthor
umm i made the variable a tmp if thats what the problem was ??

mob/var
tmp/targeter = ""
In response to Rapmaster
First: targeter isn't a string, so don't initialize it to "", that's just silly.
Second: You need to declare it as a mob: var/tmp/mob/targeter. Because it's a mob, you see.
Third: Yes, declaring it tmp was correct.
In response to Garthor
erm i think its too late to change it since i used masterdans code. Or is it??
In response to Rapmaster
No, it isn't. Also, never say never.