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

Changing Shop Prices, Hiding map layers in-game
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
BlastedEarth




Joined: 05 Oct 2009
Posts: 243

PostPosted: Mon Jan 24, 2011 10:27 pm    Post subject: Changing Shop Prices, Hiding map layers in-game Reply with quote

I'm currently working on a "Trade" skill.

1.A global variable will be set as 'trade' and its value will be the trading skill of the player.

2. When you approach a shop, a script will be run to check the value of 'trade.'

3. If the value of 'trade' is more than 10 then all the item prices are reduced by one dollar.

4. if the value of 'trade' is more than 20 then all the item prices are reduced by two dollars. (etc.)

5. If current item costs only one dollar then it retains its price (But if cents are possible in OHR, please tell me how)

Any help writing this down into real plotscript? Thanks

Edit: Another question:

Is there a way to make an entire map layer invisible when a tag is set and visible again when the tag is unset?
_________________
So many ideas, so little focus. Monk spirit please lend me your power!

Back to top
View user's profile Send private message
BlastedEarths
Guest






PostPosted: Tue Jan 25, 2011 3:12 am    Post subject: Reply with quote

I should rename the topic title into Little Gigantor list of questions^^

Code:
# Agressive Enemy Scripts

plotscript,vigilant guards activate, begin
vigilant guard
vigilant guard1
end

script, vigilant guard, begin
  variable(guard, this map)

  guard := NPC reference (0)
  this map := current map

  while (this map == current map) do, begin
    variable (n1, n2, dist)

    n1 := hero X(me)
    n2 := NPC X(guard)
   
    dist := n2 -- n1
    if (n1 == n2, and, dist <= 8, and, dist >= -8)
    then (
    Alter NPC (0,NPCstat:move type,NPCmovetype:chaseyou)
    Alter NPC (0,NPCstat:move speed,5)
    )

    n1 := hero Y(me)
    n2 := NPC Y(guard)
    dist := n2 -- n1
    if(n1 == n2, and, dist <= 8, and, dist >= -8)
    then (
    Alter NPC (0,NPCstat:move type,NPCmovetype:chaseyou)
    Alter NPC (0,NPCstat:move speed,5)
    )
    wait(1)
    end
end


I edited the code in the gigantor list of questions about npcs having a sight, the problem is, how do you apply this to the other npc slots? it works for slot 0 but copying this into another script makes it not work.

(I forgot to log in again - BE)
Back to top
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Jan 25, 2011 3:45 am    Post subject: Reply with quote

Shops:
Unfortunately there aren't any commands for modifying shop contents, so you would have to create multiple copies of the shop, and then select the shop by script ('use shop')

NPCs:
The line to change would be
guard := NPC reference (0)

However, you can't just run two copies of this script at once, not until script multitasking is implemented. Luckily there is a solution: modify the scripts so that the while loop is in "vigilant guards activate".

But wait! That script is broken. The following lines don't make sense:
Code:
  dist := n2 -- n1
  if (n1 == n2, and, dist <= 8, and, dist >= -8)

because if n1 == n2, then dist == 0.

I've fixed that, and moved the while loop, in this new version:

Code:
plotscript, vigilant guards activate, begin
  variable (this map)

  this map := current map

  while (this map == current map) do, begin
    vigilant guard (0)  #change '0' to the correct NPC ID
    #vigilant guard (1) #repeat as desired
    wait (1)
  end
end

script, vigilant guard, NPC ID, begin
  variable (guard)

  guard := NPC reference (NPC ID)

  variable (x1, x2, y1, y2, dir, dist, start chasing)

  x1 := NPC X (guard)
  x2 := hero X (me)
  y1 := NPC Y (guard)
  y2 := hero Y (me)
  dir := NPC direction (guard)
 
  dist := x2 -- x1
  if (y1 == y2) then (
    if (dir == right && dist <= 8 && dist >= 0) then (start chasing := true)
    if (dir == left && dist >= -8 && dist <= 0) then (start chasing := true)
  )
  dist := y2 -- y1
  if (x1 == x2) then (
    if (dir == down && dist <= 8 && dist >= 0) then (start chasing := true)
    if (dir == up && dist >= -8 && dist <= 0) then (start chasing := true)
  )

  if (start chasing) then (
    Alter NPC (NPC ID, NPCstat:move type, NPCmovetype:chaseyou)
    Alter NPC (NPC ID, NPCstat:move speed, 5)
  )
end
 


Note that I changed the script to take an argument, so now you should instead change the "vigilant guard (0)" lines instead to set the correct NPC IDs.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
BlastedEarth




Joined: 05 Oct 2009
Posts: 243

PostPosted: Tue Jan 25, 2011 10:18 pm    Post subject: Reply with quote

This is very impressive, to think my script was getting really long copying, pasting, changing values while you just change a single line!

But is it possible to make the enemy sight spread on all sides? I've made a little drawing that might describe this better:


For example, if you have "Basic Stealth" then the enemy sight range is dimished by three blocks while you are in sneak mode(mode is toggled by pressing a key on the keyboard)

This is useful for events like this: You need to steal a key from an evil barbarian boss who is way powerful than you are. The barbarian boss is in the room and you must sneak past him to get the said artifact. If you have expert stealth (enemy sight - 6 blocks) then this quest is easier for you.

Also if it's possible to put the party into account, that is much more realistic. Like you are unable to sneak properly because the stocky knight next to you is very clumsy and his full plate needs some oil.
_________________
So many ideas, so little focus. Monk spirit please lend me your power!

Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue Jan 25, 2011 11:53 pm    Post subject: Reply with quote

So you want the guard to be able to detect in all directions at once, with the direction which it is facing makes no difference? Or do you want the guard to "see" further in the forward direction than the others? For example, the guard could have a cone of view 9 tiles long in the direction it's facing, and 5 tiles backwards.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
BlastedEarth




Joined: 05 Oct 2009
Posts: 243

PostPosted: Wed Jan 26, 2011 1:57 am    Post subject: Reply with quote

Yes, I like the first one, the guard can see all directions all at once, that's what I had in mind at first. But a cone view? Wow that sounds even cooler! You mean the guard can see more the closer you approach it?
_________________
So many ideas, so little focus. Monk spirit please lend me your power!

Back to top
View user's profile Send private message
Nepenthe




Joined: 27 Sep 2004
Posts: 132

PostPosted: Wed Jan 26, 2011 5:54 pm    Post subject: Reply with quote

I was going to give you my guard a.i. scripts from Machine Golem, since they included cone of sight, but... erm... I can't find them. A tip though: the only really tricky part is the wall checking. You need to find walls within the cone and reshape the field of view first. Unless, of course, you want your guards to see through walls.

I'll look for those scripts again tonight when I get home; just remembered a laptop I didn't check. But TMC will probably come up with something much more elegant by then anyway, right?
Back to top
View user's profile Send private message Visit poster's website AIM Address
BlastedEarth




Joined: 05 Oct 2009
Posts: 243

PostPosted: Wed Jan 26, 2011 9:58 pm    Post subject: Reply with quote

I'd like to look at them too, the more scripts i could learn from the better :-D

Btw, I checked out your website, those were cool hellraiser pixel art, is that in a game i could play? (edit: the golem game looks impressive too, is that downloadable somewhere?)
_________________
So many ideas, so little focus. Monk spirit please lend me your power!

Back to top
View user's profile Send private message
Nepenthe




Joined: 27 Sep 2004
Posts: 132

PostPosted: Wed Jan 26, 2011 10:44 pm    Post subject: Reply with quote

They weren't on that computer either, sorry. Unfortunately I never released Machine Golem (or any of my games, for that matter), and now it looks like all my work on it has been wiped from the face of the earth.

Still, I'll gladly offer my input if you have any design questions. Sadly, my plotscripting is a bit rusty.

(Also, Pinhead vs. Bradley is technically still in production, although back-burnered for the time being.)
Back to top
View user's profile Send private message Visit poster's website AIM Address
BlastedEarth




Joined: 05 Oct 2009
Posts: 243

PostPosted: Wed Jan 26, 2011 11:08 pm    Post subject: Reply with quote

That's alright, I'll just wait for TMC and work in the other aspects of my game at the moment. I'll surely be looking forward to Pinhead VS. Doug.
_________________
So many ideas, so little focus. Monk spirit please lend me your power!

Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Jan 27, 2011 3:57 am    Post subject: Reply with quote

Yeah, checking for walls is hard - you add almost arbitrary complex realistic wall checking. It's better not to be too realistic. To be honest, I'd forgotten about walls, since the original script didn't check for them.

I wrote some hideously complex line of sight scripts for guards in Eldardeen. They did all kinds of crazy things like use A/B/H/O bits in the wallmap to encode sub-tile obstructions, so I'd rather not try to fit them into a different game. So if Nepenthe hadn't lost them, his scripts would have been a better starting point.

Here's what I imagined for the shape of the field of view, with 9 tiles forward and 4 tiles in other directions (shown with different tiles for clarity). Aside from the number of tiles, is that what you wanted? (IMO 9 tiles is a bit big though, because it's well off the screen if facing up or down)



Scripting checking for the hero in that shape (with variable range) is fairly easy, just the wall checking is hard.

Nepenthe wrote:
They weren't on that computer either, sorry. Unfortunately I never released Machine Golem (or any of my games, for that matter), and now it looks like all my work on it has been wiped from the face of the earth.


Phew, at first I misread and thought you said all your games had been lost. That would have been awful. Made me realise I forgot to read the last couple updates to your Lost Son journal. Not enough lurking I guess!
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
BlastedEarths
Guest






PostPosted: Thu Jan 27, 2011 8:42 am    Post subject: Reply with quote

Here's what I imagined for the shape of the field of view, with 9 tiles forward and 4 tiles in other directions (shown with different tiles for clarity). Aside from the number of tiles, is that what you wanted? (IMO 9 tiles is a bit big though, because it's well off the screen if facing up or down)

- Yes, that looks really good! Can I have the script for that? Six tiles would do well, you're right 9 tiles is too big. And it's alright if the guards couldn't check for walls, I'm already blown away by the idea of having this feature in my game. Oh yeah sneak skill!

Scripting checking for the hero in that shape (with variable range) is fairly easy

- If this means that the range can be easily modified with simple tag checks then wow...

(I already checked, always log me in but I'm always not logged in when visiting, arr)
Back to top
Pepsi Ranger
Reality TV Host




Joined: 05 Feb 2003
Posts: 493
Location: South Florida

PostPosted: Thu Jan 27, 2011 11:01 am    Post subject: Reply with quote

For some reason, I'm thinking that zone checking would be beneficial to the wall perspective argument. Perhaps you could paint the patrol area with zones and use a conditional that ignores any part of the cone that steps outside the zone. Obviously, you wouldn't zone in walls, so that might fix your problem. The "read zone" plotscript command is highly versatile and very simple to use, and is welcoming to even the shiest of plotscripters.
_________________
Progress Report:

The Adventures of Powerstick Man: Extended Edition

Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.

Tightfloss Maiden

Currently Updating: Chapter 2
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
msw188guest
Guest






PostPosted: Thu Jan 27, 2011 12:33 pm    Post subject: Reply with quote

Using zones might be helpful in limited circumstances, but it doesn't eliminate the fundamental problem. A giant pillar in the middle of a room should stop a guard from seeing through it, but the tiles on both sides of the pillar would be in the same zone if the guard has the ability to walk around it. Now if the guard doesn't have a lot of spaces he can walk on, you could conceivably make a separate zone for every single tile the guard can be on, together with every direction he could be facing while on that tile. This seems like a bit less thought to the script, but potentially a lot more grunt work through the course of the game.
Back to top
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Fri Jan 28, 2011 5:32 am    Post subject: Reply with quote

Zones... good idea. I used a zone to mark the obstructions instead of checking the wallmap, since often you can see past objects which you can't walk over.

OK the script is here: 'Scripts:Line of sight'. Wow, that got big and complex. But I did comment it throughly, it should still be understandable.

There's a debug button (D in the example on-keypress script), which produces something like this:

(The left arrow is the hero, and the right one is a guard)

(Also, you might notice the field of view shape is slightly different to my mockup. And in hindsight I think the shape is overcomplex, and a simple rectangle would have worked just as well. Oh well, it doesn't make the script much more complex)

I haven't finished writing the instructions, but they're quite simple: if you want proper line of sight checking paint walls or anything else you can't see through with some zone, and set the "zone:LOS obstruct" constant. Set the other constants if you want to use the debug key. Set the "forward/rear view distance" globals somewhere before the start of the script.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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