im tryin to make a Spell called Firewall its supposed to drain your hp slowly when you enter it but its not for some reason and also How would i make it so when your entering/exiting the Firewall you slow down a little.Here's my code
mob
var
Firewall
proc/Firewall()
set category = "Spells"
if(Firewall)
Firewall=0
else
Firewall=1
turf
Click()
if(usr.Firewall)
if(usr.MP <= 29)
usr << "Not enough Mp"
else
usr.MP -= 30
var/obj/a = new/obj/Firewall2(locate(src.x+1,src.y,src.z))
var/obj/b = new/obj/Firewall(locate(src.x,src.y-1,src.z))
var/obj/c = new/obj/Firewall2(locate(src.x+1,src.y-1,src.z))
var/obj/d = new/obj/Firewall(locate(src.x,src.y,src.z))
sleep(50)
del(a)
del(b)
del(c)
del(d)
turf
proc
drain(mob/M)
if(ismob(M))
if(M.client)
while(src.drain)
M.HP-=rand(1,5)
sleep(10)
return 0
Firewall
Entered(mob/M)
if(ismob(M))
if(M.client)
src.drain=1
spawn()
src.drain(M)
return ..()
Exited(mob/M)
if(ismob(M))
if(M.client)
src.drain=0
return ..()
turf
var
drain
ID:147904
Oct 5 2003, 9:21 pm
|
|
In response to Evil Incarnate Inc
|
|
k thanks also by the way it works if i change the firewall into a turf instead of a obj but then the Firewall Deletes the old turf and it creates a black spot =/
|
In response to Turles9000
|
|
yes, because when 2 turfs are on 1 space, the top layer over-powers them if the icon is completely filled and has no ''masked'' spaced. (i think, if not, it 'mixes' them together) and when it deletes the ''firewall'' since its ''mixed'' with the turfs combined, it deletes them all, making the icon of the location null (therefore- black)
|
In response to Evil Incarnate Inc
|
|
Yea i know,was just making that as a side note
|
In response to Evil Incarnate Inc
|
|
ok, lets act like the program is stupid, and only does what you say, ok it would do this: Actually, just to point out: mob only evaluates the Firewall variable once. If it's 1, then it will be 0. It will NOT perform the ELSE statement unless Firewall is FALSE to begin with. If Firewall is 0, then it will only perform the statement under the ELSE. That's the whole point of an if-else statment. Now, if he had if(Firewall) then it would perform as you say. Now, to answer the original question. You have a firewall turf and a firewall obj. I imagine that you only need one or the other. I would recommend setting up a trigger system for this. There's a few posts and demos lying around on how to do this, but I'll give you a crash course. First, you need to add a variable to the base obj called trigger (or whatever you like), like so: obj Now, you need a trigger proc for the base obj, like so: obj Notice that we did not define the proc other than it's name. This is because with a trigger, you define how you want it to work for each obj. For your firewall, for example: obj/Firewall Alright, now that we have our firewall ready to be triggered, we need to actually trigger it. For that, we need to modify the base turf like so: turf The net effect of this is that when a mob enters a turf with a firewall in it, the firewall's trigger_enter() proc will be called and the mob that entered will be used for further actions within the proc. When a mob exits, the firewall's trigger_exit() proc will be called in the same way. In order to get a mob to slow down, you first have to implement a movement delay. You might try something like this: mob Once you have a delay system implemented, you can play around with the triggers I mentioned earlier. For example: obj/Firewall Phew. Ok, class is over :P Hope it helped some. |
In response to sapphiremagus
|
|
so i should stick with my original right?Ive been asking around and no one i asked can figure out how to get it to drain hp.
|
In response to Turles9000
|
|
Edited my post, check it again.
|
In response to sapphiremagus
|
|
Alright, now that we have our firewall ready to be triggered, we need to actually trigger it. For that, we need to modify the base turf like so: > turf The net effect of this is that when a mob enters a turf with a firewall in it, the firewall's trigger_enter() proc will be called and the mob that entered will be used for further actions within the proc. When a mob exits, the firewall's trigger_exit() proc will be called in the same way.___________________________________________________________ should i delete the part in bold?and replace it with what you did or mix them together? One more question It says M.drain is not defined even though i defined it.Sorry for not being able to figure these stuff out by myself >< looked it over three times.Thanks in advance turf proc drain(mob/M) if(ismob(M)) if(M.client) while(src.drain) M.HP-=rand(1,5) sleep(10) return 0 Firewall Entered(mob/M) if(ismob(M)) if(M.client) src.drain=1 spawn() src.drain(M) return ..() Exited(mob/M) if(ismob(M)) if(M.client) src.drain=0 return ..() |
In response to Turles9000
|
|
Ok, you have your objs that trigger whenever someone enters the turf. You don't need anything else now. Just create the obj (Firewall) in the turf that you want. Whenever a mob enters that turf - be it grass, sand, or whatever - it will start damaging them. You don't need a seperate turf, just define the variables and procs I outlined above and you should be good to go.
As for the drain not defined, that was my fault. I thought drain was a mob variable. Simply change M.drain to src.drain in the trigger_enter() and trigger_exit() procs. *-------------------EDIT-------------------------* After going over your original post with a little more clarity, I realized that this will not work like I expected due to how you have the drain proc set up. Keep the triggers, but remove the calls to src.drain = TRUE and src.drain = FALSE. Instead, we're going to set these when the obj is created. obj When the firewall is created, the turf it's created on has it's drain variable set to TRUE. When the firewall is deleted, the turf has it's drain variable set to FALSE. ***********************FINAL EDIT************************* I've gone ahead and written out a fully documented version of everything so far discussed. This should do what you want it to. Take it and learn from it. If you questions, please ask. mob |
In response to sapphiremagus
|
|
2 errors ,sorry for not including this part in code.This is how you get the spell.
__________________________________ Legend of The 2 Kingdoms.dm:2027:error:/mob/proc/Firewall:undefined type path Legend of The 2 Kingdoms.dm:2032:error:/mob/proc/Firewall:undefined type path _________________________________________ obj Firewall_SpellBook icon = 'Items.dmi' icon_state = "Firewall" verb Get() set src in oview(0) if(Move(usr)) usr << "You pick up the [src]" else usr << "You cannot pick up the [src]" Drop() src.loc = usr.loc usr << "You drop the [src]" usr.verbs-=new/mob/proc/Firewall Learn() switch(input("Do you Want to Learn Firewall","???")in list("Yes","No"))//This asks the user in a input box if he/she wants to learn the fire spell and gives 2 choices Yes and No// if("Yes")//This Will Do something if the user clicks Yes// if(usr.icon == 'Warlock.dmi') usr.verbs+=new/mob/proc/Firewall del src else usr << "You Must be a Warlock to learn This Move" if("No") usr<<"Ok" |
just a little note:
ok, lets act like the program is stupid, and only does what you say, ok it would do this:
check for "firewall" variable and if theres a value, it will set to 0
then it will check if theres no "firewall" variable(the else statement) and guess what, you just earlier set it to 0, so it will then put to 1.
ok, you want to use it again, and firewall was defined, so it sets to 0 again, and back to 1... hmm, interesting
uhh ohH? it just always puts firewall on. it should be this:
I think that may have been a small problem. of course,Im new to BYOND, but this is REALLY similar to all other ''programming'' systems.And by the looks of the code you have, it would probobly cause a problem.