Page 1 of 1

Throw objects one tile away from mob

Posted: Sun Feb 28, 2016 2:31 am
by qsleepy
Hi guys!


Very new here and to coding, thanks for all the support so far on the IRC and whatnot!


I have a code in alien_powers that tries to throw_very_fast a minibomb. In that code, you have neurotoxin, which used code to determine which way the character is face, and shoots the neuro one step away from them, assumably to avoid hitting the xeno, like mine is currently doing.

The problem is, I cannot find how to implement the same type of code.

Code: Select all

/obj/effect/proc_holder/alien/wad
	name = "Spit Explosive Wad!"
	desc = "Spits an explosive wad. Pretty stupid."
	plasma_cost = 50
	action_icon_state = "alien_neurotoxin"

/obj/effect/proc_holder/alien/wad/fire(atom/target,mob/living/carbon/user = usr)
	user.visible_message("<span class='danger'>[user] Spit Wad!</span>", \
						"<span class='danger'>You Spit the Wad!</span>")

	var/turf/T = user.loc
	var/turf/U = get_step(user, user.dir) // Get the tile infront of the move, based on their direction
	if(!isturf(U) || !isturf(T))
		return 0

	var/obj/item/weapon/grenade/F = new /obj/item/weapon/grenade/syndieminibomb(user.loc)
        F.current = U
	F.yo = U.y - T.y
	F.xo = U.x - T.x

	F.throw_at_fast(target, 30, 2,U)
	spawn(15)
		F.prime()

As you can see, I borrow the code from neurotoxin just below this in the script. It returns undefined variables for F.current,.xo and .yo.


I've tried searching git and asking on IRC, people seem busy so I will put this here and see if some kind soul can help explain how to make this system work!

Thanks again.

Re: Throw objects one tile away from mob

Posted: Sun Feb 28, 2016 8:38 am
by Remie Richards
Neurotoxin spit is a bullet, an actual projectile.
projectiles have the three vars you're struggling with (current, yo, xo).
Since this is a grenade item, you can just throw it, without those 3 vars.

Re: Throw objects one tile away from mob

Posted: Sun Feb 28, 2016 11:56 am
by qsleepy
I do have throw_at_fast in the code, it seems to hit the xeno...

Re: Throw objects one tile away from mob

Posted: Sun Feb 28, 2016 7:52 pm
by oranges
Apologies for not answering yesterday, I was marathonning tv shows.

I suspect that you're getting the alien passed through as the target and that's why the grenade hit's the alien.

Re: Throw objects one tile away from mob

Posted: Sun Feb 28, 2016 11:24 pm
by qsleepy
No need for apology, I felt bad and kind of guessed that you were tired of my questions! Which I understand completely. You've all been super cool and this has been a fun experience!



In the code for throw_at_fast, I used, U, which is defined as the space in front of the direction the player is facing.


I am pretty new, could you guys show me how it would be done properly? This is kicking my ass more than I thought! :thelaw:

Re: Throw objects one tile away from mob

Posted: Mon Feb 29, 2016 5:24 pm
by qsleepy
Ok, so I switched the code around to as follows;


F.throw_at_fast(U, 30, 2,target)


It works now and throws the bomb in front of the xeno, but on 1 tile right in front. Any idea why it isn't flying farther with the throw_at_fast variable being 30?

Re: Throw objects one tile away from mob

Posted: Mon Feb 29, 2016 10:31 pm
by oranges
I suspect what you want is
F.throw_at_fast(target, 30, 2)

leave the thrower off

see if that helps.

Re: Throw objects one tile away from mob

Posted: Thu Mar 03, 2016 3:19 am
by qsleepy
Nope, back to hitting the sentinel and landing below it's feet.