SphereCommunity
Act on base function REPAIR - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Act on base function REPAIR (/Thread-Act-on-base-function-REPAIR)



Act on base function REPAIR - Rizz - 03-01-2014 09:00 AM

Is possible to act on this function?
I saw that when you repair some items, i.e. blacksmith, it takes the same amount of ingots whether you have to repair 1hits or more.

Can i change it somewhere (maybe items related proprieties) or i need to create a replacement one?


RE: Act on base function REPAIR - Ben - 03-01-2014 12:25 PM

Best way is to override the repair function.
This is an example of an old script I had on my shard of a custom repair function.
I had replaced the repair function with repairfix in the blacksmith menu, but there are other ways to do that now like overriding the repair function with the CommandTrigger INI setting, and this can definitely be updated Smile

Code:
[FUNCTION REPAIRFIX]
TARGETF f_repaire
SRC.SYSMESSAGE What would you like to repair?
RETURN 1

[FUNCTION f_repaire]
obj=<argo.uid>
LOCAL.AMOUNTFIX <EVAL <EVAL <EVAL <obj.MORE1H>+-<obj.HITPOINTS>>/4>+1>
FORITEMS 2
    IF (<TYPE> == t_anvil)
IF (<obj.TYPE>==t_armor)||(<obj.TYPE>==t_shield)||(<obj.TYPE>==t_weapon_mace_smith)||(<obj.TYPE>==t_weapon_mace_sharp)||(<obj.TYPE>==t_weapon_sword)||(<obj.TYPE>==t_weapon_fence)||(<obj.TYPE>==t_weapon_mace_pick)||(<obj.TYPE>==t_weapon_axe)||(<obj.TYPE>==t_weapon_mace_staff)
IF (<obj.HITPOINTS> < <obj.MORE1H>)
    IF <SRC.RESTEST <EVAL <LOCAL.AMOUNTFIX>> <obj.RESOURCES.1.KEY>>
    obj.HITPOINTS=<obj.MORE1H>
    SRC.CONSUME <EVAL <LOCAL.AMOUNTFIX>> <obj.RESOURCES.1.KEY>
    SRC.EMOTE repair <obj.NAME>
    SRC.SOUND 02a
    SRC.ANIM 13
    SERV.NEWITEM i_repairsound
    NEW.CONT=<SRC.UID>
    RETURN 1
    ELSE
    SRC.SYSMESSAGE You don't have enough resources to repair that
    RETURN 1
    ENDIF
ELSE
SRC.SYSMESSAGE This item is already in full repair
RETURN 1
ENDIF
ELSEIF (<obj.TYPE>==t_ingot)
SRC.SYSMESSAGE Double Click this item to craft something!
RETURN 1
ELSE
SRC.SYSMESSAGE This item can't be repaired with this
RETURN 1
ENDIF
    RETURN 1
    ENDIF
ENDFOR
SRC.SYSMESSAGE You must be near an anvil
RETURN 1

[ITEMDEF i_repairsound]
ID=i_memory
TYPE=t_eq_script
LAYER=layer_special

ON=@Create
TIMER=1

ON=@TIMER
CONT.SOUND 02a
CONT.ANIM 13
REMOVE
RETURN 1



RE: Act on base function REPAIR - Rizz - 03-01-2014 11:07 PM

Hey thx a lot for your answer!
CommandTrigger will also replace a specific function written in the scripts?

i.e.

PHP Code:
ON=i_ANVIL Repair    // pretty much anyone can attempt to repair.
TEST=BLACKSMITHING 1.0
REPAIR 

or it just works for in game commands only?


RE: Act on base function REPAIR - Ben - 03-01-2014 11:30 PM

ok CommandTrigger will only change ingame commands... bust I just remembered that if you name your function the same as another one, it will override it, even if that function is hardcoded.

so you can do a [FUNCTION repair] and it will replace the hardcoded one.