ID:170232
 
I've been looking for a way to do this, but all the demoes and libs I've seen this last week have been very poor at best. I've got all the icons I need, and I've attempted coding it, but it just isn't working! This is what I have;

mob
Monster
Drag1
Multi = new/list()
New()
Multitile('Drag1.dmi',"UR","UR",src)
Multitile('Drag1.dmi',"BL","BL",src)
Multitile('Drag1.dmi',"BR","BR",src)
Del()
for(var/obj/O in Multi)
del O
..()


proc/Multitile(icon/A,var/B,var/C,var/mob/NPC/D)
var/obj/Multi/O = new/obj/Multi
O.Pos = "[C]"
O.icon = A
O.icon_state = "[B]"
D.Multi.Add(O)
if(O.Pos == "UR")
O.loc = locate(usr.x+1,usr.y,usr.z)
O.dir = usr.dir
if(O.Pos == "BR")
O.loc = locate(usr.x+1,usr.y-1,usr.z)
O.dir = usr.dir
if(O.Pos == "BL")
O.loc = locate(usr.x,usr.y-1,usr.z)
O.dir = usr.dir


Now this makes a Dragon that stands still and does nothing. But when I call my monster wander proc everything goes wrong. I get loads of errors, then the mob disappears leaving only his extra tiles behind! Here is my wander proc;

ai_random_wander()//random wander if no mobs are in range to attack
if(src.key)//if the source is human
return//don't call the rest
if(AI==1)
var/turf/T
var/Dir=0
do
Dir=pick(1,2,4,8,5,6,9,10)
T=get_step(src,Dir)
while(!T||T.density||T.loc!=loc.loc)
step(src,Dir)
src.ai_run_away()//checks for run away
spawn(7)//delay for one tick
if(AI==1)
ai_random_wander()//wander some more

ai_run_away()//used for checking to see if it should run or attack
PROC
ai_walk_to()//someone came into view
PROC
ai_walk_to2(var/mob/M)//someone shot src
PROC

checktrg(atom/target)
if(target.loc.loc==loc.loc)
return 1
else
return 0



Thank you very much for your time!

~Ease~
Bump =D
In response to Ease
Do not ever, Bump then delete that bump hours later and re-bump like you just did.

~>Jiskuha
In response to Jiskuha
I didn't delete my bump. I bumped, or thought I did, and came back hours later to see no bump present, and my thread several pages back, so I bumped again assuming that I had clicked the wrong button previously and not noticed!

~Ease~
Wanna know why nobody responded? Too much code. Cut out the portions that aren't applicable.
mob
> Monster
> Drag1
> Multi = new/list()
> New()
> Multitile('Drag1.dmi',"UR","UR",src)
> Multitile('Drag1.dmi',"BL","BL",src)
> Multitile('Drag1.dmi',"BR","BR",src)
> Del()
> for(var/obj/O in Multi)
> del O
> ..()
>
>
> proc/Multitile(icon/A,var/B,var/C,var/mob/NPC/D)
> var/obj/Multi/O = new/obj/Multi
> O.Pos = "[C]"
> O.icon = A
> O.icon_state = "[B]"
> D.Multi.Add(O)
> if(O.Pos == "UR")
> O.loc = locate(usr.x+1,usr.y,usr.z)
> O.dir = usr.dir
> if(O.Pos == "BR")
> O.loc = locate(usr.x+1,usr.y-1,usr.z)
> O.dir = usr.dir
> if(O.Pos == "BL")
> O.loc = locate(usr.x,usr.y-1,usr.z)
> O.dir = usr.dir


Straight from the reference -
"The only time usr is assigned for you is when a player (in Dream Seeker) executes a verb, clicks something with the mouse, or any other such action. "

usr is the mob that initiated the user input that initiated that proc(if any) not your dragon. There is good reason why LummoxJR repeats his phrase. Though seriously haven't you used the forums long enough to have seen "don't use usr in procs" enough to know better :P?
In response to Ter13
I've now cut out all the portions of unappropriate code.
In response to Ease
I hate to bump again, but its been four days and I really need some help on this! Sorry!

~Ease~
In response to Theodis
Theodis wrote:
usr is the mob that initiated the user input that initiated that proc(if any) not your dragon. There is good reason why LummoxJR repeats his phrase. Though seriously haven't you used the forums long enough to have seen "don't use usr in procs" enough to know better :P?

To clarify, if you don't understand exactly why usr shouldn't be used in procs, then I strongly recommend that you read this.
What are the errors you get? You never did mention what they were, only that you got them. You know, little details like that can really make a difference when sorting out bugs. Also, I would change those references to usr in your Multitile() proc to D instead. If you call that for an NPC, it'll build it around one of your players. Probably not what you want. I really can't help much without knowing the errors.

Also, you know that moving the Drag part of the mob may fail if it's going in a direction that one of it's parts is occupying without first moving that part. That's one of the headaches I ran into when making multi-tiled mobs in this way.

~X