I want to initialize a proc that will cause a bomb to go off and damage the player if they are standing on the square of the explotion.
so far I have
obj/bomb
icon = "bomb.dmi"
and to explode the bomb I was trying
Boom()
usr << "3,2,1 Boom"
if(usr.loc.contents == /obj/bomb)
usr << "standing on a bomb is not so smart"
var/damage = 10
usr.hp -= damage
usr << "damage [damage]"
return
else
usr << "good thing you werent standing too close to that"
return
I know that an object has a location value, in the past I have called turfs in a similar way
if(usr.loc.type == /turf/ltmergconvs)
which works.
I am just having trouble finding the proper way to compare the location of an object to the location of the user, I looked at oview and wasn't sure exactly how it might apply .
Illyena
ID:179241
Jan 29 2002, 8:33 am
|
|
Jan 29 2002, 9:27 am
|
|
Try something like this:
|
Illyena wrote:
I want to initialize a proc that will cause a bomb to go off and damage the player if they are standing on the square of the explotion. I know that an object has a location value, in the past I have called turfs in a similar way oview() is a list of things within view, but not in the same space as the center of the view. That's not what you want. view(explosion range, src) will return a list of everything within explosion range of the bomb that isn't blocked from sight by an opaque object (or lack of luminosity). Search through that list for mobs, and damage each one it finds. The way you are checking to see if a bomb is in the usr's contents won't work. you could use if(src in usr.contents) to see if it's there, or simply make the verb only appear when a mob has a bomb in contents by using set src in usr near the beginning of the verb. If the bomb is still in a mob's contents, view won't return anything useful. You should leave it on the ground, wait for a delay, then explode. obj/bomb icon = "bomb.dmi" density = 0 // so people can stand on it if they really think that's a good idea var explosion_range = 1 // one space in each direction damage = 10 delay = 3 verb/Boom() set src in usr // you can only use this verb if the bomb is in your inventory if(!Move(usr.loc)) // try to drop tha bomb, if it doesn't work... usr << "You can't set a bomb there!" // tell the user return // and quit. usr can try again somewhere else usr << "Someone set us up the bomb." for(var/loop = delay, loop > 0, --loop) usr << loop sleep(10) // delay one second usr << "BOOM!" var/usrhit = 0 // a flag to see if the usr was hit for(var/mob/M in view(explosion_range,src)) if(M == usr) usrhit=1 M.hp -= damage M << "Bomb damage [damage]" if(usrhit) usr << "standing on a bomb is not so smart" else usr << "good thing you werent standing too close to that" by setting up damage, delay and explosion_range as bomb variables, you can define several types of bombs under obj/bomb that can reuse the same code. You could even allow people to modify thier bombs in their secret basement lab. :) obj/bomb big_bomb desc = "Big range, big damage" icon = 'bigbomb.dmi' damage = 20 explosion_range = 3 concentrated_bomb desc = "short range, huge damage. Great for clearing stumps." icon = 'concbomb.dmi' damage = 50 // uses bomb default range of 1 short_fuse_bomb delay = 1 // uses default values for the rest armageddon desc = "obliterate everything within 2 screens of the bomb." icon = 'armageddon.dmi' damage = 5000 delay = 60 // give the poor sucker that set this time to get away explosion_range = 42 // insert 2x world.view here |
I think he wants the bomb to be an obj sitting on the ground, not in the usr's inventory. Thus the usr.loc.contents
You should try changing: if(usr.loc.contents == /obj/bomb) to: if(usr.loc.contents.Find(/obj/bomb)) I'm pretty sure you can find them like that. If not, you can do it the long way, I don't have a compiler handy to check. for(var/obj/O in usr.loc.contents) if(istype(O,/obj/bomb)) usr << "it isn't very smart to stand on bombs" The reason why the way you tried it didn't work: if(usr.loc.type == /turf/whatever) is because your seeing if the turf type is /turf/whatever It doesn't work in the other scenerio because contents is a list and /obj/bomb is a type, they will never be the same...at least they shouldn't be. It's kind of like saying: if(basket == /obj/apple) the basket may contain apples but it isn't an actual apple |
In response to English
|
|
That was exactly what I needed and I was able to apply it to my laser fire issue as well. I still don't get the
call() proc Oh well, on new new issues |
In response to Illyena
|
|
Glad I could help :)
I'm not really that familiar with call() either and I suggest avoiding it if you can. You can usually accomplish the same thing by calling procs/verbs like this: obj proc Owner_Talk() var/mob/M = loc M.Say_Hello() That way you can call mob procs within an object proc and basically in any other combination. If you get desperate (which you really shouldn't have to) you can use: M:Say_Hello() And just make the compiler trust you that M will have such a proc. That usually isn't good practice though, but you can still use it. |