Page 1 of 1
storm cloak in U6
Posted: Fri Nov 25, 2011 11:17 am
by agentorangeguy
I've been discussing with Crowley on how to implement the storm cloak into the U6 mod to function at least similar to how it did in U6. Since npc spells are weapons I was experimenting with a usecode egg that would delete a monster's spell weapons, and then build the storm cloak code from that. Here is one way I tried it:
Code: Select all
void TestCloak1 3020()
{
var QUANTITY_ANY = -359; //had to put that there so it would compile
if (event == EGG)
{
var liche = UI_find_nearby_avatar(SHAPE_LICHE);
UI_remove_cont_items(liche, QUANTITY_ANY, SHAPE_FIREBOLT, QUALITY_ANY, FRAME_ANY); //this is supposed to find a liche and delete the firebolt spell from it but it didn't work.
}
}
Using the code on the Avatar worked just fine. I guess the problem is how to identify a liche when you encounter one, and delete it's spell weapons when the cloak is put on. How would I recoginize a monster npc such as the liche and delete its spell items? Right now I'm just working on the egg so it is easily tested. I wish I could take a look at the magebane code too. I also thought about deleting only the spell weapons of a monster npc that is set to the wearer's oppressor, would that be possible?
Re: storm cloak in U6
Posted: Sun Nov 27, 2011 9:00 pm
by Crowley
If I understood your code right, you are trying to tie the spell removal to the event of an egg spawning an enemy. I have considered a similar approach myself. There are two problems I see here: 1) The enemy's spellcasting ability would remain gone even if the anti-magic effect was turned off. 2) This would not affect hand-placed enemies and NPCs. If you solve the second problem, the first one would still remain; the player could breeze past enemies and NPCs once with the storm cloak on, and they would be permanently magically disabled.
I think a better way to handle the effect would be to attach a check to when the spell items are used as a weapon. Something like: when event = weapon, if anti-magic then fizzle, else proceed as normal.
Re: storm cloak in U6
Posted: Sun Nov 27, 2011 9:26 pm
by agentorangeguy
Yeah it would take away the spell weapons from the monster permanently which is one problem I thought of, but I was hoping to get something like that to work as a starting point.
Now, if it were possible to 'delete' all spell weapons that are fired towards the party while under the effects of the storm cloak, that would work as well. I don't know if spell items can be deleted as they are in the process of flying towards the party though.
I've not used the (event == weapon) thing yet. are you saying that each individual spell item would have to be coded where it would not fire if the cloak was worn? I guess i'd have to make it to where a flag was set that the storm cloak was readied by someoene in the party, and when the flag is true, the spell item wouldn't function... i'd need some help with the exult gurus though because I'm stumped.
Re: storm cloak in U6
Posted: Mon Nov 28, 2011 9:08 pm
by marzo
Just to be clear I understand: while worn, the cloak prevents all hostile magic from working? If so, this will be tricky. Very tricky.
In U7, enemy spells are weapons that they equip; they work not unlike a wand or a bow: when used, they fire a copy of the projectile defined in their weapon data, as long as there are charges left. This is cannot be prevented short of setting charges to zero or deleting the object.
If you set the weapon to trigger usecode (in weapon data, not the ready/unready usecode events), this is triggered when the weapon hits the intended target; so it would be too late; moreover, this does not prevent the damage and effects caused by the spell (charm, poison, etc.).
There are three basic ways I can see of making this work:
(1) Modify the cloak to work only for the wearer. You could do this by having the cloak give immunity to the common spell damage types (armor data) as well as weapon powers (frame flags).
(2) Have the cloak periodically check around for spellcaster enemies and delete their spells (starting when equipped, stopped when removed).
(3) As (2), but replace the weapons by 'drained' versions (each unique in some way) that can be turned back into the original spells when the cloak is removed (and keeping the number of charges).
I will leave to you the choice on how to handle this, and help write the usecode if you go with (2).
Re: storm cloak in U6
Posted: Mon Nov 28, 2011 9:58 pm
by agentorangeguy
I think #2 would be closest to the original, which is the route I tried but I wasn't sure how to have it check for spellcaster enemies. If all else fails, I had thought of just the individual immunity too. WHat kind of time intervals could you have the cloak check for spell caster enemies and delete their spells? I guess adding #3 to that might prevent people from just using the cloak to rid the enemies of spell weapons and taking it off.
Re: storm cloak in U6
Posted: Tue Nov 29, 2011 12:41 pm
by marzo
Strictly speaking, you don't need to recognize casters; you need to recodnize spells. This can be done by looking at spell shapes.
Here is an example of how it can be done; I haven't tested it, but it should work with some minor modifications. I took the route of deleting spells (instead of swapping for drained versions) and setting the magebane flag to prevent blink, invisibility and summon and clearing several spell effect flags (invisibility, curse, etc.). The code is not complete as I did not list all spell shapes. But it should be enough to get you started.
NPCs of hostile or random alignment get negatively affected all the time; neutral NPCs are affected only if they are being attacked by party members; friendly NPCs are positively affected if they are not fighting party members, negatively affected otherwise; party members are always positively affected.
A 'positive effect' is the removal of negative spell effects -- curse, charm, paralysis. A 'negative effect' is the removal of all spell effects (those above plus invisibility, might, protection) and spells. NPCs that lose their spells will show a fizzle and exclaim in disbelief, for color.
Code: Select all
extern var getOuterContainer 0x945(var obj);
extern void spellFails object#(0x606) ();
// No idea what shape the storm cloak is.
void StormCloak shape#(0xXXX) ()
{
if (event == 5)
{
// Come back here next tick to do initial cleanup.
script item
{
nohalt;
call StormCloak;
}
}
else if (event == 6)
{
// Don't need to do anything really.
}
else if (event == 2)
{
// Add more spells here:
var spell_shapes = {281, 408, 527, 807, 856};
// Who is wearing the cloak:
var wearer = getOuterContainer(item);
// How far from the wearer we want to search.
var dist = 20;
// Find all nearby NPCs, of any shape, within 20 tiles and whether or
// not they are invisible.
var npc_list = wearer->find_nearby(-359, dist, 0x28);
// To prevent party NPCs from being affected.
var party = UI_get_party_list();
// For color.
var barks = ["My pretty spells are gone!", "My magic?!!", "My spells?!!"];
var numbarks = UI_get_array_size(barks);
for (npc in npc_list)
{
var align = npc->get_alignment();
var in_party = npc->get_npc_object();
// Is the NPC is being attacked by a party member?
if (in_party || !(npc->get_oppressor() in party))
{
// No. Check basic alignment only.
if (in_party || align == 0)
{
// Friendly NPCs and party members.
// Uncharm.
npc->clear_item_flag(2);
// Uncurse.
npc->clear_item_flag(3);
// Unparalyze.
npc->clear_item_flag(7);
// Do nothing else.
continue;
}
else if (align == 1)
{
// Neutral NPCs.
// Do nothing? Do everything? Your choice.
// I went with 'do nothing'.
continue;
}
}
// Hostile and random NPCs, fighting neutral NPCs or friendly NPCs
// being attacked by party members.
// We want to delete spells, if any.
// We also want to count how many spells were deleted.
int cnt = 0;
// Go through the spell shapes.
for (spell in spell_shapes)
{
// Remove all spells of this shape that the NPC is carrying.
cnt += npc->remove_cont_items(-359, spell, -359, -359, true);
}
// Did we delete any spells?
if (cnt > 0)
{
// We did. Now we must to do a couple more things.
// 'Magebane' effect: prevents mages from teleporting, turning
// invisible or summoning more foes.
npc->set_item_flag(31);
// Color: spell fizzle effect plus surprised bark.
script npc after UI_die_roll(4,8) ticks
{
call spellFails;
wait 4;
say barks[UI_get_random(numbarks)];
}
}
// The following are optional tweaks:
// Force visible.
npc->clear_item_flag(0);
// Uncharm.
npc->clear_item_flag(2);
// Uncurse.
npc->clear_item_flag(3);
// Unparalyze.
npc->clear_item_flag(7);
// Unprotect.
npc->clear_item_flag(9);
// Remove might.
npc->clear_item_flag(12);
}
// Script it to return here again.
script item after 4 ticks // Change this at your leisure.
{
nohalt;
call StormCloak;
}
}
}
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 1:05 am
by agentorangeguy
awesome, thanks! I'll test it with the regular cloak for now until we get a storm cloak made.
I need your opinion and help on how to go about doing the skiff and balloon. While the skiff can be made a lesser necessity , i'll definitely need to do the balloon somehow. How would I go about doing it? Crowley and I thought about the turtle barge from SI but I think it is already there, just in a blank frame until activated. So, I guess this is how it would need to function:
-create the barge where it is able to be created (flat land, no obstructions)
- lifting it up in the air ala magic carpet by double click and seating the party
-'packing it up' after use.... and being able to carry it across maps and re-creating it when need (such as the gargoyle shrine).
I guess at the very least, I could just have it be created in a location such as outside of the basket weaver's place (where the invis. barge would be) and not have it be 'packable', but I'd have to alter the part of the quest of going to the gargoyle shrine. Is it possible to 'create' a barge through usecode, and delete it... and 're-create / move' it to the targeted spot when you want to 'unpack' the balloon? for the time being, I plan on having it be a square shape, with seats facing inward. The skiff would have to function similarily, being able to be carried and dropped where needed. I think I'd probably have a weight requirement for skiffs though, that if the party's combined weight was so much they'd refuse to use the skiff in fear of sinking.
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 4:03 am
by Dominus
If you figure this out I'd really like to see a "real" magic carpet in BG (through the keyring mod?) that folds up after use (as the bedroll does) and no longer needs seats (similar to the ice raft).
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 11:30 am
by agentorangeguy
On the storm cloak code, this part didn't compile right:
Code: Select all
// We also want to count how many spells were deleted.
int cnt = 0;
I couldn't figure out what was wrong with it.
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 4:48 pm
by marzo
That should be 'var' instead of 'int', sorry.
Regarding the balloon -- you can try this: create two different shapes for the balloon with the following characteristics:
Inflated balloon: it has a barge object (shape 961) created with edit->create barge, as well as several barge parts for the basket and bag. Since it is a barge it has 0 (infinite) weight and volume. Double-clicking the bag while on ground deflates it, double-clicking the basket (or maybe a heater) causes you to take off/land the balloon.
Deflated balloon: a single new shape of 'barge' type, but with finite weight and volume (possibly set high enough that it must be carried on the hands or in the backpack spot, but not inside a backpack or crate). Double-clicking inflates it for flight.
Inflation process: player puts deflated balloon on ground. and double-clicks it. In usecode, check flag 21 ('okay to land') of the deflated balloon with get_item_flag intrinsic to see if the deflated balloon object is on level ground with no obstructions. If it is, change the balloon to shape 961 and create (through usecode) all the barge pieces that make up the basket, the bag's support and the bag, possibly with some inflating animation. When double-clicking the balloon causes characters to go inside the basket and lifts the whole thing.
Deflation process: when landed, and the bag is double-clicked, check if there is anything inside the basket, and stop the process if so. Then, delete the barge parts that compose the balloon and change the barge's shape (the one with shape 961) to the deflated balloon's shape so it can be picked up.
Changing the shape is meant to keep the extra attached information, since both objects in question are of barge type.
Note: this is an idea. I have no idea if it will work, but I can see no reason why it wouldn't.
Bonus: if you want to implement wind, you can use static usecode variables to store wind direction (maybe changing it in a more continuous way) and speed (an idea would be the number of ticks between each wind step, or zero for no wind). When the balloon is inflated, you start the wind, and keep looping in the barge object like so:
Code: Select all
if (wind_speed)
{
script item after wind_speed ticks
{
step wind_direction; // 0-7, 0 = north, 7 = north-west
call BalloonWind;
}
}
else
{
script item
{
call BalloonWind;
}
}
Or something like that.
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 6:36 pm
by Crowley
Since unlike Lord British's Crown, the Storm Cloak is supposed to also prevent party members from using magic, I think you should also have it set the weather to magic storm when worn, and of course clear that when removed. As a bonus, that glimmering visual effect is very similar to when using the cloak in the original U6.
Re: storm cloak in U6
Posted: Wed Nov 30, 2011 10:23 pm
by agentorangeguy
I could do that part pretty easy at least, the magic storm that prevents
magic from being casted.
I'm not sure how to go about building a barge. I don't have a shape for the balloon yet, but i'm just using a new shape that is just the drawbridge for testing both that and a skiff. I know how to create the red barge shape in ES, but I'm not quite sure how to activate it. What item flags in ES do you need to select for say, the skiff. THe skiff should function similar to the ice raft in SI. How would I go about writing the code for that? Do I use double click as the event, then setting the Avatar's flag to SAILOR making him the 'captain'? Also, when the item is packed up, how does the barge shape go with it?
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 2:59 pm
by marzo
I was writing an extensive post describing how one might go about doing this, detailing how barges work and all. Then, I read Dominus' post.
Damn you, Dominus! :-p
So I decided that teaching with an example would be better. You will need to update to the latest snapshot -- I had to add a couple of intrinsics and squash a few bugs related to barge centers -- but the result is
here. It is on the same place where the (now removed) old carpet is.
I will see about integrating with Keyring and TFL later.
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 6:39 pm
by Dominus
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 6:49 pm
by Scythifuge
Spectacular!!!
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 9:28 pm
by marzo
For what is worth, I fixed the bug where the carpet could be landed on water. This was a bug at least 10 years old that was fixed by one line. Looks like Jeff was just being lazy...
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 10:13 pm
by agentorangeguy
Marzo, what post of Dominus' are you talking about, I couldn't find one regarding barges? It would be interesting to read about how they function and how to go about doing them. This code you wrote for the carpet, can it be modified (and how?) to function like a skiff too (I plan on the skiff functioning like the ice raft but 'packable')?
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 11:10 pm
by Dominus
He meant the one in here about "when you figure it out I'd like a real carpet...".
So instead of writing a description he went ahead and made an example mod. I guess he added a lot of comments to the source of that carpet mod. I wish our forum would support easy splitting of topics
Re: storm cloak in U6
Posted: Fri Dec 02, 2011 11:21 pm
by agentorangeguy
Ohhh haha.
Re: storm cloak in U6
Posted: Sat Dec 03, 2011 1:35 am
by Scythifuge
Now is there a way to make a cross legged sprite for each NPC & switch to that sprite when the new magic carpet is in use?
Re: storm cloak in U6
Posted: Sat Dec 03, 2011 1:58 am
by Scythifuge
Oh & Marzo, its great to see you on here again!
Re: storm cloak in U6
Posted: Sat Dec 03, 2011 5:24 am
by Crowley
All I can say is: Woohoo! You people are awesome!
Re: storm cloak in U6
Posted: Mon Dec 05, 2011 4:09 am
by Kensu
Wouldn't the logical thing to be to look at how Kissme's magical dampening is done, and copy that, since the effects are identical? (I'm assuming the anti-magic field in Ambrosia works in Exult.)
Re: storm cloak in U6
Posted: Mon Dec 05, 2011 5:00 am
by Crowley
That one does not affect enemies.
Re: storm cloak in U6
Posted: Sat Dec 10, 2011 6:57 pm
by Crowley
How would you prevent using the carpet under a roof or other overhead obstacle? I looked up the sextant's usecode since that only works under open sky, but that only seems to check the specific spot the Avatar is standing on. Would it be necessary to implement that same check for every single spot on the carpet?
Re: storm cloak in U6
Posted: Sun Dec 11, 2011 1:04 pm
by marzo
At least the version I did does not work under a roof; of course party members complain that there isn't enough space. You could try using the sextant's check to say something else for that case (in my version, the carpet is initially created at z=255 and checks if it can land -- which checks for roofs; if yes, it is moved to the ground and the rest of the carpet is created; if not, it is deleted).