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

The Drizzle's plotscripting problems

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
The Drizzle
Who is the Drizzle?




Joined: 12 Nov 2003
Posts: 432

PostPosted: Mon Aug 11, 2008 3:51 am    Post subject: The Drizzle's plotscripting problems Reply with quote

Code:
if (check equipment (find hero(hero:Rasp),1) == 229)
then (
write enemy data (0,enemy:experience,(read enemy data(0,enemy:experience)*11/10)))


So this is my code. It works I think. But I want to make it apply to every enemy. Can someone tell me how to do this?

Additional question: If I only wanted to do enemies 2-5, how would I do that?
_________________
My name is...
The shake-zula, the mic rulah, the old schoola, you wanna trip? I'll bring it to yah...


Last edited by The Drizzle on Thu Aug 14, 2008 4:29 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
TwinHamster
♫ Furious souls, burn eternally! ♫




Joined: 07 Mar 2004
Posts: 1352

PostPosted: Mon Aug 11, 2008 4:36 am    Post subject: Reply with quote

Well, I guess you could use a loop to apply that to as many enemies as you want:

Code:

variable(enemy count)
set variable (enemy count, 100)

while(enemy count>>0)
do(
write enemy data (Enemy Count, enemy:experience,(read enemy data(Enemy Count,enemy:experience)*11/10)))

set variable (enemy count, enemy count--1)
)

#Where 100 should be the highest ID number of an Enemy
Back to top
View user's profile Send private message Send e-mail AIM Address
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Mon Aug 11, 2008 6:47 pm    Post subject: Reply with quote

Wow, I would never think to do it that way. It feels kind of backwards to me, I guess. I would probably have a for loop instead like so:

Code:
variable(i, min enemy ID, max enemy ID)
min enemy ID:=2
max enemy ID:=5
for(i, min enemy ID, max enemy ID), do
 begin
  write enemy data (i,enemy:experience,(read enemy data(0,enemy:experience)*11/10))
 end

_________________
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
The Drizzle
Who is the Drizzle?




Joined: 12 Nov 2003
Posts: 432

PostPosted: Thu Aug 14, 2008 4:52 am    Post subject: Reply with quote

Since I know I'm probably going to have a lot of problems plotscripting, i decided to rename this thread stop making new plotscripting threads.

The purpose of this script is to create a method of lockpicking. If the player has a torsion wrench in their inventory and they encounter a lock, menu:pin1 opens up. Basically it looks like a menu with the numbers 1-5 on it. If the incorrect number is picked, then a message appears saying fail. If the correct number is picked, you continue to menu:pin2. Pin 2 will have the same numbers, minus the one you picked (if you picked 4, it will display 1, 2, 3, & 5). If successful, menu 2 leads to menu three which will have the same numbers minus the previous 2 you picked (If you picked 2, it will display 1, 3, & 5). If you pick the correct number here, the lock will open and a message will appear saying "Success". Easy locks will have 3 numbers to choose from (leaving 1 choice for menu:pin3), Medium locks will have 4 numbers, Hard locks will have 5. Failed attempts delete a torsion wrench from your inventory, successful attempts do not.

tags in this script are:
30: #1 picked first
31: #2 picked first
32: #3 picked first
33: #4 picked first
34: #5 picked first
35: #1 picked second
36: #2 picked second
37: #3 picked second
38: #4 picked second
39: #5 picked second
40: #1 picked last
41: #2 picked last
42: #3 picked last
43: #4 picked last
44: #5 picked last
45: Medium difficulty lock
46: Hard difficulty lock
40: #1 picked
41: #2 picked
42: #3 picked
43: #4 picked
44: #5 picked

Here's my code.

Code:
define script (0, lock1, none)
define script (1, unlockone, none)
define script (2, unlocktwo, none)
define script (3, unlockthree, none)
define script (autonumber, reset lock tags, none)
define script (autonumber, lockpick, none)
define script (autonumber, unlockone1, none)
define script (autonumber, unlocktwo1, none)
define script (autonumber, unlockthree1, none)

#-------------------------------------------------------------------------------------

script,lock1,begin

if (inventory (202) >> 0) #Must have torsion wrench
then(
set variable (currentlock, 1)
lockpick)
else (show text box (197),wait for text box) #No picks

end

#-------------------------------------------------------------------------------------

script,unlockone,begin

if (currentlock == 1)
then(unlockone1)

end

#-------------------------------------------------------------------------------------

script,unlocktwo,begin

if (currentlock == 1)
then(unlocktwo1)

end

#-------------------------------------------------------------------------------------

script,unlockthree,begin

if (currentlock == 1)
then(unlockthree1)

end

#-------------------------------------------------------------------------------------

script,reset lock tags,begin

# sets all lock tags to off

set tag (30,off)
set tag (31,off)
set tag (32,off)
set tag (33,off)
set tag (34,off)
set tag (35,off)
set tag (36,off)
set tag (37,off)
set tag (38,off)
set tag (39,off)
set tag (40,off)
set tag (41,off)
set tag (42,off)
set tag (43,off)
set tag (44,off)
set tag (45,off)
set tag (46,off)
set tag (47,off)
set tag (48,off)
set tag (49,off)
set tag (50,off)
set tag (51,off)

end

#-------------------------------------------------------------------------------------

script,lockpick,begin

if (currentlock == 1)
then(set tag(46, on) #hard difficulty
open menu (menu:pin1))

end

#-------------------------------------------------------------------------------------

script,unlockone1,begin

if(
check tag (33) == on)
then(
open menu (menu:pin2))
else (
close menu (menu:pin1)
close menu (menu:pin2)
close menu (menu:pin3)
delete item (202) #removes a torsion wrench
show text box (198),wait for text box #Failed
reset lock tags)

end

#-------------------------------------------------------------------------------------

script,unlocktwo1,begin

if(
check tag (35) == on)
then(
open menu (menu:pin3))
else (
close menu (menu:pin1)
close menu (menu:pin2)
close menu (menu:pin3)
delete item (202) #removes a torsion wrench
show text box (198),wait for text box #Failed
reset lock tags)

end

#-------------------------------------------------------------------------------------

script,unlockthree1,begin

if(check tag (41) == on)
then(
set tag (52, on)
show text box (199),wait for text box #Success
set variable (currentlock,0)
reset lock tags)
else (
close menu (menu:pin1)
close menu (menu:pin2)
close menu (menu:pin3)
delete item (202) #removes a torsion wrench
show text box (198),wait for text box #Failed
reset lock tags)

end


My problem isn't getting this thing to work. It already does. My real problem is that each lock will require 4 scripts of its own in addition to the scripts for lockpicking in general. That's a lot of scripts to keep track of for me. I was wondering someone could help me figure out how to compress each lock's scripts to take up less space/scripts. If any more information is necessary, let me know. I'm sort of new to this so I don't know what needs to be included and what doesn't.
_________________
My name is...
The shake-zula, the mic rulah, the old schoola, you wanna trip? I'll bring it to yah...
Back to top
View user's profile Send private message AIM Address
Camdog




Joined: 08 Aug 2003
Posts: 606

PostPosted: Thu Aug 14, 2008 6:26 am    Post subject: Reply with quote

Let's see... Working with what you've got, I'd say you could make your current series of unlock scripts generic, and fill out what the proper unlock sequence is in a single plotscript using global variables. Something like this...

Code:
global variable(1, firstNum)
global variable(2, secondNum)
global variable(3, thirdNum)

script, lock, which = 1, begin
    #set firstNum, secondNum, and thirdNum to the tags which
    #correspond to the correct choices
    switch(which) do(
        case(1) do(
            firstNum := 33
            secondNum := 35
            thirdNum := 41
        )
        case(2) do(
            #fill in the sequence for another lock....
        )
        #etc....
    )

    if (inventory (202) >> 0) #Must have torsion wrench
    then(
        set variable (currentlock, 1)
        lockpick
    )
    else (show text box (197),wait for text box) #No picks
end


From there, you can use the unlock scripts you have normally, but use the same ones for every lock, and replace the hard coded tag numbers with the variables firstNum, secondNum, and thirdNum. Once all that is set up, any time a lock is triggered, just pass the lock function a number which corresponds to the lock you're trying to unlock. If an NPC triggers that function, you can set it to pass a value to the plotscript right in the NPC editor.
Back to top
View user's profile Send private message
The Drizzle
Who is the Drizzle?




Joined: 12 Nov 2003
Posts: 432

PostPosted: Thu Aug 14, 2008 2:11 pm    Post subject: Reply with quote

I don't want to sound too dumb, but what exactly does the "which=1" do?
_________________
My name is...
The shake-zula, the mic rulah, the old schoola, you wanna trip? I'll bring it to yah...
Back to top
View user's profile Send private message AIM Address
MADSOFT Games
Representing more than 80% of the internet!




Joined: 06 Nov 2004
Posts: 221
Location: AWESOME land

PostPosted: Thu Aug 14, 2008 2:22 pm    Post subject: Reply with quote

I think "which" is a placeholder...?
As in, replace it with whatever number or w/e should go there according to your game's .hsi file
_________________
http://www.madsoftgames.net/
http://www.madsoftgames.org/
http://www.andrewdavid.net/


Last edited by MADSOFT Games on Thu Aug 14, 2008 3:22 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Bob the Hamster
OHRRPGCE Developer




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

PostPosted: Thu Aug 14, 2008 2:26 pm    Post subject: Reply with quote

The Drizzle wrote:
I don't want to sound too dumb, but what exactly does the "which=1" do?


Not a dumb question at all.

The "lock" script has an argument named "which"

the which=1 means that the default value of which is 1, so if you used the lock script with no argument it would assume you were trying to pick lock number 1

Here is a better example of a script that uses default arguments.

Code:

script, fast walk wait, who=me, direction=south, distance=1, speed=10, begin
  set hero speed(who, speed)
  walk hero(who, direction, distance)
  wait for hero(who)
  set hero speed(who, 4)
end


So you could use the above script like this:

Code:

fast walk wait (me, west)


But if you wanted to, you could be more specific

Code:

fast walk wait (me, west, 3, 5)


EDIT: Oh, hey! I noticed you are still using "define script" That is okay (it still works) but there is a new easier way. See this article for more:

How do I convert my scripts from old to new syntax?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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