I have 2 problems.
(1) MY enemies (bugs) only move straight down in a straight line. They also pile up on thenselves. Once they stop moving, they wont attack me.
(2) When i kill one, i want a random experience to be given to the player. For now i made it 3, so i could code the rest easily. When i kill an enemy, it displayes the text, but my exp doesn't go up on my stats panel, and when i get 15(the level up experience level)by counting in my head, my level doesnt go up!!
I used Zial's tutorial but now im taking it farther just so u know. And also my map is only 1 screen if that matters.
Here is my code:
//This is a test world started by Tabu34 on 3/15/04 and yet to be completed...
mob
var/level=0
var/exp=0 // experience (total)
var/expNeeded= 15 // experience for the next level
var/maxHP= 20
var/expgained= 3
proc
DeathCheck() //checks to see if an attack is deadly
if (HP <= 0) //if the defender's HP is low enough...
world << "[src] dies!" //do the death messaging
world << "[src] was killed by Tabu34!"
world << "Tabu34 gains [expgained] experience!"
exp+= 3 //adds exp points
if(exp>=expNeeded)
LevelUp()
del(src) //delete whatever just died
PDeathCheck()
if (UHP <=0)
world << "Tabu34 dies!"
world << "Tabu34 was killed by [src]"
src.loc = locate(1,1,1)//restarts
src.UHP = src.maxUHP//resets health
InjuredCheck()
if (HP <=15)
icon = 'bugcut.dmi'
else
icon = 'bug.dmi'
LevelUp()
++level
src << "Welcome to level [level]."
maxUHP+=4
UHP=maxUHP
expNeeded*= 2
mob
icon = 'person.dmi' //makes it so all mobs will be created with the person icon
name = "player"
var
HP = 30 //declares a new variable called HP, with a value of 30
wealth = 0 //total money
UHP = 40 //new var Hp for user
maxHp = 30 //max hp for bug
maxUHP = 40 //max hp for user
strength = 3//change to the amount you want the player to have
defense = 2//same here
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()
icon_state = gender //when a player logs in, make their icon's state
..() //the gender of their key. Then call the parent!
world << "[usr] had logged into Testworld!"
bug
icon = 'bug.dmi'
name = "bug"
strength = 5
defense = 3
var/mob/character/
New()
. = ..()
spawn()
move()
proc/move()
while(src)
var/Found = FALSE
for(character in oview(5,src))
step_towards(src,'person.dmi')
Found = TRUE
break
if(Found != TRUE)
step_rand(src)
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(M,/mob/))
attackb(M)
proc/attackb(mob/U)
var/damage = rand(1,strength)
UHP -= damage
U <<"You are being attacked by [src.name]!"
src.exp += rand(1,5)
src.LevelUp()
PDeathCheck()
verb
attack(mob/G as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [G]!" //send this message to the usr
oview() << "[usr] attacks [G]!" //send this message to everybody else
var/damage = rand(1,10) //assign a random # to a new variable
usr << "[damage] damage!" //tell the damage to the world
G.HP -= damage //take away the damage from M
G.InjuredCheck() //check for injuries w/ proc
G.DeathCheck() //check for death with a proc
say(msg as text) //What the usr says is passed into "msg" as text
world << "[usr]: [msg]" //The world sees chatroom-like output
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.wealth += amount //add to usr.wealth
del(src) //delete the gold
obj
tree
icon = 'tree.dmi'
density = 1
turf
grass //defines a "grass" prototype, which is a kind of turf...
icon = 'grass.dmi' //and has an icon named 'grass.dmi'. In single quotes!
world //we set one of our world's characteristics:
turf = /turf/grass //its default turf is the grass turf.
mob/Stat() //Call the Stat proc that updates the stat window every Tenth of a second...
stat("[src]'s Stats:",src.desc) //Place in the stat panel, the word Stats:, and the srcs description.
stat(" HP: ","[UHP]/[maxUHP]" ) //It makes it easier to read if you put a bunch of spaces like that.
stat(" Gold: ","[wealth]")
stat(" Experience: ","[exp]/[expNeeded]")
stat(" Level: ","[level]")
//END OF CODE
Any and all help will be appriciated. Plz make it easy to understand!!
ID:147578
Mar 21 2004, 11:37 am (Edited on Mar 21 2004, 11:43 am)
|
|
Mar 21 2004, 11:44 am
|
|
oops i put this in the wrong channel. If someone would move it to code problems that would be helpful!!
|
Tabu34 wrote:
(2) When i kill one, i want a random experience to be given to the player. For now i made it 3, so i could code the rest easily. When i kill an enemy, it displayes the text, but my exp doesn't go up on my stats panel, and when i get 15(the level up experience level)by counting in my head, my level doesnt go up!! //This is a test world started by Tabu34 on 3/15/04 and yet to be completed...Concerning your second problem.. I'm assuming that the exp+=3 line is the one you're talking about. Look closely, it's adding 3 to exp, so it should work, right? But *whose* exp is it increasing? exp is really src.exp. src, in this case, is whoever died. When doing a deathcheck procedure like this, you need to pass the mob who's the killer. Ex: mob/proc/DeathCheck(mob/M) Whenever your DeathCheck proc is called, you'll also need to remember to pass it the variable of whoever is doing the attacking. Ex: mob/verb/Attack(mob/M in view(1)) |
In response to Jon88
|
|
i understand your point, but i have 2 separate procs one for player killing bug, and one for bug killing player, mainly this code:
proc DeathCheck() //checks to see if an attack is deadly if (HP <= 0) //if the defender's HP is low enough... world << "[src] dies!" //do the death messaging world << "[src] was killed by Tabu34!" world << "Tabu34 gains [expgained] experience!" exp+= 3 //adds exp points if(exp>=expNeeded) LevelUp() del(src) //delete whatever just died PDeathCheck() if (UHP <=0) world << "Tabu34 dies!" world << "Tabu34 was killed by [src]" src.loc = locate(1,1,1)//restarts src.UHP = src.maxUHP//resets health |
In response to Tabu34
|
|
Tabu34 wrote:
i understand your point, but i have 2 separate procs one for player killing bug, and one for bug killing player, mainly this code: I don't think you do. exp+= 3 //adds exp points This adds 3 to src's exp. src in this case is whatever you have just killed! You need to pass the DeathCheck proc the mob who is doing the killing, or else you won't be able to give the right person 3 exp. proc |
In response to Jon88
|
|
thanks for that. i changed the DeathCheck to this:
proc DeathCheck(mob/M) //checks to see if an attack is deadly if (HP <= 0) //if the defender's HP is low enough... world << "[src] dies!" //do the death messaging world << "[src] was killed by Tabu34!" world << "Tabu34 gains [expgained] experience!" M.exp+= 3 //adds exp points if(exp>=expNeeded) LevelUp() del(src) //delete whatever just died but... it gives me this error when i kill a bug: runtime error: Cannot read null.exp proc name: DeathCheck (/mob/proc/DeathCheck) usr: Tabu34 (/mob) src: the bug (/mob/bug) call stack: the bug (/mob/bug): DeathCheck(null) Tabu34 (/mob): attack(the bug (/mob/bug)) and the bug also doesnt dissappear!! so close to solving the exp mystery !HELP! |
In response to Tabu34
|
|
Okay, now in your attack() verb, instead of just calling G.DeathCheck(), call G.DeathCheck(src)
Also, you'll need to make sure that in yor DeathCheck proc, you use M.exp, M.expNeeded, and M.LevelUp() |
In response to Jon88
|
|
ok now i gain exp but i wont level up!! help!!
|
In response to Tabu34
|
|
Same problem as before.
|
In response to Garthor
|
|
i dont understand that here is my level up code:
LevelUp(mob/M) level+= 1 M << "Welcome to level [level]." maxUHP+=4 UHP=maxUHP expNeeded*= 2 exp = 0 |
In response to Tabu34
|
|
Tabu34 wrote:
i dont understand that here is my level up code: What's with the mob/M? Just use src. Also, you might want to call the Levelup and Deathcheck() procs a diffrent way. mob/proc/LevelUp() You should check in the Level_Up() proc, instead of adding another if statement into the death_check() proc. --SSJ4_Gohan_Majin |
In response to SSJ4_Gohan_Majin
|
|
I cnat seem to make my bugs move. At first, they moved straight down. Then when i fiddled with the code, they were placed in the beginning at random places. I want them to walk randomly and when they bump into me they attack. Here is my code:
//This is a test world started by Tabu34 on 3/15/04 and yet to be completed... mob var/level=0 var/exp=0 // experience (total) var/expNeeded= 15 // experience for the next level var/maxHP= 20 var/expgained= 3 proc PDeathCheck() if (UHP <=0) world << "Tabu34 dies!" world << "Tabu34 was killed by [src]" src.loc = locate(1,1,1)//restarts src.UHP = src.maxUHP//resets health InjuredCheck() if (HP <=15) icon = 'bugcut.dmi' else icon = 'bug.dmi' LevelUp() if(src.exp >= src.expNeeded) src <<"Welcome,[src], to level [level]!" src.level++ src.maxUHP += 4 src.UHP = src.maxUHP src.expNeeded *= 2 src.exp = 0 DeathCheck(mob/M as mob) //checks to see if an attack is deadly if(HP <= 0) //if the defender's HP is low enough... world << "[src] dies!" //do the death messaging world << "[src] was killed by [M]!" world << "[M] gains [expgained] experience!" M.exp+= 3 //adds exp points M.LevelUp() del(src) mob icon = 'person.dmi' //makes it so all mobs will be created with the person icon name = "player" var HP = 30 //declares a new variable called HP, with a value of 30 wealth = 0 //total money UHP = 40 //new var Hp for user maxHp = 30 //max hp for bug maxUHP = 40 //max hp for user strength = 3//change to the amount you want the player to have defense = 2//same here number = 1 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() icon_state = gender //when a player logs in, make their icon's state ..() //the gender of their key. Then call the parent! world << "[usr] had logged into Testworld!" bug icon = 'bug.dmi' name = "bug" strength = 5 defense = 3 var/mob/bug/ New() . = ..() spawn(bug) step_rand(src) Bump(mob/M) if(istype(M,/mob/)) attackb(M) proc/attackb(mob/U) var/damage = rand(1,strength) UHP -= damage U <<"You are being attacked by [src.name]!" src.exp += rand(1,5) src.LevelUp() PDeathCheck() verb attack(mob/G as mob in oview(1)) //attack a mob within 1 tile of you usr << "You attack [G]!" //send this message to the usr oview() << "[usr] attacks [G]!" //send this message to everybody else var/damage = rand(1,10) //assign a random # to a new variable usr << "[damage] damage!" //tell the damage to the world G.HP -= damage //take away the damage from M G.InjuredCheck() //check for injuries w/ proc G.DeathCheck(src) //check for death with a proc say(msg as text) //What the usr says is passed into "msg" as text world << "[usr]: [msg]" //The world sees chatroom-like output 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.wealth += amount //add to usr.wealth del(src) //delete the gold obj tree icon = 'tree.dmi' density = 1 turf grass //defines a "grass" prototype, which is a kind of turf... icon = 'grass.dmi' //and has an icon named 'grass.dmi'. In single quotes! world //we set one of our world's characteristics: turf = /turf/grass //its default turf is the grass turf. mob/Stat() //Call the Stat proc that updates the stat window every Tenth of a second... stat("[src]'s Stats:",src.desc) //Place in the stat panel, the word Stats:, and the srcs description. stat(" HP: ","[UHP]/[maxUHP]" ) //It makes it easier to read if you put a bunch of spaces like that. stat(" Gold: ","[wealth]") stat(" Experience: ","[exp]/[expNeeded]") stat(" Level: ","[level]") stat(" Strength: ","[strength]") stat(" Defense: ","[defense]") //END OF CODE This is my last *known* problem. PLZ HELP!! |
In response to Tabu34
|
|
In the bumped proc, it's just being defined as a mob!
|
In response to SSJ4_Gohan_Majin
|
|
and... that means i should do what??
|