world<< istype(/obj/spells/poison,/obj/spells/poison) //evaluates false as arg 1 is a path
world<< istype(new /obj/spells/poison,/obj/spells/poison) //evaluates to true, because arg 1 is an object
This is a path and cannot be checked by istype /obj/spells/poison. You pass this as ctype in the arguments to condition.
|
Or you can just validate the paths match.
/obj/spells/poison==/obj/spells/poison |
If you want to compare types, you can simply use the equality operator.
var/a = /obj/spells/poison |
Putnyour debug world output stuff into each of the if statements to display the src to see which if statements it is breaking at.
|
Also, you have a bit of a mistake there,
You have this definition: mob/proccondition(time, damage, obj/ctype, target) But, you're passing a type, not an object in the third argument: src.target.condition(time, damage, /obj/spells/poison, src.target) Also - why are you passing src.target? When src.target.condition() is called, the src IS src.target (the same thing you're passing) inside the proc. |
src.target.condition(time, damage, new/obj/spells/poison)
The knowing of making something new or not is an issue with me. I will have to look into this more. Ripper man5 |
Except...in the way your code is written right now, it's pointless to create a new object if you're not doing anything with it.
|
mob Than how shall I deal with this? |
Like how Pirion or I suggested above - you can explicitly compare types using ==.
(and you don't need the typecasting in the ctype argument definition) |
I need to istype check because this is not only used for poison. And having many variables defined for each type would be annoying.
var/a = /obj/spells/poison |
You don't need to define the variables - you already have it defined in the argument definition. (I used a as an example)
You can use a switch statement - which is a very powerful tool in DM. mob/proc/condition(time, damage, ctype) Though, from the looks of your code, it looks like it'd be better to set up the effects within the definition of the spells themselves - and then you'd have a reason to create the object. |
Do istype target, mob/player