 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
adlingtont
Joined: 29 Aug 2006 Posts: 3
|
Posted: Tue Aug 29, 2006 6:25 am Post subject: is there a way to... |
|
|
i have 3 qestions:
1. is there a way 2 make a kinda friends thing. so say your playing a character that goes to school and they meet someone, at first there a complete stranger but then as you talk 2 them they become more of a friend.
2. is there a way that you can ring someone and make them come to a location, as a npc or party member, but there arnt normaly at that location. this links into my first idea cuz u can only ring them when there a friend.
3. can you make it so that an npc is at a location randomly. like say if you went to the map they might not b there but then if u left and came back they r there.
thanks in advance. |
|
Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Tue Aug 29, 2006 7:49 am Post subject: |
|
|
adlingtont wrote: | 1. is there a way 2 make a kinda friends thing. so say your playing a character that goes to school and they meet someone, at first there a complete stranger but then as you talk 2 them they become more of a friend. |
Yes. The best way to do this is probably with global variables (which are saved in save games.) Just increment the friendship variable every time you talk to someone.
Code: | define script,increment friendship,none
global variable(1, friendship) #define global variable 1 as friendship
script,increment friendship,begin
friendship += 1
end
|
Just call the increment friendship script whenever you talk to an npc, and that npc will become friendlier. Define multiple global variables (with different names) if you want to keep track of the friendship levels of multiple npcs.
You can also control how much the friendship is increased by adding an argument to the script.
Code: | define script,increment friendship,1,1
global variable(1, friendship) #define global variable 1 as friendship
script,increment friendship,amount,begin
friendship += amount
end
|
The first 1 in the define script command indicates there is one argument in the script, and the second 1 is its default value. In the script definition, amount is the name of the variable that takes the argument, so the friendship is increased by whatever argument you pass the script in this case.
NPCs can be set to call scripts and pass arguments to them in custom.
For a link to a good discussion on arguments and info on how to use them in Hamsterspeak, look here.
adlingtont wrote: | 2. is there a way that you can ring someone and make them come to a location, as a npc or party member, but there arnt normaly at that location. this links into my first idea cuz u can only ring them when there a friend. |
Sure. In this case, you may want to link an item to a plotscript, so that plotscript is called whenever you use the item (in this case a phone?)
Code: | define script,call friend,none
script,call friend,begin
walk NPC to x(target, xLocation)
walk NPC to y(target, yLocation)
end
|
Here, target equals the id of the npc you want to call, and xLocation and yLocation are the cartesian coordinates you want to bring the NPC to. You could also update this to include arguments, like in the above example, and have different items call different NPCs with the same script, or have them go to different places.
Beware that walking NPCs will be screwed up by walls and other NPCs. You can alleviate this problem by using the suspend obstruction and suspend npc walls commands. You could also be more realistic and have the NPC walk around everything, but that would require programming a pathfinding routine.
adlingtont wrote: | 3. can you make it so that an npc is at a location randomly. like say if you went to the map they might not b there but then if u left and came back they r there.
thanks in advance. |
Again, yes. All you have to do is create a random number, and create an NPC on certain values and not create them on others.
Code: | define script,place random npc,none
script,place random npc,begin
if (random(1, 100) >> 50) then(
create npc(id, x, y)
)
end
|
Here, id is the id of the npc you want to create, and x and y is their location. We create a random number between 1 and 100, and if it's greater than 50, the npc is created, so there is a 50% chance he will be there. You can tweak these numbers however you like.
Just make this the on map load script, and 50% of the time, the npc will be there. |
|
Back to top |
|
 |
adlingtont
Joined: 29 Aug 2006 Posts: 3
|
Posted: Tue Aug 29, 2006 10:38 am Post subject: |
|
|
ok, chears camdog!
soz another qestion, with the second one can it b posible 2 invite an npc to your house. say you ring them then they spawn on that map (your house map). but there never normally on that map?
sorry about these being probably really simple qestions but im new and an idiot. |
|
Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Tue Aug 29, 2006 11:44 am Post subject: |
|
|
In order to do this, you simply need to check if the npc exists on the map (ie it has been created by the above example script). The command NPC copy count(id) returns the number of npcs on a map of that id. So, if you know the ids of the npcs you're checking for the visits, you can count the number of those npcs on the map, and you'll know they weren't spawned if you get a 0.
Code: | define script,call friend,none
script,call friend,begin
if (NPC copy count(target) >> 0) then (
walk NPC to x(target, xLocation)
walk NPC to y(target, yLocation)
)
else (
#let the player know that no one is coming
)
end |
The else block is optional, and can be omitted if you don't want the game to take any special action when the friend you invited isn't around.
Might I suggest giving the plotscripting dictionary a quick read through? It's broken down according to category, and there are lots of commands that will relate to what you're trying to do, or give you ideas of what is possible with plotscripting.
[edit] Whoops! I misunderstood your question. What you want is easy too, though. Just check the npc copy count as described above, and make a copy before you move him if he doesn't exist.
Code: | define script,call friend,none
script,call friend,begin
if (NPC copy count(target) >> 0) then (create npc(target, x, y))
walk NPC to x(target, xLocation)
walk NPC to y(target, yLocation)
end |
Make sure you get the parentheses right! Each open parentheses requires a closing one. |
|
Back to top |
|
 |
|
|
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
|