 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
Posted: Sat Jul 29, 2006 10:53 am Post subject: Tag checking for weapons |
|
|
Okay, so I want to make it so that either the "each step" or "autorun" and the "instead of battle" scripts for maps, I want the game to check which weapon is equipped, and accordingly it will change the battle picture. Since there will be more than one weapon, how do I write the script so that the picture and attack will be correct, according to the weapon?
Code: | if (check tag(tag:Pistol Equip))
then,begin
(write spell (hero:Reed,0,0,atk:Pistol))
set hero picture (hero:Reed,1,inside battle)
end
else,begin
(write spell (hero:Reed,0,0,0))
set hero picture (hero:Reed,0,inside battle)
end
if (check tag(tag:Rifle Equip))
then,begin
(write spell (hero:Reed,atk:Pistol))
set hero picture (hero:Reed,3,inside battle)
end
else,begin
(write spell (hero:Reed,0,0,0))
set hero picture (hero:Reed,0,inside battle)
end |
That causes no attack to be used at all, since the else causes the hero to be unarmed even if he has a pistol. What should I do to get this to work for four different weapons? _________________ http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00
 |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Sun Jul 30, 2006 10:14 am Post subject: |
|
|
Code: | if (check tag(tag:Pistol Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
end, else, begin
if (check tag(tag:Rifle Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
end,else,begin,
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
end
end |
I cleaned up the script, and fixed a bug for you. The key to this type of thing (until Ubersetzung comes out, at least) is to nest the if() then...else blocks, like this:
Code: | if something then
great!
else
if something else then
great!
else
if something else 2 then
great
else
nothing worked :(
end
end
end |
_________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Jul 30, 2006 3:12 pm Post subject: |
|
|
Huh? What's going to change when U. comes out? _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
FnrrfYgmSchnish Probably the Grand Poobah or something

Joined: 19 Jul 2003 Posts: 88 Location: Not here
|
Posted: Sun Jul 30, 2006 5:34 pm Post subject: |
|
|
Just a random guess, but since "Else" and "If" are involved... maybe the addition of an "Elsif"-type thing for plotscripts? |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Sun Jul 30, 2006 5:56 pm Post subject: |
|
|
In U., I'd just do this:
Code: | if (check tag(tag:Pistol Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
exit script
end
if (check tag(tag:Rifle Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
exit script
end
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle) |
... actually, I lied. Right now, I'd do this:
Code: | write spell (hero:Reed,0,0,0) #default
set hero picture (hero:Reed,0,inside battle)
#special cases:
if (check tag(tag:Pistol Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
end
if (check tag(tag:Rifle Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
end |
_________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Jul 30, 2006 10:36 pm Post subject: |
|
|
Code: |
switch (true) do, begin
case (check tag(tag:Pistol Equip)) do(
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
)
case (check tag(tag:Rifle Equip)) do (
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
)
else (
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
)
end |
ehehe... _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Mon Jul 31, 2006 2:57 am Post subject: |
|
|
The Mad Cacti wrote: | Code: |
switch (true) do, begin
case (check tag(tag:Pistol Equip)) do(
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
)
case (check tag(tag:Rifle Equip)) do (
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
)
else (
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
)
end |
ehehe... |
That is an abomination of nature. _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Aug 01, 2006 1:35 am Post subject: |
|
|
Mike Caron wrote: | The Mad Cacti wrote: | Code: |
switch (true) do, begin
case (check tag(tag:Pistol Equip)) do(
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
)
case (check tag(tag:Rifle Equip)) do (
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
)
else (
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
)
end |
ehehe... |
That is an abomination of nature. |
I made sure to make switch alot more abusable than it is in other languages. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Mike Caron Technomancer

Joined: 26 Jul 2003 Posts: 889 Location: Why do you keep asking?
|
Posted: Tue Aug 01, 2006 2:27 pm Post subject: |
|
|
The Mad Cacti wrote: | Mike Caron wrote: | The Mad Cacti wrote: | Code: |
switch (true) do, begin
case (check tag(tag:Pistol Equip)) do(
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
)
case (check tag(tag:Rifle Equip)) do (
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
)
else (
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
)
end |
ehehe... |
That is an abomination of nature. |
I made sure to make switch alot more abusable than it is in other languages. |
It should not work that way! it should be a jump table, with optimizations, and... *cry* _________________ I stand corrected. No rivers ran blood today. At least, none that were caused by us.
Final Fantasy Q
OHR Developer BLOG
Official OHRRPGCE Wiki and FAQ |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed Aug 02, 2006 12:33 am Post subject: |
|
|
Mike Caron wrote: | The Mad Cacti wrote: | Mike Caron wrote: | The Mad Cacti wrote: | Code: |
switch (true) do, begin
case (check tag(tag:Pistol Equip)) do(
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
)
case (check tag(tag:Rifle Equip)) do (
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
)
else (
write spell (hero:Reed,0,0,0)
set hero picture (hero:Reed,0,inside battle)
)
end |
ehehe... |
That is an abomination of nature. |
I made sure to make switch alot more abusable than it is in other languages. |
It should not work that way! it should be a jump table, with optimizations, and... *cry* |
Come now, life can't always be fair... _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
|
Back to top |
|
 |
Camdog
Joined: 08 Aug 2003 Posts: 606
|
Posted: Thu Aug 03, 2006 5:53 am Post subject: |
|
|
I'd actually do it as an instead of battle script, as an every step script would use a lot of unneccessary processing time, and an autorun script (I assume you mean something like an on map load script or a new game script) would lose accuracy if someone changed equipment in the middle of a map.
Game.exe automatically passes the battle formation you would have fought as the first argument to an instead of battle script, so you can use fight formation to fight the appropriate battle as normal after you perform the appropriate calculations, like so:
Code: |
begin, my instead of battle script, formationNum, begin
write spell (hero:Reed,0,0,0) #default
set hero picture (hero:Reed,0,inside battle)
#special cases:
if (check tag(tag:Pistol Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,1,inside battle)
end
if (check tag(tag:Rifle Equip)) then, begin
write spell (hero:Reed,0,0,atk:Pistol)
set hero picture (hero:Reed,3,inside battle)
end
fight formation(formationNum)
end
|
|
|
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
|