ID:138834
 
I'm trying to make it so that when you walk into the arena through the stairs, an enemy appears but you cannot exit the same way until the enemy is dead, but when I test the game, every time a player kills the enemy the variable win stays at 0 instead of becoming 1

Player Code
//assigns mobs as human players
world/mob=/mob/player/human

mob/player/human
Login()
alert("By Christian White")
sleep(5)
loc=locate(18,5,2)
world<<"If it's your first time press the \"Instructions\" button above"
icon = 'BaseT.dmi'
verb
info()
set category = "Project"
set name = "Info"
verb
instruct()
set category = "Project"
set name = "Instruction"
usr<< "<H3><B>INSTRUCTIONS</B></H3><P>Welcome to the Collesseum</P><BR>Use the arrow keys to move. When you are ready, walk into the arena to start the fight. Once you enter you cannot leave until you have defeated the enemy. If you win you may return back to the barracks to rest. Enter the arena once more to start the next match. "
//Player Stat Variables
var
hp = 50
vit = 10
stam = 20
str = 2
win = 0


Death Check 4 enemy
mob/enemy/proc
Death_E(mob/player/human/L)
if(hp<=0)
world<<"You have Defeated your advarsary!"
del(src)
L.Win()

mob/player/human
proc
Win(mob/player/human/L)
L.win = 1

Stairs
stairs2
icon = 'stairs.dmi'
Exited()
new/mob/enemy/guy1(src)
Enter(mob)
var/mob/player/human/H
if(H.win==1)
icon = 'floors.dmi'
icon_state = "stoneground"
H.loc=locate(2,5,2)
else
world<<"You must kill the enemy to earn your freedom!


Punch verb
mob/player/human
verb
punch()
set name = "Punch"
for(var/mob/enemy/M in get_step(src,dir))
var/D = str *1
M.hp = M.hp - D
world<<"Your opponant takes [D] points of damage!"
M.Death_E()


This is the error I get when I try to go back down the stairs


proc name: Enter (/turf/floors/stairs2/Enter)
usr: Guest-3723684239 (/mob/player/human)
src: the stairs2 (21,16,1) (/turf/floors/stairs2)
call stack:
the stairs2 (21,16,1) (/turf/floors/stairs2): Enter(Guest-3723684239 (/mob/player/human), the stonef (20,16,1) (/turf/floors/stonef))
runtime error: undefined proc or verb /mob/player/human/Death E().
In response to Raruno (#1)
I had some ineccesary code in their because when I did it the normal way it didn't work, so I switched it back so that at the end of death check it just looks like win=1 and in stairs 2 it has if(H.win) now when I run it and try to exit the arena after entering it still wont give the player win =1 when he kills the enemy and now this appears when you try to leave the arena

runtime error: Cannot read null.win
proc name: Enter (/turf/floors/stairs2/Enter)
usr: Guest-3723684239 (/mob/player/human)
src: the stairs2 (21,16,1) (/turf/floors/stairs2)
call stack:
the stairs2 (21,16,1) (/turf/floors/stairs2): Enter(Guest-3723684239 (/mob/player/human), the stonef (20,16,1) (/turf/floors/stonef))
L.Win()

mob/player/human/proc/Win(mob/player/human/L)

Something tells me you don't understand how arguments work.

Try removing the argument and changing L.win=1 to src.win=1.

You're also deleting src(the dead enemy) before calling L.Win(), which means the proc is cut off before calling it. Move del src to the end.
Two things here,

mob/player/human
proc
Win()
src.win = 1


This should be amended, you were trying to pass an argument for the proc when it was never needed.


But here's the real source of your problem:

mob/enemy/proc
Death_E(mob/player/human/L)
if(hp<=0)
world<<"You have Defeated your advarsary!"
L.Win()
del(src)


When you del() something, all the procs and verbs currently being called by it are instantly killed, resulting in the L.Win() never actually getting called.





(Edit)
Your runtime seems like it's to do with something else, however.