Page 1 of 1

Infodump about multiple ammo types

Posted: 24 Sep 2013, 18:10
by o11c
Recently, I showed that it's possible for an OnEquip script to safely remove an item. This is an infodump about all the states we have to deal with during the two OnEquip scripts.

If there are both a Launcher and an Ammo equipped, the launcher's OnEquip script is called before the Ammo's.

lowercase means it is not equipped.

Initial login:
l, a: nothing to do.
L, a: same as Equip, l->L, a.
l, A: same as Equip, l, a->A.
L, A: should always be okay, but is identical to Equip, L, a->A.

Use-up:
l, A->a: impossible.
L, A->a: same as Unequip: L, A->a.

Unequip: remember there is NO hook here!
l, A->a: enters null state, want no vars in case ammo is equipped first.
L, A->a: if launcher sets a var, no chance to unset it.
L->l, a: enters null state, want no vars in case ammo is equipped first.
L->l, A: if ammo sets a var, no chance to unset it.

Equip:
l, a->A: always okay, launcher var untouched, ammo script called should be a nop.
L, a->A: may remove ammo, needs to know launcher var.
l->L, a: always okay, launcher should not create pollution in case it is unequipped.
l->L, A: may remove ammo (!), needs to know launcher var.

Other notes:
Only one item can be unequipped at a time. This means the want-unequip event should set the ID to something it won't use. OTOH a call to unequip an empty slot is probably a noop ...
We should take special steps to make sure scripts don't set variables if the other slot has nothing.

So in item_db:
Bow has set @launcher, MAT_BOW; callfunc "LauncherCheck";
Arrow has set @ammo, MAT_BOW; callfunc "AmmoCheck";

(using appropriate nonzero constants from const.txt)

The launcher function looks like:
if nothing in ammo slot, set @launcher, 0
if something in ammo slot, set @launcher to something
return

The ammo function looks like:
Get @ammo from item_db before the call.
if !@launcher, goto L_Return
if @launcher == @ammo, goto L_Return
addtimer to unequip, then fallthroughto L_Return
L_Return clears @launcher and @ammo unconditionally.
return

Re: Infodump about multiple ammo types

Posted: 03 Oct 2013, 14:28
by wushin
The Launcher only works if the Ammo equipped is the Type it uses?
Any Ammo can be equipped, but only the proper launcher type activates it?
Does the equipping a new launcher remove ammo if the type is incorrect?
Also Someone will bring this up.
#### Auto-Equip ####
please let us first get the multiple ammo types working first.
#### Auto-Equip ####
Is my stance on that.

Re: Infodump about multiple ammo types

Posted: 03 Oct 2013, 17:38
by o11c
Equipping an incompatible ammo type while holding a launcher, or equipping an incompatible launcher while already holding ammo, will automatically unequip the ammo.

Re: Infodump about multiple ammo types

Posted: 07 Oct 2013, 01:00
by AnonDuck
Or so you think ;)

Re: Infodump about multiple ammo types

Posted: 07 Oct 2013, 14:09
by wushin