mob/verb/Attack(mob/M as mob in oview())
if(usr.weapon=Sword) set src in oview(1)
if(usr.weapon=Bow) set src in oview(3)
if(usr.weapon=Longbow) set src in oview(5)
thanks
ID:165291
Jan 22 2007, 7:05 am
|
|
Here's an interesting question. At the top of my attack verb i have "set src in oview(1)" (of course). But how would i change the number inside oview() depending on something like what weapon i am wielding? Something like this:
mob/verb/Attack(mob/M as mob in oview()) thanks |
Jan 22 2007, 11:27 am
|
|
In response to Bobthehobo
|
|
ah, that's smart! i'll try it.
|
In response to Bobthehobo
|
|
mob |
In response to Adam753
|
|
Well, it compiles right for me. I do not know what is causing that error.
|
In response to Bobthehobo
|
|
Or you could just use a list:
mob Using lists may seem like a bit more work at the moment, but they are more efficient than your previous method as you'll see when you're working on future projects. For example: You're trying to get a list of people in the world to summon. Programming it with mob/m in world inside the parenthesis would get every mob in the world including npcs(and some people may even have the same name as a npc). But if you did it with a list instead, you could choose to get players only and or npcs only. Lists are EXTREMELY helpful. :D |
In response to MechaJDI
|
|
uhh, not quite...
mob This works with no compiles with no compile errors and no runtime errors, but the actual distance over which i can attack doesn't change, and i never get a LIST of enemies. |
In response to Adam753
|
|
The code you've posted there is terrible, and you should ditch it before it causes you any more problems. Rule one when you're programming a combat system is to put behavior where it belongs. An attack proc belongs to the attacker, and a hit proc belongs to the target of the attack. The hit proc is the one which subtracts hp, you should never subtract hp in an attack proc.
Further, if weapons are going to have different effects and different ranges, then those weapons should have range attributes; it shouldn't be hard coded in an attack verb. mob The above example is the sort of way you want to set up code. Notice that I can define unique monsters, like the vampire, just by adding a couple lines to it's own hit proc. Using the method suggested earlier in this thread, I'd have to check, everytime any mob ever attacked, if the moster being target was a vampire, if the attacker was using a wooden stake, if the damage was enough to kill it, etc. One you have five monsters in your game (a very small number for an RPG) your "attack verb" is going to be larger than the rest of you code. For more info, read here: http://bwicki.byond.com/ByondBwicki.dmb?BasicCombatSystem |
In response to IainPeregrine
|
|
Wow... no offence to anyone, but you're probabbly the first person to post here who actually knows anything about the subject! That works perfectly.
|
In response to Adam753
|
|
Glad to help. Read through it and be sure you understand what I'm doing. Notice how each object get's a chance to define how it should behave, and how I call a lot of different small procs, instead of using one gigantic verb.
|