ID:156731
 
i want a verb to do damage to everything within 5 spaces how would i do that??

heres the verb
Earthquake(mob/M as mob in oview(5)) if(usr.Level>=5) if(usr.Mp>=3) flick('eq.dmi',usr) usr.Mp-=3 usr<<"You make a mighty earthquake!!" oview()<<"the earth starts to tremble!" var/d = rand(20,25) world <<"The earthquake has caused [d] damage!" M.Health -= d M.DeathCheck() usr.Levelup() else usr<<"NOT ENOUGH MANA" else usr<<"You cant yet."
Please use 'dm' not 'code'

        Earthquake()
if(usr.Level>=5)
if(usr.Mp>=3)
flick('eq.dmi',usr)
usr.Mp-=3
usr<<"You make a mighty earthquake!!"
oview()<<"the earth starts to tremble!"
var/d = rand(20,25)
world <<"The earthquake has caused [d] damage!"
for(var/mob/M in oview(5))
M.Health -= d
M.DeathCheck()
usr.Levelup()
else
usr<<"NOT ENOUGH MANA"
else
usr<<"You cant yet."
In response to Ripiz
been a while sense i used these forums haha
my bad


how does that work btw?? not iso the snippet, iso the knowledge


edit: also, is there any way to make all the mobs in that area take an = ammount of damage?? (ie - if there are 5 monsters, the earthquake does a total of 50 damage, 1 monster would take 10 damage ect.ect.)

looking for knowledge on the code, not just snippets, but i learn well from snippets with explinations
In response to RanEsu
With your code you were asking too choose mob within 5 steps, with code I posted it doesn't ask anything, put loops through mobs within 5 steps and damages them all.
In response to Ripiz
okay, is there any way to divide the damage up between all the mobs in the distance??
In response to RanEsu
You mean if there's 4 mobs and you do 100 damage, make them take 25 damage each? Yes there is a way.

        Earthquake()
if(usr.Level>=5)
if(usr.Mp>=3)
flick('eq.dmi',usr)
usr.Mp-=3
usr<<"You make a mighty earthquake!!"
oview()<<"the earth starts to tremble!"
var/d = rand(20,25)
world <<"The earthquake has caused [d] damage!"
var/mobs = list()
for(var/mob/M in oview(5))
mobs += M // add all mobs in range to list
d = d / mobs.len // divine damage by list length (number of mobs)
// damage mobs in the list
for(var/mob/M in mobs) // loop the list
M.Health -= d
M.DeathCheck()
usr.Levelup()
else
usr<<"NOT ENOUGH MANA"
else
usr<<"You cant yet."
In response to Ripiz
you totally lost me there

also get that the .len is a undefined var?
d = d / mobs.len // divine damage by list length (number of mobs)

In response to RanEsu
It should be var/list/mobs, not just var/mobs.
In response to Garthor
Aww I've failed :(
In response to Garthor
i made the ajustment and it works the way i want it to now, but why does it work??

i just restarted coding recently and have no idea how that snippet works

        Earthquake()
if(usr.Level>=5)
if(usr.Mp>=3)
flick('eq.dmi',usr)
usr.Mp-=3
usr<<"You make a mighty earthquake!!"
oview()<<"the earth starts to tremble!"
var/d = rand(20,25)
world <<"The earthquake has caused [d] damage!"
var/list/mobs = list()
for(var/mob/M in oview(5))
mobs += M // add all mobs in range to list
d = d / mobs.len // divine damage by list length (number of mobs)
// damage mobs in the list
for(var/mob/M in mobs) // loop the list
M.Health -= d
M.DeathCheck()
usr.Levelup()
else
usr<<"NOT ENOUGH MANA"
else
usr<<"You cant yet."


explain plox :)
In response to RanEsu
Which part exactly?
In response to RanEsu
RanEsu wrote:
i made the ajustment and it works the way i want it to now, but why does it work??

i just restarted coding recently and have no idea how that snippet works

        Earthquake()
> if(usr.Level>=5)
> if(usr.Mp>=3)
> flick('eq.dmi',usr)
> usr.Mp-=3
> usr<<"You make a mighty earthquake!!"
> oview()<<"the earth starts to tremble!"
> var/d = rand(20,25)
> world <<"The earthquake has caused [d] damage!"
> var/list/mobs = list()
> for(var/mob/M in oview(5))
> mobs += M // add all mobs in range to list
> d = d / mobs.len // divine damage by list length (number of mobs)
> // damage mobs in the list
> for(var/mob/M in mobs) // loop the list
> M.Health -= d
> M.DeathCheck()
> usr.Levelup()
> else
> usr<<"NOT ENOUGH MANA"
> else
> usr<<"You cant yet."

explain plox :)




Basically you are defining an attack, then it is checking if the user is under or equal level to 5 and then it checks if its MP is under or equal to 3 then it shows the icon designated, minuses the MP and tells the user what they did. An announcement to all in view let them know what happened, and then its checking if anyone was damaged or died from the attack, or even leveled up. Also lets the user know what happened if they don't have enough mana, or if they can't use it at all due to exceeding requirements, or whatever.
In response to Ripiz
Earthquake()
if(usr.Level>=5)
if(usr.Mp>=3)
flick('eq.dmi',usr)
usr.Mp-=3
usr<<"You make a mighty earthquake!!"
oview()<<"the earth starts to tremble!"
var/d = rand(20,25)
world <<"The earthquake has caused [d] damage!"
var/list/mobs = list()
for(var/mob/M in oview(5)) //whats in the para's here
mobs += M
d = d / mobs.len //this
// damage mobs in the list
for(var/mob/M in mobs)
M.Health -= d
M.DeathCheck()
usr.Levelup()
else
usr<<"NOT ENOUGH MANA"
else
usr<<"You cant yet."