Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] New trigger: @Drink #1162

Open
canerksk opened this issue Oct 24, 2023 · 6 comments
Open

[Feature Request] New trigger: @Drink #1162

canerksk opened this issue Oct 24, 2023 · 6 comments

Comments

@canerksk
Copy link
Contributor

canerksk commented Oct 24, 2023

There may be a need for a trigger that will fire when a character drinks potion. It may be necessary to replace the empty bottle returned by a potion, or you may want to adjust the time of drinking the next potion here, or you may want to turn off the loss of potion when the potion is drunk.

under void CChar::Use_Drink( CItem * pItem )

	const CItemBase *pItemDef = pItem->Item_GetDef();
	ITEMID_TYPE idbottle = (ITEMID_TYPE)pItemDef->m_ttDrink.m_ridEmpty.GetResIndex();

	int64 pDelay = 150;
	word pConsume = 1;

	TRIGRET_TYPE iRet = TRIGRET_RET_DEFAULT;
	if (IsTrigUsed(TRIGGER_DRINK))
	{
		CScriptTriggerArgs args;
		args.m_pO1 = pItem;
		args.m_VarsLocal.SetNumNew("IdBottle", idbottle);
		args.m_iN1 = pDelay;
		args.m_iN2 = pConsume;
		iRet = OnTrigger(CTRIG_Drink, this, &args);
		idbottle = (ITEMID_TYPE)args.m_VarsLocal.GetKeyNum("IdBottle");
		pDelay = args.m_iN1 ? args.m_iN1 : 150;
		pConsume = args.m_iN2 ? (word)(args.m_iN2) : 1;

		if (iRet == TRIGRET_RET_TRUE)
			idbottle = (ITEMID_TYPE)ITEMID_NOTHING;
	}

ON=@ drink
// return 1 = does not give empty potions
// argo =the potion she drank
// local.IdBottle = empty potion id
// src = drinking char
// argn1 = cooldown time
// argn2 = potion reduce amount

The codes here are purely examples. Although many have been tested, some may need to be rewritten.

@drk84
Copy link
Member

drk84 commented Oct 25, 2023

SpellEffect do that with argo being the item used, but it will be nice to add the coooldown time for potions as currently is hardcoded

@canerksk
Copy link
Contributor Author

SpellEffect bunu argo kullanılan öğeyle yapıyor, ancak şu anda sabit kodlanmış olduğundan iksirlere bekleme süresi eklemek güzel olacak

It would also be nice if it gives an empty potion after using the potion or if it gives an empty potion with a different id.

@Jhobean
Copy link
Contributor

Jhobean commented Oct 25, 2023

I like this new trigger. Could be use on alcool bottle too.

@Tolokio
Copy link
Contributor

Tolokio commented Jan 31, 2024

SpellEffect bunu argo kullanılan öğeyle yapıyor, ancak şu anda sabit kodlanmış olduğundan iksirlere bekleme süresi eklemek güzel olacak

It would also be nice if it gives an empty potion after using the potion or if it gives an empty potion with a different id.

image
image

U can modify data1 to retrieve a diferent empty bottle or whatever. And u can do it by script before potion is consumed,for example using the trigger drk84 said: @spelleffect or any other trigger that allow u to modify tdata1 before potion is consumed.

and LAYER_FLAG_PotionUsed should be able to be modified so u can set there the CoolDown by many ways.

image
For example using @MEMORYEQUIP

on=@memoryequip
IF (<ARGN1> == LAYER_FLAG_PotionUsed)
      timer= 25
      if <src.tag0.potioverride>
           timer -=<src.tag0.potioverride>
           src.tag0.potioverride
     endif
eNDIF

I agree trigger could be interesting, maybe something like this:

    const CItemBase *pItemDef = pItem->Item_GetDef();
    if ((IsTrigUsed(TRIGGER_DRINK))
    {
        CScriptTriggerArgs pArgs;
        pArgs.m_iN1 = idbottle;
        if (pItem->OnTrigger(ITRIG_DRINK, this, &pArgs) == TRIGRET_RET_TRUE)
        {
            return;
        }
    }
    ITEMID_TYPE idbottle = (ITEMID_TYPE)pItemDef->m_ttDrink.m_ridEmpty.GetResIndex();
on=@drink
if (<type>==t_booze)  
    IF <src.tag. drunk>
         src.spelleffect s_bless 100.0 
    endif
     //You can script custom cd for boozes here.
elif (<type>==t_potion && !<src.findlayer.layer.LAYER_FLAG_PotionUsed>) //be sure u will drink the potion!
    IF <src.tag. drunk>
       //modify potion before everything takes places.
       more1=s_poison 
       more2=1000
       Tdata1 = //no bottle back, put it on the floor instead
       serv.newitem i_cristals_2
       new.p=<src.p>
       src.message Why do u do this to me? Dont dare to give this %&/$ to me again!!
       tdata2=3000 //cd timer override ???
    endif
else
    IF <src.tag. drunk>
           src.message I dont want to drink this.
           return 1
    endif
endif
       

@Tolokio
Copy link
Contributor

Tolokio commented Feb 1, 2024

SpellEffect do that with argo being the item used, but it will be nice to add the coooldown time for potions as currently is hardcoded

Should be nice to use tdata2 for it. so if tdata2 is defined it would be used to override potion's cd.

@canerksk
Copy link
Contributor Author

canerksk commented Feb 25, 2024

When the potion is made with the tdata value, this will be valid for all items. It seems like it would be nice to set the empty potion refund in a customized settings menu so that it can be turned on and off. For example, Empty Bottle Return is on/off and this will be character based. I don't think it's shockingly effective to include too many triggers instead of controlling many things about the pot you drink with a single trigger.

xwerswoodx added a commit to xwerswoodx/Source-X that referenced this issue Mar 26, 2024
Added: New trigger @drink added for characters. (Issue: Sphereserver#1162)
Added: New trigger @AFKmode added for characters. (Issue: Sphereserver#1161)
Added: New trigger @reveal added for characters. (Issue: Sphereserver#1157)
Added: New triggers @ArrowQuest_Add and @ArrowQuest_Close added for characters. (Issue: Sphereserver#1116)
Added: New function triggers f_onaccount_block and f_onaccount_unblock. (Issue: Sphereserver#1156)
Added: New function trigger f_onserver_broadcast. (Issue: Sphereserver#1145)
Added: Two new LOCAL variables ItemPoisonReductionChance and ItemPoisonReductionAmount to @hit trigger. (Issue: Sphereserver#1159)
@xwerswoodx xwerswoodx self-assigned this Mar 26, 2024
cbnolok pushed a commit that referenced this issue Apr 28, 2024
* Fix crafting (#1190)

* Added .editorconfig (#1188)

* Fix Issue #1191 CANMASK not being saved on server reboot (#1192)

* Fix target cancelling upon death (#1186)

* Feature/meditation fail movement (#1184)

* Fix herding dupe char (#1185)

* Editable DispID for chars  (#1178)

* Fix issue #1097 (CAN_O_NOSLEEP not working after server reboot) (#1198)

* Fixed: The issue that causes more1/2 not saved correctly for spellbook. (Issue: #1221)

* Fixed: Players automatically become criminal to everyone when attack someone. (Issue: #1213)

* Fixed: CallGuard not working correctly on the players that only criminal for target. (Issue: #1213)

* Fixed: The wrong input of Kill trigger, to make it compatible with older sphere versions. (Issue: #1210)

* Added: New Layer LAYER_STORAGE (80) to let scripters create their own storage system on chars. (Issue: #1209)
- Only t_container and t_container_locked can be equipped to this layer.

* Changed: Decay time removed from spawned items. (Issue: #1218)

* Added: New spellflag SPELLFLAG_FIELD_RANDOMDECAY to randomize field tile decay time, like old sphere versions. (Issue: #1169)

* Changed: SERV.LOG command changed to support console colors. (Issue: #1158)

* Added: Sphere.ini setting CanPetsDrinkPotion (true in default) to make pets drink potion when their owner drop it on it. (Issue: #1147)

* Fixed: Missing fCheckOnly checks block the taming skill. (Issue: #1219)

* Added: New trigger @drink added for characters. (Issue: #1162)

* Added: New trigger @AFKmode added for characters. (Issue: #1161)

* Added: New trigger @reveal added for characters. (Issue: #1157)

* Added: New triggers @ArrowQuest_Add and @ArrowQuest_Close added for characters. (Issue: #1116)

* Added: New function triggers f_onaccount_block and f_onaccount_unblock. (Issue: #1156)

* Added: New function trigger f_onserver_broadcast. (Issue: #1145)

* Added: Two new LOCAL variables ItemPoisonReductionChance and ItemPoisonReductionAmount to @hit trigger. (Issue: #1159)

* added: MAGICF_REACTIVEARMORTH (010000) MAGICF flag to Sphere.ini to let people decide if reactive armor should reflect two handed weapons.

* Fixed: Possible fix for accesses and bans not loading for multis. (Issue: #1223)

* Fixed: Possible fix for wrong damage calculation of slayer bonus damage. (Issue: #1179)

* Added: REGION_FLAG_HOUSE (0x0100) flag for houses. (Issue: #1154)

* @Murdermark Update
Added: ARGO object for @Murdermark trigger to get killed character.

* @RegionResource Fix
Fixed: ARGN1 (reap amount) doesn't updated depends on the amount left on bit. (Issue: #1224)
Added: ARGO to get bit uid under @ResourceGather and @RegionResourceGather triggers.

* Multi Invalid Region Fix
Fixed: Possible fix for the OnRegionTrigger getting called on invalid region while multi creating/removing.

* CAN Flags DWORD to UINT64
Changed: dword CAN flags changed with uint64 to increase limits.

* Fixed: Possible fix for chat debugs. (Issue: #1212) (Issue: https://discord.com/channels/354358315373035542/483721253773901824/1224030729906815077)

* Added Missing Data to sphere.ini

* t_crop update
Added: "MOREX" key to set amount of fruit given when the crop ripped.
Changed: Now @create trigger called when crop grow to let people to change MORE values in stages if needed.
Added: @ResourceTest trigger added for crops. (This trigger works seperately for every stage)
Added: @ResourceGather trigger added for crops. (This trigger works seperately for every stage)

* Fixed: Possible fix for invalid ResourceID warnings. (Issue: #1071)

* Fixed: Missing REGION reference for multis. (Issue: #1228)

* Elemental Engine Flags
Added: ElementalEngineFlags variable added to sphere.ini to let servers to filter elemental engine. (Issue: #1230)

* Custom Multi Count
Fixed: An issue that causes T_MULTI_CUSTOM keep multi count saved. (Issue: #1232)

* Fixed: Bonded pets cannot see their master while DeadCannotSeeLiving equals to 2. (Issue: #1225)

* Standard Guild Align Fix
Fixed: The issue that causes Guilds without align shown enemy to the players with a guild with align. (Issue: #1208)

* GMs Dress Players
Fixed: GMs cannot dress up players. (Issue: #901)

* GM unequip fix
Fixed: Wrong check block GMs to unequip item from players.

* Custom Hosing Fix
Fixed: An issue that causes a visual bug to remove all tiles while removing a tile in higher floors. (Issue: #345)

* Merged Jhobean's Pr
Merged Jhobean's EMOTEF_EAT PR and split EAT flag for npcs and players. (PR: #1207)

* @hit and @GetHit as Item Triggers
Added: Trigger @hit is added as an item trigger.
Added: Trigger @GetHit is added as an item trigger.

* Visual Range Update
Added: MAPVIEWRADAR, MAPVIEWSIZE and MAPVIEWSIZEMAX to sphere.ini that overrides default visual range values. (Issue: #1144)

* H keyword for Hexadecimal returns
Added: 'H' shortcut for variables to get the value as hexadecimal.

* raydienull's LAYER_STABLE PR merge
- Merged: raydienull's LAYER_STABLE build merged, but LAYER_AUCTION keep same as LAYER_STABLE added as a new layer. (PR: #1201)
- Fixed: raydienull's LAYER_STABLE follower triggers doesn't called while taking pet out of stable.
- Fixed: raydienull's LAYER_STABLE doesn't work with the new follower system.
- Removed: Unnecessary LINK == PLAYER checks as figurines will be stocked on the owned player.

* c_man_gm
- Fixed: Setting GMs dispid to c_man_gm in-game, prevents GMs to use in-game commands.

* NPC Hear Distance
- Changed: Default NPC hear range reverted back to the 14 from 4, as it was 14 in older versions, as there was no reason for changing it. (Issue: #1215)

* CCChampion Rework
- Fixed: Candles keep stuck while killing npcs. (Issue: #564)
- Fixed: LEVELMAX doesn't affect the max level of champion system, and keep spawn npcs for default max level.
- Changed: Spawn system changed and now it automatically calculate the percentage of spawns per level in descending order.
- Changed: Candle calculation is now depend on max level, instead of static 4 level.
- Added: SRC added in @start trigger. SRC is a reference of player that starts champion spawner.
- Added: @complete trigger that triggers when champion completed. (Issue: #477)
- Added: @DelRedCandle trigger that triggers while red candle removing.
- Added: @DelWhiteCandle trigger that triggers while white candle removing.
- Added: @Level trigger that triggers when champion level up.
- Added: @Stop trigger that triggers when champion stopped.

* T_MULTI_ADDON Fix
- Fixed: Script multis move 1 block north when their type set as t_multi_addon. (Issue: #1238)

* ADDCOMPONENT
- Fixed: ADDCOMPONENT command was added as ADDCOMP for houses.

* Reactivated Hardcoded Fishing Skill
- Changed: Re-activated 56b style hardcoded fishing system, as I don't know why it's deactivated as softcoded system too bad and broken.
	- Fishing skill in default script pack should updated.
	- Delay should set to 2.5-3.0
	- All softcoded system should removed.
	- If anyone want to code their own fishing system, they can use SKF_SCRIPTED.

* EF_DAMAGETOOLS Update
- Added: EF_DAMAGETOOLS flag implemented to the sphere.
	- Added LOCAL.ITEMDAMAGECHANCE to the @success trigger for skills to decide damage chance for tools. (Default: 25)
	- Added LOCAL.ITEMDAMAGEAMOUNT to the @success trigger for skills to decide damage amount. (Default: 1)
	- EF_DAMAGETOOLS only affects the skills with SKF_GATHER flag.

* m_ridFruitOverride CAN_I_SCRIPTEDMORE update

* SPELLFLAG_NOUNPARALYZE
- Fixed: SPELLFLAG_NOUNPARALYZE flag wasn't working as intended.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants