Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

plotscripting issue

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
binoal




Joined: 20 Jun 2009
Posts: 123
Location: My Own Little World

PostPosted: Sun Aug 23, 2009 2:53 pm    Post subject: plotscripting issue Reply with quote

this isnt a problem i ran into in any particular game, i have been bugged by it several times. How would i get a X Y coordinate for create NPC from hero direction? i want to create the npc directly in front of the character, and the only succesful way i have found is to use multiple if commands. Is there any way to do this in a less bulky fashion?
_________________
Resident Evil RPG Demo

http://www.castleparadox.com/gamelist-display.php?game=963

Legend Of Zelda: Reptilian Warlord Demo

http://www.castleparadox.com/gamelist-display.php?game=961
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Sun Aug 23, 2009 5:49 pm    Post subject: Reply with quote

That's pretty much the only way to do it. You can make the script appear less 'bulky' by using a switch command instead of a bunch of if commands:

Code:
switch(herodirection(me)),do
 begin
  case(north),do
    (createnpc(55,herox(me),heroy(me)--1))
  case(east),do
    (createnpc(55,herox(me)+1,heroy(me))
  case(south),do
    #and so on...

_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Aug 24, 2009 4:51 am    Post subject: Reply with quote

There is a short way. I use these scripts all the time:

Code:
script, dir X, dir, begin
  switch (dir) do (
    case (up, down) do (return (0))
    case (right) do (return (1))
    case (left) do (return (-1))
  )
end

script, dir Y, dir, begin
  switch (dir) do (
    case (left, right) do (return (0))
    case (down) do (return (1))
    case (up) do (return (-1))
  )
end

# return the distance of a point in the specified direction from the origin
script, directional dist, x, y, dir, begin
  switch (dir) do (
    case (up) do (return (0 -- y))
    case (right) do (return (x))
    case (down) do (return (y))
    case (left) do (return (0 -- x))
  )
end


Using these, you can write this:

Code:
dir := hero direction(me)
createnpc(55, hero X(me) -- dir X(dir), hero X(me) -- dir Y(dir))


Normally you would multiply dirX, dirY by the desired distance; I've implicitly multiplied by -1.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Mon Aug 24, 2009 8:01 am    Post subject: Reply with quote

The Mad Cacti wrote:
There is a short way. I use these scripts all the time:


Argh, I wish I'd thought of something like that years ago. I can't tell you how many if-statements I have dedicated to handling four directional cases.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Mon Aug 24, 2009 10:44 am    Post subject: Reply with quote

I used something similar in Baconthulhu. it saved worlds of trouble.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Spoon Weaver




Joined: 18 Nov 2008
Posts: 421
Location: @home

PostPosted: Mon Aug 24, 2009 2:07 pm    Post subject: Reply with quote

I heart IF statements
Back to top
View user's profile Send private message Send e-mail Visit poster's website
binoal




Joined: 20 Jun 2009
Posts: 123
Location: My Own Little World

PostPosted: Mon Aug 24, 2009 6:21 pm    Post subject: Reply with quote

me 2 <333 lol Happy
_________________
Resident Evil RPG Demo

http://www.castleparadox.com/gamelist-display.php?game=963

Legend Of Zelda: Reptilian Warlord Demo

http://www.castleparadox.com/gamelist-display.php?game=961
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group