Throw objects one tile away from mob

How, what and why to code in BYOND.

Moderators: MisterPerson, Code Maintainers

qsleepy
 
Joined: Fri Feb 26, 2016 11:32 pm
Byond Username: Qsleepy

Throw objects one tile away from mob

Postby qsleepy » Sun Feb 28, 2016 2:31 am #157859

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.



User avatar
Remie Richards
 
Joined: Thu Apr 17, 2014 7:11 pm
Location: England, UK, Earth, Sol, Milky Way, Local Group, Virgo Supercluster, Known Universe
Byond Username: CrimsonVision

Re: Throw objects one tile away from mob

Postby Remie Richards » Sun Feb 28, 2016 8:38 am #157964

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.
私は完璧

qsleepy
 
Joined: Fri Feb 26, 2016 11:32 pm
Byond Username: Qsleepy

Re: Throw objects one tile away from mob

Postby qsleepy » Sun Feb 28, 2016 11:56 am #157997

I do have throw_at_fast in the code, it seems to hit the xeno...

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: Throw objects one tile away from mob

Postby oranges » Sun Feb 28, 2016 7:52 pm #158084

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.

qsleepy
 
Joined: Fri Feb 26, 2016 11:32 pm
Byond Username: Qsleepy

Re: Throw objects one tile away from mob

Postby qsleepy » Sun Feb 28, 2016 11:24 pm #158128

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:

qsleepy
 
Joined: Fri Feb 26, 2016 11:32 pm
Byond Username: Qsleepy

Re: Throw objects one tile away from mob

Postby qsleepy » Mon Feb 29, 2016 5:24 pm #158306

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?

User avatar
oranges
Code Maintainer
 
Joined: Tue Apr 15, 2014 9:16 pm
Location: #CHATSHITGETBANGED
Byond Username: Optimumtact
Github Username: optimumtact

Re: Throw objects one tile away from mob

Postby oranges » Mon Feb 29, 2016 10:31 pm #158384

I suspect what you want is
F.throw_at_fast(target, 30, 2)

leave the thrower off

see if that helps.

qsleepy
 
Joined: Fri Feb 26, 2016 11:32 pm
Byond Username: Qsleepy

Re: Throw objects one tile away from mob

Postby qsleepy » Thu Mar 03, 2016 3:19 am #158995

Nope, back to hitting the sentinel and landing below it's feet.


Return to Coding

Who is online

Users browsing this forum: No registered users