ID:165686
 
How can I make it when something it gets hit, a random blood icon appears?
Put something like this in:

pick(var/T = new /turf/blood1(src.loc),var/T = new /turf/blood2(src.loc))

And so on.
I'm assuming it works. lol Might need some tweaking?
It supposed to create either blood1 or blood2 at src's location...
In response to CuriousNeptune
Basic idea yes, syntax no.

var/bloodtype=pick(typesof(/obj/blood))
new bloodtype(loc)


Then define all your bloody splatters under /obj/blood.
In response to Jp
Ah. Much better.
var/image
blood1
blood2
blood3
blood4
blood5

world/New()
.=..()
blood1=image('blood.dmi',null,"1")
blood2=image('blood.dmi',null,"2")
blood3=image('blood.dmi',null,"3")
blood4=image('blood.dmi',null,"4")
blood5=image('blood.dmi',null,"5")

mob
var
hp=25
maxhp=25
proc/attack(mob/attacker)
...
for(var/turf/T in view(1,src))
if(prob(25))
T.overlays+=pick(blood1,blood2,blood3,blood4,blood5)
Move()
.=..()
if(. && (hp/(maxhp/100))<=80 && prob( -(hp/(maxhp/100))+100 ))
var/turf/T=src.loc
if(T && istype(T))
T.overlays+=pick(blood1,blood2,blood3,blood4,blood5)

world/Repop()
.=..()
for(var/turf/T in world)
T.overlays.Remove(blood1,blood2,blood3,blood4,blood5)


That should do the trick. As soon as the player gets damaged below 80% of their HP, blood will start to appear wherever they walk. You should frequently call world.Repop() to clean the blood.
In response to CuriousNeptune
Oooh, here's a tip that you may want to know:

Instead of having
var/list/L = list(new X,new Y,new Z,new etc)
This works the sameway:
var/list/L = newlist(X, Y, Z, etc)
_>

or you could just make one blood object and randomly assign it an icon state when created >_>
obj/blood
icon='Blood.dmi'
New()
src.icon_state = pick(icon_states(src.icon)) //randomly selects an icon state in the icon's file.. I could've done rand(1,X) as well but meh
..()


I like using icon_states() rather than icon.IconStates <_<

- GhostAnime
In response to CuriousNeptune
That dosen't work.
In response to Jp
Thanks Jp, and for everyone else who helped me.
In response to Android Data
Why would you define a bunch of seperate images? You could define an obj and simply change its icon_state. If, say, the name of the icon was "blood_1" and that went up to five different states, just do something like this:
obj/blood/New() icon_state = "blood_[rand(1,5)]"
In response to Lendgens
Lendgens wrote:
Thanks Jp

Using objects to do visual tasks is a bad habit. Read my code and strongly consider using it, as it's much more robust with using overlays.
In response to Android Data
I don't want overlays. I want it so when you get shot, it splatters blood.
In response to Lendgens
Lendgens wrote:
I don't want overlays. I want it so when you get shot, it splatters blood.

You do want overlays. Using objects for that sort of a thing just gets you more and more to the limit. Bah!
Using overlays is the best thing to do here, since you just want a few visual splatters on the floor. Just read & understand my code plz.
In response to Android Data
I think I get what you're coding. I will use it, I see what you mean now :P, thanks Android.
In response to Lendgens
Lendgens wrote:
I think I get what you're coding. I will use it, I see what you mean now :P, thanks Android.

Yes! I did it! You're the first person who THINKS!
Yes! I found a person with an independant functioning brain! Woo-hoo!
In response to Android Data
Android Data wrote:
> world/Repop()
> .=..()
> for(var/turf/T in world)
> T.overlays.Remove(blood1,blood2,blood3,blood4,blood5)
>

That should do the trick. As soon as the player gets damaged below 80% of their HP, blood will start to appear wherever they walk. You should frequently call world.Repop() to clean the blood.

Me myself, I wouldn't suggest using Repop() to remove the stains. If it is a large world, everytime you call Repop(), it will lag immensly as it has to check every turf there is. I would suggest a different approach that is called after a spawn that removes each bloodstain individually.

mob/proc/attack(mob/attacker)
...
for(var/turf/T in view(1,src))
if(prob(25))
var/newoverlay=pick(blood1,blood2,blood3,blood4,blood5)
T.overlays+=newoverlay
spawn(40)
T.overlays-=newoverlay


Something like this, I would imagine, would be a lot nicer on your cpu. ;)

§atans§pawn
In response to Satans Spawn
Satans Spawn wrote:
Something like this, I would imagine, would be a lot nicer on your cpu. ;)

True, but when the player logs out it won't remove the blood.
In response to Android Data
If you keep the blood left there forever, you have poor design anyways. It should delete after a certain amount of time, or when no one is in view of it if you want to be discrete.
how do I shot web?
In response to Android Data
Android Data wrote:
Satans Spawn wrote:
Something like this, I would imagine, would be a lot nicer on your cpu. ;)

True, but when the player logs out it won't remove the blood.

You could always call a new proc with that turf and the overlay and arguments and go from there, so when the player logs out, the blood will still get deleted.

§atans§pawn
The idea behind that is just to create a new object, apply the right icon, and then place the object at the right location.


Of course, in Faction Wars, I have a system that uses trigonometry to make blood spray out. I'm not sure if you want that though.
Page: 1 2