ID:150419
 
There is no errors in the code I have made the battle area and the void stuff. But when i run it i cant get into a battle. So if you could tell me why it does this i would be very thankfull.



~Richter
more details needed
OK when i put in zagreus's random combat code i fixed it to have no errors. Then i dont know where to put the battle are ar the void or the invisible wall for me to go into a battle and here is the code
mob

//Check battlearea of usr and run randomencounter proc for that area when move
Move()
switch(onbattlefield)
if ("battlearea1")
randomencounter1(src)
return ..()
else
return ..()


//Battlearea as a variable so it can be assigned to the player
mob/var/turf/battlearea



mob/proc

//25% chance of searching for unoccupied area and beginning combat.
randomencounter1(mob/M as mob)
var/turf/battlearea/T
if (prob(25))
for(T in world)
if(!T.occupied)
T.occupied = 1
M.oldlocx = M.x
M.oldlocy = M.y
M.oldlocz = M.z
M.battlearea = T
spawn(1)M.Move(usr.battlearea)
M.oldbattlefield = M.onbattlefield
M.onbattlefield = null
M << "Fight!"
M << "Click on the monster you wish to attack to start"
spawn(1)new /mob/Monster3(locate(M.battlearea.x,M.battlearea.y+4,M.battle area.z))
return 1
return 0





//Maincombat proc called on Click() for the monster. Gives options and stuff.
maincombat(mob/attacker as mob, mob/target as mob)
var/list/CombatOps1 = list("Attack", "Run", "Magic")
var/CombatOp1 = input(usr, "What do you wish to do?", "Combat", "Attack") in CombatOps1
switch (CombatOp1)
if ("Attack")
attack(attacker, target)
if ("Run")
flee(attacker, target)
if ("Magic")
magic(attacker, target)




//attacker chose attack on main menu, see if hit or miss, if hit go to damage proc
attack(mob/attacker as mob, mob/target as mob)
attacker << "You chose to attack [src]"
if(prob(attacker.hit - target.evade))
normaldamage(attacker, target)
else
attacker << "You miss!"
npcattack1(attacker, target)



//usr choses flee on main combat menu, return to oldloc and clear battle vars if success
flee(mob/attacker as mob, mob/target as mob)
if (rand(1,3) == 1)
attacker << "You successfuly run from [target]"
endbattle(attacker)
del(target)
else
attacker << "You failed to run and loose a turn!"
npcattack1(attacker, target)


//You didn't think you'd get a fully working magic system in my demo, did you?
magic()
usr << "Not implemented yet."




//Deal damage
normaldamage(mob/attacker as mob, mob/target as mob)
var/maxdamage = attacker.attack - target.defense - (target.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
attacker << "You miss! (0 dmg)"
npcattack1(attacker, target)
else
attacker << "You hit [src] for [damage] points of damage with a normal attack!"
target.HP -= damage
npcdeathcheck(attacker, target)



//Time for the monster to attack If miss go back to maincombat.
npcattack1(mob/defender as mob, mob/monster as mob)
if (prob (monster.hit))
defender << "The [monster] attacks you and hits!"
var/maxdamage = monster.attack - (defender.defense / 4) - (defender.agility / 20)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
defender << "The attack bounces harmlessly off you."
maincombat(defender, monster)
else
defender << "Hit for [damage] damage!"
defender.HP -= damage
playerdeathcheck(defender, monster)
else
defender << "The [monster] attacks you and misses!"
maincombat(defender, monster)


//Return the user to their original loc and clear battle variables.
endbattle(mob/M as mob)
var/turf/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
mob/proc
//P for player, M for mob. :) Check to see if death and reward stuff.
npcdeathcheck(mob/P as mob, mob/M as mob)
if (M.HP <= 0)
P << "You have killed the [M]!"
P.exp += M.expreward
alert(P, "You gain [M.expreward] exp and [M.wealthreward] money,", "Victory!")
P.wealth += M.wealthreward
endbattle(P)
del (M)
//NPC is still alive, so attack.
else
npcattack1(P, M)

//reverse of the above, 1/2 exp loss penalty.
playerdeathcheck(mob/P as mob, mob/M as mob)
if (P.HP <=0)
alert (P, "You have been killed by the [M]!")
P.exp -= (P.exp / 2)
P.loc = locate(20, 43, 1) //Change this to where you want dead people to respawn
var/turf/battlearea/T = P.battlearea
T.occupied = 0
P.battlearea = null
P.onbattlefield = null
P.oldbattlefield = null
P.HP = 1
del (M)
//Player is still alive, so go back to main combat menu
else
maincombat(P, M)



//Just a very basic level system to make the combat actualy do something.
mob
proc
checklevel(mob/M as mob)
if (M.exp >= M.expreq)
levelup(M)


levelup(mob/M as mob)
M << "You gain a level! You are now level [M.level + 1]!"
usr<<sound('level up.wav')
if (usr.hit <= 100)
usr.hit += rand(5,10)
M.attack += rand(1, 5)
M.defense += rand(1,3)
M.agility += rand(1, 3)
M.evade += rand(1, 3)
M.MAXHP += 10 + rand (5,10)
M.level += 1
M.exp = 0
usr.expreq += 150
usr.HP = usr.MAXHP

mob/var
agility
attack
defense
evade
exp
expreq
expreward
hit
HP
MAXHP
level
oldbattlefield
oldlocx
oldlocy
oldlocz
onbattlefield
wealth
wealthreward


mob
icon = 'player.dmi'

HP = 50
MAXHP = 50
level = 1
exp = 0
expreq = 150
hit = 75
evade = 50
agility = 25
defense = 15
attack = 15
wealth = 100
oldbattlefield
onbattlefield




Monster3
icon = 'Monster.dmi'
expreward = 15
wealthreward = 5
attack = 7
defense = 8
agility = 5
hit = 65
evade = 2
HP = 10
//This is where the main combat is called from
Click()
maincombat(usr, src)


//Really basic stat panel
mob
Stat()
statpanel("Stats")
stat("Hit Points: [HP]/[MAXHP]")
stat("Attack: [attack]")
stat("Defense: [defense]")
stat("Hit %: [hit]")
stat("Evade %: [evade]")
stat("Agility: [agility]")
stat("Level: [level]")
stat("Experience: [exp]/[expreq]")
stat("Gold: [wealth]")
statpanel("Inventory",usr.contents)
return ..()

area
battlearea1
Enter()
spawn()usr.onbattlefield = "battlearea1"
return 1
Exit()
usr.onbattlefield = null
return 1

//Fill the battle areas with invisible wall to prevent player from moving.
//DO NOT put on the actual battlearea (blue) turf though.
invisiblewall
density = 1


turf
grass
icon = 'grass.dmi'
void
icon = 'void.dmi'
battlearea
icon = 'Battlearea.dmi'
var/occupied

I dont know how to make it go into a battle feild by just walking around
Do i have to put the battle field through out the whole world or do i do something else so please help men



In response to Richter
Richter wrote:
OK when i put in zagreus's random combat code i fixed it to have no errors. Then i dont know where to put the battle are ar the void or the invisible wall for me to go into a battle and here is the code
mob

//Check battlearea of usr and run randomencounter proc for that area when move
Move()
switch(onbattlefield)
if ("battlearea1")
randomencounter1(src)
return ..()
else
return ..()


//Battlearea as a variable so it can be assigned to the player
mob/var/turf/battlearea



mob/proc

//25% chance of searching for unoccupied area and beginning combat.
randomencounter1(mob/M as mob)
var/turf/battlearea/T
if (prob(25))
for(T in world)
if(!T.occupied)
T.occupied = 1
M.oldlocx = M.x
M.oldlocy = M.y
M.oldlocz = M.z
M.battlearea = T
spawn(1)M.Move(usr.battlearea)
M.oldbattlefield = M.onbattlefield
M.onbattlefield = null
M << "Fight!"
M << "Click on the monster you wish to attack to start"
spawn(1)new /mob/Monster3(locate(M.battlearea.x,M.battlearea.y+4,M.battle area.z))
return 1
return 0





//Maincombat proc called on Click() for the monster. Gives options and stuff.
maincombat(mob/attacker as mob, mob/target as mob)
var/list/CombatOps1 = list("Attack", "Run", "Magic")
var/CombatOp1 = input(usr, "What do you wish to do?", "Combat", "Attack") in CombatOps1
switch (CombatOp1)
if ("Attack")
attack(attacker, target)
if ("Run")
flee(attacker, target)
if ("Magic")
magic(attacker, target)




//attacker chose attack on main menu, see if hit or miss, if hit go to damage proc
attack(mob/attacker as mob, mob/target as mob)
attacker << "You chose to attack [src]"
if(prob(attacker.hit - target.evade))
normaldamage(attacker, target)
else
attacker << "You miss!"
npcattack1(attacker, target)



//usr choses flee on main combat menu, return to oldloc and clear battle vars if success
flee(mob/attacker as mob, mob/target as mob)
if (rand(1,3) == 1)
attacker << "You successfuly run from [target]"
endbattle(attacker)
del(target)
else
attacker << "You failed to run and loose a turn!"
npcattack1(attacker, target)


//You didn't think you'd get a fully working magic system in my demo, did you?
magic()
usr << "Not implemented yet."




//Deal damage
normaldamage(mob/attacker as mob, mob/target as mob)
var/maxdamage = attacker.attack - target.defense - (target.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
attacker << "You miss! (0 dmg)"
npcattack1(attacker, target)
else
attacker << "You hit [src] for [damage] points of damage with a normal attack!"
target.HP -= damage
npcdeathcheck(attacker, target)



//Time for the monster to attack If miss go back to maincombat.
npcattack1(mob/defender as mob, mob/monster as mob)
if (prob (monster.hit))
defender << "The [monster] attacks you and hits!"
var/maxdamage = monster.attack - (defender.defense / 4) - (defender.agility / 20)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
defender << "The attack bounces harmlessly off you."
maincombat(defender, monster)
else
defender << "Hit for [damage] damage!"
defender.HP -= damage
playerdeathcheck(defender, monster)
else
defender << "The [monster] attacks you and misses!"
maincombat(defender, monster)


//Return the user to their original loc and clear battle variables.
endbattle(mob/M as mob)
var/turf/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
mob/proc
//P for player, M for mob. :) Check to see if death and reward stuff.
npcdeathcheck(mob/P as mob, mob/M as mob)
if (M.HP <= 0)
P << "You have killed the [M]!"
P.exp += M.expreward
alert(P, "You gain [M.expreward] exp and [M.wealthreward] money,", "Victory!")
P.wealth += M.wealthreward
endbattle(P)
del (M)
//NPC is still alive, so attack.
else
npcattack1(P, M)

//reverse of the above, 1/2 exp loss penalty.
playerdeathcheck(mob/P as mob, mob/M as mob)
if (P.HP <=0)
alert (P, "You have been killed by the [M]!")
P.exp -= (P.exp / 2)
P.loc = locate(20, 43, 1) //Change this to where you want dead people to respawn
var/turf/battlearea/T = P.battlearea
T.occupied = 0
P.battlearea = null
P.onbattlefield = null
P.oldbattlefield = null
P.HP = 1
del (M)
//Player is still alive, so go back to main combat menu
else
maincombat(P, M)



//Just a very basic level system to make the combat actualy do something.
mob
proc
checklevel(mob/M as mob)
if (M.exp >= M.expreq)
levelup(M)


levelup(mob/M as mob)
M << "You gain a level! You are now level [M.level + 1]!"
usr<<sound('level up.wav')
if (usr.hit <= 100)
usr.hit += rand(5,10)
M.attack += rand(1, 5)
M.defense += rand(1,3)
M.agility += rand(1, 3)
M.evade += rand(1, 3)
M.MAXHP += 10 + rand (5,10)
M.level += 1
M.exp = 0
usr.expreq += 150
usr.HP = usr.MAXHP

mob/var
agility
attack
defense
evade
exp
expreq
expreward
hit
HP
MAXHP
level
oldbattlefield
oldlocx
oldlocy
oldlocz
onbattlefield
wealth
wealthreward


mob
icon = 'player.dmi'

HP = 50
MAXHP = 50
level = 1
exp = 0
expreq = 150
hit = 75
evade = 50
agility = 25
defense = 15
attack = 15
wealth = 100
oldbattlefield
onbattlefield




Monster3
icon = 'Monster.dmi'
expreward = 15
wealthreward = 5
attack = 7
defense = 8
agility = 5
hit = 65
evade = 2
HP = 10
//This is where the main combat is called from
Click()
maincombat(usr, src)


//Really basic stat panel
mob
Stat()
statpanel("Stats")
stat("Hit Points: [HP]/[MAXHP]")
stat("Attack: [attack]")
stat("Defense: [defense]")
stat("Hit %: [hit]")
stat("Evade %: [evade]")
stat("Agility: [agility]")
stat("Level: [level]")
stat("Experience: [exp]/[expreq]")
stat("Gold: [wealth]")
statpanel("Inventory",usr.contents)
return ..()

area
battlearea1
Enter()
spawn()usr.onbattlefield = "battlearea1"
return 1
Exit()
usr.onbattlefield = null
return 1

//Fill the battle areas with invisible wall to prevent player from moving.
//DO NOT put on the actual battlearea (blue) turf though.
invisiblewall
density = 1


turf
grass
icon = 'grass.dmi'
void
icon = 'void.dmi'
battlearea
icon = 'Battlearea.dmi'
var/occupied

I dont know how to make it go into a battle feild by just walking around
Do i have to put the battle field through out the whole world or do i do something else so please help men




Did you make the battlefield world? Does the screen go black or does it do nothing?
In response to Valderalgx
Dear God, man! You didn't need to quote that entire thing for a one-line comment!
In response to Valderalgx
It doesnt do anything when i walk around (it doesnt take me to the battle feild.)