ID:270827
 
Im gonna literally beg now because this is driving me insane! PLEASE! someone explain how to make a verb throw a laso from the usr to the mob and lock the mobs movement i want the laso to have rope connecting the usr to the Mob.
and please... NO beam demos.... no offense Radditz but its too difficult!



Ice: PLEASE!!!!
There's many ways of doing something so I'll do it my way... through the world of bad misuse of stuff (well, not misuse but probably horribly inefficient... don't have my laptop to code and test on :( )

WARNING: Untested, probably useless.. but hey, you MIGHT learn something and make your own

NOTICE: READ THE COMMENTS!!!

obj/lasso
icon='lasso.dmi'
var/mob/owner //..you will see why
density=0
layer=MOB_LAYER+1 //layer level, higher the number, the more apparent it will be (this will have the icon showing on top of a mob, if the mob's layer was not changed)
Hoop
icon_state="head"
density=1 //needed for Bump()
Bump(mob/M)//is called when it hits something, NOT when something hits it
if(istype(M)) //forgot if this method works to identify M as mob... better to use ismob()... in Bump, Enter, etc similar procs, it is neccesary to do these checks to stop runtime errors... safety checks are your friend
M.freeze=1 ..should be obvious
owner.verbs+=new/obj/lasso/verb/verbs/pull //This, I am nearly 100% is wrong...
spawn(100) if(src)//calls the following in 10 seconds, if the item still exists
if(M)M.freeze=0 //checks if M is still in the game and unfreezes it
if(owner)owner.verbs-=/obj/lasso/verbs/verb/pull //see comment of += version of this
del(src)
else del(src)//deletes itself if M is not a mob

New(mob/M,mob/N) //M = person followed. This is called when the item is created, format should be: new /obj/lasso/Head(victim, owner)
if(!M||!N)del src //if M/N is not specificed, it will be deleted
owner=N
loc=N.loc
walk_to(src,M) //makes the obj move towards M
Del()//called when item is deleted
for(var/obj/lasso/Body/B in world)
if(B.owner==owner)del B //looks for + deletes lasso body
..()//deletes itself at the end
Move()
.=..()
if(.) //if the move was successful
var/obj/lasso/Body/B=new(get_step(src,turn(src.dir,180))) //gets location of the last spot (spot before it moved foward) and creates the body of the lasso there
B.owner=owner //would've been easier to make it in the New() for Body with the dir but meh, I wanted to do it this way for some reason


Body //just for graphic purposes
//this has density of 0
icon_state="body"

Lasso/verb //Lets say lasso's icon_state is blank and is an item itself
capture(mob/M in oview())//oview() of usr
set name ="Drag Someone" //sets verb name
set src in usr.contents //verb shows when item in contents
if(!M)return //safety check
new /obj/lasso/Head(M, usr)
usr.verbs-=/obj/lasso/Lasso/verb/capture
verbs/verb/pull()
set name = "Pull lasso"
for(var/obj/lasso/Head/H in world) if(H.owner==usr)
var/mob/M = locate(/mob) in H.loc //looks for mob in hoop area
if(M)
M.freeze=0
M.loc=usr.loc
del H
return //stops loop+code

This is meant to teach you ONE possible way of doing what you said (from what I gathered).

Somebody double check this for me and prove me wrong, once again >_<

Live, learn, and die in a horrible fasioned way because nobody cares about you.. maybe not even in the way you die

- GhostAnime - Being emo is hardcore... but it's not like you guys care about me anyways...*slits wrist and sings Barney's theme song*
In response to GhostAnime
Dude, if you know the right way to implement a projectile then deliberately show somebody the wrong way, you need to stop offering code help. Actually if you show them the wrong way at all, it's time to stop. Bad enough to not know what you're doing, but worse to know and still do it wrong. If you're gonna use code you know is lousy, do it on your own, but don't offer it on the forums to people who need help.

Lummox JR
In response to Lummox JR
mob/var/canmove="Yes"

client/Move()
if(usr.canmove=="Yes")
return ..()

mob/verb/Lasso(var/mob/M in oview())
usr.dir=get_dir(usr,M)
new/obj/Lasso(usr,M)

obj/Lasso
icon='turfs.dmi'
icon_state="lasso"
New(mob/U,mob/T)
src.dir=U.dir
src.loc=U.loc
Lassinate(U,T)

proc/Lassinate(mob/U,mob/T)
var/obj/Rope/R=new(src.loc)
R.dir=src.dir
step_towards(src,T)
if(src in oview(0,T))
T.canmove="No"
else
spawn(5) src.Lassinate(U,T)

obj/Rope
icon='turfs.dmi'
icon_state="rope"
In response to Falacy
Falacy wrote:
mob/var/canmove=1
>
> client/Move()
> if(usr.canmove)
> return ..()
>
> mob/verb/Lasso(var/mob/M in oview())
> usr.dir=get_dir(usr,M)
> new/obj/Lasso(usr,M)
>
> obj/Lasso
> icon='turfs.dmi'
> icon_state="lasso"
> New(mob/U,mob/T)
> src.dir=U.dir
> src.loc=U.loc
> Lassinate(U,T)
>
> proc/Lassinate(mob/U,mob/T)
> var/obj/Rope/R=new(src.loc)
> R.dir=src.dir
> step_towards(src,T)
> if(src in oview(0,T))
> T.canmove = 0
> else
> spawn(5) src.Lassinate(U,T)
>
> obj/Rope
> icon='turfs.dmi'
> icon_state="rope"


whats with the yes and no?
In response to Lightning Inc.
Lightning Inc. wrote:
whats with the yes and no?

lol 1s and 0s are lame... plus usualy when i use canmove i have mulitple reasons, KO, busy, just plain no... so just using 1 and 0 for it doesnt satisfy my needs!
In response to GhostAnime
I think something like this would be better:

#define LASSO 1
mob
var
obj/item/equipped
status=0 //single variable for all status
ailments
Click()
if(usr.status&LASSO)return //the bound may not free the bound
if(status&LASSO)
usr<<"<b>You quickly free [src] from \his chains!</b>"
src<<"<b>[usr] has quickly freed you from your chains!</b>"
status&=~LASSO
new/obj/item/lasso(src.loc)
else usr<<"<b>[src] isn't bound.</b>"
obj/item
icon='items.dmi'
proc //two procs to call when equipping/unequipping stuff (perhaps to set variables and do stuff on an object-per-object basis)
equipped()
unequipped()
verb
get()
set src in oview(1)
Move(usr)
drop()
Move(usr.loc)
equip()
if(usr.equipped=src)
usr<<"<b>You have unequipped [src]!</b>" //note: using [src] so it's proper noun
unequipped()
usr.equipped=null
return
if(usr.equipped)
usr.equipped.equip() //unequip the object
usr.equipped=src
usr<<"<b>You have equipped [src]!</b>"
Del()
if(ismob(loc))
var/mob/parent=loc
if(parent.equipped==src)
usr=parent
equip() //unequip the object
return ..()
lasso/icon_state="lasso"

client
Move()
if(status&LASSO)return 0 //the bound may not move of their own accord
return ..()
Click(O)
var/turf/L
if(isturf(O))L=O
else if(isturf(O.loc))L=O.loc

if(L&&istype(mob.equipped,/obj/item/lasso)&&(O in view(mob))) //if we clicked on a spot on the map AND we have a lasso equipped AND the object is within range
del mob.equipped //delete it
missile(icon('items.dmi',"lasso"),L) //perform a visual animation that goes there.\
I don't know if I used this correctly but bear with me. Use s_missile for increased accuracy.

var/mob/M
for(var/mob/M in L)if(!M.status&LASSO)break //find someone that is occupying the tile that was hit but only if that person isn't already lasso'd
if(M) //if we found a target
M.status|=LASSO //lasso the mob
M.overlays+=image('items.dmi',"lasso") //apply overlays etc.
else return ..() //execute O.Click() if none of the above apply


I haven't actually tested it, but what it should do is allow you to pick up a lasso and equip it. Once equipped, you may click anywhere on the map to THROW the lasso there. Once thrown, it will use <code>missile()</code (though I think it returns immidiatly, allowing no chance of escape; I think hub://Spuzzum.s_missile would do better under the circumstance) to deliver the lasso there. If a person is standing on the tile the person will be bound by the lasso (and cannot move by themself). You can free someone by clicking them (assuming you're not bound yourself).
In response to Falacy
but you could just use !,null etc
In response to Lightning Inc.
Lightning Inc. wrote:
but you could just use !,null etc

lol and then you have to remember what each value represents... plus that still only leaves what, 3 choices? 1 0 null, still not enough, cause then what are you gona use when they can move?
In response to Falacy
if(canmove)//the var is 1
return ..()
if(!canmove)//the var is 0 or no in your opinion
return 0
btw this is the same guy just using a different key
In response to Falacy
Falacy wrote:
Lightning Inc. wrote:
whats with the yes and no?

lol 1s and 0s are lame... plus usualy when i use canmove i have mulitple reasons, KO, busy, just plain no... so just using 1 and 0 for it doesnt satisfy my needs!

Consider using bit flags if you have multiple booleans like KO and busy.

#define KO 1
#define BUSY 2
#define AFK 4
mob
var
status=0
verb
afk()
status^=AFK
if(status&AFK)usr<<"You have gone AFK."
else usr<<"You are back from AFK."
busy()
status^=BUSY
usr<<"You are [status&BUSY ? "now marked" : "no longer marked"] as busy."


Keep in mind that the numbers are binary. 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ...
In response to Android Data
lol and how is that easier then just putting busy?
In response to Falacy
Falacy wrote:
lol and how is that easier then just putting busy?

You're only using one variable instead of three.
Alternate version:

mob
var
afk=0
busy=0
ko=0
verb
afk()
afk=!afk
if(afk)usr<<"You have gone AFK."
else usr<<"You are back from AFK."
busy()
busy=!busy
usr<<"You are [busy ? "now marked" : "no longer marked"] as busy."


You should know that programming shouldn't be about doing things as easy as possible; it's about doing it as efficent as possible. My example allows you to store those three variables into one single variable, which I think is what you were on about. Even if it wasn't, it's a good lesson for you to use bit flags for booleans.
In response to Falacy
Falacy wrote:
lol and how is that easier then just putting busy?

Easier? Maybe not.

Faster and more robust? HECK YES.

But hey, if you want laggy games and broken code, go right ahead!
In response to Falacy
Well, for one, it uses less data. That's always awesome.
In response to Android Data
Programming is about producing a wanted result for some reason. Are their any understandable guides on bitflags anyway? I never really understood them.
In response to Falacy
Why would you have multiple reasons why a user can move? Scratch that, why would you even record them? That's ultimately useless.
In response to Lummox JR
Thank you for making me feel guilty :( Fine, fine, next time I'll be sure to give "good" help.. though as I like to piss people off, I'll probably make it a bit cryptic.

- GhostAnime - Feels very.. :( -ish ... God I wish work was finished now so I can go get a drink -_- >.> Atleast I left comments as so Ice can learn new tricks <.< I am not TOTALLY evil, about 89% I am ..
In response to CaptFalcon33035
CaptFalcon33035 wrote:
it uses less data. That's always awesome.

:[
In response to Android Data
using less data: since i doubt byond 1s and 0s are actualy boolean, and instead are integers, they would take up more memory then a character, ie B, but a whole string ie Busy would probably be more yes

efficieny: a program checking for a 1 vs a busy is not going to run 10 times slower, yeesh get a grip lol

using more variables: im not using more then 1 variable? im just setting canmove="Busy" canmove="KOed" etc...
Page: 1 2