Community
SCI Programming => Mega Tokyo SCI Archive => Topic started by: Jim C on December 13, 2003, 04:42:33 PM
-
Hi:
My short game is almost finished! I have a question, though. If I want to be able to give an item to another actor, but only when I'm within a certain distance of him, how do I do it? This other actor can move, so that complicates things a little. I'm sure there's an easy way to do it. Can anyone help?
Thanks!
-
Here you go Jim try something like this:
(if(Said('give/fish'))
(if(send gEgo:has(INV_FISH))
(if(< (send gEgo:distanceTo(hMan)) 30)
(send gEgo:put(INV_FISH))
Print("Here ya go buddy!"))
(else Print("Stand closer to the hungry man!"))
)
(else Print("You don't have a fish to give!"))
)
The other actor moving is irrelevant, on line 3 it checks to see the distance to hMan if it is less than 30 you're close enough, otherwise you're told to stand closer
-
Ah, great! Thanks so much! That's exactly what I needed.