Ok so my goal is to make a game. This code im wanting says if the player attacks, and the monster is a spider, he has a chance to get poisoned and the rest of the damage steps go on. I used an If,Else statement and I edited this code from the internet so im worried it wont work. I did compile it and it only gave one error which was Verbs.dm:18:error: "Spider": missing comma ',' or right-paren ')' . Heres the code. Btw I didn't know if I should put the start of it or not so I just went ahead and did it. the save part is obviously a saving code
mob/verb
Save()
src.SaveProc()
Attack()
flick("Attack",src)
for(var/mob/M in get_step(src,src.dir))
if(M=icon_state"Spider")
var/Poison=rand()/3
var/Damage=max(0,src.Str-M.Def)
view(M)<<"[src] hit [M] for [Damage] damage,but was given a level [Poison] poison"
M.TakeDamage(Damage,src)
else
var/Damage=max(0,src.Str-M.Def)
view(M)<<"[src] hit [M] for [Damage] Damage!"
M.TakeDamage(Damage,src)
I am not sure what language this is, but it certainly isn't c++
without more knowledge of your implementation it is very difficult to offer any help.
But generally speaking, implementing something like what you described shouldn't be terribly hard, its more a question of how you have structured your code. Normally you would have a "character" base class, the "player" would inherit from this.
That way you can add a "poisoned" flag to the character then within the player update function you would test to see if this flag has been set.
If the "poisoned" flag has been set, you apply a small amount of damage to the player every update.
as for having a chance of getting poisoned this would be a case of using a random number generator, if it returns a certain number you would turn the flag on, but the specific code to do this would depend on your implementation and the chance.
It is dream maker language, what ever that is (deduced from file extension in error code). Also if you want to refer to a specific line and not post the full code, just note that you are going to have to adjust line numbers. So would you mind telling us: Which line is line 18?
ok sorry guys I didn't know there was a difference between C++ and DML (or that DM had its own language.....) but I went to the DML site and got it all fixed :) I had the code backwards HAHA the spider poison code goes into its own set. not int he battle system x3 I didn't even think of that xD