Infodump about multiple ammo types
Forum rules
This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.
Its current use is for the continued development of the server and game it has always served: TMW Classic.
Infodump about multiple ammo types
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
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
Former programmer for the TMWA server.
- wushin
- TMW Adviser
- Posts: 1759
- Joined: 18 Dec 2012, 05:56
- Location: RiverBest, Brew City, Merica
- Contact:
Re: Infodump about multiple ammo types
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.
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.
The secret to getting all the important stuff done is doing nothing.
Re: Infodump about multiple ammo types
Equipping an incompatible ammo type while holding a launcher, or equipping an incompatible launcher while already holding ammo, will automatically unequip the ammo.
Former programmer for the TMWA server.
- wushin
- TMW Adviser
- Posts: 1759
- Joined: 18 Dec 2012, 05:56
- Location: RiverBest, Brew City, Merica
- Contact:
Re: Infodump about multiple ammo types
Well
https://github.com/wushin/tmwa-server-d ... ncher-ammo
with
https://github.com/wushin/tmwa-client-d ... ncher-ammo
Works for equipping/equipping.
Or these Pull requests
https://github.com/themanaworld/tmwa-se ... ta/pull/39
https://github.com/themanaworld/tmwa-cl ... ta/pull/26
https://github.com/wushin/tmwa-server-d ... ncher-ammo
with
https://github.com/wushin/tmwa-client-d ... ncher-ammo
Works for equipping/equipping.
Or these Pull requests
https://github.com/themanaworld/tmwa-se ... ta/pull/39
https://github.com/themanaworld/tmwa-cl ... ta/pull/26
The secret to getting all the important stuff done is doing nothing.