I am useing a Zagreus random battle system when i added it to my code but a battle never starts i also named the player
mob
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
usr.oldlocx = M.x
usr.oldlocy = M.y
usr.oldlocz = M.z
usr.battlearea = T
spawn(1)M.Move(usr.battlearea)
usr.oldbattlefield = M.onbattlefield
usr.onbattlefield = null
usr << "Fight!"
usr << "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
checklevel(M)
ID:179614
Nov 27 2001, 12:46 pm
|
|
Nov 27 2001, 2:09 pm
|
|
did you make the map correctly? i may need a little more detail to help you alot.
|
In response to Nebathemonk
|
|
i will post the other code i am using what happens is you walk around the map and nothing happens i am useing a class system a such
1st file 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 = 'bluebrick.dmi' battlearea icon = 'BrickWall.dmi' var/occupied 2nd file mob Monster3 icon = 'druid.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) 3rd file mob/var agility // attack // defense evade // exp expreq expreward hit HP MAXHP level oldbattlefield oldlocx oldlocy oldlocz onbattlefield wealth wealthreward mob/player icon = 'gladtor.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 |