Make equipment invincible?

Post » Wed Aug 26, 2009 6:27 am

I'm trying to write a script what makes equipment invincible. Because there is no option to do so i had the idea of a workarround.
I thought, whenever a weapon or armor gets damaged by something, its life will be set again to 100%
But there are several problems and so i need your help

This is just a prealpha because i'm new to MW Scripts. I use the http://www.uesp.net/morrow/editor/mw_cscommands.shtml#set

begin a_selfrepairshort stateif (state == 0)	if (OnActivate == 1)		if ( player->GetHealthGetRatio < 0.5 )			; player->SetHealth, 1.1			set player->health to, 1.1		endif	endifendifend


What does this test script do?

Whe i click on an object with this script, it checks if my current health is below 50% and should fill it up to 100% (thats not working). I can only add fixed live instead 100%

So i've the following questions:

- How do i add 100% (float) health instead fixed values or wrong values (now he sets life to 1/1)
- How do i make this script global because later it should work for all equipment and by OnActivate
- Finally how do i get a weapon or armor in this script instead of player because i dont want to add "this_specific_armor" for example
User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Tue Aug 25, 2009 11:45 pm

sorry for disappointing you, but what you want to make is impossible.
you can check for a weapons health using gethealth, but this returns the maximum health and not the current one...

I can think of a rather clumsy workaround: everytime, the player unequips the sword, it will be removed from his inventory and a new one will be added. the obvious problem is, if the player never unequips it, it gets broken over long... but you may set its health in the CS to a very high value.

the script for adding a new sword may be a bit complicated because MW can CtD if something removes itself, so you will need two scripts. the first one is attached to the sword or whatever.
here is my attept:
begin a_selfrepairshort OnPCEquipshort equippedshort doneif ( OnPCEquip )if (done == 0 )set done to 1set equipped to 1elseif ( equipped == 1 )set equipped to 0StartScript a_selfrepair_globalendifendifend


here is the second script to prevent CtD (you have to paste the ID of your invincible item):

begin a_selfrepair_globalplayer->RemoveItem invincibleitemID 1player->AddItem invincibleitemID 1StopScript a_selfrepair_globalend

User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Wed Aug 26, 2009 4:51 am

Another thing to try:
short lastOnshort isOnSet isOn To "player"->HasItemEquipped "your_item"if ( "player"->GetSoundPlaying "weapon break" )    if ( lastOn > isOn )        "player"->RemoveItem "your_item" 1        "player"->AddItem "your_item" 1        "player"->EquipItem "your_item" 1    endifendifSet lastOn To isOn


I'm not sure if that'll work, but basically it waits till the player's weapon breaks. If they were using your weapon the frame before the break and aren't now, we'll assume it broke and replace the broken copy. Just to be nice, we'll re-equip it too.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm

Post » Wed Aug 26, 2009 2:29 am

What if they enchant the weapon, won't the enchantment be lost when it's replaced?
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Tue Aug 25, 2009 10:25 pm

Thanks for your help.

I thinking over it and my conclusion is, ok, [censored] happens, i will continue self repairing my weapons. But, is there any possibility to reequip npcs weapons. Why? I want to make a siege. There should be some npc's fighting with creatures. And after some minutes watching or alonger time their weapons will broke and thats not what i want.

So situation:
- new npcs made
- new weapons made with changing id name

I read that it is possible to force someone equip something.
So
a) Check equip
- GetHealthGetRatio possible on equip?

B) Replace instead of repair but how?
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am

Post » Wed Aug 26, 2009 6:40 am

I think you want peachykeen's last script for that, but replace "Player" with your NPC name, or MrMuh's...

Both aim to re-equip a weapon when it breaks.
User avatar
Neko Jenny
 
Posts: 3409
Joined: Thu Jun 22, 2006 4:29 am

Post » Tue Aug 25, 2009 11:40 pm

What if they enchant the weapon, won't the enchantment be lost when it's replaced?

Yes. Actually, it won't even register. Enchanting changes the ID to the current timestamp, I think (it gets an ID similar to dialogue entries).


Thanks for your help.

I thinking over it and my conclusion is, ok, [censored] happens, i will continue self repairing my weapons. But, is there any possibility to reequip npcs weapons. Why? I want to make a siege. There should be some npc's fighting with creatures. And after some minutes watching or alonger time their weapons will broke and thats not what i want.

So situation:
- new npcs made
- new weapons made with changing id name

I read that it is possible to force someone equip something.
So
a) Check equip
- GetHealthGetRatio possible on equip?

B) Replace instead of repair but how?

It's not possible to do GetHealthGetRatio on a weapon.

For a large scale battle, you'll need something different:
if ( "npc1"->HasItemEquipped "sword" < 1 )    "npc1"->RemoveItem "sword" 1    "npc1"->AddItem "sword" 1    "npc1"->EquipItem "sword" 1endif

Repeat that snippet for every NPC, using the weapon they'll naturally equip. If the AI conflicts with your chosen weapon, they'll glitch and won't be able to fight (because they'll keep equipping different things).
You can also add in a frame-based delay or even a cycle, for example:
short cycleSet cycle To cycle + 1if ( cycle == 15 )    set cycle to 0elseif ( cycle == 1 )   "npc1"... (above snippet)elseif ( cycle == 2 )   "npc2"...elseif ( continue for all )   ...endif

That will process one NPC each frame, cycling through them all.


I think you want peachykeen's last script for that, but replace "Player" with your NPC name, or MrMuh's...

Both aim to re-equip a weapon when it breaks.

Mine is simpler and runs as a lone global, but MrMuh's can be more reliable, so it's an even tie there. For many people, though, neither is a good solution.
User avatar
.X chantelle .x Smith
 
Posts: 3399
Joined: Thu Jun 15, 2006 6:25 pm

Post » Wed Aug 26, 2009 8:07 am

For large-scale battles, you can also just create a set of equipment with stupidly high health for the NPC's to wear. The problem, of course, is if you get to loot the bodies.
User avatar
Carlos Rojas
 
Posts: 3391
Joined: Thu Aug 16, 2007 11:19 am

Post » Wed Aug 26, 2009 4:25 am

You can always script it so that the player CAN'T loot the bodies ;)

Or, failing that, can't equip the NPC's equipment.
User avatar
Kat Ives
 
Posts: 3408
Joined: Tue Aug 28, 2007 2:11 pm


Return to III - Morrowind