In response to Lummox JR
Ergh I'm very confused. Could you spare me a little time to sort out my code?

I've been toying with it and I've got the level up system to work. However, now the enemies simply won't die.

Can you see if you can change this code so that it will work? Otherwise I have a backup of my code from last night (although I think I've worked on it a lot since)

mob

var
HP = 30 //define a new variable called HP, with a value of 30
MaxHP=30
Level=1
EXP=0
EXPNeeded=15
Strength=2
GP=10

Del()
var/obj/gold/G = new(loc) //create a new obj from the gold blueprint
G.amount = rand(1,100) //set its amount variable randomly
..() //call the parent

Login()
switch(input("Which race would you like to be?") in list ("Human","Elf","Vampire","Lycan","Demon","Angel"))
if("Human")
src.icon = 'human.dmi'
if("Elf")
src.icon = 'elf.dmi'
if("Vampire")
src.icon = 'vampire.dmi'
if("Lycan")
src.icon = 'lycan.dmi'
if("Demon")
src.icon = 'demon.dmi'
if("Angel")
src.icon = 'angel.dmi'

..() //the gender of their key. Then call the parent!
world << "[usr] has entered!"

proc/GainEXP(n) // gain n experience points //start
EXP=(EXP+n)
if(EXP>=EXPNeeded) LevelUp()

proc/LevelUp(mob/M)
src.Level++
src << "You levelled up! (Level [Level])."
src.MaxHP=26+4*src.Level // 26+(4*1) = 30, the original value
src.HP=src.MaxHP
src.Strength = src.Level*2
src.EXPNeeded=(30+Level)*src.Level //end

proc
DeathCheck(mob/Victim,mob/M) //checks to see if an attack is deadly
if (Victim.HP <= 0) //if the defender's HP is low enough...
world << "[M] killed [Victim]!" //do the death messaging
del(Victim) //delete whatever just died

verb
say(msg as text) //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output
EXPboost(mob/M)
usr.GainEXP(20)
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
oview() << "[usr] attacks [M]!" //send this message to everybody else
var/damage = rand(1,10)+Strength //assign a random # to a new variable and add strength
world << "[damage] damage!" //tell the damage to the world
M.HP -= damage //take away the damage from M
M.DeathCheck(src) //check for death with a proc
status(mob/M) //stats
usr << "-----------------------------------------"
usr << "LEVEL [Level]"
usr << "Max HP = [MaxHP]"
usr << "Strength = [Strength]"
usr << "EXP = [EXP]"
usr << "[EXPNeeded] EXP to level [Level+1]"
usr << "[GP] gold."
usr << "-----------------------------------------"



wolf //new prototype
icon = 'wolf.dmi' //override the parent's icon, which was 'person.dmi'
EXP = 10

obj
gold //define a "gold" prototype, which is a kind of obj
icon = 'gold.dmi' //set the default icon
var
amount //declare a new variable called "amount"
verb
get() //obj/gold/verb/get()
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.GP += amount //add to usr.GP
del(src) //delete the gold


I'd appreciate your help, Lummox JR
In response to RoadToDawn
RoadToDawn wrote:
Ergh I'm very confused. Could you spare me a little time to sort out my code?

I've been toying with it and I've got the level up system to work. However, now the enemies simply won't die.

Can you see if you can change this code so that it will work? Otherwise I have a backup of my code from last night (although I think I've worked on it a lot since)

> mob
>
> var
> HP = 30 //define a new variable called HP, with a value of 30
> MaxHP=30
> Level=1
> EXP=0
> EXPNeeded=15
> Strength=2
> GP=10
>
> Del()
> var/obj/gold/G = new(loc) //create a new obj from the gold blueprint
> G.amount = rand(1,100) //set its amount variable randomly
> ..() //call the parent
>
> Login()
> switch(input("Which race would you like to be?") in list ("Human","Elf","Vampire","Lycan","Demon","Angel"))
> if("Human")
> src.icon = 'human.dmi'
> if("Elf")
> src.icon = 'elf.dmi'
> if("Vampire")
> src.icon = 'vampire.dmi'
> if("Lycan")
> src.icon = 'lycan.dmi'
> if("Demon")
> src.icon = 'demon.dmi'
> if("Angel")
> src.icon = 'angel.dmi'
>
> ..() //the gender of their key. Then call the parent!
> world << "[usr] has entered!"
>
> proc/GainEXP(n) // gain n experience points //start
> EXP=(EXP+n)
> if(EXP>=EXPNeeded) LevelUp()
>
> proc/LevelUp(mob/M)
> src.Level++
> src << "You levelled up! (Level [Level])."
> src.MaxHP=26+4*src.Level // 26+(4*1) = 30, the original value
> src.HP=src.MaxHP
> src.Strength = src.Level*2
> src.EXPNeeded=(30+Level)*src.Level //end
>
> proc
> DeathCheck(mob/Victim,mob/M) //checks to see if an attack is deadly
> if (Victim.HP <= 0) //if the defender's HP is low enough...
> world << "[M] killed [Victim]!" //do the death messaging
> del(Victim) //delete whatever just died
>
> verb
> say(msg as text) //what the usr says is passed into "msg" as text
> world << "[usr]: [msg]" //the world sees chatroom-like output
> EXPboost(mob/M)
> usr.GainEXP(20)
> attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
> usr << "You attack [M]!" //send this message to the usr
> oview() << "[usr] attacks [M]!" //send this message to everybody else
> var/damage = rand(1,10)+Strength //assign a random # to a new variable and add strength
> world << "[damage] damage!" //tell the damage to the world
> M.HP -= damage //take away the damage from M
> M.DeathCheck(M,src) //check for death with a proc
> status(mob/M) //stats
> usr << "-----------------------------------------"
> usr << "LEVEL [Level]"
> usr << "Max HP = [MaxHP]"
> usr << "Strength = [Strength]"
> usr << "EXP = [EXP]"
> usr << "[EXPNeeded] EXP to level [Level+1]"
> usr << "[GP] gold."
> usr << "-----------------------------------------"
>
>
>
> wolf //new prototype
> icon = 'wolf.dmi' //override the parent's icon, which was 'person.dmi'
> EXP = 10
>
> obj
> gold //define a "gold" prototype, which is a kind of obj
> icon = 'gold.dmi' //set the default icon
> var
> amount //declare a new variable called "amount"
> verb
> get() //obj/gold/verb/get()
> set src in view(1) //src must be close
> usr << "You pick up [amount] gold."
> usr.GP += amount //add to usr.GP
> del(src) //delete the gold
>

I'd appreciate your help, Lummox JR

Try that... When attack verb was running through you had M.DeathCheck(src) when it should be M.DeathCheck(M,src)simple mistake really quite easy to do.
In response to Oak Tree
Ah, yes. The enemies will die now.

I know for a fact that my levelling system works (I have created an EXPBoost command to give me EXP for nothing). When enough EXP is added to gain the next level, (by clicking the EXPBoost button which runs "usr.GainEXP(20)") then the character levels up and his stats are increased as they should.

So the problem is that killing enemies is not activating a similar line, and adding to my EXP in the same way. Can anyone tell me how?
In response to RoadToDawn
Ah. I have made a discovery. I have added the 'M.GainEXP()' line to the DeathCheck proc.

Alone, this doesnt seem to work. However, if I add a number "M.GainEXP(20)" then every enemy I kill nets me 20 EXP.

However, this means that any enemy will always give me 20 EXP. How can I add to this so that it will change dependant on the enemy?

My DeathCheck proc:

proc
DeathCheck(mob/Victim,mob/M) //checks to see if an attack is deadly
if (Victim.HP <= 0) //if the defender's HP is low enough...
world << "[M] killed [Victim]!" //do the death messaging
M.GainEXP()
del(Victim) //delete whatever just died



I already have this in my coding:

    wolf            //new prototype
icon = 'wolf.dmi' //override the parent's icon, which was 'person.dmi'
EXP = 10


Is there a way I can add a formula in the GainEXP() line so that it takes the EXP figure from here?
In response to Lummox JR
*Rickoshay starts crying* Sorry sir maybe we can talk on msn or aim if you have either of them

msn - [email protected]
email - same as msn.
AIM - HearKBreak

ps i dont use aim much and i live in england
In response to RoadToDawn
You can reference to the victim's EXP var by simply doing Victim.EXP in place of the 20.

Also, as Lummox has said before, you only need 1 variable for your DeathCheck(). src will be the victim, and the variable you have, will be the killer.

mob/proc/DeathCheck(mob/killer)
if(src.HP <= 0)
world << "[killer] killed [src]!"
killer.GainEXP(src.EXP) //Remember, src is the victim, so give the killer the victim's amount of exp give, src.EXP
del(src)


Then when checking if they die, call src.DeathCheck(killer), where killer is the mob who attacked src.

Hope thats not confusing, just wanted to fix some things up for you.

-Doh
In response to XxDohxX
Well, most of that went over my head, but what I learned was that by adding src.EXP to the brackets on GainEXP() it means that the EXP gained is taken from the EXP listed on the enemy's details.

And it works! I can attack enemies, do damage, then gain EXP depending on what the enemy is.

Now, I have a lot to do, but the first steps are finished.


Next, what I want to do is this:

1. When the usr is next to an enemy, movement is disabled.
2. I want enemies to fight back.
3. I want to have a tab on the menu that shows stats. (I think this one is simple but I don't know how to create a new tab)

If you can offer any advice in any of these areas, can you let me know?

If you think I'd be better off starting a new topic I'll do that instead.
In response to Rickoshay
Rickoshay wrote:
*Rickoshay starts crying* Sorry sir maybe we can talk on msn or aim if you have either of them

No need to get upset over it. I'm just stating a fact here: You're in no position to offer people code help--yet. I'd like you to reach a point where you can, naturally, but you're still way at the newbie end of the learning curve. Posting responses to people's code problems is not for you right now.

Lummox JR
In response to Oak Tree
Oak Tree wrote:
Try that... When attack verb was running through you had M.DeathCheck(src) when it should be M.DeathCheck(M,src)simple mistake really quite easy to do.

Wrong. As I pointed out to others who've done damage on this thread, please don't post responses to code help if you don't know what you're doing.

M.DeathCheck(src) is quite correct, because DeathCheck() should have one and only one argument: the killer. The victim must always be src, and therefore it is not needed as an argument.

Lummox JR
In response to RoadToDawn
Your LevelUp() still has that useless mob/M argument, so you need to ditch that. May as well lose all those src.var bits too, because the extra src. in front of each var is unnecessary and just clutters your code.

DeathCheck(), as I mentioned, should have only one argument. That should be the killer. The victim is src.

Lummox JR
In response to Lummox JR
I was only joking Lummox Jr but thats why i gave you my email address and AIM so you could add me and we could talk sometime
In response to Lummox JR
Umm if you don't mind I'll leave those as they are? I'm not quite sure which bits I'm deleting and I don't want to cause problems by deleting the wrong parts.

Obviously I'll fix them if it will cause problems, but if its for the sake of tidiness I'd like to stick with whats working.

Do you have any solutions to any of the three questions I posted?
In response to RoadToDawn
RoadToDawn wrote:
Umm if you don't mind I'll leave those as they are? I'm not quite sure which bits I'm deleting and I don't want to cause problems by deleting the wrong parts.

Obviously I'll fix them if it will cause problems, but if its for the sake of tidiness I'd like to stick with whats working.

What you have now isn't at all tidy, and is needlessly complicating your code and interfering with your ability to maintain it. You need to at least remove the mob/M from LevelUp(), and remove the victim var from DeathCheck().

Lummox JR
In response to Lummox JR
Ok, but I am really clueless so I am worried that if I move things around I'm going to mess it all up.

My code currently looks like this:

mob

var
HP = 30 //define a new variable called HP, with a value of 30
MP = 10
MaxHP=30
MaxMP=10
Level=1
EXP=0
EXPNeeded=15
Strength=2
Magic=1
GP=10

Del()
var/obj/gold/G = new(loc) //create a new obj from the gold blueprint
G.amount = rand(1,100) //set its amount variable randomly
..() //call the parent

Login()
switch(input("Which race would you like to be?") in list ("Human","Elf","Vampire","Lycan","Demon","Angel"))
if("Human")
src.icon = 'human.dmi'
if("Elf")
src.icon = 'elf.dmi'
if("Vampire")
src.icon = 'vampire.dmi'
if("Lycan")
src.icon = 'lycan.dmi'
if("Demon")
src.icon = 'demon.dmi'
if("Angel")
src.icon = 'angel.dmi'

..() //the gender of their key. Then call the parent!
world << "[usr] has entered!"

proc/GainEXP(n) // gain n experience points //start
EXP=(EXP+n)
if(EXP>=EXPNeeded) LevelUp()

proc/LevelUp()
src.Level++
src << "You levelled up! (Level [Level])."
src.MaxHP=26+4*src.Level // 26+(4*1) = 30, the original value
src.MaxMP=6+4*src.Level
src.HP=src.MaxHP
src.MP=src.MaxMP
src.Strength = src.Strength+3
src.Magic = src.Magic+3
src.EXPNeeded=(30+(Level*2))*src.Level //end

proc
DeathCheck(mob/M) //checks to see if an attack is deadly
if (HP <= 0) //if the defender's HP is low enough...
usr << "You killed [src]!" //do the death messaging
M.GainEXP(src.EXP)
del(src) //delete whatever just died

verb
say(msg as text) //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output
EXPboost(mob/M)
usr.GainEXP(20)
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
var/damage = rand(1,10)+Strength //assign a random # to a new variable and add strength
usr << "[damage] damage!" //tell the damage to the usr
M.HP -= damage //take away the damage from M
M.DeathCheck(M,src) //check for death with a proc
usr << "[M] attacks you!"
var/Mdamage = rand(1,10)+M.Strength
usr << "You lose [Mdamage] HP!"
usr.HP -= Mdamage
M.DeathCheck(usr,src)
cure (mob/M)
usr << "You cast cure on [M]!"
var/healed = rand(1,8)+Magic
usr << "You healed [healed] HP"
M.HP += healed
M.MP -= 5



status(mob/M) //stats
usr << "-----------------------------------------"
usr << "[src] LEVEL [Level]"
usr << "HP = [HP]/[MaxHP]"
usr << "MP = [MP]/[MaxMP]"
usr << "Strength = [Strength]"
usr << "EXP = [EXP]"
usr << "[EXPNeeded-EXP] EXP to level [Level+1]"
usr << "[GP] gold."
usr << "-----------------------------------------"



wolf //new prototype
icon = 'wolf.dmi' //override the parent's icon, which was 'person.dmi'
EXP = 5
Strength = -1

obj
gold //define a "gold" prototype, which is a kind of obj
icon = 'gold.dmi' //set the default icon
var
amount //declare a new variable called "amount"
verb
get() //obj/gold/verb/get()
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.GP += amount //add to usr.GP
del(src) //delete the gold


It seems to be working correctly, but I recieve this error every time I kill an enemy:

runtime error: Cannot read null.Strength
proc name: attack (/mob/verb/attack)
usr: RoadToDawn (/mob)
src: RoadToDawn (/mob)
call stack:
RoadToDawn (/mob): attack(null)

The system seems to work properly, but I'm not sure what this error is trying to tell me.
In response to RoadToDawn
Two problems:

  • You still have usr in your DeathCheck() proc, where that now should be M. No put usr in proc. Ungh.
  • In attack() you're calling DeathCheck() twice, and both times you're calling it wrong. The correct call is M.DeathCheck(src), since in the attack verb src is the attacker and M is the victim. You should only call that when you're done reporting all the damage.

    Lummox JR
In response to Lummox JR
Right. The reason why I had DeathCheck twice is because what I was trying to accomplish would have been something along the lines of-

Player Attacks
Does Damage
Damage taken from enemy health
DeathCheck on enemy
Enemy attacks
Does Damage
Damage taken from player health
DeathCheck on player.

I realise that this doesn't work, I assume a deathcheck on player requires a new proc?


    verb
say(msg as text) //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output
EXPboost(mob/M)
usr.GainEXP(20)
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
var/damage = rand(1,10)+Strength //assign a random # to a new variable and add strength
usr << "[damage] damage!" //tell the damage to the usr
M.HP -= damage //take away the damage from M
M.DeathCheck(src) //check for death with a proc
if (M.HP<=0)
usr << "[M] attacks you!"
var/Mdamage = rand(1,10)+M.Strength
usr << "You lose [Mdamage] HP!"
usr.HP -= Mdamage


On this code, I'm trying to stop an enemy from retaliating if it has been killed. My thoughts were to have an if statement - if the enemy HP is above 0 then proceed, otherwise stop. I haven't finished this as of yet though, as you'll be able to tell.
Page: 1 2