ID:179105
 
this code is right i think but it always come up with Combat.dm:92:error::missing expression
Combat.dm:96:error::missing expression


Magic(mob/attacker as mob, mob/target as mob)
usr << "Which spell do you want to use?"
var/list/Magic = list("Thunder", "Ice Blast")
var/CombatOp2 = input(usr, "What do you wish to do?", "Thunder", "Ice Blast") in Magic
switch (CombatOp2)
if ("Thunder")
usr << "A giant lighting blot apears in your hand and then it zaps the enemy with a giant force!"
target.hp -= 4
npcdeathcheck(attacker, target)
if ("Ice Blast")
if (usr.iceblastmemorized = 1\\here is where the error occurs
usr << "A frosty ice blast shots at the enemy and freezes him!"
target.hp -= 5
npcdeathcheck(attacker, target)
else(usr.thundermemorized = 0)
usr << "You havent Memorized that spell!"
Mrhat99au wrote:
this code is right i think but it always come up with Combat.dm:92:error::missing expression
Combat.dm:96:error::missing expression


Magic(mob/attacker as mob, mob/target as mob)
usr << "Which spell do you want to use?"
var/list/Magic = list("Thunder", "Ice Blast")
var/CombatOp2 = input(usr, "What do you wish to do?", "Thunder", "Ice Blast") in Magic
switch (CombatOp2)
if ("Thunder")
usr << "A giant lighting blot apears in your hand and then it zaps the enemy with a giant force!"
target.hp -= 4
npcdeathcheck(attacker, target)
if ("Ice Blast")
if (usr.iceblastmemorized = 1\\here is where the error occurs
usr << "A frosty ice blast shots at the enemy and freezes him!"
target.hp -= 5
npcdeathcheck(attacker, target)
else(usr.thundermemorized = 0)
usr << "You havent Memorized that spell!"

if (usr.iceblastmemorized = 1\\here is where the error occurs

should be
if (usr.iceblastmemorized ==1) //You need 2 = sign's
Also, I don't think you need the (usr.thundermemorized = 0) after the else
In response to Creek
poo it still says Combat.dm:92:error::expected a constant expression
dont no why any help?
In response to Mrhat99au
I don't see what could be wrong with Creek's correction. Show me exactly what line 92 looks like.
In response to Cinnom
okee dokey

//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(5))
for(T in world)
if(!T.occupied)
M <<sound('music/Town1.mid',1)
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(mob/attacker as mob, mob/target as mob)
usr << "Which spell do you want to use?"
var/list/Magic = list("Thunder", "Ice Blast")
var/CombatOp2 = input(usr, "What do you wish to do?", "Thunder", "Ice Blast") in Magic
switch (CombatOp2)
if ("Thunder")
if (usr.thundermemorized == 1)
usr << "A giant lighting blot apears in your hand and then it zaps the enemy with a giant force!"
target.hp -= 4
npcdeathcheck(attacker, target)
if ("Ice Blast")
if (usr.iceblastmemorized == 1)
usr << "A frosty ice blast shots at the enemy and freezes him!"
target.hp -= 5
npcdeathcheck(attacker, target)


//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)

area\enteredbattlezone
Entered()
usr.enteredbattles = 1

area\enteredbattlezone
Exited()
usr.enteredbattles = 0










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(22, 5, 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]!"
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.lvl += 1
M.meelee += 1
M.magic += 1
M.exp = 0
usr.expreq += 150
usr.hp = usr.maxhp
Memorize_Thunder()

//Define all the vars
mob/var
agility
attack
defense
evade
expreq
expreward
hit
hp
level
oldbattlefield
oldlocx
oldlocy
oldlocz
onbattlefield
wealth
wealthreward
enteredbattles

mob

hp = 50
level = 1
expreq = 150
hit = 75
evade = 50
agility = 25
defense = 15
attack = 15
wealth = 100
oldbattlefield
onbattlefield





Monster3
icon = 'orc.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)


/*Heres where the special area is. As you can see, it sets usr.onbattielf when
entering, and clears it when exiting. If you want to use more than one battlearea,
you will have to put spaces between them.*/
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















In response to Mrhat99au
do not worry figured it out i think no errors which is good