Infodump about multiple ammo types

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


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.

Post Reply
User avatar
o11c
Grand Knight
Grand Knight
Posts: 2262
Joined: 20 Feb 2011, 21:09
Location: ^ ^

Infodump about multiple ammo types

Post 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
Former programmer for the TMWA server.
User avatar
wushin
TMW Adviser
TMW Adviser
Posts: 1759
Joined: 18 Dec 2012, 05:56
Location: RiverBest, Brew City, Merica
Contact:

Re: Infodump about multiple ammo types

Post 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.
The secret to getting all the important stuff done is doing nothing.
User avatar
o11c
Grand Knight
Grand Knight
Posts: 2262
Joined: 20 Feb 2011, 21:09
Location: ^ ^

Re: Infodump about multiple ammo types

Post 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.
Former programmer for the TMWA server.
User avatar
AnonDuck
TMW Adviser
TMW Adviser
Posts: 645
Joined: 02 Jan 2009, 04:19
Location: Catland

Re: Infodump about multiple ammo types

Post by AnonDuck »

Or so you think ;)
Head of the TMW Illuminati
User avatar
wushin
TMW Adviser
TMW Adviser
Posts: 1759
Joined: 18 Dec 2012, 05:56
Location: RiverBest, Brew City, Merica
Contact:

Re: Infodump about multiple ammo types

Post by wushin »

The secret to getting all the important stuff done is doing nothing.
Post Reply