Hello everybody, how are you doin?
I have two questions regarding some advanced topics of zscript:
1) How do I make a item (lets say, an flashlight), that draws power (for ease some kind of ther inv item, like batteries). How do I make it? I poked around the DoEffect() in gzdoom.pk3, but since my coding knowledge is belowe this level of coding, its barely understandable for me. So, how do I make an item, that draws (simple TakeInventory() ) power every one second (35 tics)?
I made an item with decorate and ACS, but I would like to get rid of the ACS part and let zscript do the job.
2) Is it possible to change the inventory icon of item? If so, how?
Many thanks
Making a powerup that draws power & how to change inv icon
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- ramon.dexter
- Posts: 1529
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Making a powerup that draws power & how to change inv ic
For inventory item, as example
This item spawn in direction where player look, in crosshair, one plasma ball every tick, and every second pick from player inventory one cell. Next yourself.
Basicaly, all you need to do its place word "owner" before any action with holder of this item. This tell engine do something using actor as centher of the universe for this functions, like spawn/check inventory/proximity/health/etc. not item. Because simple a_defaulfunction(first, second, third variable) force engine do something with inventory item itself, which not always makes sense, like check health of inventory item.
Code: Select all
class test_item : inventory
{
int tick_amount; //store integer variable with name tick_amount in this actor
overide void attachtoowner(actor user)//call every time item become part of actor inventory
{
tick_amount = 0;//define value of tick_amount, because compiler use value which left in memory in place where it left place for this integer value
super.attachtoowner(user);//call super function
}
override void doeffect()
{
if(owner.countinv("cell") == 0) {return;}//break funtion if owner of this item dont have cell in inventory
tick_amount++;//AKA tick_amount + 1
if(tick_amount == 35)
{
owner.takeinventory("cell", 1);
tick_amount = 0;}
owner.a_spawnprojectile("plasmaball");
}
}
Basicaly, all you need to do its place word "owner" before any action with holder of this item. This tell engine do something using actor as centher of the universe for this functions, like spawn/check inventory/proximity/health/etc. not item. Because simple a_defaulfunction(first, second, third variable) force engine do something with inventory item itself, which not always makes sense, like check health of inventory item.
- ramon.dexter
- Posts: 1529
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Making a powerup that draws power & how to change inv ic
Thank you Apeirogon, that's the example I wanted!
-
- Posts: 4949
- Joined: Sun Nov 14, 2010 12:59 am
Re: Making a powerup that draws power & how to change inv ic
Assuming the calling object is the item itself:ramon.dexter wrote:2) Is it possible to change the inventory icon of item? If so, how?
Code: Select all
Icon = TexMan.CheckForTexture(<newicon>, TexMan.Type_MiscPatch);
- ramon.dexter
- Posts: 1529
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Making a powerup that draws power & how to change inv ic
Well, the mechanic is following: Playere uses the item, the item starts the script (so I assume the item IS the activator, but I'm not fully sure).Blue Shadow wrote: Assuming the calling object is the item itself: