I must be really really slow as I keep reading about them and don't get them at all. So Datums are ancestors to everything right? And they store data? But I don't get how to use them or how to make my coding simpler with them.
I think I did this right:
randomdmg var randdmg proc rdmg() randdmg=rand(1,10) world << "[randdmg] damage!"
mob/var/randomdmg/rdmgtwo
mob/proc/randatk() rdmgtwo.rdmg()
|
I am trying to make a verb based on that but nothing works. I just don't know what to do with this! How do I use this to make my coding simpler?
I have this for example:
proc battleinput() while(1) if(src.loc==locate(12,6,1) | src.loc==locate(12,3,1) | src.loc==locate(11,9,1) && src.pturn) for(var/mob/enemy/Prowler/o in locate(15,6,1)) for(var/mob/enemy/Bandit/i in locate(15,3,1)) world << "[src]'s turn" var/tmp/action=input("What would you like to do?") in list ("Attack", "Run") if(action=="Attack") var/tmp/attackwho=input("Attack who?") in list ("Enemy 1", "Enemy 2") if(attackwho=="Enemy 1") var/tmp/randomdmg = rand(1,10) o.hp-= randomdmg world << "[src] attacks [o] for [randomdmg] dmg" src.pturn=0 cancel3rd4=1 cancel2nd4=1 if(attackwho=="Enemy 2") var/tmp/randomdmg = rand(1,30) i.hp-=randomdmg world << "[src] attacks [i] for [randomdmg] dmg" src.pturn=0 cancel3rd4=1 cancel2nd4=1 if(action=="Run") if(prob(20)) src.loc=prevloc src.pturn=1 else src.pturn=0 sleep(10)
|
How can a Datum make this simpler and shorter?
So looking at this piece, the thing that was missed was to initialize a new instance of the rdmgtwo.
Then anytime you need this, you can call src.rdmgtwo.rdmg() where src is the mob that owns this.
You can also define it in the global scope (with just putting var/randomdmg/rdmgtwo = new()) as it does a function that may not be specific to just that one mob.
Now for the battle, to make the simpler my datum would look like this:
I only coded one of the items in it as it would be pretty long for a system like this, but it is much more flexible that what you have here.
Your system is built to ALWAYs have only 1 player and always be 2 enemies. Although you can shorten yours greatly, there is not really much going on.