The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to make a "gift chest"
Author Message
Jozack
Apprentice
*

Posts: 34
Likes Given: 15
Likes Received: 0 in 0 posts
Joined: Apr 2017
Reputation: 0



Post: #1
Trying to make a "gift chest"
Let me start by saying I'm VERY new at this scripting thing. I've gotten super help from other members here before, and have learned a lot. Sooooo, what I'm trying to do now is make a worldgem bit that spawns a chest with a random Vanquishing Weapon inside. I want this chest to be static when it spawns, and I want it to disappear after the item inside has been taken. The code below is what I have so far. It DOES work, except for the disappearing part. The code, as it is now, has a vanq_bow, but would rather it be a random weapon, which I think I can do. Just haven't bothered until I get the fool chest to work properly. Someone PLEASE help me!!

Code:
[DEFNAME i_loot_chest]
random_loot_test { i_bow_vanq }

[TEMPLATE i_loot_chest]
CATEGORY=Item Templates
SUBSECTION= New Loot Templates
DESCRIPTION=Vanq_bow_chest
container = i_chest_metal
ATTR=attr_can_decay
ATTR=attr_static
ATTR=attr_move_never
ITEM = i_bow_vanq
ON=@DClick
    ATTR=attr_decay 10
    TIMER={1 2}
ON=@Timer
   REMOVE
04-30-2017 02:50 PM
Find all posts by this user Like Post Quote this message in a reply
pointhz
Journeyman
*

Posts: 148
Likes Given: 1
Likes Received: 55 in 28 posts
Joined: Oct 2013
Reputation: 1



Post: #2
RE: Trying to make a "gift chest"
add this and see if it works. forget the worldgem bit. didnt test

[ITEMDEF i_loot_chest]
ID=i_chest_metal
NAME=Loot Chest
TYPE=t_container

ON=@CREATE
ATTR=08010
COLOR=07a1
NEWITEM=random_loot_test
NEW.CONT=<UID>

ON=@PickUp_Self
IF (<COUNT>==0)
ATTR=08090
UPDATE
TIMER=300 // Respawn time, in seconds
ENDIF

ON=@TIMER
ATTR=08010
NEWITEM=random_loot_test
NEW.CONT=<UID>
TIMER=-1
(This post was last modified: 05-01-2017 03:50 AM by pointhz.)
05-01-2017 03:42 AM
Find all posts by this user Like Post Quote this message in a reply
[+] 2 users Like pointhz's post
Jozack
Apprentice
*

Posts: 34
Likes Given: 15
Likes Received: 0 in 0 posts
Joined: Apr 2017
Reputation: 0



Post: #3
RE: Trying to make a "gift chest"
Forget the worldgem bit? But I want it to be a recurring spawn.
05-01-2017 10:45 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #4
RE: Trying to make a "gift chest"
honestly I don't know if TEMPLATEs works fine with triggers because I never had used triggers on templates, but anyway you can try using @PickUp_Self trigger, just add it on your current script

you don't need to create another container again because the worldgem bit will already do it later automatically

Code:
//Remove the container after someone pick an item inside it
//PS: TIMERF is needed because @PickUp_Self is called before the item is picked, so if you delete the container before the player pick the item, it will delete the item too
ON=@PickUp_Self
TIMERF 1,REMOVE

//Prevent drop more items inside the container
//PS: not really needed, but this will avoid players losing items if for some reason someone drop an item inside the container
ON=@DropOn_Self
return 1
05-01-2017 04:20 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Coruja's post
Jozack
Apprentice
*

Posts: 34
Likes Given: 15
Likes Received: 0 in 0 posts
Joined: Apr 2017
Reputation: 0



Post: #5
RE: Trying to make a "gift chest"
Thanks everyone SO much for helping with this. So this is what I have so far, and it does work....except for the removal of the previous chest. It just sits there after the item has been picked from it. Any ideas? Also, what is the item name for a random vanq weapon? In the code below I'm just using i_bow_vanq. But when I get it working properly, I'd rather use a random vanq weapon.

Code:
[ITEMDEF i_loot_chest]
ID=i_chest_metal_brass
NAME=Loot Chest
TYPE=t_container

ON=@CREATE
ATTR=08010
NEWITEM=i_bow_vanq
NEW.CONT=<UID>

ON=@PickUp_Self
IF (<COUNT>=0)
ATTR=08090
UPDATE
TIMER=10 // Respawn time, in seconds
ENDIF

ON=@TIMER
ATTR=08010
NEWITEM=i_bow_vanq
NEW.CONT=<UID>
TIMER=-1
05-02-2017 01:03 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #6
RE: Trying to make a "gift chest"
ATTR 08010 is the same of 08000 (attr_static) + 010 (attr_move_never). Probably you're trying to make it decay using an timer, so you also must use 02 (attr_decay). Anyway, attr_static is useless in this case so if you use only 012 (attr_move_never + attr_decay) will be enough

PS¹: to make things "more readable" you can write ATTR=attr_move_never|attr_decay instead ATTR=012
PS²: on sphere_defs.scp you can find all these attr_* values and on sphere_template.scp you can find the templates to create random items (eg: random_weapon_vanq, random_bowtype_vanq, etc)
05-03-2017 03:10 AM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Coruja's post
Jozack
Apprentice
*

Posts: 34
Likes Given: 15
Likes Received: 0 in 0 posts
Joined: Apr 2017
Reputation: 0



Post: #7
RE: Trying to make a "gift chest"
Thanks so much for the reply, Coruja! Below is the code as it is now....but the previously spawned chest still doesn't decay. I just can't figure out why.

Code:
[ITEMDEF i_loot_chest]
ID=i_chest_metal_brass
NAME=Loot Chest
TYPE=t_container

ON=@CREATE
ATTR=attr_move_never|attr_decay
NEWITEM=i_bow_vanq
NEW.CONT=<UID>

ON=@PickUp_Self
IF (<COUNT>=0)
ATTR=08090
UPDATE
TIMER=10 // Respawn time, in seconds
ENDIF

ON=@TIMER
ATTR=attr_move_never|attr_decay
NEWITEM=i_bow_vanq
NEW.CONT=<UID>
TIMER=-1
05-03-2017 04:16 AM
Find all posts by this user Like Post Quote this message in a reply
pointhz
Journeyman
*

Posts: 148
Likes Given: 1
Likes Received: 55 in 28 posts
Joined: Oct 2013
Reputation: 1



Post: #8
RE: Trying to make a "gift chest"
Why do you want the chest decaying? As it is now it is invisible. Players won't see the chest unless there is an item inside it, what only happens after X seconds.

To be honest I dont like worldgem bits. If you want you can just add the chest to the worldgem bit and change the script to this:

[ITEMDEF i_loot_chest]
ID=i_chest_metal_brass
NAME=Loot Chest
TYPE=t_container

ON=@CREATE
ATTR=attr_move_never|attr_decay
NEWITEM=i_bow_vanq
NEW.CONT=<UID>

ON=@PickUp_Self
IF (<COUNT>=0)
REMOVE
UPDATE
ENDIF
05-03-2017 06:58 AM
Find all posts by this user Like Post Quote this message in a reply
Jozack
Apprentice
*

Posts: 34
Likes Given: 15
Likes Received: 0 in 0 posts
Joined: Apr 2017
Reputation: 0



Post: #9
RE: Trying to make a "gift chest"
I want it to decay away so I don't end up with a room full of empty chests. With the script as I have it now, the chest is very much visible to players, whether there is an item inside or not. When the item inside is taken, I want THAT chest to disappear before the next one spawns.

Pointhz, I just tested your script, exactly as you posted it.....every chest that spawns, remains....I'll end up with empty chests all over my spawn area. That's why I need them to decay away once the item inside has been taken.
(This post was last modified: 05-03-2017 09:13 AM by Jozack.)
05-03-2017 08:54 AM
Find all posts by this user Like Post Quote this message in a reply
pointhz
Journeyman
*

Posts: 148
Likes Given: 1
Likes Received: 55 in 28 posts
Joined: Oct 2013
Reputation: 1



Post: #10
RE: Trying to make a "gift chest"
try the chests without the worldgem bit.

.add i_loot_chest
open the chest
take the item
see what happens. With the 1st script it should go invisible (if you have .gm ON you will still see the chest. Type .gm and .update to test it properly) and with the 2nd script it should be removed.

If it doesnt work, change the script to (this should work as you want, with the worldgem bit and everything):

[ITEMDEF i_loot_chest]
ID=i_chest_metal_brass
NAME=Loot Chest
TYPE=t_container

ON=@CREATE
ATTR=attr_move_never|attr_decay
NEWITEM=i_bow_vanq
NEW.CONT=<UID>

ON=@PickUp_Self
TIMERF 1, f_loot_chest

[FUNCTION f_loot_chest]
IF (<COUNT>==0)
REMOVE
ENDIF
(This post was last modified: 05-03-2017 09:20 AM by pointhz.)
05-03-2017 09:19 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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