ID:156879
 
Ok, so i basically have two questions.

1. Is it possible to save a persons "icon/overlays" in a list?

Some things to keep in mind:
1.1. What i want to "create" is an ability to copy a person, basically like the standard bushins in naruto for those who have seen it, but i want to "save" the person so i can turn back into him later on or at any given time.

1.2. I do not save overlays directly to a savefile. I use a list containing every item/clothing that the person is wearing and add the objects based on that upon loading the character, overlays are then removed before saving/quitting the game. At least that's what i think i'm doing :)

Now, Question 2. What is the proper way/or better way, of doing this:
obj
Bullet
density = 1
icon = 'effects.dmi'
icon_state = "bullet"
var/owner
var/dmg
New()
spawn(50) del(src)
..()
Bump(mob/M)
if(istype(M,/obj))
del(src)
return
if(istype(M,/mob))
view() << output("Test","SM")
var/dd = round(src.dmg - M.def)
if(dd <= 0)
dd = 1
M.hp -= dd
spawn() M.Health_Bar()
view() << output("[M] was hit by [src.owner]'s [src]! and did [dd] damage!","SM")
sleep(1)
del(src)
return


With this version it technically does what i want it to, though the text does not display in the SM output, damage however is dealth and Health_Bar() is called.

also as an addon: the way i create the object is very inefficient. (suits the rest of my coding i guess)

mob/verb/Do_This()
var/obj/A = new/obj/B // This is just as an example
A.owner = usr
A.dmg = usr.strength
A.loc = locate(usr.x,usr.y,usr.z) // Now this the biggest issue from my P.O.V.
walk(A,usr.dir,2)

This might be silghtly off balance since i just made it right now, anyways.. i Remember to have had it so it was to locate itself directly infront of the user, whichever direction he is facing. like this, however more efficient:
mob/verb/Do_This()
var/obj/A = new/obj/B
if(usr.dir == NORTH)
A.loc = locate(usr,NORTH)
if(usr.dir == SOUTH)
A.loc = locate(usr.SOUTH)
// or something like that, however within a simple line of code.


Anyways, Anyone who could help me out here?
Feel free to be as harsh as you need to.
For question 1: yes, you can. Just save the icon in some variable and a copy of the overlays in some other variable (so var/temp_overlays = overlays.Copy()).

For question 2, changes I suggest are:

Instead of view(), use view(src).
Instead of spawn(), use spawn(-1), so that you no longer need a sleep() at the end of the Bump() proc. spawn() queues up some command to execute as soon as the current thread sleeps, but with you deleting the obj and ending the proc before then, it never gets to do anything. spawn(-1) executes the code within it (until it reaches a sleep) BEFORE continuing on the main proc.
To get the location of a player, just use the loc variable, you don't need to use locate(). To get a step in the direction they're facing, use get_step(src, src.dir). Keep in mind that this might not be preferable as you would end up shooting through thin walls.
In response to Garthor
thanks alot!

Yes, shooting trough thin walls would not be preferable. the problem i've had with having it spawn at the players loc is that the player himself, is moving faster than the bullet, so you would shoot yourself if moving while firing. guess i could play around with the delays for this issue.
In response to Narutostory
Just have it take a step immediately, then, rather than relying entirely on walk(), which has a delay before its first step.
In addition to Garthor's suggestions, I also recommend passing the shooter as a second argument to New(), and then setting up the projectile's movement and other vars there. Doing this in the calling verb is neither robust nor flexible.

Lummox JR
In response to Garthor
thanks again! i would've never thought about that :P