Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Respawning Loot
Author Message
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #1
Respawning Loot
Ok I saw a few post regarding spawning loot in containers. What I noticed was that most people respawn the whole container which in turn spawns loot in side it. Why not just have the loot spawn in the container? Well here is one way!

PHP Code:
[DEFNAME respawning_loot_settings]
RESPAWN_CUSTOM_LOOT_TIME 10 //secs

/////////////////////////////////////////////////////
////     EVENTS/TYPEDEF e_eventhandler_respawn_loot
////    -our event handler for ON=@ PickUp_Self/DropOn_Self/TIMER
////    @ PickUp_Self - checks contents of container, when empty use TIMERF to call f_loopback_timer to trigger our @Timer event
////    @ DropOn_Self - prevents adding items to the container
////    @ TIMER - if container empty calls f_Load_Loot passing in a list created from TAG.loot
/////////////////////////////////////////////////////
[TYPEDEF e_eventhandler_respawn_loot]    //loot handler
ON=@PickUp_Self
    
//when an item is removed from container reset our timer
    //we have -1 because COUNT still considers the current object to still be in the container
    
IF ((<I.COUNT> - 1)== 0)    //only fire if no other items are left
        
TIMERF <dDEF.RESPAWN_CUSTOM_LOOT_TIMEf_loopback_timer      
    
ENDIF
    
UPDATE

ON
=@DropOn_Self
    
//prevent droping things into this container
        
return 1

ON
=@TIMER
    
//if container is empty add new loot based on stored template(s) above or previous
    
IF (<I.COUNT> == 0)
        
//turn TAG.loot into a list then pass into function
        //    f_Load_Loot expects a list
            
f_Load_Loot <EXPLODE +,<TAG.loot>>    
    ENDIF

/////////////////////////////////////////////////////
////     FUNCTION f_loopback_timer
////    -loopback to call @TIMER
////    -without this loopback, timers that reach zero will auto decay the object.
////        If that item is static -> error object timer elapsed without decay
////        error is thrown.  This prevents that error.
/////////////////////////////////////////////////////
[FUNCTION f_loopback_timer]
    
//call this items TIMER event
    
I.TRIGGER @TIMER

/////////////////////////////////////////////////////
//// FUNCTION f_Load_Loot <args>
////    Param <args> - must be a list
//// -takes a list of items and adds each item to the calling container's contents
//// -updates nearby clients so tooltip shows correctly
/////////////////////////////////////////////////////
[FUNCTION f_Load_Loot]
    
//a list is passed in, loop through and add each item
    
FOR <EVAL (<ARGV> - 1)> 
            
SERV.NEWITEM <ARGV[<LOCAL._FOR>]>
        NEW.
CONT=<UID>
    ENDFOR
    
UPDATE

/////////////////////////////////////////////////////
//// ITEM i_metal_chest_rloot 
/////////////////////////////////////////////////////
[ITEMDEF i_metal_chest_rloot]    //A - our item ref
ID i_chest_metal                //B - what our item looks & feels like
TAG.loot poor_gold_pile+poor_pouch    //C - the loot this item respawns, can have mutiple items seperated by a +
ON=@Create
    EVENTS 
+e_eventhandler_respawn_loot
    I
.TRIGGER @TIMER 

Now define your own containers.
Try .add i_metal_chest_rloot then .set attr=08010 so no one walks away with it.


I'm currently writing a script for respawning loot & relocking containers using a gump. I'll post the whole script when its done.

Capes
(This post was last modified: 04-21-2018 02:06 AM by Capes.)
04-21-2018 02:04 AM
Find all posts by this user Like Post Quote this message in a reply
lewless53
Apprentice
*

Posts: 12
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Apr 2020
Reputation: 0



Post: #2
RE: Respawning Loot
Ty very colll
04-01-2020 01:46 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

This forum uses Lukasz Tkacz MyBB addons.